Fix analyzer warnings (original) (raw)
This is an overarching issue to track analyzer warnings that are currently silenced. To fix a single warning:
- Remove the warning silence from .editorconfig
- Run a build locally
- Fix any warnings that are emitted
- Create a pull request
- Link it to this issue
- Once merged check the relevant box below
StyleCop.Analyzers
- SA1000
- Keywords should be spaced correctly
- chore: SA1000 keywords must be spaced correctly #362
- SA1028
- Code should not contain trailing whitespace
- chore: SA1028 code must not contain trailing whitespace #363
- SA1101
- Prefix local calls with this
- SA1108
- Block statements should not contain embedded comments
- refactor: fix SA1108 block statements must not contain embedded comments #348
- SA1117
- Parameters should be on same line or separate lines
- chore: SA1117 parameters must be on same line or separate lines #364
- SA1124
- Do not use regions
- chore: Remove SA1124 override #604
- SA1200
- Using directive should appear within a namespace declaration
- SA1201
- Elements must appear in the correct order
- SA1202
- Elements must be ordered by access
- SA1203
- Constants must appear before fields
- SA1204
- Static elements must appear before instance elements
- SA1206
- Declaration keywords should follow order
- chore: SA1206 declaration keywords must follow order #365
- SA1207
- Member attributes should follow the order
- Address a targeted set of analyzer warnings #901
- SA1214
- Readonly fields must appear before non-readonly fields
- SA1316
- Tuple parameters should use correct casing
- SA1401
- Fields should be private
- SA1413
- Use trailing comma in multi-line initializers
- SA1414
- Tuple types in signatures should have element names
- SA1500
- Braces for multi-line statements should not share line
- SA1502
- Element should not be on a single line
- SA1518
- Use line endings correctly
- refactor: SA1518 use line endings correctly at end of file #351
- SA1600
- Elements should be documented
- SA1602
- Enumeration items should be documented
- SA1604
- Element documentation should have summary
- SA1611
- Element parameters should be documented
- SA1612
- Element parameter documentation should match element parameters
- SA1614
- Element parameter documentation should have text
- SA1615
- Element return value should be documented
- SA1616
- Element return value should be documented
- SA1618
- Generic type parameters should be documented
- SA1622
- Generic type parameters should be documented
- SA1625
- Element documentation should not be copied and pasted
- Address a targeted set of analyzer warnings #901
- SA1626
- Single-line comments should not use documentation style slashes
- Address a targeted set of analyzer warnings #901
- SA1627
- Documentation text should not be empty
- SA1629
- Documentation text should end with a period
- SA1633
- File should have header
- Address a targeted set of analyzer warnings #901
- SA1642
- Constructor summary documentation should begin with standard text
Microsoft.CodeAnalysis.NetAnalyzers
Quality rules
- CA1001
- Types that own disposable fields should be disposable
- CA1002
- Do not expose generic lists
- CA1012
- Abstract types should not have constructors
- CA1014
- Mark assemblies with CLSCompliantAttribute
- CA1019
- Define accessors for attribute arguments
- CA1024
- Use properties where appropriate
- CA1031
- Modify 'Main' to catch a more specific allowed exception type, or rethrow the exception
- CA1032
- Implement standard exception constructors
- CA1040
- Avoid empty interfaces
- Address a targeted set of analyzer warnings #901
- CA1041
- Provide ObsoleteAttribute message
- CA1050
- Declare types in namespaces
- CA1051
- Do not declare visible instance fields
- CA1052
- Static holder types should be sealed
- CA1054
- Uri parameters should not be strings
- CA1055
- Uri return values should not be strings
- CA1056
- Uri properties should not be strings
- CA1062
- Validate arguments of public methods
- CA1063
- Implement IDisposable correctly
- CA1064
- Exceptions should be public
- CA1066
- Implement IEquatable when overriding Object.Equals
- CA1303
- Do not pass literals as localized parameters
- CA1304
- Specify CultureInfo
- CA1305
- Specify IFormatProvider
- CA1307
- Specify StringComparison
- CA1308
- Normalize strings to uppercase
- CA1309
- Use ordinal StringComparison
- CA1311
- Specify a culture in string conversion calls
- CA1508
- Avoid dead conditional code
- Address a targeted set of analyzer warnings #901
- CA1510
- Use '...' instead of explicitly throwing a new exception instance
- CA1707
- Identifiers should not contain underscores
- CA1711
- Identifiers should not have incorrect suffix
- CA1715
- Prefix generic type names with 'T'
- chore: CA1715 identifiers should have correct prefix #367
- CA1716
- Identifiers should not match keywords
- CA1720
- Identifier contains type name
- CA1724
- Type names should not match namespaces
- CA1725
- Parameter names should match base declaration
- CA1805
- Do not initialize unnecessarily
- CA1806
- Do not ignore method results
- CA1812
- Avoid uninstantiated internal classes
- CA1813
- Avoid unsealed attributes
- CA1815
- Override equals and operator equals on value types
- CA1816
- Call GC.SuppressFinalize correctly
- chore: CA1816 Call GC.SuppressFinalize correctly #375
- CA1819
- Properties should not return arrays
- CA1822
- Mark members as static
- CA1825
- Avoid zero-length array allocations
- CA1829
- Use Length/Count property instead of Count() when available
- CA1849
- '...' synchronously blocks. Await '...' instead.
- CA1850
- Prefer static '...' method over '...'
- CA1851
- Possible multiple enumeration of IEnumerable
- CA1852
- Type '...' can be sealed because it has no subtypes in its containing assembly and is not externally visible
- CA1854
- Prefer 'TryGetValue' over 'ContainsKey' and 'Item' when accessing dictionary items
- CA1859
- Use culture-aware string operations
- CA1860
- Avoid using 'Enumerable.Any()' extension method.
- CA1861
- Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly
- CA2000
- Dispose objects before losing scope
- CA2007
- Consider calling ConfigureAwait on the awaited task
- CA2201
- Do not raise reserved exception types
- CA2211
- Non-constant fields should not be visible
- CA2208
- Instantiate argument exceptions correctly
- CA2225
- Operator overloads have named alternates
- CA2227
- Collection properties should be read only
- CA2229
- Implement serialization constructors
- CA2231
- Overload operator equals on overriding ValueType.Equals
- CA2235
Compiler messages
- Mark all non-serializable fields
- CS1570
- XML comment has badly formed XML -- '...'
- CS1572
- XML comment has a param tag for '...' but there is no parameter by that name
- CS1573
- Parameter '...' has no matching param tag in the XML comment for '...'
- CS1574
- XML comment has cref attribute '...' that could not be resolved
- CS1584
- XML comment has syntactically incorrect cref attribute '...'
- CS1591
- Missing XML comment for publicly visible type or member '...'
- CS1723
- XML comment on '...' has a cref tag for '...' that could not be resolved
- CS1734
- XML comment on '...' has a paramref tag for '...' that could not be resolved
- CS3001
- Argument type '...' is not CLS-compliant
- CS3002
- Return type '...' is not CLS-compliant
- CS3003
- Type of '...' is not CLS-compliant
- CS8001
- Referenced assembly '...' does not have a strong name
- CS8632
- The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
Style rules
- IDE0004
- Cast is redundant
- refactor: fix IDE0004 #345
- IDE0005
- Using directive is unnecessary
- Address a targeted set of analyzer warnings #901
- IDE0007
- use 'var' instead of explicit type
- refactor: IDE0007 Use var instead of explicit type #405
- IDE0009
- Add 'this' or 'Me' qualification
- IDE0010
- Add missing cases
- IDE0017
- Simplify object initialization
- refactor: IDE0017 simplify object initialization #350
- IDE0019
- Use pattern matching
- IDE0021
- Use expression body for constructors
- IDE0022
- Use expression body for method
- IDE0023
- Use expression body for operators
- IDE0024
- Use expression body for constructors
- IDE0025
- Use expression body for properties
- IDE0027
- Use expression body for accessors
- IDE0028
- Simplify collection initialization
- IDE0032
- Use auto property
- IDE0036
- Modifiers are not ordered
- IDE0044
- Make field readonly
- IDE0048
- Parentheses should be added for clarity
- IDE0053
- Use expression body for lambda expression
- IDE0055
- Fix formatting
- IDE0057
- Use range operator
- IDE0060
- Remove unused parameter
- IDE0065
- Using directives must be placed inside of a namespace declaration
- IDE0066
- Convert switch statement to expression
- IDE0070
- Use 'System.HashCode' instead of 'GetHashCode()'
- IDE0072
- Add missing cases to switch statement
- IDE0073
- Require file header
- refactor: fix IDE0073 require file header #347
- IDE0074
- Use compound assignment
- IDE0078
- Use pattern matching
- IDE0083
- Use pattern matching
- IDE0090
- Use 'new(...)' instead of 'new ...'
- IDE0110
- Discard can be removed
- IDE0120
- Simplify LINQ expression
- refactor: multiple roslyn analyzer fixes #404
- IDE0200
- Lambda expression can be simplified
- refactor: multiple roslyn analyzer fixes #404
- IDE0220
- 'foreach' statement implicitly converts '...' to '...'
- IDE0251
- Member can be made 'readonly'
- IDE0270
- Null check can be simplified
- refactor: multiple roslyn analyzer fixes #404
- IDE1006
- Naming rule violation: These words must begin with upper case characters: ...