Live data from Hacker News

How we enforce .NET coding standards to improve productivity

anthonysimmon.com

21–30 of 55 posts

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

#21

Is there a 'prettier' equivalent for code formatting? In my opinion, it's the only thing missing for a truly scalable codebase.

dotnet format[0] with .editorconfig should do the job.

[0]: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-f...

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

#22
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…

While msbuild is powerful, I strongly believe it should have been a standard C# language build system instead of a XML-based one.

Any non-trivial thing to do is a pain to figure out if the documentation is not extensive enough.

I really love C#, but msbuild is one of the weak links to me, almost everything else is a joy to use.

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

#23
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…

I agree with you on MsBuild being powerful. I often really hate certain technologies like MsBuild and use them begrudgingly for years, fighting with the tooling, right up until I decide once and for all to give it enough of my attention to properly learn, and then realise how powerful and useful it actually is! I went through the same thing with webpack too. MsBuild is far from perfect though. I often think about try…

> I often really hate certain technologies like MsBuild and use them begrudgingly for years, fighting with the tooling, right up until I decide once and for all to give it enough of my attention to properly learn, and then realise how powerful and useful it actually is!

I had a similar expreience with Cmake. Note, I still hate the DSL but what it can do and what you nowadays actually need to do (or how you organize it) if you are writing a new project can be relatively clean and easy to follow.

Not to say its easy to get to that point, but I don't think anyone really would say that.

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

#25
This is a good article and I appreciate the author sharing his ideas. But that screenshot showing an example of poorly written code. Man if someone in your team is writing code like that you have much more serious problems. I understand the need for guardrails and standards, but when you go through the right process of hiring someone and giving an offer this should not happen. This is the equivalent of a law firm hiring a lawyer then adding a tool that checks their work when drafting documents making sure they don’t make mistakes. I’m not talking about complex compliance issues but fundamental knowledge a lawyer should have. The case can be made this is for junior developers, and I agree it can be useful, but there’s usually a path for junior developers that involves 1:1 mentorship before they start pushing critical code. We do have standards and guidelines in my team, but most of them are nice-to-haves. We assume we are all professionals and trust each other’s work even when many times we disagree on design and coding style. Our effort and enforcement is testing, accountability and good documentation. We nudge for readable code. We have a guy that loves Regex and we let him use it if well documented.

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

#26
post #22
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…

While msbuild is powerful, I strongly believe it should have been a standard C# language build system instead of a XML-based one. Any non-trivial thing to do is a pain to figure out if the documentation is not extensive enough. I really love C#, but msbuild is one of the weak links to me, almost everything else is a joy to use.

I remember using nant back in 2010 or so. Lol those were the days.

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

#27
post #25

This is a good article and I appreciate the author sharing his ideas. But that screenshot showing an example of poorly written code. Man if someone in your team is writing code like that you have much more serious problems. I understand the need for guardrails and standards, but when you go through the right process of hiring someone and giving an offer this should not happen. This is the equivalent of a law firm hir…

isn't it[0] intentionally bad, so as to highlight the things .editorconfig might suggest to improve it?

[0] https://anthonysimmon.com/workleap-dotnet-coding-standards/w...

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

#28
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…

> If you’re working in the .net ecosystem, you need to grok msbuild.

Agreed, it makes a huge difference.

Sadly Visual Studio made that difficult from the start of .net, given its history with attempting to hide the .csproj files from developers and thus reduce their exposure to it. Its a real shame they decided to build visual studio like that and didn't change it for years.

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

#29
post #25

This is a good article and I appreciate the author sharing his ideas. But that screenshot showing an example of poorly written code. Man if someone in your team is writing code like that you have much more serious problems. I understand the need for guardrails and standards, but when you go through the right process of hiring someone and giving an offer this should not happen. This is the equivalent of a law firm hir…

I remember seeing at one job, to share a “token” that was in a byte array, they iterated the byte array and concatenated the values. It was supposed to be an internal “auth tool”/“sso” but was unusable in the php app I was trying to use it with because it couldn’t (or at least I wasn’t sure how to) convert the byte array back. I ended up writing a small Java console app to convert it for me.

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

#30
It's probably a bit overkill for most shops, but you can actually write your own code fixes if you've got some common pattern:

https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/t...

These suggestions being immediately executable can dramatically improve compliance. I find myself taking things like range operator syntax even though I don't really prefer it simply because the tool does the conversion automatically for me.

Post reply on HN