Live data from Hacker News

How we enforce .NET coding standards to improve productivity

anthonysimmon.com

1–10 of 55 posts

Re: How we enforce .NET coding standards to improve productivity

#4
If you’re working in the .net ecosystem, you need to grok msbuild. Is not exactly painless or elegant, but is incredibly powerful. Creating a nuget package that applies settings and configuration files to consuming projects is the tip of a very deep iceberg.

I’m the author and owner of a similar code style/code quality package in a fairly large company and went through a very similar process, culminating with writing our own Roslyn-based analyzers to enforce various internal practices to supplant the customized configuration of the Microsoft provided analyzers. Also, we discovered that different projects need different level of analysis. We’re less strict with e.g test projects than core infrastructure. But all projects need to have the same formatting and style. That too can be easily done with one nuget using msbuild.

Re: How we enforce .NET coding standards to improve productivity

#8

Title should be C# not .Net

I'm not sure i understand your comment, .editorconfig works just fine for VB files as well as F#

You could almost think of F# is an extremely strict set of conventions for C# … ;)

Re: How we enforce .NET coding standards to improve productivity

#9
post #4

If you’re working in the .net ecosystem, you need to grok msbuild. Is not exactly painless or elegant, but is incredibly powerful. Creating a nuget package that applies settings and configuration files to consuming projects is the tip of a very deep iceberg. I’m the author and owner of a similar code style/code quality package in a fairly large company and went through a very similar process, culminating with writing…

>But all projects need to have the same formatting and style.That too can be easily done with one nuget using msbuild.

That's like using a car for "traveling" 3 meters. Why not just use dotnet format + .editorconfig , they were created just for this purpose.

Re: How we enforce .NET coding standards to improve productivity

#10
post #7

[deleted]

The article does mention they only turn on “TreatWarningAsErrors” in production builds.

It’s definitely a tough balance to strike. I go back and forth on this myself.

Maybe the happy medium is to have everything strictly enforced in CI, relatively relaxed settings during normal dev loop builds and then perhaps a pre-commit build configuration that forces/reminds you to do one production build before pushing… (which if you miss, just means you may end up with a failed CI build to fix…)

Post reply on HN