Skip to content

Commit c787a53

Browse files
committed
cleanup
1 parent 7f26e70 commit c787a53

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

src/FastExpressionCompiler/TestTools.cs

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ public CallerArgumentExpression(string parameterName) { }
564564
#endif
565565

566566
/// <summary>Wrapper for the context per test method</summary>
567+
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "This is used for the testing purposes only.")]
567568
public struct TestContext
568569
{
569570
public readonly TestRun TestRun;
@@ -600,8 +601,6 @@ public bool IsTrue(bool actual,
600601
Fail(testName, sourceLineNumber, AssertKind.IsTrue,
601602
$"Expected `IsTrue({actualName})`, but found false");
602603

603-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
604-
Justification = "The method is used for the testing purposes only.")]
605604
[MethodImpl(MethodImplOptions.AggressiveInlining)]
606605
public bool AreEqual<T>(T expected, T actual,
607606
[CallerArgumentExpression(nameof(expected))] string expectedName = "<expected>",
@@ -610,8 +609,6 @@ public bool AreEqual<T>(T expected, T actual,
610609
Equals(expected, actual) || Fail(testName, sourceLineNumber, AssertKind.AreEqual,
611610
$"Expected `AreEqual({expectedName}, {actualName})`, but found `{expected.ToCode()}` is Not equal to `{actual.ToCode()}`");
612611

613-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
614-
Justification = "The method is used for the testing purposes only.")]
615612
[MethodImpl(MethodImplOptions.AggressiveInlining)]
616613
public static bool AreSame<T>(T expected, T actual,
617614
[CallerArgumentExpression(nameof(expected))]
@@ -621,8 +618,6 @@ public static bool AreSame<T>(T expected, T actual,
621618
ReferenceEquals(expected, actual) ? true : throw new AssertionException(
622619
$"Expected `AreSame({expectedName}, {actualName})`, but found `{expected.ToCode()}` is Not the same `{actual.ToCode()}`");
623620

624-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
625-
Justification = "The method is used for the testing purposes only.")]
626621
[MethodImpl(MethodImplOptions.AggressiveInlining)]
627622
public static bool AreNotSame<T>(T expected, T actual,
628623
[CallerArgumentExpression(nameof(expected))]
@@ -632,8 +627,6 @@ public static bool AreNotSame<T>(T expected, T actual,
632627
!ReferenceEquals(expected, actual) ? true : throw new AssertionException(
633628
$"Expected `AreNotSame({expectedName}, {actualName})`, but found `{expected.ToCode()}` is same as `{actual.ToCode()}`");
634629

635-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
636-
Justification = "The method is used for the testing purposes only.")]
637630
[MethodImpl(MethodImplOptions.AggressiveInlining)]
638631
public static bool AreEqual<T>(T expected, T actual,
639632
[CallerArgumentExpression(nameof(expected))]
@@ -643,8 +636,6 @@ public static bool AreEqual<T>(T expected, T actual,
643636
Equals(expected, actual) ? true : throw new AssertionException(
644637
$"Expected `AreEqual({expectedName}, {actualName})`, but found `{expected.ToCode()}` is Not equal to `{actual.ToCode()}`");
645638

646-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
647-
Justification = "The method is used for the testing purposes only.")]
648639
[MethodImpl(MethodImplOptions.AggressiveInlining)]
649640
public static bool AreNotEqual<T>(T expected, T actual,
650641
[CallerArgumentExpression(nameof(expected))] string expectedName = "expected", [CallerArgumentExpression(nameof(actual))]
@@ -655,8 +646,6 @@ public static bool AreNotEqual<T>(T expected, T actual,
655646
public record struct ItemsCompared<T>(int Index, bool IsEqual, T Expected, T Actual);
656647

657648
/// <summary>Should cover the case with the `expected` to be an array as well.</summary>
658-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
659-
Justification = "The method is used for the testing purposes only.")]
660649
public static bool AreEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual,
661650
[CallerArgumentExpression(nameof(expected))] string expectedName = "expected",
662651
[CallerArgumentExpression(nameof(actual))] string actualName = "actual")
@@ -805,15 +794,14 @@ public static bool AreEqual<T>(IEnumerable<T> expected, IEnumerable<T> actual,
805794
return true;
806795
}
807796

797+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
808798
public static bool AreEqual<T>(T[] expected, T[] actual,
809799
[CallerArgumentExpression(nameof(expected))]
810800
string expectedName = "expected",
811801
[CallerArgumentExpression(nameof(actual))]
812802
string actualName = "actual") =>
813803
AreEqual((IEnumerable<T>)expected, actual, expectedName, actualName);
814804

815-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
816-
Justification = "The method is used for the testing purposes only.")]
817805
[MethodImpl(MethodImplOptions.AggressiveInlining)]
818806
public static bool GreaterOrEqual<T>(T expected, T actual,
819807
[CallerArgumentExpression(nameof(expected))]
@@ -824,8 +812,6 @@ public static bool GreaterOrEqual<T>(T expected, T actual,
824812
expected.CompareTo(actual) >= 0 ? true : throw new AssertionException(
825813
$"Expected `GreaterOrEqual({expectedName}, {actualName})`, but found `{expected.ToCode()} < {actual.ToCode()}`");
826814

827-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
828-
Justification = "The method is used for the testing purposes only.")]
829815
[MethodImpl(MethodImplOptions.AggressiveInlining)]
830816
public static bool Less<T>(T expected, T actual,
831817
[CallerArgumentExpression(nameof(expected))]
@@ -836,8 +822,6 @@ public static bool Less<T>(T expected, T actual,
836822
expected.CompareTo(actual) < 0 ? true : throw new AssertionException(
837823
$"Expected `Less({expectedName}, {actualName})`, but found `{expected.ToCode()} >= {actual.ToCode()}`");
838824

839-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
840-
Justification = "The method is used for the testing purposes only.")]
841825
[MethodImpl(MethodImplOptions.AggressiveInlining)]
842826
public static bool Greater<T>(T expected, T actual,
843827
[CallerArgumentExpression(nameof(expected))]
@@ -848,8 +832,6 @@ public static bool Greater<T>(T expected, T actual,
848832
expected.CompareTo(actual) > 0 ? true : throw new AssertionException(
849833
$"Expected `Greater({expectedName}, {actualName})`, but found `{expected.ToCode()} <= {actual.ToCode()}`");
850834

851-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
852-
Justification = "The method is used for the testing purposes only.")]
853835
[MethodImpl(MethodImplOptions.AggressiveInlining)]
854836
public static bool LessOrEqual<T>(T expected, T actual,
855837
[CallerArgumentExpression(nameof(expected))]
@@ -860,8 +842,6 @@ public static bool LessOrEqual<T>(T expected, T actual,
860842
expected.CompareTo(actual) <= 0 ? true : throw new AssertionException(
861843
$"Expected `LessOrEqual({expectedName}, {actualName})`, but found `{expected.ToCode()} > {actual.ToCode()}`");
862844

863-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
864-
Justification = "The method is used for the testing purposes only.")]
865845
[MethodImpl(MethodImplOptions.AggressiveInlining)]
866846
public bool IsNull<T>(T actual,
867847
[CallerArgumentExpression(nameof(actual))] string actualName = "actual",
@@ -904,17 +884,13 @@ public bool IsFalse(bool actual,
904884
!actual || Fail(testName, sourceLineNumber, AssertKind.IsFalse,
905885
$"Expected `IsFalse({actualName})`, but found true");
906886

907-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
908-
Justification = "The method is used for the testing purposes only.")]
909887
[MethodImpl(MethodImplOptions.AggressiveInlining)]
910888
public static bool IsInstanceOf<T>(object actual,
911889
[CallerArgumentExpression(nameof(actual))]
912890
string actualName = "actual") =>
913891
actual is T ? true : throw new AssertionException(
914892
$"Expected `IsInstanceOf<{typeof(T).ToCode()}>({actualName})`, but found `IsInstanceOf<{actual?.GetType().ToCode() ?? "_"}>({actual.ToCode()})`");
915893

916-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
917-
Justification = "The method is used for the testing purposes only.")]
918894
public static E Throws<E>(Action action,
919895
[CallerArgumentExpression(nameof(action))]
920896
string actionName = "<action to throw>")
@@ -936,8 +912,6 @@ public static E Throws<E>(Action action,
936912
throw new AssertionException($"Expected `Throws<{typeof(E).ToCode()}>({actionName})`, but no exception was thrown");
937913
}
938914

939-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
940-
Justification = "The method is used for the testing purposes only.")]
941915
[MethodImpl(MethodImplOptions.AggressiveInlining)]
942916
public static bool Contains(string expected, string actual,
943917
[CallerArgumentExpression(nameof(expected))]
@@ -947,8 +921,6 @@ public static bool Contains(string expected, string actual,
947921
actual.Contains(expected) ? true : throw new AssertionException(
948922
$"Expected string `Contains({expectedName}, {actualName})`, but found expected `{expected.ToCode()}` is not in `{actual.ToCode()}`");
949923

950-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
951-
Justification = "The method is used for the testing purposes only.")]
952924
[MethodImpl(MethodImplOptions.AggressiveInlining)]
953925
public static bool DoesNotContain(string expected, string actual,
954926
[CallerArgumentExpression(nameof(expected))]
@@ -958,8 +930,6 @@ public static bool DoesNotContain(string expected, string actual,
958930
!actual.Contains(expected) ? true : throw new AssertionException(
959931
$"Expected string `DoesNotContain({expectedName}, {actualName})`, but found expected `{expected.ToCode()}` is in `{actual.ToCode()}`");
960932

961-
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
962-
Justification = "The method is used for the testing purposes only.")]
963933
[MethodImpl(MethodImplOptions.AggressiveInlining)]
964934
public static bool StartsWith(string expected, string actual,
965935
[CallerArgumentExpression(nameof(expected))]
@@ -1030,4 +1000,4 @@ public void Run<T>(T test, TestTracking tracking = TestTracking.TrackFailedTests
10301000
}
10311001
}
10321002

1033-
#pragma warning restore CS1591
1003+
#pragma warning restore CS1591

0 commit comments

Comments
 (0)