summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Salem <josalem@microsoft.com>2018-10-24 20:29:40 -0700
committerJan Kotas <jkotas@microsoft.com>2018-10-24 20:29:40 -0700
commit5d1acb06a0d426928cb8c9881ccd2400fe57abce (patch)
tree34abcf44e1e8787d3c05fe5b108b9f32ac74c052
parentbbf09029f78dc096f9eade80ed2c1926c900f83b (diff)
downloadcoreclr-5d1acb06a0d426928cb8c9881ccd2400fe57abce.tar.gz
coreclr-5d1acb06a0d426928cb8c9881ccd2400fe57abce.tar.bz2
coreclr-5d1acb06a0d426928cb8c9881ccd2400fe57abce.zip
Add IsCollectible property to Assembly and necessary backing functions (#20574)
-rw-r--r--src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs1
-rw-r--r--src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs2
-rw-r--r--src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs6
-rw-r--r--src/vm/assemblynative.cpp15
-rw-r--r--src/vm/assemblynative.hpp2
-rw-r--r--src/vm/ecalllist.h1
6 files changed, 27 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs
index 3574797714..516f81d370 100644
--- a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs
+++ b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs
@@ -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; }
diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs
index aa9dcaced3..f36745a02d 100644
--- a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs
+++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs
@@ -639,6 +639,8 @@ namespace System.Reflection.Emit
return true;
}
}
+
+ public override bool IsCollectible => InternalAssembly.IsCollectible;
#endregion
diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
index ae2e79f844..f885c15636 100644
--- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
+++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
@@ -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)
diff --git a/src/vm/assemblynative.cpp b/src/vm/assemblynative.cpp
index e658f25822..89e6768c33 100644
--- a/src/vm/assemblynative.cpp
+++ b/src/vm/assemblynative.cpp
@@ -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;
diff --git a/src/vm/assemblynative.hpp b/src/vm/assemblynative.hpp
index 0bdb2c31ed..8ae1fe57c5 100644
--- a/src/vm/assemblynative.hpp
+++ b/src/vm/assemblynative.hpp
@@ -113,6 +113,8 @@ public:
static
void QCALLTYPE GetImageRuntimeVersion(QCall::AssemblyHandle pAssembly, QCall::StringHandleOnStack retString);
+ static BOOL QCALLTYPE GetIsCollectible(QCall::AssemblyHandle pAssembly);
+
//
// PEFile QCalls
//
diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h
index ac5794e7f7..e168886aca 100644
--- a/src/vm/ecalllist.h
+++ b/src/vm/ecalllist.h
@@ -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)