You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I added the following method to Host in GenericTest:
public bool TryGet<T1, T2>(T2 obj1, out T1 obj2)
{
obj2 = default;
return true;
}
If I DO NOT include the Flags as below then it throws a NullReferenceException in MemberFilter when it attempts to call SubString on the name variable inside if( ignoreParameterModifiers && parameterType.IsByRef ). This is because the parameterType.FullName is null as the parameterType is generic.
[TestMethod]
public void Test_invoke_instance_generic_out()
{
var target = typeof(Host).CreateInstance();
var parameters = new object[] {1, null};
var result = (bool)target.CallMethod(new[] {typeof(string), typeof(int)}, "TryGet",
new[] {typeof(int), typeof(string).MakeByRefType()}, Flags.ExactBinding | Flags.InstancePublicDeclaredOnly, parameters);
Assert.IsTrue(result);
Assert.AreEqual(null, parameters[1]);
}
To work around this current problem, as I've done here, you must specify Flags.ExactBinding which then skips that particular bit of code.
Apologies, for not providing a PR with a failing test - I just had time to figure out a workaround and to then write it here so that somebody might fix in the future (or find the workaround!)
The text was updated successfully, but these errors were encountered:
I added the following method to
Host
inGenericTest
:If I DO NOT include the Flags as below then it throws a NullReferenceException in
MemberFilter
when it attempts to callSubString
on thename
variable insideif( ignoreParameterModifiers && parameterType.IsByRef )
. This is because the parameterType.FullName is null as the parameterType is generic.To work around this current problem, as I've done here, you must specify Flags.ExactBinding which then skips that particular bit of code.
Apologies, for not providing a PR with a failing test - I just had time to figure out a workaround and to then write it here so that somebody might fix in the future (or find the workaround!)
The text was updated successfully, but these errors were encountered: