-
-
Notifications
You must be signed in to change notification settings - Fork 111
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
This will throw InvalidOperationException:
public record Record(Type Type);
public class Foo
{
[Test]
public async Task Bar()
{
var r = new Record(typeof(string));
await Assert.That(r).IsEquivalentTo(r);
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TUnit" Version="1.13.11" />
</ItemGroup>
</Project>
Expected Behavior
The test should pass
Actual Behavior
Test fails
Steps to Reproduce
See description
TUnit Version
1.13.11
.NET Version
net10.0
Operating System
macOS
IDE / Test Runner
JetBrains Rider
Error Output / Stack Trace
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.InvalidOperationException: Method may only be called on a Type for which Type.IsGenericParameter is true.
at System.RuntimeType.get_DeclaringMethod()
at InvokeStub_RuntimeType.get_DeclaringMethod(Object, Object, IntPtr*)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at TUnit.Assertions.Conditions.Helpers.ReflectionHelper.GetMemberValue(Object obj, MemberInfo member)
at TUnit.Assertions.Conditions.StructuralEquivalencyAssertion`1.CompareObjects(Object actual, Object expected, String path, HashSet`1 visitedActual, HashSet`1 visitedExpected)
at TUnit.Assertions.Conditions.StructuralEquivalencyAssertion`1.CompareObjects(Object actual, Object expected, String path, HashSet`1 visitedActual, HashSet`1 visitedExpected)
at TUnit.Assertions.Conditions.StructuralEquivalencyAssertion`1.CheckAsync(EvaluationMetadata`1 metadata)
at TUnit.Assertions.Core.Assertion`1.CreateMetadataAndCheckAsync(TValue value, Exception exception)
at TUnit.Assertions.Core.Assertion`1.ExecuteCoreAsync()
at TUnit.Assertions.Core.Assertion`1.AssertAsync()
at Foo.Bar() in /Users/alex/Projects/ConsoleApp1/ConsoleApp1/Program.cs:line 9Additional Context
No response
IDE-Specific Issue?
- I've confirmed this issue occurs when running via
dotnet testordotnet run, not just in my IDE
Reactions are currently unavailable
Metadata
Metadata
Labels
bugSomething isn't workingSomething isn't working