Skip to content
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

chore: Suppress messages generated by CodeAnalyzers #9224

Merged
merged 50 commits into from
Sep 21, 2023

Conversation

filzrev
Copy link
Contributor

@filzrev filzrev commented Sep 20, 2023

This PR aims to resolve some part of #9207 that can be fixed by Visual Studio's code fixer and handled with small code modifications.

Please review If there are changes that contains undesirable code changes.
Then I'll remove that changes.

ID Commit Description
CA1018 51bbfa8 CA1018: Mark attributes with AttributeUsageAttribute
CA1041 b614c9e CA1041: Provide ObsoleteAttribute message
CA1050 c0f8515 CA1050: Declare types in namespaces
CA1507 4dc6426 CA1507: Use nameof in place of string
CA1822 591c6ed CA1822: Mark members as static
CA1825 80d6c10 CA1825: Avoid zero-length array allocations
CA1827 a44bc8d CA1827: Do not use Count()/LongCount() when Any() can be used
CA1829 e758c9f CA1829: Use Length/Count property instead of Enumerable.Count method
CA1830 027807a CA1830: Prefer strongly-typed Append and Insert method overloads on StringBuilder
CA1834 254d172 CA1834: Use StringBuilder.Append(char) for single character strings
CA1836 cac85d0 CA1836: Prefer IsEmpty over Count when available
CA1841 27c0251 CA1841: Prefer Dictionary Contains methods
CA1846 c784799 CA1846: Prefer AsSpan over Substring
CA1847 cf3f1d4 CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters
CA1850 12383b5 CA1850: Prefer static HashData method over ComputeHash
CA2208 f7e57cd CA2208: Instantiate argument exceptions correctly
CA2249 fbbb5a1 CA2249: Consider using String.Contains instead of String.IndexOf
ID Commit Description
IDE0001 99e2d8e Simplify name (IDE0001)
IDE0002 36242f1 Simplify member access (IDE0002)
IDE0003 1df7925 this preferences (IDE0003)
IDE0004 073f675 Remove unnecessary cast (IDE0004)
IDE0005 0fe7159 Remove unnecessary using directives (IDE0005)
IDE0007/IDE0008 09181f4 'var' preferences (IDE0007 and IDE0008)
IDE0017 27c2b04 Use object initializers (IDE0017)
IDE0018 6e57632 Inline variable declaration (IDE0018)
IDE0019 3b86b47 Use pattern matching to avoid 'as' followed by a 'null' check (IDE0019)
IDE0029 9dd355c Null check can be simplified (IDE0029)
IDE0031 22175e8 Use null propagation (IDE0031)
IDE0034 7523e16 Simplify 'default' expression (IDE0034)
IDE0036 65da193 Order modifiers (IDE0036)
IDE0038 5f19db3 Use pattern matching to avoid 'is' check followed by a cast (IDE0038)
IDE0039 8446077 Use local function instead of lambda (IDE0039)
IDE0041 2ce102a Use 'is null' check (IDE0041)
IDE0044 a661ac1 Add readonly modifier (IDE0044)
IDE0049 1bf1a9b Use language keywords instead of framework type names for type references (IDE0049)
IDE0054 99585f5 Use compound assignment (IDE0054 and IDE0074)
IDE0058 a425568 Remove unnecessary expression value (IDE0058) (For test projects)
IDE0059 f43c862 Remove unnecessary value assignment (IDE0059) (For test projects)
IDE0062 3597d7a Make local function static (IDE0062)
IDE0065 c246e9e 'using' directive placement (IDE0065)
IDE0071 1668652 Simplify interpolation (IDE0071)
IDE0079 bcef7fc Remove unnecessary suppression (IDE0079)
IDE0083 f302cc6 Use pattern matching (not operator) (IDE0083)
IDE0090 22e4c7a Simplify new expression (IDE0090)
IDE0110 82511bf Remove unnecessary discard (IDE0110)
IDE0161 e10d1d5 Namespace declaration preferences (IDE0160 and IDE0161)
IDE0200 5e3df45 Remove unnecessary lambda expression (IDE0200)
IDE1006 584c5ec Naming rules for static/internal/private fields

TODO:
Following tasks will be handled by another PR.

  • Suppress other code that require some code modification.
  • Change resolved analyzer rules level from suggestion to warning.
  • Try to using more strict analyzer level (Default -> Recommended)
  • Apply C#12 specific code analyzer rules. (It needs be compiled when targeting .NET 6 SDK)

@filzrev
Copy link
Contributor Author

filzrev commented Sep 21, 2023

I've added a commit (33554b2) to resolve CA2011 message.
If this setter property called. It cause StackOverflow exception.

Copy link
Contributor

@yufeih yufeih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @filzrev !

@yufeih yufeih merged commit 98628ae into dotnet:main Sep 21, 2023
7 checks passed
@yufeih yufeih added the engineering Makes the pull request to appear in the "Engineering" section of the next release note label Sep 21, 2023
p-kostov pushed a commit to ErpNetDocs/docfx that referenced this pull request Jun 28, 2024
* chore: suppress CA1018 message

* chore: suppress CA1041 message

* chore: suppress CA1050 message

* chore: suppress CA1507 message

* chore: suppress CA1822 message

* chore: suppress CA1825 message

* chore: suppress CA1827 message

* chore: suppress CA1829 message

* chore: suppress CA1830 message

* chore: suppress CA1834 message

* chore: suppress CA1836 message

* chore: suppress CA1841 message

* chore: suppress CA1846 message

* chore: suppress CA1847 message

* chore: suppress CA1850 message

* chore: suppress CA2208 message

* chore: suppress CA2249 message

* chore: suppress IDE0001 message

* chore: suppress IDE0002 message

* chore: suppress IDE0003 message

* chore: suppress IDE0004 message

* chore: suppress IDE0005 message

* chore: suppress IDE0007/IDE0008 message

* chore: suppress IDE0017 message

* chore: suppress IDE0018 message

* chore: suppress IDE0019 message

* chore: suppress IDE0029 message

* chore: suppress IDE0031 message

* chore: suppress IDE0034 message

* chore: suppress IDE0036 message

* chore: suppress IDE0038 message

* chore: suppress IDE0039 message

* chore: suppress IDE0041 message

* chore: suppress IDE0044 message

* chore: suppress IDE0049 message

* chore: suppress IDE0054 message

* chore: suppress IDE0058 message for test projects

* chore: suppress IDE0059 for test projects

* chore: suppress IDE0062 message

* chore: suppress IDE0065 message

* chore: suppress IDE0071 message

* chore: suppress IDE0079 message

* chore: suppress IDE0083 message

* chore: suppress IDE0090 message

* chore: suppress IDE0110 message

* chore: suppress IDE0161 message

* chore: suppress IDE0200 message

* chore: suppress IDE1006 message

* chore: revert wrong code and add message suppression

* chore: fix infinite recursion problem reported as CA2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engineering Makes the pull request to appear in the "Engineering" section of the next release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants