Make GetModuleHandle() sharable. (dotnet/coreclr#10309)
authorAtsushi Kanamori <AtsushiKan@users.noreply.github.com>
Mon, 20 Mar 2017 17:03:26 +0000 (10:03 -0700)
committerGitHub <noreply@github.com>
Mon, 20 Mar 2017 17:03:26 +0000 (10:03 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/05e35b9e4edb317ec0fcfbe622ae3d7621ef5ae4

src/coreclr/src/mscorlib/System.Private.CoreLib.csproj
src/coreclr/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs
src/coreclr/src/mscorlib/src/System/Reflection/Module.CoreCLR.cs [deleted file]
src/coreclr/src/mscorlib/src/System/Reflection/Module.cs
src/coreclr/src/mscorlib/src/System/Reflection/RuntimeModule.cs
src/coreclr/src/mscorlib/src/System/Type.CoreCLR.cs

index 6673ee8..a672034 100644 (file)
     <Compile Include="$(BclSourcesRoot)\System\Reflection\MethodImplAttributes.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\Missing.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\Module.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Reflection\Module.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\ModuleResolveEventHandler.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\MethodBody.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Reflection\ParameterAttributes.cs" />
index 2dc9f51..13ae4ee 100644 (file)
@@ -368,7 +368,7 @@ namespace System.Reflection.Emit
             }
         }
 
-        internal override ModuleHandle GetModuleHandle()
+        protected override ModuleHandle GetModuleHandleImpl()
         {
             return new ModuleHandle(GetNativeHandle());
         }
diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/Module.CoreCLR.cs b/src/coreclr/src/mscorlib/src/System/Reflection/Module.CoreCLR.cs
deleted file mode 100644 (file)
index 93908b1..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Runtime.Serialization;
-
-namespace System.Reflection
-{
-    public abstract partial class Module : ISerializable, ICustomAttributeProvider
-    {
-        // Used to provide implementation and overriding point for ModuleHandle.
-        // To get a module handle inside mscorlib, use GetNativeHandle instead.
-        internal virtual ModuleHandle GetModuleHandle()
-        {
-            return ModuleHandle.EmptyHandle;
-        }
-    }
-}
index 0b78c9d..56f83c4 100644 (file)
@@ -7,7 +7,7 @@ using System.Runtime.Serialization;
 
 namespace System.Reflection
 {
-    public abstract partial class Module : ICustomAttributeProvider, ISerializable
+    public abstract class Module : ICustomAttributeProvider, ISerializable
     {
         protected Module() { }
 
@@ -18,7 +18,8 @@ namespace System.Reflection
         public virtual int MDStreamVersion { get { throw NotImplemented.ByDesign; } }
         public virtual Guid ModuleVersionId { get { throw NotImplemented.ByDesign; } }
         public virtual string ScopeName { get { throw NotImplemented.ByDesign; } }
-        public ModuleHandle ModuleHandle => GetModuleHandle();
+        public ModuleHandle ModuleHandle => GetModuleHandleImpl();
+        protected virtual ModuleHandle GetModuleHandleImpl() => ModuleHandle.EmptyHandle; // Not an api but declared protected because of Reflection.Core/Corelib divide (when built by CoreRt)
         public virtual void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine) { throw NotImplemented.ByDesign; }
         public virtual bool IsResource() { throw NotImplemented.ByDesign; }
 
index 703aaff..2b663a8 100644 (file)
@@ -249,7 +249,7 @@ namespace System.Reflection
 
             try
             {
-                Type t = GetModuleHandle().ResolveTypeHandle(metadataToken, typeArgs, methodArgs).GetRuntimeType();
+                Type t = GetModuleHandleImpl().ResolveTypeHandle(metadataToken, typeArgs, methodArgs).GetRuntimeType();
 
                 if (t == null)
                     throw new ArgumentException(Environment.GetResourceString("Argument_ResolveType", tk, this), nameof(metadataToken));
@@ -588,8 +588,7 @@ namespace System.Reflection
             return m_runtimeAssembly;
         }
 
-
-        internal override ModuleHandle GetModuleHandle()
+        protected override ModuleHandle GetModuleHandleImpl()
         {
             return new ModuleHandle(this);
         }
index 1a8a36f..f06b633 100644 (file)
@@ -2,13 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-//
-//
-//
-// Implements System.Type
-//
-// ======================================================================================
-
 using System.Reflection;
 using System.Threading;
 using System.Runtime.CompilerServices;