-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Enable .NET analyzers and Upgrade langversion #9237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Consider using https://github.com/dotnet/winforms/blob/main/.editorconfig as a starting point for what you enable/disable. You can drop multiple ones in your tree as you work through things, just remove |
Should this PR use the existing infrastructure for code analysis by setting |
[*.{cs,vb}] | ||
charset = utf-8-bom | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
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.
This setting can change the semantic meaning of code. It should never be set to true.
trim_trailing_whitespace = true | |
trim_trailing_whitespace = false |
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.
Can you give an example?
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.
Trailing spaces in a verbatim string would be one example. The C# formatter removes non-semantic trailing whitespaces automatically. The only difference that should exist between trim_trailing_whitespace
and the formatter is trim_trailing_whitespace
also removes trailing whitespaces that change the meaning of code. Other differences would be considered formatter bugs that Roslyn intends to fix.
dotnet_style_namespace_match_folder = true:suggestion | ||
dotnet_style_operator_placement_when_wrapping = beginning_of_line | ||
tab_width = 4 | ||
end_of_line = crlf |
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.
end_of_line
should not be set in .editorconfig
end_of_line = crlf |
|
||
[*.vb] | ||
# Modifier preferences | ||
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion |
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.
💡 For readability, probably better to just leave the default for this one (by omitting the line here) unless it's being changed.
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.0" /> | ||
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.8.0"> |
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.
These are really old versions
@@ -9,12 +9,23 @@ | |||
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch> | |||
<Platforms>AnyCPU;x64;arm64</Platforms> | |||
<GenerateDependencyFile>false</GenerateDependencyFile> | |||
<LangVersion>latest</LangVersion> |
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.
💡 latest
is a moving target and not a real version. Would recommend using a numeric value for build stability across users who work on the project.
Closing this in favor of using the existing infrastructure. |
Enable .NET analyzers and Upgrade langversion
This is an experimental effort, NOT to be merged.
Microsoft Reviewers: Open in CodeFlow