Update .editorconfig file with improved syntax to support IDEs and MSBuild #1051
alexandrejobin
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone!
I needed to have an editorconfig file to apply code styling that would be respected by any IDE and also by the MSBuild. The goal was that if you do not respect the rules, whatever tool that you use to edit the files, MSBuild would alert us with a list of warnings and errors.
By reading about this subject on the web, I came accross the article C# code style by EditorConfig in .NET 5 SDK and beyond that explain the different syntaxes that we should use and how they affect the IDE and MSBuild. By using
option_name = option_value:severity
syntax, only IDEs recognise it. MSBuild will only honor thedotnet_diagnostic.RULEID.severity
syntax so we have to mix the two syntaxes. You also have to add theEnforceCodeStyleInBuild = true
config to each .csproj files.So here's a glimpse of what I did for my projects. I would like your thoughts on this and if it would be good to include it in the template.
For exemple,
dotnet_style_qualification_for_field = false
is the default value taken from Microsoft online doc and then I usedotnet_diagnostic.IDE0003.severity = default
to tell to use the default severity if the rules is not respected.Beta Was this translation helpful? Give feedback.
All reactions