Commit 8fed488
Add Roslyn analyzers to detect incorrect usage of BenchmarkDotNet (#2837)
* Add Roslyn analyzers to detect incorrect usage of BenchmarkDotNet
* Unify C# language version
* Remove Analyzers package projects
* Revert BenchmarkDotNet.Disassembler changes
* Reference Analyzers project from Annotations
* Move Benchmark.Analyzers and Benchmark.Analyzers.Tests to correct directories
* Remove accidentally added package Microsoft.CodeAnalysis.NetAnalyzers from BenchmarkDotNet.Annotations
* * Benchmark classes annotated with a [GenericTypeArguments] attribute must be non-abstract and generic
* Benchmark classes are allowed to be generic if they are either abstract or annotated with at least one [GenericTypeArguments] attribute
* Assume that a class can be annotated with more than one [GenericTypeArguments] attribute
* * Change diagnostic ID increment ordering
* Add a rule that the benchmark class referenced in the type argument of the BenchmarkRunner.Run method cannot be abstract
* When determining whether a class has any benchmark methods, iterate through its ancestors
* Move "Benchmark class cannot be sealed" to Run analyzer
* Move "Benchmark class must be public" to Run analyzer
* Support analyzing overload of BenchmarkRunner.Run that takes a Type parameter created by using a typeof expression
* Remove requirement that a class must have at least one method annotated with the Benchmark attribute when analyzing GenericTypeArguments attribute rules
* * Integer attribute values that fit within target type range should not trigger mismatching type diagnostics
* Test all valid attribute value types when performing type matching
* Use a dummy syntax tree to test whether types are implicitly convertible
* Move "Generic class must be abstract or annotated with a [GenericTypeArgumentsAttribute]" to Run analyzer and remove abstract modifier requirement
* Add support to analyze implicit conversion from an array to a Span of said array for [Arguments] attribute values
* Add support to analyze implicit conversion when using constant values for [Params] and [Arguments] attribute values
* * Add support to analyze a boolean constant value for the Baseline property on BenchmarkAttribute
* Split logic for baseline method analyzer into two rules, also verifying whether they're unique per category
* Add test to OnlyOneMethodCanBeBaselinePerCategory rule verifying that it works correctly with invalid string values
* Disable warnings for "Missing XML comment for publicly visible type or member" (CS1591)
* Correct resource strings for OnlyOneMethodCanBeBaselinePerCategory rule
* Build error fixes
* Add analyzer projects to main sln.
Run analyzer tests in CI.
Fix compile errors.
Ensure analyzers run against test projects.
* Revert annotations csproj.
Add analyzers to samples.
* * Change severity level of "UnnecessarySingleValuePassedToAttribute" rule from warning to information
* Move diagnostic "MethodWithoutAttributeMustHaveNoParameters" to its own analyzer and also take [ArgumentsSource] attribute into consideration
* Suppress analyzer errors for incorrect BenchmarkDotNet usages in tests
* Adjust wording of "ClassWithGenericTypeArgumentsAttributeMustBeGenericRule" diagnostic and move trigger location to the attribute level
* Revert suppressing of BDN1401 in ArgumentsTests.cs
* Revert suppressing of BDN1401 in FullNameProviderTests.cs, PriorityTests.cs and TypeFilterTests.cs
* Fix Directory.build.props included in autogenerated projects.
* Add message to failing CI test.
* Revert sdk update.
* Suppress warning.
* Skip failing test
* Adjust wording of "ClassWithGenericTypeArgumentsAttributeMustBeNonAbstract" diagnostic and move trigger location to the attribute level
* Add diagnostics for unintendedly passing a single null value to the [Arguments] or [Params] attribute
* Revert commit d760312
* Formatting
---------
Co-authored-by: Tim Cassell <cassell.timothy@gmail.com>1 parent 24a357b commit 8fed488
File tree
52 files changed
+11009
-73
lines changed- .github/workflows
- build
- BenchmarkDotNet.Build
- Runners
- samples/BenchmarkDotNet.Samples
- src
- BenchmarkDotNet.Analyzers
- Attributes
- BenchmarkRunner
- General
- BenchmarkDotNet.Annotations
- tests
- BenchmarkDotNet.Analyzers.Tests
- AnalyzerTests
- Attributes
- BenchmarkRunner
- General
- Fixtures
- Extensions
- Generators
- Serializable
- TheoryData
- BenchmarkDotNet.Exporters.Plotting.Tests
- BenchmarkDotNet.IntegrationTests
- BenchmarkDotNet.Tests
- Attributes
- Exporters
- Running
- Validators
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
52 files changed
+11009
-73
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| |||
79 | 85 | | |
80 | 86 | | |
81 | 87 | | |
| 88 | + | |
| 89 | + | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
| |||
116 | 124 | | |
117 | 125 | | |
118 | 126 | | |
| 127 | + | |
| 128 | + | |
119 | 129 | | |
120 | 130 | | |
121 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
| |||
161 | 165 | | |
162 | 166 | | |
163 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
164 | 176 | | |
165 | 177 | | |
166 | 178 | | |
| |||
190 | 202 | | |
191 | 203 | | |
192 | 204 | | |
| 205 | + | |
| 206 | + | |
193 | 207 | | |
194 | 208 | | |
195 | 209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
101 | 123 | | |
102 | 124 | | |
103 | 125 | | |
| |||
123 | 145 | | |
124 | 146 | | |
125 | 147 | | |
126 | | - | |
| 148 | + | |
127 | 149 | | |
| 150 | + | |
128 | 151 | | |
129 | 152 | | |
130 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
| |||
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
73 | 85 | | |
74 | 86 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
43 | 47 | | |
0 commit comments