dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.41k stars 982 forks source link

Enable Analyzers disabled as a part of globalconfig merge from runtime #7887

Open elachlan opened 2 years ago

elachlan commented 2 years ago

Is your feature request related to a problem? Please describe

List of diagnostics that need to be investigated, fixed, and enabled.

Line  297: dotnet_diagnostic.CA1821.severity = none # TODO: warning
Line  466: dotnet_diagnostic.CA2208.severity = none # TODO: warning
Line  533: dotnet_diagnostic.CA2245.severity = none # TODO: warning
Line  851: dotnet_diagnostic.IL3000.severity = none # TODO: warning
Line 1137: dotnet_diagnostic.SA1302.severity = none # TODO: warning
Line 1179: dotnet_diagnostic.SA1400.severity = none # TODO: warning
Line 1191: dotnet_diagnostic.SA1404.severity = none # TODO: warning
Line 1608: dotnet_diagnostic.IDE0059.severity = none # TODO: warning

Describe the solution you'd like and alternatives you've considered

N/A

Will this feature affect UI controls?

N/A

elachlan commented 2 years ago

I started investigating CA1416(https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1416). Winforms would have to swap out its OsVersion static class with OperatingSystem.IsWindowsVersionAtLeast().

@JeremyKuhne Coincidently this would remove the need for us to convert the NtDll PInvoke.

Edit: runtime does cache the OSVersion.

elachlan commented 2 years ago

@RussKie CA2007 has single violation: https://github.com/dotnet/winforms/blob/e9a1042a6fd3718324237e843174e2cc5cc3c825/src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBase.vb#L883-L886

I am unsure if ConfigureAwait(false) is correct. I am pretty sure it is, since it should be resolved inside the Task.Run().

elachlan commented 1 year ago

@dreddy-work IDE0059 is complimented by CA1804. Can I enable CA1804 (Remove unused locals)?

elachlan commented 1 year ago

Turns out CA1804 is replaced by IDE0059? But IDE0059 is replacing values with underscores.

dreddy-work commented 1 year ago

@elachlan, can you share your preferred contact email? I do not see it on your github profile. Like to reach out to you regarding a blog we plan to publish.

elachlan commented 1 year ago

@dreddy-work thanks!

edited to remove.

JeremyKuhne commented 3 months ago

@elachlan I think we're good here now, aren't we?

elachlan commented 3 months ago

The ones that need to be addressed are marked as TODO in CodeAnalysis.src.globalconfig and CodeAnalysis.test.globalconfig

    \winforms\eng\CodeAnalysis.src.globalconfig (8 hits)
    Line  297: dotnet_diagnostic.CA1821.severity = none # TODO: warning
    Line  466: dotnet_diagnostic.CA2208.severity = none # TODO: warning
    Line  533: dotnet_diagnostic.CA2245.severity = none # TODO: warning
    Line  851: dotnet_diagnostic.IL3000.severity = none # TODO: warning
    Line 1097: # SA1206: Keyword ordering - TODO Re-enable as warning after https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3527
    Line 1137: dotnet_diagnostic.SA1302.severity = none # TODO: warning
    Line 1191: dotnet_diagnostic.SA1404.severity = none # TODO: warning
    Line 1608: dotnet_diagnostic.IDE0059.severity = none # TODO: warning
  \winforms\eng\CodeAnalysis.test.globalconfig (7 hits)
    Line   7: dotnet_diagnostic.CA1052.severity = none # TODO: warning
    Line  14: dotnet_diagnostic.CA1416.severity = none # TODO: warning
    Line  26: dotnet_diagnostic.CA1810.severity = none # TODO: warning
    Line  35: dotnet_diagnostic.CA1822.severity = none # TODO: warning
    Line  48: dotnet_diagnostic.CA2007.severity = none # TODO: warning
    Line  51: dotnet_diagnostic.CA2014.severity = none # TODO: warning
    Line 327: dotnet_diagnostic.xUnit1004.severity = silent # TODO: warning