Add IsCollectible property to Assembly and necessary backing functions (dotnet/corecl...
authorJohn Salem <josalem@microsoft.com>
Thu, 25 Oct 2018 03:29:40 +0000 (20:29 -0700)
committerJan Kotas <jkotas@microsoft.com>
Thu, 25 Oct 2018 03:29:40 +0000 (20:29 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/5d1acb06a0d426928cb8c9881ccd2400fe57abce

src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
src/coreclr/src/vm/assemblynative.cpp
src/coreclr/src/vm/assemblynative.hpp
src/coreclr/src/vm/ecalllist.h
src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs

index aa9dcac..f36745a 100644 (file)
@@ -639,6 +639,8 @@ namespace System.Reflection.Emit
                 return true;
             }
         }
+
+        public override bool IsCollectible => InternalAssembly.IsCollectible;
         #endregion
 
 
index ae2e79f..f885c15 100644 (file)
@@ -201,6 +201,12 @@ namespace System.Reflection
             }
         }
 
+        [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+        [return: MarshalAs(UnmanagedType.Bool)]
+        internal static extern bool GetIsCollectible(RuntimeAssembly assembly);
+
+        public override bool IsCollectible => GetIsCollectible(GetNativeHandle());
+
         // Load a resource based on the NameSpace of the type.
         [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public override Stream GetManifestResourceStream(Type type, string name)
index e658f25..89e6768 100644 (file)
@@ -730,6 +730,21 @@ BOOL QCALLTYPE AssemblyNative::GetNeutralResourcesLanguageAttribute(QCall::Assem
     return retVal;
 }
 
+BOOL QCALLTYPE AssemblyNative::GetIsCollectible(QCall::AssemblyHandle pAssembly)
+{
+    QCALL_CONTRACT;
+
+    BOOL retVal = FALSE;
+
+    BEGIN_QCALL;
+
+    retVal = pAssembly->IsCollectible();
+
+    END_QCALL;
+
+    return retVal;
+}
+
 void QCALLTYPE AssemblyNative::GetModule(QCall::AssemblyHandle pAssembly, LPCWSTR wszFileName, QCall::ObjectHandleOnStack retModule)
 {
     QCALL_CONTRACT;
index 0bdb2c3..8ae1fe5 100644 (file)
@@ -113,6 +113,8 @@ public:
     static 
     void QCALLTYPE GetImageRuntimeVersion(QCall::AssemblyHandle pAssembly, QCall::StringHandleOnStack retString);
 
+    static BOOL QCALLTYPE GetIsCollectible(QCall::AssemblyHandle pAssembly);
+
     //
     // PEFile QCalls
     // 
index ac5794e..e168886 100644 (file)
@@ -538,6 +538,7 @@ FCFuncStart(gAssemblyFuncs)
     QCFuncElement("GetImageRuntimeVersion", AssemblyNative::GetImageRuntimeVersion)
     FCFuncElement("GetManifestModule", AssemblyHandle::GetManifestModule)
     FCFuncElement("GetToken", AssemblyHandle::GetToken)
+    QCFuncElement("GetIsCollectible", AssemblyNative::GetIsCollectible)
 FCFuncEnd()
 
 FCFuncStart(gAssemblyExtensionsFuncs)
index 3574797..516f81d 100644 (file)
@@ -69,6 +69,7 @@ namespace System.Reflection
         public virtual bool IsDynamic => false;
         public virtual string Location { get { throw NotImplemented.ByDesign; } }
         public virtual bool ReflectionOnly { get { throw NotImplemented.ByDesign; } }
+        public virtual bool IsCollectible => true;
 
         public virtual ManifestResourceInfo GetManifestResourceInfo(string resourceName) { throw NotImplemented.ByDesign; }
         public virtual string[] GetManifestResourceNames() { throw NotImplemented.ByDesign; }