Skip to content

Commit e20d4f9

Browse files
committed
Revert suppressing of BDN1401 in ArgumentsTests.cs
1 parent 0af0204 commit e20d4f9

File tree

1 file changed

+31
-77
lines changed

1 file changed

+31
-77
lines changed

tests/BenchmarkDotNet.IntegrationTests/ArgumentsTests.cs

Lines changed: 31 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,14 @@ public ValueTask<int> SimpleValueTaskAsync(bool boolean, int number)
6666

6767
public class WithArgumentsSource
6868
{
69-
#pragma warning disable BDN1401
7069
[Benchmark]
7170
[ArgumentsSource(nameof(ArgumentsProvider))]
7271
public void Simple(bool boolean, int number)
7372
{
7473
if (boolean && number != 1 || !boolean && number != 2)
7574
throw new InvalidOperationException("Incorrect values were passed");
76-
}
77-
#pragma warning restore BDN1401
78-
75+
}
76+
7977
public IEnumerable<object[]> ArgumentsProvider()
8078
{
8179
yield return new object[] { true, 1 };
@@ -88,38 +86,31 @@ public IEnumerable<object[]> ArgumentsProvider()
8886

8987
public class WithArgumentsSourceInAnotherClass
9088
{
91-
#pragma warning disable BDN1401
9289
[Benchmark]
9390
[ArgumentsSource(typeof(ExternalClassWithArgumentsSource), nameof(ExternalClassWithArgumentsSource.OnePrimitiveType))]
9491
public void OnePrimitiveType(int number)
9592
{
9693
if (number % 2 != 1)
9794
throw new InvalidOperationException("Incorrect values were passed");
9895
}
99-
#pragma warning restore BDN1401
10096

101-
#pragma warning disable BDN1401
10297
[Benchmark]
10398
[ArgumentsSource(typeof(ExternalClassWithArgumentsSource), nameof(ExternalClassWithArgumentsSource.TwoPrimitiveTypes))]
10499
public void TwoPrimitiveTypes(bool boolean, int number)
105100
{
106101
if (boolean && number != 1 || !boolean && number != 2)
107102
throw new InvalidOperationException("Incorrect values were passed");
108-
}
109-
#pragma warning restore BDN1401
110-
111-
#pragma warning disable BDN1401
103+
}
104+
112105
[Benchmark]
113106
[ArgumentsSource(typeof(ExternalClassWithArgumentsSource), nameof(ExternalClassWithArgumentsSource.OneNonPrimitiveType))]
114107
public void OneNonPrimitiveType(Version version)
115108
{
116109
int[] versionNumbers = { version.Major, version.Minor, version.MinorRevision, version.Build };
117110
if (versionNumbers.Distinct().Count() != 4)
118111
throw new InvalidOperationException("Incorrect values were passed");
119-
}
120-
#pragma warning restore BDN1401
121-
122-
#pragma warning disable BDN1401
112+
}
113+
123114
[Benchmark]
124115
[ArgumentsSource(typeof(ExternalClassWithArgumentsSource), nameof(ExternalClassWithArgumentsSource.TwoNonPrimitiveTypes))]
125116
public void TwoNonPrimitiveTypes(Version version, DateTime dateTime)
@@ -130,10 +121,8 @@ public void TwoNonPrimitiveTypes(Version version, DateTime dateTime)
130121

131122
if (dateTime.Month != dateTime.Day)
132123
throw new InvalidOperationException("Incorrect values were passed");
133-
}
134-
#pragma warning restore BDN1401
135-
136-
#pragma warning disable BDN1401
124+
}
125+
137126
[Benchmark]
138127
[ArgumentsSource(typeof(ExternalClassWithArgumentsSource), nameof(ExternalClassWithArgumentsSource.OnePrimitiveAndOneNonPrimitive))]
139128
public void OnePrimitiveAndOneNonPrimitive(Version version, int number)
@@ -144,8 +133,7 @@ public void OnePrimitiveAndOneNonPrimitive(Version version, int number)
144133

145134
if (number != version.Major)
146135
throw new InvalidOperationException("Incorrect values were passed");
147-
}
148-
#pragma warning restore BDN1401
136+
}
149137
}
150138
public static class ExternalClassWithArgumentsSource
151139
{
@@ -221,7 +209,6 @@ public class WithComplexTypesReturnedFromSources
221209
[ParamsSource(nameof(SameButStatic))]
222210
public Dictionary<int, string> DictionaryParamStatic;
223211

224-
#pragma warning disable BDN1401
225212
[Benchmark]
226213
[ArgumentsSource(nameof(NonPrimitive))]
227214
public void Simple(SomeClass someClass, SomeStruct someStruct)
@@ -241,9 +228,8 @@ public void Simple(SomeClass someClass, SomeStruct someStruct)
241228
for (int i = 0; i < someStruct.RangeEnd; i++)
242229
if (someClass.Values[i] != i * 2)
243230
throw new InvalidOperationException("Incorrect array values were passed");
244-
}
245-
#pragma warning restore BDN1401
246-
231+
}
232+
247233
public IEnumerable<object[]> NonPrimitive()
248234
{
249235
yield return new object[] { new SomeClass(Enumerable.Range(0, 100).ToArray()), new SomeStruct(100) };
@@ -307,19 +293,16 @@ public IEnumerable<object[]> Sources()
307293
yield return new object[] { "Iterator.Select.Where", Iterator().Select(i => i).Where(i => i % 2 == 0) };
308294
}
309295

310-
#pragma warning disable BDN1401
311296
[Benchmark]
312297
[ArgumentsSource(nameof(Sources))]
313-
public void Any(string name, IEnumerable<int> source) => source.Any();
314-
#pragma warning restore BDN1401
298+
public void Any(string name, IEnumerable<int> source) => source.Any();
315299
}
316300

317301
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
318302
public void JaggedArrayCanBeUsedAsArgument(IToolchain toolchain) => CanExecute<WithJaggedArray>(toolchain);
319303

320304
public class WithJaggedArray
321305
{
322-
#pragma warning disable BDN1401
323306
[Benchmark]
324307
[ArgumentsSource(nameof(CreateMatrix))]
325308
public void Test(int[][] array)
@@ -331,9 +314,8 @@ public void Test(int[][] array)
331314
for (int j = 0; j < i; j++)
332315
if (array[i][j] != i)
333316
throw new ArgumentException("Invalid value");
334-
}
335-
#pragma warning restore BDN1401
336-
317+
}
318+
337319
public IEnumerable<object> CreateMatrix()
338320
{
339321
int[][] jagged = new int[10][];
@@ -369,7 +351,6 @@ public Generic(T1 item1, T2 item2)
369351
}
370352
}
371353

372-
#pragma warning disable BDN1401
373354
[Benchmark]
374355
[ArgumentsSource(nameof(GetInputData))]
375356
public bool ValueTupleCompareNoOpt(ref Generic<int, string> byRef)
@@ -381,9 +362,8 @@ public bool ValueTupleCompareNoOpt(ref Generic<int, string> byRef)
381362
throw new ArgumentException("Wrong values");
382363

383364
return true;
384-
}
385-
#pragma warning restore BDN1401
386-
365+
}
366+
387367
public IEnumerable<object> GetInputData()
388368
{
389369
yield return new Generic<int, string>(3, "red");
@@ -504,15 +484,13 @@ public IEnumerable<object> GetArrayOfString()
504484
yield return new string[123];
505485
}
506486

507-
#pragma warning disable BDN1401
508487
[Benchmark]
509488
[ArgumentsSource(nameof(GetArrayOfString))]
510489
public void TypeReflectionArrayGetType(string[] array)
511490
{
512491
if (array.Length != 123)
513492
throw new ArgumentException("The array was empty");
514-
}
515-
#pragma warning restore BDN1401
493+
}
516494
}
517495

518496
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)] // make sure BDN mimics xunit's MemberData behaviour
@@ -526,15 +504,13 @@ public IEnumerable<object[]> GetArguments()
526504
yield return new object[] { true };
527505
}
528506

529-
#pragma warning disable BDN1401
530507
[Benchmark]
531508
[ArgumentsSource(nameof(GetArguments))]
532509
public void SingleArgument(bool boolean)
533510
{
534511
if (boolean != true)
535512
throw new ArgumentException("The value of boolean was incorrect");
536-
}
537-
#pragma warning restore BDN1401
513+
}
538514
}
539515

540516
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
@@ -551,7 +527,6 @@ public IEnumerable<object[]> GetArrays()
551527
};
552528
}
553529

554-
#pragma warning disable BDN1401
555530
[Benchmark]
556531
[ArgumentsSource(nameof(GetArrays))]
557532
public void AcceptsArrays(int[] even, int[] notEven)
@@ -564,8 +539,7 @@ public void AcceptsArrays(int[] even, int[] notEven)
564539

565540
if (!notEven.All(n => n % 2 != 0))
566541
throw new ArgumentException("Even");
567-
}
568-
#pragma warning restore BDN1401
542+
}
569543
}
570544

571545
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
@@ -578,7 +552,6 @@ public IEnumerable<object> GetVeryBigInteger()
578552
yield return BigInteger.Parse(new string(Enumerable.Repeat('1', 1000).ToArray()));
579553
}
580554

581-
#pragma warning disable BDN1401
582555
[Benchmark]
583556
[ArgumentsSource(nameof(GetVeryBigInteger))]
584557
public void Method(BigInteger passed)
@@ -587,8 +560,7 @@ public void Method(BigInteger passed)
587560

588561
if (expected != passed)
589562
throw new ArgumentException("The BigInteger has wrong value!");
590-
}
591-
#pragma warning restore BDN1401
563+
}
592564
}
593565

594566
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
@@ -606,7 +578,6 @@ public IEnumerable<object[]> GetSpecialDoubleValues()
606578
yield return new object[] { double.PositiveInfinity, nameof(double.PositiveInfinity) };
607579
}
608580

609-
#pragma warning disable BDN1401
610581
[Benchmark]
611582
[ArgumentsSource(nameof(GetSpecialDoubleValues))]
612583
public void Method(double passed, string name)
@@ -634,8 +605,7 @@ public void Method(double passed, string name)
634605
default:
635606
throw new InvalidOperationException($"Unknown case! {name}");
636607
}
637-
}
638-
#pragma warning restore BDN1401
608+
}
639609
}
640610

641611
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
@@ -653,7 +623,6 @@ public IEnumerable<object[]> GetSpecialFloatValues()
653623
yield return new object[] { float.PositiveInfinity, nameof(float.PositiveInfinity) };
654624
}
655625

656-
#pragma warning disable BDN1401
657626
[Benchmark]
658627
[ArgumentsSource(nameof(GetSpecialFloatValues))]
659628
public void Method(float passed, string name)
@@ -681,8 +650,7 @@ public void Method(float passed, string name)
681650
default:
682651
throw new InvalidOperationException($"Unknown case! {name}");
683652
}
684-
}
685-
#pragma warning restore BDN1401
653+
}
686654
}
687655

688656
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
@@ -696,7 +664,6 @@ public IEnumerable<object[]> GetSpecialDecimalValues()
696664
yield return new object[] { decimal.MinValue, nameof(decimal.MinValue) };
697665
}
698666

699-
#pragma warning disable BDN1401
700667
[Benchmark]
701668
[ArgumentsSource(nameof(GetSpecialDecimalValues))]
702669
public void Method(decimal passed, string name)
@@ -712,8 +679,7 @@ public void Method(decimal passed, string name)
712679
default:
713680
throw new InvalidOperationException($"Unknown case! {name}");
714681
}
715-
}
716-
#pragma warning restore BDN1401
682+
}
717683
}
718684

719685
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
@@ -726,7 +692,6 @@ public IEnumerable<object> DateTimeValues()
726692
yield return new DateTime(2018, 8, 15);
727693
}
728694

729-
#pragma warning disable BDN1401
730695
[Benchmark]
731696
[ArgumentsSource(nameof(DateTimeValues))]
732697
public void Test(DateTime passed)
@@ -735,8 +700,7 @@ public void Test(DateTime passed)
735700

736701
if (expected != passed)
737702
throw new ArgumentException("The DateTime has wrong value!");
738-
}
739-
#pragma warning restore BDN1401
703+
}
740704
}
741705

742706
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
@@ -846,7 +810,6 @@ public static IEnumerable<object> StaticProperty
846810
[ParamsSource(nameof(StaticProperty))]
847811
public int ParamTwo { get; set; }
848812

849-
#pragma warning disable BDN1401
850813
[Benchmark]
851814
[ArgumentsSource(nameof(StaticMethod))]
852815
public void TestMethod(int argument)
@@ -857,10 +820,8 @@ public void TestMethod(int argument)
857820
throw new ArgumentException("The ParamOne value is incorrect!");
858821
if (ParamTwo != 2 && ParamTwo != 3)
859822
throw new ArgumentException("The ParamTwo value is incorrect!");
860-
}
861-
#pragma warning restore BDN1401
862-
863-
#pragma warning disable BDN1401
823+
}
824+
864825
[Benchmark]
865826
[ArgumentsSource(nameof(StaticProperty))]
866827
public void TestProperty(int argument)
@@ -871,8 +832,7 @@ public void TestProperty(int argument)
871832
throw new ArgumentException("The ParamOne value is incorrect!");
872833
if (ParamTwo != 2 && ParamTwo != 3)
873834
throw new ArgumentException("The ParamTwo value is incorrect!");
874-
}
875-
#pragma warning restore BDN1401
835+
}
876836
}
877837

878838
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
@@ -897,7 +857,6 @@ public static IEnumerable<object[]> StaticProperty
897857
[ParamsSource(nameof(StaticProperty))]
898858
public int ParamTwo { get; set; }
899859

900-
#pragma warning disable BDN1401
901860
[Benchmark]
902861
[ArgumentsSource(nameof(StaticMethod))]
903862
public void TestMethod(int argument)
@@ -908,10 +867,8 @@ public void TestMethod(int argument)
908867
throw new ArgumentException("The ParamOne value is incorrect!");
909868
if (ParamTwo != 2 && ParamTwo != 3)
910869
throw new ArgumentException("The ParamTwo value is incorrect!");
911-
}
912-
#pragma warning restore BDN1401
913-
914-
#pragma warning disable BDN1401
870+
}
871+
915872
[Benchmark]
916873
[ArgumentsSource(nameof(StaticProperty))]
917874
public void TestProperty(int argument)
@@ -922,8 +879,7 @@ public void TestProperty(int argument)
922879
throw new ArgumentException("The ParamOne value is incorrect!");
923880
if (ParamTwo != 2 && ParamTwo != 3)
924881
throw new ArgumentException("The ParamTwo value is incorrect!");
925-
}
926-
#pragma warning restore BDN1401
882+
}
927883
}
928884

929885
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
@@ -996,7 +952,6 @@ public IEnumerable<object[]> Arguments()
996952
yield return new object[] { LongString, LongString2 };
997953
}
998954

999-
#pragma warning disable BDN1401
1000955
[Benchmark]
1001956
[ArgumentsSource(nameof(Arguments))]
1002957
public void Test(string first, string second)
@@ -1005,8 +960,7 @@ public void Test(string first, string second)
1005960
throw new ArgumentException($"{nameof(first)} passed string has wrong value!");
1006961
if (second != LongString2)
1007962
throw new ArgumentException($"{nameof(second)} passed string has wrong value!");
1008-
}
1009-
#pragma warning restore BDN1401
963+
}
1010964
}
1011965

1012966
[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]

0 commit comments

Comments
 (0)