Describe the bug
通过GetCustomAttributes获取Attribute,ILRuntime与预期结果不一致
To Reproduce
[AttributeUsage(AttributeTargets.Class,AllowMultiple = true)]
public class TestSystemAttribute:Attribute
{
public List<int> KeyCode { get; }
public TestSystemAttribute(int[] keyCode)
{
this.KeyCode = new List<int>(keyCode) ;
}
}
[AttributeUsage(AttributeTargets.Class,AllowMultiple = true)]
public class TestSystem2Attribute:Attribute
{
public int[] KeyCode { get; }
public TestSystem2Attribute(int[] keyCode)
{
this.KeyCode = keyCode;
}
}
[TestSystem2(new []{1,2})]
[TestSystem(new []{1,2})]
public class Test
{
}
public class AttributeTest
{
public static void TestRun()
{
var attrs = typeof (Test).GetCustomAttributes(typeof (TestSystemAttribute), false);
Console.WriteLine(attrs.Length);// attrs.Length=0,此处该为1才对
var attr2s= typeof (Test).GetCustomAttributes(typeof (TestSystem2Attribute), false);
foreach (TestSystem2Attribute attr in attr2s)
{
Console.WriteLine(attr.KeyCode[0]);//IL_0078: ldelem.i4
}
}
}
Expected behavior
执行TestRun
Unity Version
2020.3.33f1
ILRuntime Version
075a4805251f6c5bbe59f6398d7e4ac9160fdd16
Describe the bug 通过GetCustomAttributes获取Attribute,ILRuntime与预期结果不一致
To Reproduce
Expected behavior 执行TestRun
Unity Version 2020.3.33f1
ILRuntime Version 075a4805251f6c5bbe59f6398d7e4ac9160fdd16