Skip to content

Commit a41008f

Browse files
committed
Remove requirement that a class must have at least one method annotated with the Benchmark attribute when analyzing GenericTypeArguments attribute rules
1 parent 3fbb615 commit a41008f

File tree

5 files changed

+296
-401
lines changed

5 files changed

+296
-401
lines changed

src/BenchmarkDotNet.Analyzers/BenchmarkDotNetAnalyzerResources.Designer.cs

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/BenchmarkDotNet.Analyzers/BenchmarkDotNetAnalyzerResources.resx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
<value>A property annotated with a parameter attribute must have a public setter; make sure that the access modifier of the setter is empty and that the property is not an auto-property or an expression-bodied property.</value>
224224
</data>
225225
<data name="Attributes_ParamsAttribute_UnexpectedValueType_Description" xml:space="preserve">
226-
<value>The type of each value provided to the [Params] attribute must match the type of the field or property it is applied to</value>
226+
<value>The type of each value provided to the [Params] attribute must match the type of (or be implicitly convertible to) the field or property it is applied to</value>
227227
</data>
228228
<data name="Attributes_ParamsAllValuesAttribute_NotAllowedOnFlagsEnumPropertyOrFieldType_Description" xml:space="preserve">
229229
<value>The [ParamsAllValues] attribute cannot be applied to a field or property of an enum type marked with the [Flags] attribute. Use this attribute only with non-flags enum types, as [Flags] enums support bitwise combinations that cannot be exhaustively enumerated.</value>
@@ -289,7 +289,7 @@
289289
<value>Benchmark methods without [Arguments] attribute(s) cannot declare parameters</value>
290290
</data>
291291
<data name="Attributes_ArgumentsAttribute_MustHaveMatchingValueType_Title" xml:space="preserve">
292-
<value>Values passed to an [Arguments] attribute must match exactly the parameters declared in the targeted benchmark method in both type and order</value>
292+
<value>Values passed to an [Arguments] attribute must match exactly the parameters declared in the targeted benchmark method in both type (or be implicitly convertible to) and order</value>
293293
</data>
294294
<data name="Attributes_GeneralParameterAttributes_PropertyMustBePublic_Title" xml:space="preserve">
295295
<value>Properties annotated with a parameter attribute must be public</value>
@@ -304,7 +304,7 @@
304304
<value>Unnecessary single value passed to [Params] attribute</value>
305305
</data>
306306
<data name="Attributes_ParamsAttribute_UnexpectedValueType_Title" xml:space="preserve">
307-
<value>Type of all value(s) passed to the [Params] attribute must match the type of the annotated field or property</value>
307+
<value>Type of all value(s) passed to the [Params] attribute must match the type of (or be implicitly convertible to) the annotated field or property</value>
308308
</data>
309309
<data name="Attributes_ParamsAllValuesAttribute_NotAllowedOnFlagsEnumPropertyOrFieldType_Title" xml:space="preserve">
310310
<value>The [ParamsAllValues] attribute cannot be applied to fields or properties of enum types marked with [Flags]</value>
@@ -341,7 +341,7 @@
341341
Either add the [Arguments] attribute(s) or remove the parameters.</value>
342342
</data>
343343
<data name="Attributes_ArgumentsAttribute_MustHaveMatchingValueType_Description" xml:space="preserve">
344-
<value>The values passed to an [Arguments] attribute must match the parameters declared in the targeted benchmark method in both type (or be convertible to) and order</value>
344+
<value>The values passed to an [Arguments] attribute must match the parameters declared in the targeted benchmark method in both type (or be implicitly convertible to) and order</value>
345345
</data>
346346
<data name="Attributes_ArgumentsAttribute_RequiresBenchmarkAttribute_Title" xml:space="preserve">
347347
<value>[Arguments] attribute can only be used on methods annotated with the [Benchmark] attribute</value>

src/BenchmarkDotNet.Analyzers/DiagnosticIds.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ public static class DiagnosticIds
66
public const string BenchmarkRunner_Run_TypeArgumentClassMustBePublic = "BDN1001";
77
public const string BenchmarkRunner_Run_TypeArgumentClassMustBeNonAbstract = "BDN1002";
88
public const string BenchmarkRunner_Run_TypeArgumentClassMustBeUnsealed = "BDN1003";
9-
public const string General_BenchmarkClass_MethodMustBePublic = "BDN1100";
10-
public const string General_BenchmarkClass_MethodMustBeNonGeneric = "BDN1101";
11-
public const string General_BenchmarkClass_ClassMustBeNonStatic = "BDN1102";
12-
public const string General_BenchmarkClass_ClassWithGenericTypeArgumentsAttributeMustBeNonAbstract = "BDN1103";
13-
public const string General_BenchmarkClass_GenericClassMustBeAbstractOrAnnotatedWithAGenericTypeArgumentsAttribute = "BDN1104";
14-
public const string General_BenchmarkClass_ClassWithGenericTypeArgumentsAttributeMustBeGeneric = "BDN1105";
15-
public const string General_BenchmarkClass_GenericTypeArgumentsAttributeMustHaveMatchingTypeParameterCount = "BDN1106";
9+
public const string General_BenchmarkClass_ClassWithGenericTypeArgumentsAttributeMustBeNonAbstract = "BDN1100";
10+
public const string General_BenchmarkClass_GenericClassMustBeAbstractOrAnnotatedWithAGenericTypeArgumentsAttribute = "BDN1101";
11+
public const string General_BenchmarkClass_ClassWithGenericTypeArgumentsAttributeMustBeGeneric = "BDN1102";
12+
public const string General_BenchmarkClass_GenericTypeArgumentsAttributeMustHaveMatchingTypeParameterCount = "BDN1103";
13+
public const string General_BenchmarkClass_MethodMustBePublic = "BDN1104";
14+
public const string General_BenchmarkClass_MethodMustBeNonGeneric = "BDN1105";
15+
public const string General_BenchmarkClass_ClassMustBeNonStatic = "BDN1106";
1616
public const string General_BenchmarkClass_OnlyOneMethodCanBeBaseline = "BDN1107";
1717
public const string Attributes_GeneralParameterAttributes_MutuallyExclusiveOnField = "BDN1200";
1818
public const string Attributes_GeneralParameterAttributes_MutuallyExclusiveOnProperty = "BDN1201";

0 commit comments

Comments
 (0)