From 33c6c003a5318fa2efdebb283eaab6801899af82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A4=E9=9D=9E=E5=87=A1?= Date: Wed, 8 Jun 2022 16:20:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[a]=20=E6=B7=BB=E5=8A=A0=E5=8F=8D=E5=B0=84?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E5=B8=B8=E9=87=8F=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestCases/ReflectionTest.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/TestCases/ReflectionTest.cs b/TestCases/ReflectionTest.cs index 775a30e4..a02ce40e 100644 --- a/TestCases/ReflectionTest.cs +++ b/TestCases/ReflectionTest.cs @@ -66,12 +66,18 @@ public static void ReflectionTest05() { var fi = typeof(TestCls).GetField("aa"); var fi2 = typeof(TestCls).GetField("bb"); + var fi3 = typeof(TestCls).GetField("cc"); var a = new TestCls(); Console.WriteLine("aa=" + fi.GetValue(a)); Console.WriteLine("bb=" + fi2.GetValue(null)); + var cc = (int)fi3.GetValue(null); + Console.WriteLine("cc=" + cc); + if(cc!=444) + throw new Exception("worng value"); + fi.SetValue(a, 123); fi2.SetValue(null, 233); Console.WriteLine("aa=" + fi.GetValue(a)); @@ -198,6 +204,9 @@ public class TestCls int aa = 203; static int bb = 333; + + const int cc = 444; + public TestCls foo(int b) { Console.WriteLine("foo" + (aa + b)); From 98d7db454aa97283d62603d115b495d8ec372964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A4=E9=9D=9E=E5=87=A1?= Date: Wed, 8 Jun 2022 16:22:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[f]=20=E4=BF=AE=E5=A4=8DILRuntimeFieldInfo?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=AD=A3=E7=A1=AE=E8=AF=BB=E5=8F=96=E5=B8=B8?= =?UTF-8?q?=E9=87=8F=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ILRuntime/Reflection/ILRuntimeFieldInfo.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ILRuntime/Reflection/ILRuntimeFieldInfo.cs b/ILRuntime/Reflection/ILRuntimeFieldInfo.cs index 021c5529..f5b491cf 100644 --- a/ILRuntime/Reflection/ILRuntimeFieldInfo.cs +++ b/ILRuntime/Reflection/ILRuntimeFieldInfo.cs @@ -172,6 +172,8 @@ public override object GetValue(object obj) ILTypeInstance ins; if (isStatic) { + if (definition.HasConstant) + return definition.Constant; ins = ilType.StaticInstance; } else