Skip to content

Commit 6b73e58

Browse files
paulirwinclaude
andcommitted
Fix CS0121 ambiguity for NUnit 4.6 Action overloads in Assert wrappers
NUnit 4.6 added Action overloads alongside the existing TestDelegate ones, making `() => action()` lambdas ambiguous. Pass the Action directly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 220bec8 commit 6b73e58

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

  • src/Lucene.Net.TestFramework/Support/TestFramework

src/Lucene.Net.TestFramework/Support/TestFramework/Assert.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -898,14 +898,14 @@ public static void Greater(int arg1, int arg2)
898898
[MethodImpl(MethodImplOptions.AggressiveInlining)]
899899
public static void DoesNotThrow(Action action, string message, params object[] args)
900900
{
901-
_NUnit.ClassicAssert.DoesNotThrow(() => action(), message, args);
901+
_NUnit.ClassicAssert.DoesNotThrow(action, message, args);
902902
}
903903

904904
[DebuggerStepThrough]
905905
[MethodImpl(MethodImplOptions.AggressiveInlining)]
906906
public static void DoesNotThrow(Action action)
907907
{
908-
_NUnit.ClassicAssert.DoesNotThrow(() => action());
908+
_NUnit.ClassicAssert.DoesNotThrow(action);
909909
}
910910

911911
[DebuggerStepThrough]
@@ -926,22 +926,22 @@ public static Exception Throws<TException>(Action action)
926926
[MethodImpl(MethodImplOptions.AggressiveInlining)]
927927
public static Exception Throws(Type expectedExceptionType, Action action)
928928
{
929-
return _NUnit.ClassicAssert.Throws(expectedExceptionType, () => action());
929+
return _NUnit.ClassicAssert.Throws(expectedExceptionType, action);
930930
}
931931

932932
[DebuggerStepThrough]
933933
[MethodImpl(MethodImplOptions.AggressiveInlining)]
934934
public static Exception Throws(Type expectedExceptionType, Action action, string message, params object[] args)
935935
{
936-
return _NUnit.ClassicAssert.Throws(expectedExceptionType, () => action(), message, args);
936+
return _NUnit.ClassicAssert.Throws(expectedExceptionType, action, message, args);
937937
}
938938

939939
[DebuggerStepThrough]
940940
[MethodImpl(MethodImplOptions.AggressiveInlining)]
941941
public static T Throws<T>(string expectedParamName, Action action)
942942
where T : ArgumentException
943943
{
944-
T exception = _NUnit.ClassicAssert.Throws<T>(() => action());
944+
T exception = _NUnit.ClassicAssert.Throws<T>(action);
945945

946946
if (exception is null)
947947
{

0 commit comments

Comments
 (0)