-
Notifications
You must be signed in to change notification settings - Fork 173
Add StyleCop to CommandLineTool project and reformat source code; add .editorconfig for all projects #496
Conversation
bettinaheim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All in all looks good to me! Thanks for looking into this!
|
If you're adding an |
ScottCarda-MS
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very excited for these changes! I've been wanting something like this for a while. Good job!
|
@filipw Do you know what the best way is to show Roslyn analyzers in OmniSharp (for VS Code support)? It was not showing them by default, so I added this but now it shows all StyleCop warnings, even the ones that were disabled by |
|
editorconfig has to be opted into separately in OmniSharp, add this to |
|
Thanks! |
This is a first step to resolving #342. I added the
StyleCop.Analyzerspackage to theCommandLineToolproject to try out StyleCop's formatting rules. I plan to add StyleCop to the rest of the projects in qsharp-compiler, but I wanted to make a smaller PR with just this project to get feedback on the style choices I made.StyleCop's default rules are extensive, and highly opinionated, so I ended up disabling several rules that seemed too strict for us. Those disabled rules are in
src/Common/CodeAnalysis.ruleset.I also added an
.editorconfigfile to override Visual Studio's default behavior and to enforce a style rule that StyleCop doesn't have:dotnet_style_qualification_for_{event,field,method,property} = trueBy default, Visual Studio suggests replacing
this.FoowithFoo. @bettinaheim and I decided that we want to requirethis.in all cases. This is already the default for StyleCop, but Visual Studio's behavior needs to be set separately.dotnet_diagnostic.IDE0002.severity = warningThis promotes Visual Studio's code action for simplifying qualified names to a warning. I added this to simplify references to static members within the same class. So if class
Foohas a static methodBar, for example, I think we should call that method from withinFooby writingBar()instead ofFoo.Bar(). I think we should use this style because:this., we don't need to prefix static members - we know any unprefixed reference is static.