Move common corelib code to shared partition (#47956)
authorAdeel Mujahid <3840695+am11@users.noreply.github.com>
Mon, 8 Feb 2021 22:50:53 +0000 (00:50 +0200)
committerGitHub <noreply@github.com>
Mon, 8 Feb 2021 22:50:53 +0000 (14:50 -0800)
* Move common corelib code to shared partition

* Inline SetCustomAttributeNoLock method

13 files changed:
src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilderData.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodBody.cs
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeMethodBody.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Threading/StackCrawlMark.cs [moved from src/coreclr/System.Private.CoreLib/src/System/Threading/StackCrawlMark.cs with 100% similarity]
src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj
src/mono/System.Private.CoreLib/src/System/NotImplemented.cs [deleted file]
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeMethodBody.cs
src/mono/System.Private.CoreLib/src/System/Threading/StackCrawlMark.cs [deleted file]

index 6a9e316..24c4b35 100644 (file)
@@ -14,7 +14,7 @@
     <Platforms>x64;x86;arm;arm64</Platforms>
 
     <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
-    
+
     <ILLinkTrimAssembly>true</ILLinkTrimAssembly>
     <ILLinkTrimXml>$(IntermediateOutputPath)System.Private.CoreLib.xml</ILLinkTrimXml>
     <ILLinkDirectory>$(MSBuildThisFileDirectory)src\ILLink\</ILLinkDirectory>
     <Compile Include="$(BclSourcesRoot)\System\Threading\Interlocked.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Monitor.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Overlapped.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\StackCrawlMark.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\SynchronizationContext.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Thread.CoreCLR.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\ProcessorIdCache.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\ClrThreadPoolBoundHandle.Windows.cs" />
   </ItemGroup>
   <!-- Include additional sources shared files in the compilation -->
-  <ItemGroup>
-    <Compile Include="$(CommonPath)System\NotImplemented.cs">
-      <Link>Common\System\NotImplemented.cs</Link>
-    </Compile>
-  </ItemGroup>
   <Import Project="$(LibrariesProjectRoot)\System.Private.CoreLib\src\System.Private.CoreLib.Shared.projitems" Label="Shared" />
-  
+
   <ItemGroup>
     <ProjectReference Include="$(LibrariesProjectRoot)\System.Private.CoreLib\generators\System.Private.CoreLib.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
   </ItemGroup>
-  
+
   <ItemGroup>
     <!-- This is the T4 template service and is added by VS anytime you modify a T4 template. Required for .tt files. -->
     <Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
index a2b88b6..6f2f862 100644 (file)
@@ -116,7 +116,7 @@ namespace System.Reflection.Emit
         #endregion
     }
 
-    public sealed class AssemblyBuilder : Assembly
+    public sealed partial class AssemblyBuilder : Assembly
     {
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern RuntimeModule GetInMemoryAssemblyModule(RuntimeAssembly assembly);
@@ -192,7 +192,7 @@ namespace System.Reflection.Emit
                                   ObjectHandleOnStack.Create(ref retAssembly));
             _internalAssemblyBuilder = (InternalAssemblyBuilder)retAssembly!;
 
-            _assemblyData = new AssemblyBuilderData(_internalAssemblyBuilder, access);
+            _assemblyData = new AssemblyBuilderData(access);
 
             // Make sure that ManifestModule is properly initialized
             // We need to do this before setting any CustomAttribute
@@ -287,16 +287,12 @@ namespace System.Reflection.Emit
         /// a transient module.
         /// </summary>
         [DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod.
-        public ModuleBuilder DefineDynamicModule(string name)
-        {
-            return DefineDynamicModuleInternal(name, emitSymbolInfo: false);
-        }
+        public ModuleBuilder DefineDynamicModule(string name) =>
+            DefineDynamicModuleInternal(name, emitSymbolInfo: false);
 
         [DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod.
-        public ModuleBuilder DefineDynamicModule(string name, bool emitSymbolInfo)
-        {
-            return DefineDynamicModuleInternal(name, emitSymbolInfo);
-        }
+        public ModuleBuilder DefineDynamicModule(string name, bool emitSymbolInfo) =>
+            DefineDynamicModuleInternal(name, emitSymbolInfo);
 
         private ModuleBuilder DefineDynamicModuleInternal(string name, bool emitSymbolInfo)
         {
@@ -406,88 +402,29 @@ namespace System.Reflection.Emit
         public override int GetHashCode() => InternalAssembly.GetHashCode();
 
         #region ICustomAttributeProvider Members
-        public override object[] GetCustomAttributes(bool inherit)
-        {
-            return InternalAssembly.GetCustomAttributes(inherit);
-        }
+        public override object[] GetCustomAttributes(bool inherit) =>
+            InternalAssembly.GetCustomAttributes(inherit);
 
-        public override object[] GetCustomAttributes(Type attributeType, bool inherit)
-        {
-            return InternalAssembly.GetCustomAttributes(attributeType, inherit);
-        }
+        public override object[] GetCustomAttributes(Type attributeType, bool inherit) =>
+            InternalAssembly.GetCustomAttributes(attributeType, inherit);
 
-        public override bool IsDefined(Type attributeType, bool inherit)
-        {
-            return InternalAssembly.IsDefined(attributeType, inherit);
-        }
+        public override bool IsDefined(Type attributeType, bool inherit) =>
+            InternalAssembly.IsDefined(attributeType, inherit);
 
-        public override IList<CustomAttributeData> GetCustomAttributesData()
-        {
-            return InternalAssembly.GetCustomAttributesData();
-        }
+        public override IList<CustomAttributeData> GetCustomAttributesData() =>
+            InternalAssembly.GetCustomAttributesData();
 
         #endregion
 
         #region Assembly overrides
 
-        /// <returns>The names of all the resources.</returns>
-        public override string[] GetManifestResourceNames()
-        {
-            return InternalAssembly.GetManifestResourceNames();
-        }
-
-        public override FileStream GetFile(string name)
-        {
-            return InternalAssembly.GetFile(name);
-        }
-
-        public override FileStream[] GetFiles(bool getResourceModules)
-        {
-            return InternalAssembly.GetFiles(getResourceModules);
-        }
-
-        public override Stream? GetManifestResourceStream(Type type, string name)
-        {
-            return InternalAssembly.GetManifestResourceStream(type, name);
-        }
-
-        public override Stream? GetManifestResourceStream(string name)
-        {
-            return InternalAssembly.GetManifestResourceStream(name);
-        }
-
-        public override ManifestResourceInfo? GetManifestResourceInfo(string resourceName)
-        {
-            return InternalAssembly.GetManifestResourceInfo(resourceName);
-        }
-
-        public override string Location => InternalAssembly.Location;
-
-        public override string ImageRuntimeVersion => InternalAssembly.ImageRuntimeVersion;
-
-        public override string? CodeBase => InternalAssembly.CodeBase;
-
-        /// <sumary>
-        /// Override the EntryPoint method on Assembly.
-        /// This doesn't need to be synchronized because it is simple enough.
-        /// </sumary>
-        public override MethodInfo? EntryPoint => _assemblyData._entryPointMethod;
-
-        /// <sumary>
-        /// Get an array of all the public types defined in this assembly.
-        /// </sumary>
-        [RequiresUnreferencedCode("Types might be removed")]
-        public override Type[] GetExportedTypes() => InternalAssembly.GetExportedTypes();
-
         public override AssemblyName GetName(bool copiedName) => InternalAssembly.GetName(copiedName);
 
         public override string? FullName => InternalAssembly.FullName;
 
         [RequiresUnreferencedCode("Types might be removed")]
-        public override Type? GetType(string name, bool throwOnError, bool ignoreCase)
-        {
-            return InternalAssembly.GetType(name, throwOnError, ignoreCase);
-        }
+        public override Type? GetType(string name, bool throwOnError, bool ignoreCase) =>
+            InternalAssembly.GetType(name, throwOnError, ignoreCase);
 
         public override Module ManifestModule => _manifestModuleBuilder.InternalModule;
 
@@ -496,40 +433,25 @@ namespace System.Reflection.Emit
         public override Module? GetModule(string name) => InternalAssembly.GetModule(name);
 
         [RequiresUnreferencedCode("Assembly references might be removed")]
-        public override AssemblyName[] GetReferencedAssemblies()
-        {
-            return InternalAssembly.GetReferencedAssemblies();
-        }
-
-        [Obsolete(Obsoletions.GlobalAssemblyCacheMessage, DiagnosticId = Obsoletions.GlobalAssemblyCacheDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
-        public override bool GlobalAssemblyCache => InternalAssembly.GlobalAssemblyCache;
+        public override AssemblyName[] GetReferencedAssemblies() =>
+            InternalAssembly.GetReferencedAssemblies();
 
         public override long HostContext => InternalAssembly.HostContext;
 
-        public override Module[] GetModules(bool getResourceModules)
-        {
-            return InternalAssembly.GetModules(getResourceModules);
-        }
+        public override Module[] GetModules(bool getResourceModules) =>
+            InternalAssembly.GetModules(getResourceModules);
 
-        public override Module[] GetLoadedModules(bool getResourceModules)
-        {
-            return InternalAssembly.GetLoadedModules(getResourceModules);
-        }
+        public override Module[] GetLoadedModules(bool getResourceModules) =>
+            InternalAssembly.GetLoadedModules(getResourceModules);
 
-        public override Assembly GetSatelliteAssembly(CultureInfo culture)
-        {
-            return InternalAssembly.GetSatelliteAssembly(culture, null);
-        }
+        public override Assembly GetSatelliteAssembly(CultureInfo culture) =>
+            InternalAssembly.GetSatelliteAssembly(culture, null);
 
         /// <sumary>
         /// Useful for binding to a very specific version of a satellite assembly
         /// </sumary>
-        public override Assembly GetSatelliteAssembly(CultureInfo culture, Version? version)
-        {
-            return InternalAssembly.GetSatelliteAssembly(culture, version);
-        }
-
-        public override bool IsDynamic => true;
+        public override Assembly GetSatelliteAssembly(CultureInfo culture, Version? version) =>
+            InternalAssembly.GetSatelliteAssembly(culture, version);
 
         public override bool IsCollectible => InternalAssembly.IsCollectible;
 
@@ -584,19 +506,14 @@ namespace System.Reflection.Emit
 
             lock (SyncRoot)
             {
-                SetCustomAttributeNoLock(con, binaryAttribute);
+                TypeBuilder.DefineCustomAttribute(
+                    _manifestModuleBuilder,     // pass in the in-memory assembly module
+                    AssemblyBuilderData.AssemblyDefToken,
+                    _manifestModuleBuilder.GetConstructorToken(con),
+                    binaryAttribute);
             }
         }
 
-        private void SetCustomAttributeNoLock(ConstructorInfo con, byte[] binaryAttribute)
-        {
-            TypeBuilder.DefineCustomAttribute(
-                _manifestModuleBuilder,     // pass in the in-memory assembly module
-                AssemblyBuilderData.AssemblyDefToken,
-                _manifestModuleBuilder.GetConstructorToken(con),
-                binaryAttribute);
-        }
-
         /// <summary>
         /// Use this function if client wishes to build CustomAttribute using CustomAttributeBuilder.
         /// </summary>
@@ -609,13 +526,8 @@ namespace System.Reflection.Emit
 
             lock (SyncRoot)
             {
-                SetCustomAttributeNoLock(customBuilder);
+                customBuilder.CreateCustomAttribute(_manifestModuleBuilder, AssemblyBuilderData.AssemblyDefToken);
             }
         }
-
-        private void SetCustomAttributeNoLock(CustomAttributeBuilder customBuilder)
-        {
-            customBuilder.CreateCustomAttribute(_manifestModuleBuilder, AssemblyBuilderData.AssemblyDefToken);
-        }
     }
 }
index 1f94816..4b44a4d 100644 (file)
@@ -16,13 +16,9 @@ namespace System.Reflection.Emit
 
         public readonly List<ModuleBuilder> _moduleBuilderList;
         public readonly AssemblyBuilderAccess _access;
-        public MethodInfo? _entryPointMethod;
 
-        private readonly InternalAssemblyBuilder _assembly;
-
-        internal AssemblyBuilderData(InternalAssemblyBuilder assembly, AssemblyBuilderAccess access)
+        internal AssemblyBuilderData(AssemblyBuilderAccess access)
         {
-            _assembly = assembly;
             _access = access;
             _moduleBuilderList = new List<ModuleBuilder>();
         }
index 8be4480..3227a7e 100644 (file)
@@ -1,28 +1,17 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System.Collections.Generic;
-
 namespace System.Reflection
 {
-    internal sealed class RuntimeMethodBody : MethodBody
+    internal sealed partial class RuntimeMethodBody : MethodBody
     {
         // This class can only be created from inside the EE.
-        private RuntimeMethodBody() { }
-
-        private byte[] _IL = null!;
-        private ExceptionHandlingClause[] _exceptionHandlingClauses = null!;
-        private LocalVariableInfo[] _localVariables = null!;
-        internal MethodBase _methodBase = null!;
-        private int _localSignatureMetadataToken;
-        private int _maxStackSize;
-        private bool _initLocals;
-
-        public override int LocalSignatureMetadataToken => _localSignatureMetadataToken;
-        public override IList<LocalVariableInfo> LocalVariables => Array.AsReadOnly(_localVariables);
-        public override int MaxStackSize => _maxStackSize;
-        public override bool InitLocals => _initLocals;
-        public override byte[] GetILAsByteArray() => _IL;
-        public override IList<ExceptionHandlingClause> ExceptionHandlingClauses => Array.AsReadOnly(_exceptionHandlingClauses);
+        private RuntimeMethodBody()
+        {
+            _IL = null!;
+            _exceptionHandlingClauses = null!;
+            _localVariables = null!;
+            _methodBase = null!;
+        }
     }
 }
index 39f915e..a21bf72 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\CustomAttributeNamedArgument.cs" Condition="'$(TargetsCoreRT)' != 'true'" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\CustomAttributeTypedArgument.cs" Condition="'$(TargetsCoreRT)' != 'true'" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\DefaultMemberAttribute.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\AssemblyBuilder.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\AssemblyBuilderAccess.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\EmptyCAHolder.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\FlowControl.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\ReflectionTypeLoadException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\ResourceAttributes.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\ResourceLocation.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\RuntimeMethodBody.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\RuntimeReflectionExtensions.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\SignatureArrayType.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Reflection\SignatureByRefType.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\CancellationTokenRegistration.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\CancellationTokenSource.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\CompressedStack.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\StackCrawlMark.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\DeferredDisposableLifetime.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\EventResetMode.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\EventWaitHandle.cs" />
     <Compile Include="$(CommonPath)System\HResults.cs">
       <Link>Common\System\HResults.cs</Link>
     </Compile>
+    <Compile Include="$(CommonPath)System\NotImplemented.cs">
+      <Link>Common\System\NotImplemented.cs</Link>
+    </Compile>
     <Compile Include="$(CommonPath)System\Obsoletions.cs">
       <Link>Common\System\Obsoletions.cs</Link>
     </Compile>
diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs
new file mode 100644 (file)
index 0000000..7013362
--- /dev/null
@@ -0,0 +1,38 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+
+namespace System.Reflection.Emit
+{
+    public sealed partial class AssemblyBuilder : Assembly
+    {
+        public override string? CodeBase => throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
+        public override string Location => throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
+        public override MethodInfo? EntryPoint => null;
+        public override bool IsDynamic => true;
+
+        [RequiresUnreferencedCode("Types might be removed")]
+        public override Type[] GetExportedTypes() =>
+            throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
+
+        public override FileStream GetFile(string name) =>
+            throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
+
+        public override FileStream[] GetFiles(bool getResourceModules) =>
+            throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
+
+        public override ManifestResourceInfo? GetManifestResourceInfo(string resourceName) =>
+            throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
+
+        public override string[] GetManifestResourceNames() =>
+            throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
+
+        public override Stream? GetManifestResourceStream(string name) =>
+            throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
+
+        public override Stream? GetManifestResourceStream(Type type, string name) =>
+            throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
+    }
+}
diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeMethodBody.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeMethodBody.cs
new file mode 100644 (file)
index 0000000..30a15c7
--- /dev/null
@@ -0,0 +1,27 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Collections.Generic;
+
+namespace System.Reflection
+{
+    internal sealed partial class RuntimeMethodBody : MethodBody
+    {
+        private byte[] _IL;
+        private ExceptionHandlingClause[] _exceptionHandlingClauses;
+        private LocalVariableInfo[] _localVariables;
+#if CORECLR
+        internal MethodBase _methodBase;
+#endif
+        private int _localSignatureMetadataToken;
+        private int _maxStackSize;
+        private bool _initLocals;
+
+        public override int LocalSignatureMetadataToken => _localSignatureMetadataToken;
+        public override IList<LocalVariableInfo> LocalVariables => Array.AsReadOnly(_localVariables);
+        public override int MaxStackSize => _maxStackSize;
+        public override bool InitLocals => _initLocals;
+        public override byte[] GetILAsByteArray() => _IL;
+        public override IList<ExceptionHandlingClause> ExceptionHandlingClauses => Array.AsReadOnly(_exceptionHandlingClauses);
+    }
+}
index efd199d..68887b4 100644 (file)
@@ -14,7 +14,7 @@
     <OutputPath>$(RuntimeBinDir)IL/</OutputPath>
     <Configurations>Debug;Release;Checked</Configurations>
     <Platforms>x64;x86;arm;arm64;wasm</Platforms>
-    
+
     <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
   </PropertyGroup>
 
       <Compile Include="$(BclSourcesRoot)\System\MissingMemberException.Mono.cs" />
       <Compile Include="$(BclSourcesRoot)\System\ModuleHandle.cs" />
       <Compile Include="$(BclSourcesRoot)\System\MulticastDelegate.cs" />
-      <Compile Include="$(BclSourcesRoot)\System\NotImplemented.cs" />
       <Compile Include="$(BclSourcesRoot)\System\Nullable.Mono.cs" />
       <Compile Include="$(BclSourcesRoot)\System\RuntimeArgumentHandle.cs" />
       <Compile Include="$(BclSourcesRoot)\System\RuntimeFieldHandle.cs" />
       <Compile Include="$(BclSourcesRoot)\System\Threading\Monitor.Mono.cs" />
       <Compile Include="$(BclSourcesRoot)\System\Threading\Overlapped.cs" />
       <Compile Include="$(BclSourcesRoot)\System\Threading\PreAllocatedOverlapped.cs" />
-      <Compile Include="$(BclSourcesRoot)\System\Threading\StackCrawlMark.cs" />
       <Compile Include="$(BclSourcesRoot)\System\Threading\Thread.Mono.cs" />
       <Compile Include="$(BclSourcesRoot)\System\Threading\ThreadPool.Mono.cs" />
       <Compile Include="$(BclSourcesRoot)\System\Threading\LowLevelLock.cs" />
diff --git a/src/mono/System.Private.CoreLib/src/System/NotImplemented.cs b/src/mono/System.Private.CoreLib/src/System/NotImplemented.cs
deleted file mode 100644 (file)
index 244fba7..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System
-{
-    //
-    // This simple class enables one to throw a NotImplementedException using the following
-    // idiom:
-    //
-    //     throw NotImplemented.ByDesign;
-    //
-    // Used by methods whose intended implementation is to throw a NotImplementedException (typically
-    // virtual methods in public abstract classes that intended to be subclassed by third parties.)
-    //
-    // This makes it distinguishable both from human eyes and CCI from NYI's that truly represent undone work.
-    //
-    internal static class NotImplemented
-    {
-        internal static Exception ByDesign
-        {
-            get
-            {
-                return new NotImplementedException();
-            }
-        }
-    }
-}
index 32d869b..bdebf80 100644 (file)
 //
 
 #if MONO_FEATURE_SRE
-using System.IO;
-using System.Globalization;
-using System.Runtime.CompilerServices;
 using System.Collections.Generic;
 using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.IO;
+using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 namespace System.Reflection.Emit
@@ -171,7 +171,7 @@ namespace System.Reflection.Emit
     }
 
     [StructLayout(LayoutKind.Sequential)]
-    public sealed class AssemblyBuilder : Assembly
+    public sealed partial class AssemblyBuilder : Assembly
     {
         //
         // AssemblyBuilder inherits from Assembly, but the runtime thinks its layout inherits from RuntimeAssembly
@@ -229,27 +229,6 @@ namespace System.Reflection.Emit
             modules = new ModuleBuilder[] { manifest_module };
         }
 
-        public override string? CodeBase
-        {
-            get { throw not_supported(); }
-        }
-
-        public override MethodInfo? EntryPoint
-        {
-            get
-            {
-                return null;
-            }
-        }
-
-        public override string Location
-        {
-            get
-            {
-                throw not_supported();
-            }
-        }
-
         public override bool ReflectionOnly
         {
             get { return base.ReflectionOnly; }
@@ -275,10 +254,7 @@ namespace System.Reflection.Emit
             return ab;
         }
 
-        public ModuleBuilder DefineDynamicModule(string name)
-        {
-            return DefineDynamicModule(name, false);
-        }
+        public ModuleBuilder DefineDynamicModule(string name) => DefineDynamicModule(name, false);
 
         public ModuleBuilder DefineDynamicModule(string name, bool emitSymbolInfo)
         {
@@ -309,49 +285,7 @@ namespace System.Reflection.Emit
             return null;
         }
 
-        [RequiresUnreferencedCode("Types might be removed")]
-        public override Type[] GetExportedTypes()
-        {
-            throw not_supported();
-        }
-
-        public override FileStream GetFile(string name)
-        {
-            throw not_supported();
-        }
-
-        public override FileStream[] GetFiles(bool getResourceModules)
-        {
-            throw not_supported();
-        }
-
-        public override ManifestResourceInfo? GetManifestResourceInfo(string resourceName)
-        {
-            throw not_supported();
-        }
-
-        public override string[] GetManifestResourceNames()
-        {
-            throw not_supported();
-        }
-
-        public override Stream? GetManifestResourceStream(string name)
-        {
-            throw not_supported();
-        }
-
-        public override Stream? GetManifestResourceStream(Type type, string name)
-        {
-            throw not_supported();
-        }
-
-        public override bool IsCollectible
-        {
-            get
-            {
-                return access == (uint)AssemblyBuilderAccess.RunAndCollect;
-            }
-        }
+        public override bool IsCollectible => access == (uint)AssemblyBuilderAccess.RunAndCollect;
 
         public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
         {
@@ -385,17 +319,9 @@ namespace System.Reflection.Emit
             SetCustomAttribute(new CustomAttributeBuilder(con, binaryAttribute));
         }
 
-        private static Exception not_supported()
-        {
-            // Strange message but this is what MS.NET prints...
-            return new NotSupportedException("The invoked member is not supported in a dynamic module.");
-        }
-
         /*Warning, @typeArguments must be a mscorlib internal array. So make a copy before passing it in*/
-        internal static Type MakeGenericType(Type gtd, Type[] typeArguments)
-        {
-            return new TypeBuilderInstantiation(gtd, typeArguments);
-        }
+        internal static Type MakeGenericType(Type gtd, Type[] typeArguments) =>
+            new TypeBuilderInstantiation(gtd, typeArguments);
 
         [RequiresUnreferencedCode("Types might be removed")]
         public override Type? GetType(string name, bool throwOnError, bool ignoreCase)
@@ -434,97 +360,40 @@ namespace System.Reflection.Emit
             return null;
         }
 
-        public override Module[] GetModules(bool getResourceModules)
-        {
-            return (Module[])modules.Clone();
-        }
+        public override Module[] GetModules(bool getResourceModules) => (Module[])modules.Clone();
 
-        public override AssemblyName GetName(bool copiedName)
-        {
-            return AssemblyName.Create(_mono_assembly, null);
-        }
+        public override AssemblyName GetName(bool copiedName) => AssemblyName.Create(_mono_assembly, null);
 
         [RequiresUnreferencedCode("Assembly references might be removed")]
-        public override AssemblyName[] GetReferencedAssemblies() => RuntimeAssembly.GetReferencedAssemblies (this);
+        public override AssemblyName[] GetReferencedAssemblies() => RuntimeAssembly.GetReferencedAssemblies(this);
 
-        public override Module[] GetLoadedModules(bool getResourceModules)
-        {
-            return GetModules(getResourceModules);
-        }
+        public override Module[] GetLoadedModules(bool getResourceModules) => GetModules(getResourceModules);
 
         //FIXME MS has issues loading satelite assemblies from SRE
         [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
-        public override Assembly GetSatelliteAssembly(CultureInfo culture)
-        {
-            return GetSatelliteAssembly(culture, null);
-        }
+        public override Assembly GetSatelliteAssembly(CultureInfo culture) => GetSatelliteAssembly(culture, null);
 
         //FIXME MS has issues loading satelite assemblies from SRE
         [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
-        public override Assembly GetSatelliteAssembly(CultureInfo culture, Version? version)
-        {
-            return RuntimeAssembly.InternalGetSatelliteAssembly(this, culture, version, true)!;
-        }
+        public override Assembly GetSatelliteAssembly(CultureInfo culture, Version? version) =>
+            RuntimeAssembly.InternalGetSatelliteAssembly(this, culture, version, true)!;
 
-        public override Module ManifestModule
-        {
-            get
-            {
-                return manifest_module;
-            }
-        }
+        public override Module ManifestModule => manifest_module;
+        public override string? FullName => aname.ToString();
 
-        [Obsolete(Obsoletions.GlobalAssemblyCacheMessage, DiagnosticId = Obsoletions.GlobalAssemblyCacheDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
-        public override bool GlobalAssemblyCache
-        {
-            get
-            {
-                return false;
-            }
-        }
+        public override bool Equals(object? obj) => base.Equals(obj);
 
-        public override bool IsDynamic
-        {
-            get { return true; }
-        }
+        public override int GetHashCode() => base.GetHashCode();
 
-        public override bool Equals(object? obj)
-        {
-            return base.Equals(obj);
-        }
+        public override bool IsDefined(Type attributeType, bool inherit) =>
+            CustomAttribute.IsDefined(this, attributeType, inherit);
 
-        public override int GetHashCode()
-        {
-            return base.GetHashCode();
-        }
+        public override object[] GetCustomAttributes(bool inherit) => CustomAttribute.GetCustomAttributes(this, inherit);
 
-        public override bool IsDefined(Type attributeType, bool inherit)
-        {
-            return CustomAttribute.IsDefined(this, attributeType, inherit);
-        }
+        public override object[] GetCustomAttributes(Type attributeType, bool inherit) =>
+            CustomAttribute.GetCustomAttributes(this, attributeType, inherit);
 
-        public override object[] GetCustomAttributes(bool inherit)
-        {
-            return CustomAttribute.GetCustomAttributes(this, inherit);
-        }
-
-        public override object[] GetCustomAttributes(Type attributeType, bool inherit)
-        {
-            return CustomAttribute.GetCustomAttributes(this, attributeType, inherit);
-        }
-
-        public override IList<CustomAttributeData> GetCustomAttributesData()
-        {
-            return CustomAttributeData.GetCustomAttributes(this);
-        }
-
-        public override string? FullName
-        {
-            get
-            {
-                return aname.ToString();
-            }
-        }
+        public override IList<CustomAttributeData> GetCustomAttributesData() => CustomAttributeData.GetCustomAttributes(this);
     }
 }
 #endif
index e580b0c..dff80e1 100644 (file)
@@ -1,38 +1,20 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-using System.Collections.Generic;
-
 namespace System.Reflection
 {
-
-    internal sealed class RuntimeMethodBody : MethodBody
+    internal sealed partial class RuntimeMethodBody : MethodBody
     {
-        private ExceptionHandlingClause[] clauses;
-        private LocalVariableInfo[] locals;
-        private byte[] il;
-        private bool init_locals;
-        private int sig_token;
-        private int max_stack;
-
         // Called by the runtime
         internal RuntimeMethodBody(ExceptionHandlingClause[] clauses, LocalVariableInfo[] locals,
                                     byte[] il, bool init_locals, int sig_token, int max_stack)
         {
-            this.clauses = clauses;
-            this.locals = locals;
-            this.il = il;
-            this.init_locals = init_locals;
-            this.sig_token = sig_token;
-            this.max_stack = max_stack;
+            _exceptionHandlingClauses = clauses;
+            _localVariables = locals;
+            _IL = il;
+            _initLocals = init_locals;
+            _localSignatureMetadataToken = sig_token;
+            _maxStackSize = max_stack;
         }
-
-        public override int LocalSignatureMetadataToken => sig_token;
-        public override IList<LocalVariableInfo> LocalVariables => Array.AsReadOnly(locals);
-        public override int MaxStackSize => max_stack;
-        public override bool InitLocals => init_locals;
-        public override byte[] GetILAsByteArray() => il;
-        public override IList<ExceptionHandlingClause> ExceptionHandlingClauses => Array.AsReadOnly(clauses);
     }
-
 }
diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/StackCrawlMark.cs b/src/mono/System.Private.CoreLib/src/System/Threading/StackCrawlMark.cs
deleted file mode 100644 (file)
index a4634a8..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Threading
-{
-    // declaring a local var of this enum type and passing it by ref into a function that needs to do a
-    // stack crawl will both prevent inlining of the calle and pass an ESP point to stack crawl to
-    // Declaring these in EH clauses is illegal; they must declared in the main method body
-    internal enum StackCrawlMark
-    {
-        LookForMe = 0,
-        LookForMyCaller = 1,
-        LookForMyCallersCaller = 2,
-        LookForThread = 3
-    }
-}