Skip to content

Commit 2d763cf

Browse files
alinasmirnovaAndreyAkinshin
authored andcommitted
Enable nullability for BenchmarkDotNet.Annotations
1 parent d391085 commit 2d763cf

File tree

6 files changed

+67
-65
lines changed

6 files changed

+67
-65
lines changed

src/BenchmarkDotNet.Annotations/Attributes/ArgumentsAttribute.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ namespace BenchmarkDotNet.Attributes
66
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
77
public class ArgumentsAttribute : PriorityAttribute
88
{
9-
public object[] Values { get; }
9+
public object?[] Values { get; }
1010

1111
// CLS-Compliant Code requires a constructor without an array in the argument list
1212
[PublicAPI]
1313
public ArgumentsAttribute() => Values = new object[0];
1414

15-
public ArgumentsAttribute(params object[] values)
16-
=> Values = values ?? new object[] { null }; // when users do Arguments(null) they mean one, null argument
15+
public ArgumentsAttribute(params object?[]? values)
16+
=> Values = values ?? new object?[] { null }; // when users do Arguments(null) they mean one, null argument
1717
}
1818
}

src/BenchmarkDotNet.Annotations/Attributes/BenchmarkAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public BenchmarkAttribute([CallerLineNumber] int sourceCodeLineNumber = 0, [Call
1414
SourceCodeFile = sourceCodeFile;
1515
}
1616

17-
public string Description { get; set; }
17+
public string? Description { get; set; }
1818

1919
public bool Baseline { get; set; }
2020

src/BenchmarkDotNet.Annotations/Attributes/BenchmarkCategoryAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class BenchmarkCategoryAttribute : Attribute
99
public string[] Categories { get; }
1010

1111
// CLS-Compliant Code requires a constructor without an array in the argument list
12-
[PublicAPI] protected BenchmarkCategoryAttribute() { }
12+
[PublicAPI] protected BenchmarkCategoryAttribute() => Categories = new string[0];
1313

1414
public BenchmarkCategoryAttribute(params string[] categories) => Categories = categories;
1515
}

src/BenchmarkDotNet.Annotations/Attributes/ParamsAttribute.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ namespace BenchmarkDotNet.Attributes
55
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
66
public class ParamsAttribute : PriorityAttribute
77
{
8-
public object[] Values { get; }
8+
public object?[] Values { get; }
99

1010
// CLS-Compliant Code requires a constructor without an array in the argument list
1111
public ParamsAttribute() => Values = new object[0];
1212

13-
public ParamsAttribute(params object[] values)
14-
=> Values = values ?? new object[] { null }; // when users do Params(null) they mean one, null argument
13+
public ParamsAttribute(params object?[]? values)
14+
=> Values = values ?? new object?[] { null }; // when users do Params(null) they mean one, null argument
1515
}
1616
}

src/BenchmarkDotNet.Annotations/BenchmarkDotNet.Annotations.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<RootNamespace>BenchmarkDotNet</RootNamespace>
1010
<!-- needed for docfx xref resolver -->
1111
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
12+
<Nullable>enable</Nullable>
1213
</PropertyGroup>
1314
<ItemGroup>
1415
<Compile Include="..\BenchmarkDotNet\Helpers\CodeAnnotations.cs" Link="Attributes\CodeAnnotations.cs" />

0 commit comments

Comments
 (0)