From 6683974049216d706ba916d330a20c7ae3a420b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Mon, 10 May 2021 11:14:09 +0200 Subject: [PATCH 1/2] Delete suspicious code in RuntimeType This code indicates that we can somehow get to fields on interfaces by reflecting on fields of a type implementing the interface. If that's the case, we have work to do in IL Linker. But I have not been able to find a way to do that, mostly because static fields don't get inherited the same as instance fields and we don't allow instance fields on interfaces. Deleting the code to see if we have any failing tests. --- .../src/System/RuntimeType.CoreCLR.cs | 30 +------------------ 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs index d01d077b473689..b879c38a02445a 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs @@ -822,35 +822,7 @@ private RuntimeFieldInfo[] PopulateFields(Filter filter) declaringType = RuntimeTypeHandle.GetBaseType(declaringType); } #endregion - - #region Populate Literal Fields on Interfaces - if (ReflectedType.IsGenericParameter) - { - Type[] interfaces = ReflectedType.BaseType!.GetInterfaces(); - - for (int i = 0; i < interfaces.Length; i++) - { - // Populate literal fields defined on any of the interfaces implemented by the declaring type - PopulateLiteralFields(filter, (RuntimeType)interfaces[i], ref list); - PopulateRtFields(filter, (RuntimeType)interfaces[i], ref list); - } - } - else - { - Type[]? interfaces = RuntimeTypeHandle.GetInterfaces(ReflectedType); - - if (interfaces != null) - { - for (int i = 0; i < interfaces.Length; i++) - { - // Populate literal fields defined on any of the interfaces implemented by the declaring type - PopulateLiteralFields(filter, (RuntimeType)interfaces[i], ref list); - PopulateRtFields(filter, (RuntimeType)interfaces[i], ref list); - } - } - } - #endregion - + return list.ToArray(); } From 5f681dc913ab119cf31997bf558b2910afcc3550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Mon, 10 May 2021 11:22:23 +0200 Subject: [PATCH 2/2] Update RuntimeType.CoreCLR.cs --- .../System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs index b879c38a02445a..83e21bdb53244d 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs @@ -822,7 +822,7 @@ private RuntimeFieldInfo[] PopulateFields(Filter filter) declaringType = RuntimeTypeHandle.GetBaseType(declaringType); } #endregion - + return list.ToArray(); }