|
1 | | -<?xml version="1.0" encoding="utf-8"?> |
2 | | -<RuleSet Name="Autofac Analyzer Rules" Description="Analyzer rules for Autofac test assemblies." ToolsVersion="16.0"> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<RuleSet Name="Autofac Analyzer Rules" Description="Analyzer rules for Autofac assemblies." ToolsVersion="16.0"> |
3 | 3 | <IncludeAll Action="Warning" /> |
4 | 4 | <Rules AnalyzerId="Microsoft.Usage" RuleNamespace="Microsoft.Usage"> |
| 5 | + <!-- Avoid excessive parameters on generic types (must be explicitly enabled). --> |
5 | 6 | <Rule Id="CA1005" Action="Warning" /> |
| 7 | + <!-- Don't catch general exceptions - test scenarios sometimes require general exception handling. --> |
6 | 8 | <Rule Id="CA1031" Action="None" /> |
| 9 | + <!-- Implement standard exception constructors - not all of the exception constructors (e.g., parameterless) are desired in our system. --> |
7 | 10 | <Rule Id="CA1032" Action="None" /> |
| 11 | + <!-- Avoid empty interfaces - in unit tests for service resolution, this happens a lot. --> |
8 | 12 | <Rule Id="CA1040" Action="None" /> |
| 13 | + <!-- Do not pass literals as localized parameters - tests don't need to localize. --> |
9 | 14 | <Rule Id="CA1303" Action="None" /> |
| 15 | + <!-- Avoid excessive inheritance (must be explicitly enabled). --> |
10 | 16 | <Rule Id="CA1501" Action="Warning" /> |
| 17 | + <!-- Avoid excessive complexity (must be explicitly enabled). --> |
11 | 18 | <Rule Id="CA1502" Action="Warning" /> |
| 19 | + <!-- Avoid unmaintainable code (must be explicitly enabled). --> |
12 | 20 | <Rule Id="CA1505" Action="Warning" /> |
| 21 | + <!-- Avoid excessive class coupling (must be explicitly enabled). --> |
13 | 22 | <Rule Id="CA1506" Action="Warning" /> |
| 23 | + <!-- Use ArgumentNullException.ThrowIfNull - this isn't available until we stop targeting netstandard. --> |
14 | 24 | <Rule Id="CA1510" Action="None" /> |
| 25 | + <!-- Make API types internal - causes problems with tests and test assemblies. --> |
15 | 26 | <Rule Id="CA1515" Action="None" /> |
| 27 | + <!-- Remove the underscores from member name - unit test scenarios may use underscores. --> |
16 | 28 | <Rule Id="CA1707" Action="None" /> |
| 29 | + <!-- Change names to avoid reserved word overlaps (e.g., Delegate, GetType, etc.) - too many of these in the public API, we'd break if we fixed it. --> |
17 | 30 | <Rule Id="CA1716" Action="None" /> |
| 31 | + <!-- Internal class that appears to never be instantiated - lots of false positives here because they're test stubs created by Autofac registrations. --> |
18 | 32 | <Rule Id="CA1812" Action="None" /> |
| 33 | + <!-- Change Dispose() to call GC.SuppressFinalize - in tests we don't really care and it can impact readability. --> |
19 | 34 | <Rule Id="CA1816" Action="None" /> |
| 35 | + <!-- Mark members static - test methods may not access member data but also can't be static. --> |
20 | 36 | <Rule Id="CA1822" Action="None" /> |
| 37 | + <!-- Seal internal types for performance - in tests we don't really care and it gets painful to enforce. --> |
21 | 38 | <Rule Id="CA1852" Action="None" /> |
| 39 | + <!-- Prefer static readonly fields over constant array arguments - constant array arguments happen a lot in unit tests for assertions and test setup. --> |
22 | 40 | <Rule Id="CA1861" Action="None" /> |
| 41 | + <!-- Cache a CompositeFormat object for use in String.Format - this makes unit tests harder to read, and performance isn't an issue. --> |
23 | 42 | <Rule Id="CA1863" Action="None" /> |
| 43 | + <!-- Call ConfigureAwait on tasks - you shouldn't do this in unit test libraries; XUnit has an opposite analyzer. --> |
24 | 44 | <Rule Id="CA2007" Action="None" /> |
| 45 | + <!-- Implement serialization constructors - false positive when building .NET Core. --> |
25 | 46 | <Rule Id="CA2229" Action="None" /> |
| 47 | + <!-- Use Uri instead of string parameters - strings are easier for testing. --> |
26 | 48 | <Rule Id="CA2234" Action="None" /> |
| 49 | + <!-- Mark ISerializable types with SerializableAttribute - false positive when building .NET Core. --> |
27 | 50 | <Rule Id="CA2237" Action="None" /> |
| 51 | + <!-- Prefer generic overloads to using Type parameters - we do a lot of reflection work in Autofac that needs to be tested. --> |
28 | 52 | <Rule Id="CA2263" Action="None" /> |
29 | 53 | </Rules> |
30 | 54 | <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers"> |
| 55 | + <!-- Prefix local calls with this. --> |
31 | 56 | <Rule Id="SA1101" Action="None" /> |
| 57 | + <!-- Use built-in type alias. --> |
32 | 58 | <Rule Id="SA1121" Action="None" /> |
| 59 | + <!-- Use String.Empty instead of "". --> |
33 | 60 | <Rule Id="SA1122" Action="None" /> |
| 61 | + <!-- Enforce order of class members by member type - sometimes putting test classes/data by the test helps. --> |
34 | 62 | <Rule Id="SA1201" Action="None" /> |
| 63 | + <!-- Enforce order of class members by member visibility - sometimes putting test classes/data by the test helps. --> |
35 | 64 | <Rule Id="SA1202" Action="None" /> |
| 65 | + <!-- Enforce order of static vs. non-static members - sometimes putting test classes/data by the test helps. --> |
36 | 66 | <Rule Id="SA1204" Action="None" /> |
| 67 | + <!-- Fields can't start with underscore. --> |
37 | 68 | <Rule Id="SA1309" Action="None" /> |
| 69 | + <!-- Elements should be documented. --> |
38 | 70 | <Rule Id="SA1600" Action="None" /> |
| 71 | + <!-- Partial items should be documented. --> |
39 | 72 | <Rule Id="SA1601" Action="None" /> |
| 73 | + <!-- Enumeration items should be documented. --> |
40 | 74 | <Rule Id="SA1602" Action="None" /> |
| 75 | + <!-- Parameter should be documented. --> |
41 | 76 | <Rule Id="SA1611" Action="None" /> |
| 77 | + <!-- Parameter documentation must be in the right order. --> |
42 | 78 | <Rule Id="SA1612" Action="None" /> |
| 79 | + <!-- Return value must be documented. --> |
43 | 80 | <Rule Id="SA1615" Action="None" /> |
| 81 | + <!-- Generic type parameters must be documented. --> |
44 | 82 | <Rule Id="SA1618" Action="None" /> |
| 83 | + <!-- Don't copy/paste documentation. --> |
45 | 84 | <Rule Id="SA1625" Action="None" /> |
46 | | - <Rule Id="SA1633" Action="None" /> |
| 85 | + <!-- Private member is unused - tests for reflection require members that may not get used. --> |
47 | 86 | <Rule Id="IDE0051" Action="None" /> |
| 87 | + <!-- Private member assigned value never read - tests for reflection require values that may not get used. --> |
48 | 88 | <Rule Id="IDE0052" Action="None" /> |
| 89 | + <!-- Remove unused parameter - tests for reflection require parameters that may not get used. --> |
49 | 90 | <Rule Id="IDE0060" Action="None" /> |
50 | 91 | </Rules> |
51 | 92 | </RuleSet> |
0 commit comments