提交 3d4bb394 编写于 作者: Z Zoltan Varga 提交者: Jonathan Chambers

[bcl] Allow conversion from enums and their basetypes in both directions with...

[bcl] Allow conversion from enums and their basetypes in both directions with Delegate.CreateDelegate (). Fixes https://github.com/mono/mono/issues/6255. (case 977917)
上级 2c936e01
......@@ -134,6 +134,8 @@ namespace System
if (!match) {
if (delArgType.IsEnum && Enum.GetUnderlyingType (delArgType) == argType)
match = true;
else if (argType.IsEnum && Enum.GetUnderlyingType (argType) == delArgType)
match = true;
}
return match;
......
......@@ -1395,6 +1395,23 @@ namespace MonoTests.System
Assert.IsTrue (d (0, 0));
}
[Test]
public void EnumBaseTypeConversion2 () {
Func<Enum22, int> dm = EnumArg;
var d = (Func<int, int>)Delegate.CreateDelegate (typeof (Func<int, int>), dm.Method);
Assert.AreEqual (1, d (1));
}
public enum Enum22 {
none,
one,
two
}
public static int EnumArg (Enum22 e) {
return (int)e;
}
#if !MONOTOUCH && !FULL_AOT_RUNTIME
public static void DynInvokeWithClosedFirstArg (object a, object b)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册