-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Enable CA1069 for ErrorCode and MessageID #54695
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
Changes from all commits
0e93230
eee1dac
3e3e5d6
fe010a5
e9c83f4
1793d60
805d1ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # CSharp code style settings: | ||
| [*.cs] | ||
| # CA1069: Enums should not have duplicate values | ||
| dotnet_diagnostic.CA1069.severity = warning | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 These lines should appear in .globalconfig instead of .editorconfig for performance and consistent application
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The compiler team doesn't currently desire consistent application of this warning. Is there a change that we should make here to improve performance which doesn't affect which files are subject to the new warning?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For intentional conditional application, .editorconfig is fine. |
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ | |
|
|
||
| using System; | ||
| using System.Runtime.InteropServices; | ||
| using System.Runtime.Versioning; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using System.Windows.Forms; | ||
|
|
@@ -14,7 +13,6 @@ namespace Microsoft.CodeAnalysis.Interactive | |
| { | ||
| internal static class InteractiveHostEntryPoint | ||
| { | ||
| [SupportedOSPlatform("windows")] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😕 I'm not sure what this has to do with "Enums should not have duplicate values"
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to update the roslyn-analyzers version in this PR which introduced new warnings. This looked to me like the most straightforward way to resolve the warning in this file. I speculate that the new analyzer infers a "default" SupportedOSPlatform based on the target framework of the project.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you clarify why removing Just to recap, the diagnostic was "src\Interactive\HostProcess\InteractiveHostEntryPoint.cs(23,113): error CA1416: (NETCORE_ENGINEERING_TELEMETRY=Build) This call site is reachable on: 'windows' all versions. 'InteractiveHostEntryPoint.ErrorMode.SEM_NOGPFAULTERRORBOX' is only supported on: 'Windows' 7.0 and later." Looking at the doc on CA1416, it's not clear why removing the SupportedOSPlatform would even fix this diagnostic.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically an analyzer thinks it's not OK to use an enum in one of these methods because the enum (which was also declared in this project) has a "supported os platform" value that is more restrictive than the caller's value. The enum's value is being inferred as "windows7" from the project while the caller's was explicitly set to "windows". So deleting these attributes causes a consistently restrictive "supported os platform" value to be associated with all the symbols in the project.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. So removing the attribute is functionally equivalent to changing it Should we revert other parts of commit c756744 too then?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That seems reasonable to me. Thanks |
||
| private static async Task<int> Main(string[] args) | ||
| { | ||
| FatalError.Handler = FailFast.OnFatalException; | ||
|
|
@@ -53,11 +51,9 @@ private static async Task<int> Main(string[] args) | |
| } | ||
| } | ||
|
|
||
| [SupportedOSPlatform("windows")] | ||
| [DllImport("kernel32", PreserveSig = true)] | ||
| internal static extern ErrorMode SetErrorMode(ErrorMode mode); | ||
|
|
||
| [SupportedOSPlatform("windows")] | ||
| [DllImport("kernel32", PreserveSig = true)] | ||
| internal static extern ErrorMode GetErrorMode(); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,8 @@ public async Task FindReferencesAsync(ISymbol symbol, CancellationToken cancella | |
| await _progress.OnStartedAsync(cancellationToken).ConfigureAwait(false); | ||
| try | ||
| { | ||
| await using var _ = await _progressTracker.AddSingleItemAsync(cancellationToken).ConfigureAwait(false); | ||
| var disposable = await _progressTracker.AddSingleItemAsync(cancellationToken).ConfigureAwait(false); | ||
| await using var _ = disposable.ConfigureAwait(false); | ||
|
Comment on lines
+67
to
+68
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 The separate form is typically for cases where
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I chatted with @CyrusNajmabadi offline about this and he expressed a preference to factor it this way rather than as a single line. |
||
|
|
||
| // For the starting symbol, always cascade up and down the inheritance hierarchy. | ||
| var symbols = await DetermineAllSymbolsAsync( | ||
|
|
||
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.
😕 Why are we adding a new file here?
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.
We want to run the analyzer specifically on the enums in this file. We're not interested in having the warning on the rest of the enums in the compiler at this time.