You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow ArgumentsSource to reference methods in other types (#2748)
* Allow ArgumentsSource to reference methods in other types
* Update docs for custom ArgumentsSource type
* Allow ParamsSource to reference methods in other types
* Update docs for custom ParamsSource type
* Add test for ArgumentsSource with custom type
* Add test for ParamsSource with custom type
In this attribute, you have to specify the name of public method/property which is going to provide the values
13
13
(something that implements `IEnumerable`).
14
-
The source must be within benchmarked type!
14
+
The source may be instance or static. If the source is not in the same type as the benchmark, the type containing the source must be specified in the attribute constructor.
In this attribute, you have to specify the name of public method/property which is going to provide the values
12
12
(something that implements `IEnumerable`).
13
-
The source must be within benchmarked type!
13
+
The source may be instance or static. If the source is not in the same type as the benchmark, the type containing the source must be specified in the attribute constructor.
Copy file name to clipboardExpand all lines: samples/BenchmarkDotNet.Samples/IntroArgumentsSource.cs
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,12 @@ public class IntroArgumentsSource
20
20
}
21
21
22
22
[Benchmark]
23
-
[ArgumentsSource(nameof(TimeSpans))]
23
+
[ArgumentsSource(typeof(BenchmarkArguments),nameof(BenchmarkArguments.TimeSpans))]// when the arguments come from a different type, specify that type here
thrownewInvalidBenchmarkDeclarationException($"{parentType.Name} has no public, accessible method/property called {sourceName}, unable to read values for [ParamsSource]");
327
+
thrownewInvalidBenchmarkDeclarationException($"{sourceType.Name} has no public, accessible method/property called {sourceName}, unable to read values for [ParamsSource]");
0 commit comments