Skip to content

Commit

Permalink
Add tests documenting a CLR bug in System.Reflection.Emit
Browse files Browse the repository at this point in the history
Both the CLR and Core CLR versions of System.Reflection.Emit do not
reproduce method signatures correctly if they include a modreq (such
as is caused by a C# 7.2 `in` parameter modifier) and if the method,
its declaring type, or both are generic. See dotnet/corefx#29254.
  • Loading branch information
stakx committed May 2, 2018
1 parent 7ef5e62 commit 3c7521b
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,33 @@ public void Can_intercept_method_having_valuetypes_parameter_with_in_modifier()
Assert.AreEqual(expectedValue, ((ReadOnlyStruct)receivedArg).Value);
}

[Test]
[Ignore("Fails on both the CLR and CoreCLR with a MissingMethodException due to a bug in System.Reflection.Emit. See https://github.com/dotnet/corefx/issues/29254.")]
public void Can_proxy_method_in_generic_type_having_valuetyped_parameter_with_in_modifier()
{
var proxy = this.generator.CreateInterfaceProxyWithoutTarget<IGenericTypeWithInModifier<bool>>(new DoNothingInterceptor());
var readOnlyStruct = new ReadOnlyStruct();
proxy.Method(in readOnlyStruct);
}

[Test]
[Ignore("Fails on both the CLR and CoreCLR with a MissingMethodException due to a bug in System.Reflection.Emit. See https://github.com/dotnet/corefx/issues/29254.")]
public void Can_proxy_generic_method_in_nongeneric_type_having_valuetyped_parameter_with_in_modifier()
{
var proxy = this.generator.CreateInterfaceProxyWithoutTarget<IGenericMethodWithInModifier>(new DoNothingInterceptor());
var readOnlyStruct = new ReadOnlyStruct();
proxy.Method<bool>(in readOnlyStruct);
}

[Test]
[Ignore("Fails on both the CLR and CoreCLR with a MissingMethodException due to a bug in System.Reflection.Emit. See https://github.com/dotnet/corefx/issues/29254.")]
public void Can_proxy_generic_method_in_generic_type_having_valuetyped_parameter_with_in_modifier()
{
var proxy = this.generator.CreateInterfaceProxyWithoutTarget<IGenericTypeAndMethodWithInModifier<bool>>(new DoNothingInterceptor());
var readOnlyStruct = new ReadOnlyStruct();
proxy.Method<int>(in readOnlyStruct);
}

#endif

public readonly struct ReadOnlyStruct
Expand All @@ -86,5 +113,20 @@ public interface IWithInModifier
{
void Method(in ReadOnlyStruct readOnlyStruct);
}

public interface IGenericMethodWithInModifier
{
void Method<T>(in ReadOnlyStruct readOnlyStruct);
}

public interface IGenericTypeWithInModifier<T>
{
void Method(in ReadOnlyStruct readOnlyStruct);
}

public interface IGenericTypeAndMethodWithInModifier<T>
{
void Method<U>(in ReadOnlyStruct readOnlyStruct);
}
}
}

0 comments on commit 3c7521b

Please sign in to comment.