component-detection
component-detection copied to clipboard
Fix analyzer warnings
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
Table of Contents
-
StyleCop.Analyzers -
Microsoft.VisualStudio.Threading.Analyzers -
Roslyn - Introduced with .NET 6 migration
- Language rules
- Code quality rules
-
StyleCop.Analyzers
StyleCop.Analyzers
- [x] SA1001
- Commas should not be preceded by whitespace
- #204
- [x] SA1005
- Single line comment should begin with a space
- #205
- [x] SA1101
- Prefix local calls with this
- #236
- [x] SA1105
- Single line comment should begin with a space
- #206
- [x] SA1008
- Opening parenthesis should not be followed by a space.
- #212
- [x] SA1009
- Closing parenthesis should not be followed by a space
- #210
- [x] SA1011
- Closing square bracket should be followed by a space
- #211
- [x] SA1012
- Opening brace should be preceded by a space
- #213
- [x] SA1013
- Closing brace should be preceded by a space
- #213
- [x] SA1026
- The keyword 'new' should not be followed by a space or a blank line
- #213
- [x] SA1108
- Block statements should not contain embedded comments
- #237
- [x] SA1114
- Parameter list should follow declaration
- #238
- [x] SA1117
- The parameters should all be placed on the same line or each parameter should be placed on its own line
- #214
- [x] SA1118
- The parameter spans multiple lines
- #213
- [x] SA1135
- Using directive for namespace '...' should be qualified
- #225
- [x] SA1137
- Elements should have the same indentation
- #209
- [x] SA1142
- Refer to tuple fields by name
- ~#239~
- #308
- [x] SA1200
- Using directive should appear within a namespace declaration
- ~#239~
- #416
- [x] SA1201
- A field should not follow a property
- ~#239~
- #308
- [x] SA1202
- Constant fields should appear before non-constant fields
- [x] SA1203
- 'public' members should come before 'private' members
- #264
- #319
- [x] SA1204
- Static members should appear before non-static members
- #219
- [x] SA1208
- Using directive for '...' should appear before directive for '...'
- #218
- [x] SA1210
- Using directives should be ordered alphabetically by the namespaces
- #227
- [x] SA1214
- Readonly fields should appear before non-readonly fields
- #250
- [x] SA1216
- Using static directives should be placed at the correct location
- #265
- #319
- [x] SA1316
- Tuple element names should use correct casing
- #319
- [x] SA1401
- Field should be private
- #319
- [x] SA1413
- Use trailing comma in multi-line initializers
- #249
- [ ] SA1414
- Tuple types in signatures should have element names
- [x] SA1500
- Braces for multi-line statements should not share line
- #223
- #317
- [x] SA1515
- Single-line comment should be preceded by blank line
- #248
- #317
- [x] SA1518
- File is required to end with a single newline character
- #208
- [ ] SA1600
- Elements should be documented
- [ ] SA1602
- Enumeration items should be documented
- [ ] SA1604
- Element documentation should have summary
- [ ] SA1611
- The documentation for parameter '...' is missing
- [x] SA1614
- Element parameter documentation should have text
- [x] SA1615
- Element return value should be documented
- [x] SA1616
- Element return value documentation should have text
- [x] SA1617
- Void return value should not be documented
- [x] SA1629
- Documentation text should end with a period
- #226
- [ ] SA1633
- The file header is missing or not located at the top of the file.
- [ ] SA1642
- Constructor summary documentation should begin with standard text
- [x] SA1648
- inheritdoc should be used with inheriting class
- #207
Microsoft.VisualStudio.Threading.Analyzers
- [ ] VSTHRD002
- Synchronously waiting on tasks or awaiters may cause deadlocks. Use await or JoinableTaskFactory.Run instead.
- [ ] VSTHRD103
- Result synchronously blocks. Use await instead.
- [ ] VSTHRD101
- Avoid using async lambda for a void returning delegate type, because any exceptions not handled by the delegate will crash the process
- [ ] VSTHRD104
- Expose an async version of this method that does not synchronously block. Then simplify this method to call that async method within a JoinableTaskFactory.Run delegate.
- [ ] VSTHRD111
- Add .ConfigureAwait(bool) to your await expressio
- [x] VSTHRD200
- Use "Async" suffix in names of methods that return an awaitable type
- #416
Roslyn
- [ ] CS0618
- '...' is obsolete
- [ ] CS1591
- Missing XML comment for publicly visible type or member '...'
Introduced with .NET 6 migration
Language rules
- [ ] IDE0003
- Remove this or Me qualification
- [x] IDE0004
- Cast is redundant
- #305
- [x] IDE0005
- Using directive is unnecessary
- #303
- [x] IDE0007
- use 'var' instead of explicit type
- #305
- [ ] IDE0008
- 'var' preferences
- [x] IDE0009
- Add 'this' or 'Me' qualification
- #303
- [x] IDE0010
- Populate switch
- #317
- [x] IDE0016
- Null check can be simplified
- #305
- [x] IDE0017
- Object initialization can be simplified
- #305
- [x] IDE0018
- Variable declaration can be inlined
- #305
- [x] IDE0019
- Use pattern matching to avoid 'as' followed by a 'null' check
- #326
- [x] IDE0021
- Use expression body for constructors
- #326
- [ ] IDE0022
- Use expression body for methods
- [x] IDE0024
- Use expression body for operators
- #317
- [ ] IDE0025
- Use expression body for properties
- [x] IDE0031
- Null check can be simplified
- #305
- [x] IDE0032
- Use auto property
- #319
- [x] IDE0033
- Prefer explicitly provided tuple element name
- #303
- [ ] IDE0034
- Simplify 'default' expression
- [ ] IDE0036
- Order modifiers
- [x] IDE0037
- Member name can be simplified
- #326
- [x] IDE0039
- Use local function
- #317
- [x] IDE0041
- Null check can be
- #303
- [x] IDE0042
- Variable declaration can be deconstructed
- #305
- [x] IDE0044
- Add readonly modifier
- #317
- [x] IDE0051
- Private member is unused
- #303
- [x] IDE0052
- Private member 'TabularStringFormat.totalWidth' can be removed as the value assigned to it is never read
- #319
- [x] IDE0054
- Use compound assignment
- #319
- [x] IDE0055
- Formatting rule
- #326
- [x] IDE0057
- Substring can be simplified
- #326
- [ ] IDE0060
- Remove unused parameter
- [ ] IDE0065
- 'using' directive placement
- [x] IDE0066
- Use 'switch'
- #317
- [x] IDE0071
- Interpolation can be simplified
- #319
- [x] IDE0074
- Use compound assignment
- #317
- [x] IDE0075
- Conditional expression can be simplified
- #317
- [ ] IDE0078
- Use pattern matching (may change code meaning)
- [ ] IDE0083
- Use pattern matchin
- [ ] IDE0090
- Simplify new expression
- [x] IDE0120
- Simplify LINQ
- #319
- [x] IDE0150
- Null check can be clarified
- #303
- [ ] IDE0160 and IDE0161
- Namespace declaration preferences
- [ ] IDE0220
- N/A
- [ ] IDE1006
- Naming rule violation
Code quality rules
- [ ] CA1001
- Types that own disposable fields should be disposable
- [ ] CA1002
- Do not expose generic lists
- [ ] CA1014
- Mark assemblies with CLSCompliantAttribute
- [x] CA1018
- Mark attributes with AttributeUsageAttribute
- #416
- [ ] CA1024
- Use properties where appropriate
- [ ] CA1027
- Mark enums with FlagsAttribute
- [ ] CA1028
- Enum Storage should be Int32
- [ ] CA1031
- Do not catch general exception types
- [x] CA1032
- Implement standard exception constructors
- #416
- [x] CA1033
- Interface methods should be callable by child types
- #416
- [ ] CA1034
- Nested types should not be visible
- [ ] CA1036
- Override methods on comparable types
- [x] CA1040
- Avoid empty interfaces
- #337
- [ ] CA1051
- Do not declare visible instance fields
- [x] CA1052
- Static holder types should be Static or NotInheritable
- #416
- [ ] CA1054
- URI-like parameters should not be strings
- [ ] CA1056
- URI-like properties should not be strings
- [ ] CA1062
- Validate arguments of public methods
- [ ] CA1064
- Exceptions should be public
- [ ] CA1303
- Do not pass literals as localized parameters
- [ ] CA1304
- Specify CultureInfo
- [ ] CA1305
- Specify IFormatProvider
- [ ] CA1307
- Specify StringComparison for clarity
- [x] CA1308
- Normalize strings to uppercase
- #335
- [ ] CA1309
- Use ordinal string comparison
- [ ] CA1310
- Specify StringComparison for correctness
- [x] CA1401
- P/Invokes should not be visible
- #416
- [x] CA1508
- Avoid dead conditional code
- #416
- [x] CA1707
- Identifiers should not contain underscores
- #337
- [ ] CA1711
- Identifiers should not have incorrect suffix
- [ ] CA1724
- Type names should not match namespaces
- [x] CA1725
- Parameter names should match base declaration
- #416
- [x] CA1805
- Do not initialize unnecessarily
- #416
- [ ] CA1806
- Do not ignore method results
- [x] CA1813
- Avoid unsealed attributes
- #416
- [ ] CA1819
- Properties should not return arrays
- [ ] CA1820
- Test for empty strings using string length
- [ ] CA1822
- Mark members as static
- [ ] CA1823
- Avoid unused private fields
- [ ] CA1824
- Mark assemblies with NeutralResourcesLanguageAttribute
- [x] CA1825
- Avoid zero-length array allocations
- #416
- [x] CA1827
- Do not use Count() or LongCount() when Any() can be used
- #317
- [x] CA1836
- Prefer IsEmpty over Count
- #416
- [x] CA1829
- Use Length/Count property instead of Count() when available
- #338
- [x] CA1834
- Consider using 'StringBuilder.Append(char)' when applicable
- #338
- [x] CA1835
- Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync'
- #416
- [ ] CA1837
- Use 'Environment.ProcessId'
- [x] CA1838
- Avoid 'StringBuilder' parameters for P/Invokes
- #416
- [x] CA1846
- Prefer 'AsSpan' over 'Substring'
- #338
- [x] CA1847
- Use char literal for a single character lookup
- #338
- [ ] CA1849
- Call async methods when in an async method
- [x] CA2000
- Dispose objects before losing scope
- #416
- [ ] CA2007
- Consider calling ConfigureAwait on the awaited task
- [x] CA2016
- Forward the 'CancellationToken' parameter to methods
- #416
- [x] CA2101
- Specify marshaling for P/Invoke string arguments
- #416
- [x] CA2201
- Exception type System.Exception is not sufficiently specific
- #416
- [x] CA2208
- Instantiate argument exceptions correctly
- #416
- [ ] CA2211
- Non-constant fields should not be visible
- [ ] CA2219
- Do not raise exceptions in finally clauses
- [x] CA2234
- Pass system uri objects instead of strings
- #416
- [ ] CA2251
- Use 'string.Equals'
- [ ] CA2227
- Collection properties should be read only
- [x] CA2249
- Consider using 'string.Contains' instead of 'string.IndexOf'
- #416
- [x] CA5392
- Use DefaultDllImportSearchPaths attribute for P/Invokes
- #416
StyleCop.Analyzers
- [x] SA1028
- Code should not contain trailing whitespace
- #303
- [ ] SA1101
- Prefix local calls with this
- [ ] SA1201
- Elements should appear in the correct order
- [ ] SA1202
- Elements should be ordered by access
- [x] SA1500
- Braces for multi-line statements should not share line
- #317
- [x] SA1515
- Single-line comment should be preceded by blank line
- #317