summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Reflection/Emit
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Reflection/Emit')
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs280
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs346
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ComInterfaces.cs143
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs34
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs18
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs243
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs36
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs13
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs7
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/EventToken.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs23
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/FieldToken.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/FlowControl.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs5
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs67
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs143
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/Label.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs6
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs319
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/MethodToken.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs263
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs32
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/OpCodes.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/Opcode.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/OperandType.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs26
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs7
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs15
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs44
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/StringToken.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SymbolType.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs215
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/TypeToken.cs7
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/UnmanagedMarshal.cs183
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs18
43 files changed, 81 insertions, 2445 deletions
diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
index 9331ae1..5575e28 100644
--- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
@@ -38,7 +38,6 @@ namespace System.Reflection.Emit
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
- using System.Security.Permissions;
using System.Security.Policy;
using System.Threading;
@@ -156,10 +155,7 @@ namespace System.Reflection.Emit
// AssemblyBuilder class.
// deliberately not [serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_AssemblyBuilder))]
- [ComVisible(true)]
- public sealed class AssemblyBuilder : Assembly, _AssemblyBuilder
+ public sealed class AssemblyBuilder : Assembly
{
#region FCALL
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -221,11 +217,6 @@ namespace System.Reflection.Emit
return InternalAssembly.GetNativeHandle();
}
- internal Version GetVersion()
- {
- return InternalAssembly.GetVersion();
- }
-
#if FEATURE_APPX
internal bool ProfileAPICheck
{
@@ -243,9 +234,6 @@ namespace System.Reflection.Emit
AssemblyBuilderAccess access,
String dir,
Evidence evidence,
- PermissionSet requiredPermissions,
- PermissionSet optionalPermissions,
- PermissionSet refusedPermissions,
ref StackCrawlMark stackMark,
IEnumerable<CustomAttributeBuilder> unsafeAssemblyAttributes,
SecurityContextSource securityContextSource)
@@ -257,9 +245,7 @@ namespace System.Reflection.Emit
#if FEATURE_REFLECTION_ONLY_LOAD
&& access != AssemblyBuilderAccess.ReflectionOnly
#endif // FEATURE_REFLECTION_ONLY_LOAD
-#if FEATURE_COLLECTIBLE_TYPES
&& access != AssemblyBuilderAccess.RunAndCollect
-#endif // FEATURE_COLLECTIBLE_TYPES
)
{
throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)access), nameof(access));
@@ -274,18 +260,6 @@ namespace System.Reflection.Emit
// Clone the name in case the caller modifies it underneath us.
name = (AssemblyName)name.Clone();
- // If the caller is trusted they can supply identity
- // evidence for the new assembly. Otherwise we copy the
- // current grant and deny sets from the caller's assembly,
- // inject them into the new assembly and mark policy as
- // resolved. If/when the assembly is persisted and
- // reloaded, the normal rules for gathering evidence will
- // be used.
- if (evidence != null)
-#pragma warning disable 618
- new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
-#pragma warning restore 618
-
// Scan the assembly level attributes for any attributes which modify how we create the
// assembly. Currently, we look for any attribute which modifies the security transparency
// of the assembly.
@@ -320,9 +294,6 @@ namespace System.Reflection.Emit
name,
evidence,
ref stackMark,
- requiredPermissions,
- optionalPermissions,
- refusedPermissions,
securityRulesBlob,
aptcaBlob,
access,
@@ -333,10 +304,6 @@ namespace System.Reflection.Emit
name.Name,
access,
dir);
- m_assemblyData.AddPermissionRequests(requiredPermissions,
- optionalPermissions,
- refusedPermissions);
-
#if FEATURE_APPX
if (AppDomain.ProfileAPICheck)
{
@@ -393,7 +360,7 @@ namespace System.Reflection.Emit
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return InternalDefineDynamicAssembly(name, access, null,
- null, null, null, null, ref stackMark, null, SecurityContextSource.CurrentAssembly);
+ null, ref stackMark, null, SecurityContextSource.CurrentAssembly);
}
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
@@ -407,7 +374,7 @@ namespace System.Reflection.Emit
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return InternalDefineDynamicAssembly(name,
access,
- null, null, null, null, null,
+ null, null,
ref stackMark,
assemblyAttributes, SecurityContextSource.CurrentAssembly);
}
@@ -418,9 +385,6 @@ namespace System.Reflection.Emit
AssemblyName name,
Evidence identity,
ref StackCrawlMark stackMark,
- PermissionSet requiredPermissions,
- PermissionSet optionalPermissions,
- PermissionSet refusedPermissions,
byte[] securityRulesBlob,
byte[] aptcaBlob,
AssemblyBuilderAccess access,
@@ -434,9 +398,6 @@ namespace System.Reflection.Emit
AssemblyBuilderAccess access,
String dir,
Evidence evidence,
- PermissionSet requiredPermissions,
- PermissionSet optionalPermissions,
- PermissionSet refusedPermissions,
ref StackCrawlMark stackMark,
IEnumerable<CustomAttributeBuilder> unsafeAssemblyAttributes,
SecurityContextSource securityContextSource)
@@ -449,9 +410,6 @@ namespace System.Reflection.Emit
access,
dir,
evidence,
- requiredPermissions,
- optionalPermissions,
- refusedPermissions,
ref stackMark,
unsafeAssemblyAttributes,
securityContextSource);
@@ -532,12 +490,6 @@ namespace System.Reflection.Emit
if (emitSymbolInfo)
{
writer = SymWrapperCore.SymWriter.CreateSymWriter();
- // Set the underlying writer for the managed writer
- // that we're using. Note that this function requires
- // unmanaged code access.
-#pragma warning disable 618
- new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
-#pragma warning restore 618
String fileName = "Unused"; // this symfile is never written to disk so filename does not matter.
@@ -559,19 +511,8 @@ namespace System.Reflection.Emit
return dynModule;
} // DefineDynamicModuleInternalNoLock
- #endregion
-
- private Assembly LoadISymWrapper()
- {
- if (m_assemblyData.m_ISymWrapperAssembly != null)
- return m_assemblyData.m_ISymWrapperAssembly;
- Assembly assem = Assembly.Load("ISymWrapper, Version=" + ThisAssembly.Version +
- ", Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken);
-
- m_assemblyData.m_ISymWrapperAssembly = assem;
- return assem;
- }
+#endregion
internal void CheckContext(params Type[][] typess)
{
@@ -839,52 +780,11 @@ namespace System.Reflection.Emit
}
return null;
}
-
- /**********************************************
- *
- * Setting the entry point if the assembly builder is building
- * an exe.
- *
- **********************************************/
- public void SetEntryPoint(
- MethodInfo entryMethod)
- {
- SetEntryPoint(entryMethod, PEFileKinds.ConsoleApplication);
- }
- public void SetEntryPoint(
- MethodInfo entryMethod, // entry method for the assembly. We use this to determine the entry module
- PEFileKinds fileKind) // file kind for the assembly.
- {
- lock(SyncRoot)
- {
- SetEntryPointNoLock(entryMethod, fileKind);
- }
- }
-
- private void SetEntryPointNoLock(
- MethodInfo entryMethod, // entry method for the assembly. We use this to determine the entry module
- PEFileKinds fileKind) // file kind for the assembly.
- {
-
- if (entryMethod == null)
- throw new ArgumentNullException(nameof(entryMethod));
- Contract.EndContractBlock();
-
- BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.SetEntryPoint");
-
- Module tmpModule = entryMethod.Module;
- if (tmpModule == null || !InternalAssembly.Equals(tmpModule.Assembly))
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EntryMethodNotDefinedInAssembly"));
-
- m_assemblyData.m_entryPointMethod = entryMethod;
- m_assemblyData.m_peFileKind = fileKind;
- }
/**********************************************
* Use this function if client decides to form the custom attribute blob themselves
**********************************************/
- [System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
if (con == null)
@@ -947,78 +847,6 @@ namespace System.Reflection.Emit
}
}
-
- /**********************************************
- *
- * Saves the assembly to disk. Also saves all dynamic modules defined
- * in this dynamic assembly. Assembly file name can be the same as one of
- * the module's name. If so, assembly info is stored within that module.
- * Assembly file name can be different from all of the modules underneath. In
- * this case, assembly is stored stand alone.
- *
- **********************************************/
-
- public void Save(String assemblyFileName) // assembly file name
- {
- Save(assemblyFileName, System.Reflection.PortableExecutableKinds.ILOnly, System.Reflection.ImageFileMachine.I386);
- }
-
- public void Save(String assemblyFileName,
- PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
- {
- lock(SyncRoot)
- {
- SaveNoLock(assemblyFileName, portableExecutableKind, imageFileMachine);
- }
- }
-
- private void SaveNoLock(String assemblyFileName,
- PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
- {
- // AssemblyBuilderAccess.Save can never be set in CoreCLR
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CantSaveTransientAssembly"));
- }
-
- internal bool IsPersistable()
- {
- {
- return false;
- }
- }
-
- /**********************************************
- *
- * Internal helper to walk the nested type hierachy
- *
- **********************************************/
- private int DefineNestedComType(Type type, int tkResolutionScope, int tkTypeDef)
- {
- Type enclosingType = type.DeclaringType;
- if (enclosingType == null)
- {
- // Use full type name for non-nested types.
- return AddExportedTypeOnDisk(GetNativeHandle(), type.FullName, tkResolutionScope, tkTypeDef, type.Attributes);
- }
-
- tkResolutionScope = DefineNestedComType(enclosingType, tkResolutionScope, tkTypeDef);
- // Use simple name for nested types.
- return AddExportedTypeOnDisk(GetNativeHandle(), type.Name, tkResolutionScope, tkTypeDef, type.Attributes);
- }
-
- internal int DefineExportedTypeInMemory(Type type, int tkResolutionScope, int tkTypeDef)
- {
- Type enclosingType = type.DeclaringType;
- if (enclosingType == null)
- {
- // Use full type name for non-nested types.
- return AddExportedTypeInMemory(GetNativeHandle(), type.FullName, tkResolutionScope, tkTypeDef, type.Attributes);
- }
-
- tkResolutionScope = DefineExportedTypeInMemory(enclosingType, tkResolutionScope, tkTypeDef);
- // Use simple name for nested types.
- return AddExportedTypeInMemory(GetNativeHandle(), type.Name, tkResolutionScope, tkTypeDef, type.Attributes);
- }
-
/**********************************************
*
* Private methods
@@ -1030,105 +858,5 @@ namespace System.Reflection.Emit
* @internonly
**********************************************/
private AssemblyBuilder() {}
-
- // Create a new module in which to emit code. This module will not contain the manifest.
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- static private extern void DefineDynamicModule(RuntimeAssembly containingAssembly,
- bool emitSymbolInfo,
- String name,
- String filename,
- StackCrawlMarkHandle stackMark,
- ref IntPtr pInternalSymWriter,
- ObjectHandleOnStack retModule,
- bool fIsTransient,
- out int tkFile);
-
- private static Module DefineDynamicModule(RuntimeAssembly containingAssembly,
- bool emitSymbolInfo,
- String name,
- String filename,
- ref StackCrawlMark stackMark,
- ref IntPtr pInternalSymWriter,
- bool fIsTransient,
- out int tkFile)
- {
- RuntimeModule retModule = null;
-
- DefineDynamicModule(containingAssembly.GetNativeHandle(),
- emitSymbolInfo,
- name,
- filename,
- JitHelpers.GetStackCrawlMarkHandle(ref stackMark),
- ref pInternalSymWriter,
- JitHelpers.GetObjectHandleOnStack(ref retModule),
- fIsTransient,
- out tkFile);
-
- return retModule;
- }
-
- // The following functions are native helpers for creating on-disk manifest
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- static private extern void PrepareForSavingManifestToDisk(RuntimeAssembly assembly, RuntimeModule assemblyModule); // module to contain assembly information if assembly is embedded
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- static private extern void SaveManifestToDisk(RuntimeAssembly assembly,
- String strFileName,
- int entryPoint,
- int fileKind,
- int portableExecutableKind,
- int ImageFileMachine);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- static private extern int AddFile(RuntimeAssembly assembly, String strFileName);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- static private extern void SetFileHashValue(RuntimeAssembly assembly,
- int tkFile,
- String strFullFileName);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- static private extern int AddExportedTypeInMemory(RuntimeAssembly assembly,
- String strComTypeName,
- int tkAssemblyRef,
- int tkTypeDef,
- TypeAttributes flags);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- static private extern int AddExportedTypeOnDisk(RuntimeAssembly assembly,
- String strComTypeName,
- int tkAssemblyRef,
- int tkTypeDef,
- TypeAttributes flags);
-
- // Add an entry to assembly's manifestResource table for a stand alone resource.
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- static private extern void AddStandAloneResource(RuntimeAssembly assembly,
- String strName,
- String strFileName,
- String strFullFileName,
- int attribute);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
-#pragma warning disable 618
- static private extern void AddDeclarativeSecurity(RuntimeAssembly assembly, SecurityAction action, byte[] blob, int length);
-#pragma warning restore 618
-
- // Functions for defining unmanaged resources.
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- static private extern void CreateVersionInfoResource(String filename, String title, String iconFilename, String description,
- String copyright, String trademark, String company, String product,
- String productVersion, String fileVersion, int lcid, bool isDll,
- StringHandleOnStack retFileName);
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs
index 5c86d8e..b3d1711 100644
--- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs
@@ -10,7 +10,6 @@ using System;
namespace System.Reflection.Emit
{
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
[Flags]
public enum AssemblyBuilderAccess
{
@@ -18,8 +17,6 @@ namespace System.Reflection.Emit
#if FEATURE_REFLECTION_ONLY_LOAD
ReflectionOnly = 6, // 4 | Save,
#endif // FEATURE_REFLECTION_ONLY_LOAD
-#if FEATURE_COLLECTIBLE_TYPES
RunAndCollect = 8 | Run
-#endif
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs
index f0f83e7..7ac9dae 100644
--- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs
@@ -14,7 +14,6 @@ namespace System.Reflection.Emit {
using System.Security;
using System.Diagnostics;
using CultureInfo = System.Globalization.CultureInfo;
- using IResourceWriter = System.Resources.IResourceWriter;
using System.IO;
using System.Runtime.Versioning;
using System.Diagnostics.SymbolStore;
@@ -52,12 +51,6 @@ namespace System.Reflection.Emit {
{
m_moduleBuilderList.Add(dynModule);
}
-
- // Helper to add a resource information into the tracking list
- internal void AddResWriter(ResWriterData resData)
- {
- m_resWriterList.Add(resData);
- }
// Helper to track CAs to persist onto disk
@@ -110,194 +103,6 @@ namespace System.Reflection.Emit {
m_CACons[m_iCAs] = con;
m_iCAs++;
}
-
- // Helper to calculate unmanaged version info from Assembly's custom attributes.
- // If DefineUnmanagedVersionInfo is called, the parameter provided will override
- // the CA's value.
- //
- internal void FillUnmanagedVersionInfo()
- {
- // Get the lcid set on the assembly name as default if available
- // Note that if LCID is not avaible from neither AssemblyName or AssemblyCultureAttribute,
- // it is default to -1 which is treated as language neutral.
- //
- CultureInfo locale = m_assembly.GetLocale();
-#if FEATURE_USE_LCID
- if (locale != null)
- m_nativeVersion.m_lcid = locale.LCID;
-#endif
-
- for (int i = 0; i < m_iCABuilder; i++)
- {
- // check for known attributes
- Type conType = m_CABuilders[i].m_con.DeclaringType;
- if (m_CABuilders[i].m_constructorArgs.Length == 0 || m_CABuilders[i].m_constructorArgs[0] == null)
- continue;
-
- if (conType.Equals(typeof(System.Reflection.AssemblyCopyrightAttribute)))
- {
- // assert that we should only have one argument for this CA and the type should
- // be a string.
- //
- if (m_CABuilders[i].m_constructorArgs.Length != 1)
- {
- throw new ArgumentException(Environment.GetResourceString(
- "Argument_BadCAForUnmngRSC",
- m_CABuilders[i].m_con.ReflectedType.Name));
- }
- if (m_OverrideUnmanagedVersionInfo == false)
- {
- m_nativeVersion.m_strCopyright = m_CABuilders[i].m_constructorArgs[0].ToString();
- }
- }
- else if (conType.Equals(typeof(System.Reflection.AssemblyTrademarkAttribute)))
- {
- // assert that we should only have one argument for this CA and the type should
- // be a string.
- //
- if (m_CABuilders[i].m_constructorArgs.Length != 1)
- {
- throw new ArgumentException(Environment.GetResourceString(
- "Argument_BadCAForUnmngRSC",
- m_CABuilders[i].m_con.ReflectedType.Name));
- }
- if (m_OverrideUnmanagedVersionInfo == false)
- {
- m_nativeVersion.m_strTrademark = m_CABuilders[i].m_constructorArgs[0].ToString();
- }
- }
- else if (conType.Equals(typeof(System.Reflection.AssemblyProductAttribute)))
- {
- if (m_OverrideUnmanagedVersionInfo == false)
- {
- // assert that we should only have one argument for this CA and the type should
- // be a string.
- //
- m_nativeVersion.m_strProduct = m_CABuilders[i].m_constructorArgs[0].ToString();
- }
- }
- else if (conType.Equals(typeof(System.Reflection.AssemblyCompanyAttribute)))
- {
- if (m_CABuilders[i].m_constructorArgs.Length != 1)
- {
- throw new ArgumentException(Environment.GetResourceString(
- "Argument_BadCAForUnmngRSC",
- m_CABuilders[i].m_con.ReflectedType.Name));
- }
- if (m_OverrideUnmanagedVersionInfo == false)
- {
- // assert that we should only have one argument for this CA and the type should
- // be a string.
- //
- m_nativeVersion.m_strCompany = m_CABuilders[i].m_constructorArgs[0].ToString();
- }
- }
- else if (conType.Equals(typeof(System.Reflection.AssemblyDescriptionAttribute)))
- {
- if (m_CABuilders[i].m_constructorArgs.Length != 1)
- {
- throw new ArgumentException(Environment.GetResourceString(
- "Argument_BadCAForUnmngRSC",
- m_CABuilders[i].m_con.ReflectedType.Name));
- }
- m_nativeVersion.m_strDescription = m_CABuilders[i].m_constructorArgs[0].ToString();
- }
- else if (conType.Equals(typeof(System.Reflection.AssemblyTitleAttribute)))
- {
- if (m_CABuilders[i].m_constructorArgs.Length != 1)
- {
- throw new ArgumentException(Environment.GetResourceString(
- "Argument_BadCAForUnmngRSC",
- m_CABuilders[i].m_con.ReflectedType.Name));
- }
- m_nativeVersion.m_strTitle = m_CABuilders[i].m_constructorArgs[0].ToString();
- }
- else if (conType.Equals(typeof(System.Reflection.AssemblyInformationalVersionAttribute)))
- {
- if (m_CABuilders[i].m_constructorArgs.Length != 1)
- {
- throw new ArgumentException(Environment.GetResourceString(
- "Argument_BadCAForUnmngRSC",
- m_CABuilders[i].m_con.ReflectedType.Name));
- }
- if (m_OverrideUnmanagedVersionInfo == false)
- {
- m_nativeVersion.m_strProductVersion = m_CABuilders[i].m_constructorArgs[0].ToString();
- }
- }
- else if (conType.Equals(typeof(System.Reflection.AssemblyCultureAttribute)))
- {
- // retrieve the LCID
- if (m_CABuilders[i].m_constructorArgs.Length != 1)
- {
- throw new ArgumentException(Environment.GetResourceString(
- "Argument_BadCAForUnmngRSC",
- m_CABuilders[i].m_con.ReflectedType.Name));
- }
- // CultureInfo attribute overrides the lcid from AssemblyName.
- CultureInfo culture = new CultureInfo(m_CABuilders[i].m_constructorArgs[0].ToString());
-#if FEATURE_USE_LCID
- m_nativeVersion.m_lcid = culture.LCID;
-#endif
- }
- else if (conType.Equals(typeof(System.Reflection.AssemblyFileVersionAttribute)))
- {
- if (m_CABuilders[i].m_constructorArgs.Length != 1)
- {
- throw new ArgumentException(Environment.GetResourceString(
- "Argument_BadCAForUnmngRSC",
- m_CABuilders[i].m_con.ReflectedType.Name));
- }
- if (m_OverrideUnmanagedVersionInfo == false)
- {
- m_nativeVersion.m_strFileVersion = m_CABuilders[i].m_constructorArgs[0].ToString();
- }
- }
- }
- }
-
-
- // Helper to ensure the resource name is unique underneath assemblyBuilder
- internal void CheckResNameConflict(String strNewResName)
- {
- int size = m_resWriterList.Count;
- int i;
- for (i = 0; i < size; i++)
- {
- ResWriterData resWriter = m_resWriterList[i];
- if (resWriter.m_strName.Equals(strNewResName))
- {
- // Cannot have two resources with the same name
- throw new ArgumentException(Environment.GetResourceString("Argument_DuplicateResourceName"));
- }
- }
- }
-
-
- // Helper to ensure the module name is unique underneath assemblyBuilder
- internal void CheckNameConflict(String strNewModuleName)
- {
- int size = m_moduleBuilderList.Count;
- int i;
- for (i = 0; i < size; i++)
- {
- ModuleBuilder moduleBuilder = m_moduleBuilderList[i];
- if (moduleBuilder.m_moduleData.m_strModuleName.Equals(strNewModuleName))
- {
- // Cannot have two dynamic modules with the same name
- throw new ArgumentException(Environment.GetResourceString("Argument_DuplicateModuleName"));
- }
- }
-
- // Right now dynamic modules can only be added to dynamic assemblies in which
- // all modules are dynamic. Otherwise we would also need to check the static modules
- // with this:
- // if (m_assembly.GetModule(strNewModuleName) != null)
- // {
- // // Cannot have two dynamic modules with the same name
- // throw new ArgumentException(Environment.GetResourceString("Argument_DuplicateModuleName"));
- // }
- }
// Helper to ensure the type name is unique underneath assemblyBuilder
internal void CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType)
@@ -320,134 +125,6 @@ namespace System.Reflection.Emit {
// }
}
-
- // Helper to ensure the file name is unique underneath assemblyBuilder. This includes
- // modules and resources.
- //
- //
- //
- internal void CheckFileNameConflict(String strFileName)
- {
- int size = m_moduleBuilderList.Count;
- int i;
- for (i = 0; i < size; i++)
- {
- ModuleBuilder moduleBuilder = m_moduleBuilderList[i];
- if (moduleBuilder.m_moduleData.m_strFileName != null)
- {
- if (String.Compare(moduleBuilder.m_moduleData.m_strFileName, strFileName, StringComparison.OrdinalIgnoreCase) == 0)
- {
- // Cannot have two dynamic module with the same name
- throw new ArgumentException(Environment.GetResourceString("Argument_DuplicatedFileName"));
- }
- }
- }
- size = m_resWriterList.Count;
- for (i = 0; i < size; i++)
- {
- ResWriterData resWriter = m_resWriterList[i];
- if (resWriter.m_strFileName != null)
- {
- if (String.Compare(resWriter.m_strFileName, strFileName, StringComparison.OrdinalIgnoreCase) == 0)
- {
- // Cannot have two dynamic module with the same name
- throw new ArgumentException(Environment.GetResourceString("Argument_DuplicatedFileName"));
- }
- }
- }
-
- }
-
- // Helper to look up which module that assembly is supposed to be stored at
- //
- //
- //
- internal ModuleBuilder FindModuleWithFileName(String strFileName)
- {
- int size = m_moduleBuilderList.Count;
- int i;
- for (i = 0; i < size; i++)
- {
- ModuleBuilder moduleBuilder = m_moduleBuilderList[i];
- if (moduleBuilder.m_moduleData.m_strFileName != null)
- {
- if (String.Compare(moduleBuilder.m_moduleData.m_strFileName, strFileName, StringComparison.OrdinalIgnoreCase) == 0)
- {
- return moduleBuilder;
- }
- }
- }
- return null;
- }
-
- // Helper to look up module by name.
- //
- //
- //
- internal ModuleBuilder FindModuleWithName(String strName)
- {
- int size = m_moduleBuilderList.Count;
- int i;
- for (i = 0; i < size; i++)
- {
- ModuleBuilder moduleBuilder = m_moduleBuilderList[i];
- if (moduleBuilder.m_moduleData.m_strModuleName != null)
- {
- if (String.Compare(moduleBuilder.m_moduleData.m_strModuleName, strName, StringComparison.OrdinalIgnoreCase) == 0)
- return moduleBuilder;
- }
- }
- return null;
- }
-
-
- // add type to public COMType tracking list
- internal void AddPublicComType(Type type)
- {
- BCLDebug.Log("DYNIL","## DYNIL LOGGING: AssemblyBuilderData.AddPublicComType( " + type.FullName + " )");
- if (m_isSaved == true)
- {
- // assembly has been saved before!
- throw new InvalidOperationException(Environment.GetResourceString(
- "InvalidOperation_CannotAlterAssembly"));
- }
- EnsurePublicComTypeCapacity();
- m_publicComTypeList[m_iPublicComTypeCount] = type;
- m_iPublicComTypeCount++;
- }
-
- // add security permission requests
- internal void AddPermissionRequests(
- PermissionSet required,
- PermissionSet optional,
- PermissionSet refused)
- {
- BCLDebug.Log("DYNIL","## DYNIL LOGGING: AssemblyBuilderData.AddPermissionRequests");
- if (m_isSaved == true)
- {
- // assembly has been saved before!
- throw new InvalidOperationException(Environment.GetResourceString(
- "InvalidOperation_CannotAlterAssembly"));
- }
- m_RequiredPset = required;
- m_OptionalPset = optional;
- m_RefusedPset = refused;
- }
-
- private void EnsurePublicComTypeCapacity()
- {
- if (m_publicComTypeList == null)
- {
- m_publicComTypeList = new Type[m_iInitialSize];
- }
- if (m_iPublicComTypeCount == m_publicComTypeList.Length)
- {
- Type[] tempTypeList = new Type[m_iPublicComTypeCount * 2];
- Array.Copy(m_publicComTypeList, 0, tempTypeList, 0, m_iPublicComTypeCount);
- m_publicComTypeList = tempTypeList;
- }
- }
-
internal List<ModuleBuilder> m_moduleBuilderList;
internal List<ResWriterData> m_resWriterList;
internal String m_strAssemblyName;
@@ -463,11 +140,6 @@ namespace System.Reflection.Emit {
// hard coding the assembly def token
internal const int m_tkAssembly = 0x20000001;
-
- // Security permission requests
- internal PermissionSet m_RequiredPset;
- internal PermissionSet m_OptionalPset;
- internal PermissionSet m_RefusedPset;
// tracking AssemblyDef's CAs for persistence to disk
internal CustomAttributeBuilder[] m_CABuilders;
@@ -497,24 +169,6 @@ namespace System.Reflection.Emit {
**********************************************/
internal class ResWriterData
{
- internal ResWriterData(
- IResourceWriter resWriter,
- Stream memoryStream,
- String strName,
- String strFileName,
- String strFullFileName,
- ResourceAttributes attribute)
- {
- m_resWriter = resWriter;
- m_memoryStream = memoryStream;
- m_strName = strName;
- m_strFileName = strFileName;
- m_strFullFileName = strFullFileName;
- m_nextResWriter = null;
- m_attribute = attribute;
- }
-
- internal IResourceWriter m_resWriter;
internal String m_strName;
internal String m_strFileName;
internal String m_strFullFileName;
diff --git a/src/mscorlib/src/System/Reflection/Emit/ComInterfaces.cs b/src/mscorlib/src/System/Reflection/Emit/ComInterfaces.cs
deleted file mode 100644
index 8dba934..0000000
--- a/src/mscorlib/src/System/Reflection/Emit/ComInterfaces.cs
+++ /dev/null
@@ -1,143 +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.
-
-namespace System.Runtime.InteropServices
-{
- [GuidAttribute("BEBB2505-8B54-3443-AEAD-142A16DD9CC7")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.AssemblyBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _AssemblyBuilder
- {
- }
-
- [GuidAttribute("ED3E4384-D7E2-3FA7-8FFD-8940D330519A")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.ConstructorBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _ConstructorBuilder
- {
- }
-
- [GuidAttribute("BE9ACCE8-AAFF-3B91-81AE-8211663F5CAD")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.CustomAttributeBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _CustomAttributeBuilder
- {
- }
-
- [GuidAttribute("C7BD73DE-9F85-3290-88EE-090B8BDFE2DF")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.EnumBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _EnumBuilder
- {
- }
-
- [GuidAttribute("AADABA99-895D-3D65-9760-B1F12621FAE8")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.EventBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _EventBuilder
- {
- }
-
- [GuidAttribute("CE1A3BF5-975E-30CC-97C9-1EF70F8F3993")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.FieldBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _FieldBuilder
- {
- }
-
- [GuidAttribute("A4924B27-6E3B-37F7-9B83-A4501955E6A7")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.ILGenerator))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _ILGenerator
- {
- }
-
- [GuidAttribute("4E6350D1-A08B-3DEC-9A3E-C465F9AEEC0C")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.LocalBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _LocalBuilder
- {
- }
-
- [GuidAttribute("007D8A14-FDF3-363E-9A0B-FEC0618260A2")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.MethodBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _MethodBuilder
- {
- }
-
-#if FEATURE_METHOD_RENTAL
- [GuidAttribute("C2323C25-F57F-3880-8A4D-12EBEA7A5852")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.MethodRental))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _MethodRental
- {
- }
-#endif
-
- [GuidAttribute("D05FFA9A-04AF-3519-8EE1-8D93AD73430B")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.ModuleBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _ModuleBuilder
- {
- }
-
- [GuidAttribute("36329EBA-F97A-3565-BC07-0ED5C6EF19FC")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.ParameterBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _ParameterBuilder
- {
- }
-
- [GuidAttribute("15F9A479-9397-3A63-ACBD-F51977FB0F02")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.PropertyBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _PropertyBuilder
- {
- }
-
- [GuidAttribute("7D13DD37-5A04-393C-BBCA-A5FEA802893D")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.SignatureHelper))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _SignatureHelper
- {
- }
-
- [GuidAttribute("7E5678EE-48B3-3F83-B076-C58543498A58")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Emit.TypeBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _TypeBuilder
- {
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs
index ef76adc..3bc0286 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs
@@ -12,14 +12,10 @@ namespace System.Reflection.Emit
using System.Collections.Generic;
using System.Diagnostics.SymbolStore;
using System.Security;
- using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_ConstructorBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class ConstructorBuilder : ConstructorInfo, _ConstructorBuilder
+ public sealed class ConstructorBuilder : ConstructorInfo
{
private readonly MethodBuilder m_methodBuilder;
internal bool m_isDefaultConstructor;
@@ -65,11 +61,6 @@ namespace System.Reflection.Emit
{
return m_methodBuilder.GetTypeBuilder();
}
-
- internal ModuleBuilder GetModuleBuilder()
- {
- return GetTypeBuilder().GetModuleBuilder();
- }
#endregion
#region Object Overrides
@@ -181,11 +172,6 @@ namespace System.Reflection.Emit
return m_methodBuilder.DefineParameter(iSequence, attributes, strParamName);
}
- public void SetSymCustomAttribute(String name, byte[] data)
- {
- m_methodBuilder.SetSymCustomAttribute(name, data);
- }
-
public ILGenerator GetILGenerator()
{
if (m_isDefaultConstructor)
@@ -202,16 +188,6 @@ namespace System.Reflection.Emit
return m_methodBuilder.GetILGenerator(streamSize);
}
- public void SetMethodBody(byte[] il, int maxStack, byte[] localSignature, IEnumerable<ExceptionHandler> exceptionHandlers, IEnumerable<int> tokenFixups)
- {
- if (m_isDefaultConstructor)
- {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_DefaultConstructorDefineBody"));
- }
-
- m_methodBuilder.SetMethodBody(il, maxStack, localSignature, exceptionHandlers, tokenFixups);
- }
-
public override CallingConventions CallingConvention
{
get
@@ -227,13 +203,6 @@ namespace System.Reflection.Emit
{
return m_methodBuilder.GetModule();
}
-
-
- [Obsolete("This property has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")] //It always returns null.
- public Type ReturnType
- {
- get { return GetReturnType(); }
- }
// This always returns null. Is that what we want?
internal override Type GetReturnType()
@@ -246,7 +215,6 @@ namespace System.Reflection.Emit
get { return m_methodBuilder.Signature; }
}
- [System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
m_methodBuilder.SetCustomAttribute(con, binaryAttribute);
diff --git a/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
index 545657a..5d08ca0 100644
--- a/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
@@ -19,16 +19,12 @@ namespace System.Reflection.Emit {
using System.Reflection;
using System.IO;
using System.Text;
- using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Globalization;
using System.Diagnostics;
using System.Diagnostics.Contracts;
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_CustomAttributeBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public class CustomAttributeBuilder : _CustomAttributeBuilder
+ public class CustomAttributeBuilder
{
// public constructor to form the custom attribute with constructor and constructor
// parameters.
@@ -556,18 +552,6 @@ namespace System.Reflection.Emit {
}
//*************************************************
- // Upon saving to disk, we need to create the memberRef token for the custom attribute's type
- // first of all. So when we snap the in-memory module for on disk, this token will be there.
- // We also need to enforce the use of MemberRef. Because MemberDef token might move.
- // This function has to be called before we snap the in-memory module for on disk (i.e. Presave on
- // ModuleBuilder.
- //*************************************************
- internal int PrepareCreateCustomAttributeToDisk(ModuleBuilder mod)
- {
- return mod.InternalGetConstructorToken(m_con, true).Token;
- }
-
- //*************************************************
// Call this function with toDisk=1, after on disk module has been snapped.
//*************************************************
internal void CreateCustomAttribute(ModuleBuilder mod, int tkOwner, int tkAttrib, bool toDisk)
diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
index 9e1d829..cb2667a 100644
--- a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
@@ -14,7 +14,6 @@ namespace System.Reflection.Emit
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
- using System.Security.Permissions;
using System.Threading;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
@@ -142,7 +141,6 @@ namespace System.Reflection.Emit
PutInteger4(token);
}
- [System.Runtime.InteropServices.ComVisible(true)]
public override void Emit(OpCode opcode, ConstructorInfo con)
{
if (con == null)
@@ -267,43 +265,6 @@ namespace System.Reflection.Emit
PutInteger4(token);
}
- public override void EmitCalli(OpCode opcode,
- CallingConvention unmanagedCallConv,
- Type returnType,
- Type[] parameterTypes)
- {
- int stackchange = 0;
- int cParams = 0;
- int i;
- SignatureHelper sig;
-
- if (parameterTypes != null)
- cParams = parameterTypes.Length;
-
- sig = SignatureHelper.GetMethodSigHelper(unmanagedCallConv, returnType);
-
- if (parameterTypes != null)
- for (i = 0; i < cParams; i++)
- sig.AddArgument(parameterTypes[i]);
-
- // If there is a non-void return type, push one.
- if (returnType != typeof(void))
- stackchange++;
-
- // Pop off arguments if any.
- if (parameterTypes != null)
- stackchange -= cParams;
-
- // Pop the native function pointer.
- stackchange--;
- UpdateStackSize(OpCodes.Calli, stackchange);
-
- EnsureCapacity(7);
- Emit(OpCodes.Calli);
- int token = GetTokenForSig(sig.GetSignature(true));
- PutInteger4(token);
- }
-
public override void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[] optionalParameterTypes)
{
if (methodInfo == null)
@@ -379,19 +340,20 @@ namespace System.Reflection.Emit
// Exception related generation
//
//
- public override Label BeginExceptionBlock()
+ public override void BeginExceptFilterBlock()
{
- return base.BeginExceptionBlock();
- }
+ // Begins an exception filter block. Emits a branch instruction to the end of the current exception block.
- public override void EndExceptionBlock()
- {
- base.EndExceptionBlock();
- }
+ if (CurrExcStackCount == 0)
+ throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock"));
- public override void BeginExceptFilterBlock()
- {
- throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod"));
+ __ExceptionInfo current = CurrExcStack[CurrExcStackCount - 1];
+
+ Label endLabel = current.GetEndLabel();
+ Emit(OpCodes.Leave, endLabel);
+ UpdateStackSize(OpCodes.Nop, 1);
+
+ current.MarkFilterAddr(ILOffset);
}
public override void BeginCatchBlock(Type exceptionType)
@@ -412,6 +374,8 @@ namespace System.Reflection.Emit
}
this.Emit(OpCodes.Endfilter);
+
+ current.MarkCatchAddr(ILOffset, null);
}
else
{
@@ -427,24 +391,14 @@ namespace System.Reflection.Emit
// if this is a catch block the exception will be pushed on the stack and we need to update the stack info
UpdateStackSize(OpCodes.Nop, 1);
- }
-
- current.MarkCatchAddr(ILOffset, exceptionType);
-
- // this is relying on too much implementation details of the base and so it's highly breaking
- // Need to have a more integreted story for exceptions
- current.m_filterAddr[current.m_currentCatch - 1] = GetTokenFor(rtType);
- }
+ current.MarkCatchAddr(ILOffset, exceptionType);
- public override void BeginFaultBlock()
- {
- throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod"));
- }
- public override void BeginFinallyBlock()
- {
- base.BeginFinallyBlock();
+ // this is relying on too much implementation details of the base and so it's highly breaking
+ // Need to have a more integrated story for exceptions
+ current.m_filterAddr[current.m_currentCatch - 1] = GetTokenFor(rtType);
+ }
}
//
@@ -520,22 +474,18 @@ namespace System.Reflection.Emit
Type[] parameterTypes,
Type[] optionalParameterTypes)
{
- int cParams;
- int i;
- SignatureHelper sig;
- if (parameterTypes == null)
- cParams = 0;
- else
- cParams = parameterTypes.Length;
- sig = SignatureHelper.GetMethodSigHelper(call, returnType);
- for (i = 0; i < cParams; i++)
- sig.AddArgument(parameterTypes[i]);
+ SignatureHelper sig = SignatureHelper.GetMethodSigHelper(call, returnType);
+ if (parameterTypes != null)
+ {
+ foreach (Type t in parameterTypes)
+ sig.AddArgument(t);
+ }
if (optionalParameterTypes != null && optionalParameterTypes.Length != 0)
{
// add the sentinel
sig.AddSentinel();
- for (i = 0; i < optionalParameterTypes.Length; i++)
- sig.AddArgument(optionalParameterTypes[i]);
+ foreach (Type t in optionalParameterTypes)
+ sig.AddArgument(t);
}
return sig;
}
@@ -811,17 +761,6 @@ namespace System.Reflection.Emit
typeOwner = m_method.m_typeOwner;
-#if FEATURE_COMPRESSEDSTACK
- if (m_method.m_creationContext != null)
- {
- flags |= SecurityControlFlags.HasCreationContext;
- if(m_method.m_creationContext.CanSkipEvaluation)
- {
- flags |= SecurityControlFlags.CanSkipCSEvaluation;
- }
- }
-
-#endif // FEATURE_COMPRESSEDSTACK
securityControlFlags = (int)flags;
@@ -904,12 +843,6 @@ namespace System.Reflection.Emit
internal override String GetStringLiteral(int token) { return m_scope.GetString(token); }
-#if FEATURE_COMPRESSEDSTACK
- internal override CompressedStack GetSecurityContext()
- {
- return m_method.m_creationContext;
- }
-#endif // FEATURE_COMPRESSEDSTACK
internal override void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle, out IntPtr fieldHandle)
{
@@ -991,8 +924,7 @@ namespace System.Reflection.Emit
}
- [System.Runtime.InteropServices.ComVisible(true)]
- public class DynamicILInfo
+ internal class DynamicILInfo
{
#region Private Data Members
private DynamicMethod m_method;
@@ -1004,18 +936,6 @@ namespace System.Reflection.Emit
private int m_methodSignature;
#endregion
- #region Constructor
- internal DynamicILInfo(DynamicScope scope, DynamicMethod method, byte[] methodSignature)
- {
- m_method = method;
- m_scope = scope;
- m_methodSignature = m_scope.GetTokenFor(methodSignature);
- m_exceptions = EmptyArray<Byte>.Value;
- m_code = EmptyArray<Byte>.Value;
- m_localSignature = EmptyArray<Byte>.Value;
- }
- #endregion
-
#region Internal Methods
internal void GetCallableMethod(RuntimeModule module, DynamicMethod dm)
{
@@ -1042,113 +962,8 @@ namespace System.Reflection.Emit
public DynamicMethod DynamicMethod { get { return m_method; } }
internal DynamicScope DynamicScope { get { return m_scope; } }
- public void SetCode(byte[] code, int maxStackSize)
- {
- m_code = (code != null) ? (byte[])code.Clone() : EmptyArray<Byte>.Value;
- m_maxStackSize = maxStackSize;
- }
-
- [CLSCompliant(false)]
- public unsafe void SetCode(byte* code, int codeSize, int maxStackSize)
- {
- if (codeSize < 0)
- throw new ArgumentOutOfRangeException(nameof(codeSize), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
-
- if (codeSize > 0 && code == null)
- throw new ArgumentNullException(nameof(code));
- Contract.EndContractBlock();
-
- m_code = new byte[codeSize];
- for (int i = 0; i < codeSize; i++)
- {
- m_code[i] = *code;
- code++;
- }
-
- m_maxStackSize = maxStackSize;
- }
-
- public void SetExceptions(byte[] exceptions)
- {
- m_exceptions = (exceptions != null) ? (byte[])exceptions.Clone() : EmptyArray<Byte>.Value;
- }
-
- [CLSCompliant(false)]
- public unsafe void SetExceptions(byte* exceptions, int exceptionsSize)
- {
- if (exceptionsSize < 0)
- throw new ArgumentOutOfRangeException(nameof(exceptionsSize), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
-
- if (exceptionsSize > 0 && exceptions == null)
- throw new ArgumentNullException(nameof(exceptions));
- Contract.EndContractBlock();
-
- m_exceptions = new byte[exceptionsSize];
-
- for (int i = 0; i < exceptionsSize; i++)
- {
- m_exceptions[i] = *exceptions;
- exceptions++;
- }
- }
-
- public void SetLocalSignature(byte[] localSignature)
- {
- m_localSignature = (localSignature != null) ? (byte[])localSignature.Clone() : EmptyArray<Byte>.Value;
- }
-
- [CLSCompliant(false)]
- public unsafe void SetLocalSignature(byte* localSignature, int signatureSize)
- {
- if (signatureSize < 0)
- throw new ArgumentOutOfRangeException(nameof(signatureSize), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
-
- if (signatureSize > 0 && localSignature == null)
- throw new ArgumentNullException(nameof(localSignature));
- Contract.EndContractBlock();
-
- m_localSignature = new byte[signatureSize];
- for (int i = 0; i < signatureSize; i++)
- {
- m_localSignature[i] = *localSignature;
- localSignature++;
- }
- }
- #endregion
-
- #region Public Scope Methods
- public int GetTokenFor(RuntimeMethodHandle method)
- {
- return DynamicScope.GetTokenFor(method);
- }
- public int GetTokenFor(DynamicMethod method)
- {
- return DynamicScope.GetTokenFor(method);
- }
- public int GetTokenFor(RuntimeMethodHandle method, RuntimeTypeHandle contextType)
- {
- return DynamicScope.GetTokenFor(method, contextType);
- }
- public int GetTokenFor(RuntimeFieldHandle field)
- {
- return DynamicScope.GetTokenFor(field);
- }
- public int GetTokenFor(RuntimeFieldHandle field, RuntimeTypeHandle contextType)
- {
- return DynamicScope.GetTokenFor(field, contextType);
- }
- public int GetTokenFor(RuntimeTypeHandle type)
- {
- return DynamicScope.GetTokenFor(type);
- }
- public int GetTokenFor(string literal)
- {
- return DynamicScope.GetTokenFor(literal);
- }
- public int GetTokenFor(byte[] signature)
- {
- return DynamicScope.GetTokenFor(signature);
- }
+#endregion
+#region Public Scope Methods
#endregion
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
index 1b8c97d..f1d99d3 100644
--- a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
@@ -11,7 +11,6 @@ namespace System.Reflection.Emit
using CultureInfo = System.Globalization.CultureInfo;
using System.Reflection;
using System.Security;
- using System.Security.Permissions;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
@@ -19,7 +18,6 @@ namespace System.Reflection.Emit
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class DynamicMethod : MethodInfo
{
private RuntimeType[] m_parameterTypes;
@@ -58,9 +56,6 @@ namespace System.Reflection.Emit
// We capture the creation context so that we can do the checks against the same context,
// irrespective of when the method gets compiled. Note that the DynamicMethod does not know when
// it is ready for use since there is not API which indictates that IL generation has completed.
-#if FEATURE_COMPRESSEDSTACK
- internal CompressedStack m_creationContext;
-#endif // FEATURE_COMPRESSEDSTACK
private static volatile InternalModuleBuilder s_anonymouslyHostedDynamicMethodsModule;
private static readonly object s_anonymouslyHostedDynamicMethodsModuleLock = new object();
@@ -274,7 +269,7 @@ namespace System.Reflection.Emit
AssemblyBuilder assembly = AssemblyBuilder.InternalDefineDynamicAssembly(
assemblyName,
AssemblyBuilderAccess.Run,
- null, null, null, null, null,
+ null, null,
ref stackMark,
assemblyAttributes,
SecurityContextSource.CurrentAssembly);
@@ -330,9 +325,6 @@ namespace System.Reflection.Emit
m_restrictedSkipVisibility = true;
}
-#if FEATURE_COMPRESSEDSTACK
- m_creationContext = CompressedStack.Capture();
-#endif // FEATURE_COMPRESSEDSTACK
}
else
{
@@ -401,7 +393,6 @@ namespace System.Reflection.Emit
// Delegate and method creation
//
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed override Delegate CreateDelegate(Type delegateType) {
if (m_restrictedSkipVisibility)
{
@@ -416,7 +407,6 @@ namespace System.Reflection.Emit
return d;
}
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed override Delegate CreateDelegate(Type delegateType, Object target) {
if (m_restrictedSkipVisibility)
{
@@ -594,30 +584,6 @@ namespace System.Reflection.Emit
return null;
}
- public DynamicILInfo GetDynamicILInfo()
- {
-#pragma warning disable 618
- new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
-#pragma warning restore 618
-
- if (m_DynamicILInfo != null)
- return m_DynamicILInfo;
-
- return GetDynamicILInfo(new DynamicScope());
- }
-
- internal DynamicILInfo GetDynamicILInfo(DynamicScope scope)
- {
- if (m_DynamicILInfo == null)
- {
- byte[] methodSignature = SignatureHelper.GetMethodSigHelper(
- null, CallingConvention, ReturnType, null, null, m_parameterTypes, null, null).GetSignature(true);
- m_DynamicILInfo = new DynamicILInfo(scope, this, methodSignature);
- }
-
- return m_DynamicILInfo;
- }
-
public ILGenerator GetILGenerator() {
return GetILGenerator(64);
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs
index 82dc282..96564d5 100644
--- a/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs
@@ -20,13 +20,8 @@ namespace System.Reflection.Emit {
using System.Reflection;
using System.Runtime.InteropServices;
using CultureInfo = System.Globalization.CultureInfo;
- using System.Security.Permissions;
-
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_EnumBuilder))]
-[System.Runtime.InteropServices.ComVisible(true)]
- sealed public class EnumBuilder : TypeInfo, _EnumBuilder
+ sealed public class EnumBuilder : TypeInfo
{
public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
if(typeInfo==null) return false;
@@ -137,7 +132,6 @@ namespace System.Reflection.Emit {
types, modifiers);
}
-[System.Runtime.InteropServices.ComVisible(true)]
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
{
return m_typeBuilder.GetConstructors(bindingAttr);
@@ -218,7 +212,6 @@ namespace System.Reflection.Emit {
return m_typeBuilder.GetMembers(bindingAttr);
}
-[System.Runtime.InteropServices.ComVisible(true)]
public override InterfaceMapping GetInterfaceMap(Type interfaceType)
{
return m_typeBuilder.GetInterfaceMap(interfaceType);
@@ -312,7 +305,6 @@ namespace System.Reflection.Emit {
// Use this function if client decides to form the custom attribute blob themselves
-[System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
m_typeBuilder.SetCustomAttribute(con, binaryAttribute);
@@ -341,9 +333,6 @@ namespace System.Reflection.Emit {
{
return m_typeBuilder.IsDefined(attributeType, inherit);
}
-
-
- internal int MetadataTokenInternal { get { return m_typeBuilder.MetadataTokenInternal; } }
/*****************************************************
*
diff --git a/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs
index 449b208..34c76b9 100644
--- a/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs
@@ -16,7 +16,6 @@ namespace System.Reflection.Emit {
using System;
using System.Reflection;
- using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
@@ -24,10 +23,7 @@ namespace System.Reflection.Emit {
// A EventBuilder is always associated with a TypeBuilder. The TypeBuilder.DefineEvent
// method will return a new EventBuilder to a client.
//
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_EventBuilder))]
-[System.Runtime.InteropServices.ComVisible(true)]
- public sealed class EventBuilder : _EventBuilder
+ public sealed class EventBuilder
{
// Make a private constructor so these cannot be constructed externally.
@@ -95,7 +91,6 @@ namespace System.Reflection.Emit {
// Use this function if client decides to form the custom attribute blob themselves
-[System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
if (con == null)
diff --git a/src/mscorlib/src/System/Reflection/Emit/EventToken.cs b/src/mscorlib/src/System/Reflection/Emit/EventToken.cs
index 0642cec..8ffdce9 100644
--- a/src/mscorlib/src/System/Reflection/Emit/EventToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/EventToken.cs
@@ -16,9 +16,7 @@ namespace System.Reflection.Emit {
using System;
using System.Reflection;
- using System.Security.Permissions;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public struct EventToken
{
public static readonly EventToken Empty = new EventToken();
diff --git a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
index 595d60a..5953b67 100644
--- a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
@@ -10,13 +10,9 @@ namespace System.Reflection.Emit
using System;
using CultureInfo = System.Globalization.CultureInfo;
using System.Reflection;
- using System.Security.Permissions;
using System.Diagnostics.Contracts;
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_FieldBuilder))]
-[System.Runtime.InteropServices.ComVisible(true)]
- public sealed class FieldBuilder : FieldInfo, _FieldBuilder
+ public sealed class FieldBuilder : FieldInfo
{
#region Private Data Members
private int m_fieldTok;
@@ -71,8 +67,6 @@ namespace System.Reflection.Emit
{
ModuleBuilder.SetFieldRVAContent(m_typeBuilder.GetModuleBuilder().GetNativeHandle(), m_tkField.Token, data, size);
}
-
- internal TypeBuilder GetTypeBuilder() { return m_typeBuilder; }
#endregion
#region MemberInfo Overrides
@@ -185,20 +179,6 @@ namespace System.Reflection.Emit
TypeBuilder.SetFieldLayoutOffset(m_typeBuilder.GetModuleBuilder().GetNativeHandle(), GetToken().Token, iOffset);
}
- [Obsolete("An alternate API is available: Emit the MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- public void SetMarshal(UnmanagedMarshal unmanagedMarshal)
- {
- if (unmanagedMarshal == null)
- throw new ArgumentNullException(nameof(unmanagedMarshal));
- Contract.EndContractBlock();
-
- m_typeBuilder.ThrowIfCreated();
-
- byte[] ubMarshal = unmanagedMarshal.InternalGetBytes();
-
- TypeBuilder.SetFieldMarshal(m_typeBuilder.GetModuleBuilder().GetNativeHandle(), GetToken().Token, ubMarshal, ubMarshal.Length);
- }
-
public void SetConstant(Object defaultValue)
{
m_typeBuilder.ThrowIfCreated();
@@ -207,7 +187,6 @@ namespace System.Reflection.Emit
}
-[System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
if (con == null)
diff --git a/src/mscorlib/src/System/Reflection/Emit/FieldToken.cs b/src/mscorlib/src/System/Reflection/Emit/FieldToken.cs
index 42fd684..add428f 100644
--- a/src/mscorlib/src/System/Reflection/Emit/FieldToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/FieldToken.cs
@@ -16,14 +16,12 @@ namespace System.Reflection.Emit {
using System;
using System.Reflection;
- using System.Security.Permissions;
// The FieldToken class is an opaque representation of the Token returned
// by the Metadata to represent the field. FieldTokens are generated by
// Module.GetFieldToken(). There are no meaningful accessors on this class,
// but it can be passed to ILGenerator which understands it's internals.
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public struct FieldToken
{
public static readonly FieldToken Empty = new FieldToken();
diff --git a/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs b/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs
index 31bb564..9e528b2 100644
--- a/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs
@@ -16,7 +16,6 @@ namespace System.Reflection.Emit {
using System;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum FlowControl
{
diff --git a/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs
index 6987ea1..894f57d 100644
--- a/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs
@@ -13,7 +13,6 @@ namespace System.Reflection.Emit
using System.Globalization;
using System.Diagnostics.Contracts;
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class GenericTypeParameterBuilder: TypeInfo
{
public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
@@ -118,7 +117,6 @@ namespace System.Reflection.Emit
protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); }
-[System.Runtime.InteropServices.ComVisible(true)]
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { throw new NotSupportedException(); }
protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); }
@@ -147,7 +145,6 @@ namespace System.Reflection.Emit
public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) { throw new NotSupportedException(); }
-[System.Runtime.InteropServices.ComVisible(true)]
public override InterfaceMapping GetInterfaceMap(Type interfaceType) { throw new NotSupportedException(); }
public override EventInfo[] GetEvents(BindingFlags bindingAttr) { throw new NotSupportedException(); }
@@ -198,7 +195,6 @@ namespace System.Reflection.Emit
public override bool IsAssignableFrom(Type c) { throw new NotSupportedException(); }
- [System.Runtime.InteropServices.ComVisible(true)]
[Pure]
public override bool IsSubclassOf(Type c) { throw new NotSupportedException(); }
#endregion
@@ -228,7 +224,6 @@ namespace System.Reflection.Emit
m_type.SetParent(baseTypeConstraint);
}
- [System.Runtime.InteropServices.ComVisible(true)]
public void SetInterfaceConstraints(params Type[] interfaceConstraints)
{
m_type.CheckContext(interfaceConstraints);
diff --git a/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
index ed0763b..2cee63f 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
@@ -10,15 +10,11 @@ namespace System.Reflection.Emit
using System.Diagnostics.SymbolStore;
using System.Runtime.InteropServices;
using System.Reflection;
- using System.Security.Permissions;
using System.Globalization;
using System.Diagnostics;
using System.Diagnostics.Contracts;
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_ILGenerator))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public class ILGenerator : _ILGenerator
+ public class ILGenerator
{
#region Const Members
private const int defaultSize = 16;
@@ -388,20 +384,17 @@ namespace System.Reflection.Emit
// Just a cheap insertion sort. We don't expect many exceptions (<10), where InsertionSort beats QuickSort.
// If we have more exceptions than this in real life, we should consider moving to a QuickSort.
- int least;
- __ExceptionInfo temp;
- int length = exceptions.Length;
- for (int i =0; i < length; i++)
+ for (int i = 0; i < exceptions.Length; i++)
{
- least = i;
- for (int j =i + 1; j < length; j++)
+ int least = i;
+ for (int j = i + 1; j < exceptions.Length; j++)
{
if (exceptions[least].IsInner(exceptions[j]))
{
least = j;
}
}
- temp = exceptions[i];
+ __ExceptionInfo temp = exceptions[i];
exceptions[i] = exceptions[least];
exceptions[least] = temp;
}
@@ -543,51 +536,6 @@ namespace System.Reflection.Emit
PutInteger4(modBuilder.GetSignatureToken(sig).Token);
}
- public virtual void EmitCalli(OpCode opcode, CallingConvention unmanagedCallConv, Type returnType, Type[] parameterTypes)
- {
- int stackchange = 0;
- int cParams = 0;
- int i;
- SignatureHelper sig;
-
- ModuleBuilder modBuilder = (ModuleBuilder) m_methodBuilder.Module;
-
- if (parameterTypes != null)
- {
- cParams = parameterTypes.Length;
- }
-
- sig = SignatureHelper.GetMethodSigHelper(
- modBuilder,
- unmanagedCallConv,
- returnType);
-
- if (parameterTypes != null)
- {
- for (i = 0; i < cParams; i++)
- {
- sig.AddArgument(parameterTypes[i]);
- }
- }
-
- // If there is a non-void return type, push one.
- if (returnType != typeof(void))
- stackchange++;
-
- // Pop off arguments if any.
- if (parameterTypes != null)
- stackchange -= cParams;
-
- // Pop the native function pointer.
- stackchange--;
- UpdateStackSize(OpCodes.Calli, stackchange);
-
- EnsureCapacity(7);
- Emit(OpCodes.Calli);
- RecordTokenFixup();
- PutInteger4(modBuilder.GetSignatureToken(sig).Token);
- }
-
public virtual void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[] optionalParameterTypes)
{
if (methodInfo == null)
@@ -660,7 +608,6 @@ namespace System.Reflection.Emit
PutInteger4(tempVal);
}
- [System.Runtime.InteropServices.ComVisible(true)]
public virtual void Emit(OpCode opcode, ConstructorInfo con)
{
if (con == null)
@@ -1160,13 +1107,9 @@ namespace System.Reflection.Emit
private static Type GetConsoleType()
{
-#if FEATURE_LEGACYSURFACE
- return typeof(Console);
-#else
return Type.GetType(
"System.Console, System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
throwOnError: true);
-#endif
}
public virtual void EmitWriteLine(String value)
diff --git a/src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs b/src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs
index a737895..e6f4622 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs
@@ -166,23 +166,6 @@ namespace System.Reflection.Emit
private SymWriter()
{
}
-
- //=========================================================================================
- // Public interface methods start here.
- //=========================================================================================
-
-
- //------------------------------------------------------------------------------
- // Initialize() wrapper
- //------------------------------------------------------------------------------
- void ISymbolWriter.Initialize(IntPtr emitter, String filename, bool fFullBuild)
- {
- int hr = m_vtable.Initialize(m_pWriter, emitter, filename, (IntPtr)0, fFullBuild);
- if (hr < 0)
- {
- throw Marshal.GetExceptionForHR(hr);
- }
- }
//------------------------------------------------------------------------------
// DefineDocument() wrapper
@@ -207,18 +190,6 @@ namespace System.Reflection.Emit
}
//------------------------------------------------------------------------------
- // SetUserEntryPoint() wrapper
- //------------------------------------------------------------------------------
- void ISymbolWriter.SetUserEntryPoint(SymbolToken entryMethod)
- {
- int hr = m_vtable.SetUserEntryPoint(m_pWriter, entryMethod.GetToken());
- if (hr < 0)
- {
- throw Marshal.GetExceptionForHR(hr);
- }
- }
-
- //------------------------------------------------------------------------------
// OpenMethod() wrapper
//------------------------------------------------------------------------------
void ISymbolWriter.OpenMethod(SymbolToken method)
@@ -326,18 +297,6 @@ namespace System.Reflection.Emit
throw Marshal.GetExceptionForHR(hr);
}
}
-
- //------------------------------------------------------------------------------
- // SetScopeRange() wrapper
- //------------------------------------------------------------------------------
- void ISymbolWriter.SetScopeRange(int scopeID, int startOffset, int endOffset)
- {
- int hr = m_vtable.SetScopeRange(m_pWriter, scopeID, startOffset, endOffset);
- if (hr < 0)
- {
- throw Marshal.GetExceptionForHR(hr);
- }
- }
//------------------------------------------------------------------------------
// DefineLocalVariable() wrapper
@@ -368,62 +327,7 @@ namespace System.Reflection.Emit
throw Marshal.GetExceptionForHR(hr);
}
}
-
- //------------------------------------------------------------------------------
- // DefineParameter() wrapper
- //------------------------------------------------------------------------------
- void ISymbolWriter.DefineParameter(String name,
- ParameterAttributes attributes,
- int sequence,
- SymAddressKind addrKind,
- int addr1,
- int addr2,
- int addr3)
- {
- throw new NotSupportedException(); // Intentionally not supported to match desktop CLR
- }
-
- //------------------------------------------------------------------------------
- // DefineField() wrapper
- //------------------------------------------------------------------------------
- void ISymbolWriter.DefineField(SymbolToken parent,
- String name,
- FieldAttributes attributes,
- byte[] signature,
- SymAddressKind addrKind,
- int addr1,
- int addr2,
- int addr3)
- {
- throw new NotSupportedException(); // Intentionally not supported to match desktop CLR
- }
-
- //------------------------------------------------------------------------------
- // DefineGlobalVariable() wrapper
- //------------------------------------------------------------------------------
- void ISymbolWriter.DefineGlobalVariable(String name,
- FieldAttributes attributes,
- byte[] signature,
- SymAddressKind addrKind,
- int addr1,
- int addr2,
- int addr3)
- {
- throw new NotSupportedException(); // Intentionally not supported to match desktop CLR
- }
-
- //------------------------------------------------------------------------------
- // Close() wrapper
- //------------------------------------------------------------------------------
- void ISymbolWriter.Close()
- {
- int hr = m_vtable.Close(m_pWriter);
- if (hr < 0)
- {
- throw Marshal.GetExceptionForHR(hr);
- }
- }
-
+
//------------------------------------------------------------------------------
// SetSymAttribute() wrapper
//------------------------------------------------------------------------------
@@ -437,30 +341,6 @@ namespace System.Reflection.Emit
}
//------------------------------------------------------------------------------
- // OpenNamespace() wrapper
- //------------------------------------------------------------------------------
- void ISymbolWriter.OpenNamespace(String name)
- {
- int hr = m_vtable.OpenNamespace(m_pWriter, name);
- if (hr < 0)
- {
- throw Marshal.GetExceptionForHR(hr);
- }
- }
-
- //------------------------------------------------------------------------------
- // CloseNamespace() wrapper
- //------------------------------------------------------------------------------
- void ISymbolWriter.CloseNamespace()
- {
- int hr = m_vtable.CloseNamespace(m_pWriter);
- if (hr < 0)
- {
- throw Marshal.GetExceptionForHR(hr);
- }
- }
-
- //------------------------------------------------------------------------------
// UsingNamespace() wrapper
//------------------------------------------------------------------------------
void ISymbolWriter.UsingNamespace(String name)
@@ -471,27 +351,6 @@ namespace System.Reflection.Emit
throw Marshal.GetExceptionForHR(hr);
}
}
-
- //------------------------------------------------------------------------------
- // SetMethodSourceRange() wrapper
- //------------------------------------------------------------------------------
- void ISymbolWriter.SetMethodSourceRange(ISymbolDocumentWriter startDoc,
- int startLine,
- int startColumn,
- ISymbolDocumentWriter endDoc,
- int endLine,
- int endColumn)
- {
- throw new NotSupportedException(); // Intentionally not supported to match desktop CLR
- }
-
- //------------------------------------------------------------------------------
- // SetUnderlyingWriter() wrapper.
- //------------------------------------------------------------------------------
- void ISymbolWriter.SetUnderlyingWriter(IntPtr ppUnderlyingWriter)
- {
- throw new NotSupportedException(); // Intentionally not supported on Telesto as it's a very unsafe api
- }
//------------------------------------------------------------------------------
// InternalSetUnderlyingWriter() wrapper.
diff --git a/src/mscorlib/src/System/Reflection/Emit/Label.cs b/src/mscorlib/src/System/Reflection/Emit/Label.cs
index dd248b6..c7b987f 100644
--- a/src/mscorlib/src/System/Reflection/Emit/Label.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/Label.cs
@@ -16,7 +16,6 @@
namespace System.Reflection.Emit {
using System;
using System.Reflection;
- using System.Security.Permissions;
using System.Runtime.InteropServices;
// The Label class is an opaque representation of a label used by the
@@ -26,7 +25,6 @@ namespace System.Reflection.Emit {
// Labels are created by using ILGenerator.CreateLabel and their position is set
// by using ILGenerator.MarkLabel.
[Serializable]
- [ComVisible(true)]
public struct Label {
internal int m_label;
diff --git a/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs
index a34d5ebe..fe4c331 100644
--- a/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs
@@ -4,15 +4,11 @@
using System;
using System.Reflection;
-using System.Security.Permissions;
using System.Runtime.InteropServices;
namespace System.Reflection.Emit
{
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_LocalBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class LocalBuilder : LocalVariableInfo, _LocalBuilder
+ public sealed class LocalBuilder : LocalVariableInfo
{
#region Private Data Members
private int m_localIndex;
diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs
index 654e166..17c8ce0 100644
--- a/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs
@@ -14,15 +14,11 @@ namespace System.Reflection.Emit
using System.Security;
using System.Collections;
using System.Collections.Generic;
- using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Diagnostics.Contracts;
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_MethodBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class MethodBuilder : MethodInfo, _MethodBuilder
+ public sealed class MethodBuilder : MethodInfo
{
#region Private Data Members
// Identity
@@ -67,11 +63,6 @@ namespace System.Reflection.Emit
#endregion
#region Constructor
- internal MethodBuilder(String name, MethodAttributes attributes, CallingConventions callingConvention,
- Type returnType, Type[] parameterTypes, ModuleBuilder mod, TypeBuilder type, bool bIsGlobalMethod)
- {
- Init(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null, mod, type, bIsGlobalMethod);
- }
internal MethodBuilder(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
@@ -371,11 +362,6 @@ namespace System.Reflection.Emit
}
}
- internal void SetToken(MethodToken token)
- {
- m_tkMethod = token;
- }
-
internal byte[] GetBody()
{
// Returns the il bytes of this method.
@@ -851,199 +837,13 @@ namespace System.Reflection.Emit
return new ParameterBuilder(this, position, attributes, strParamName);
}
- [Obsolete("An alternate API is available: Emit the MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- public void SetMarshal(UnmanagedMarshal unmanagedMarshal)
- {
- ThrowIfGeneric ();
-
- // set Marshal info for the return type
-
- m_containingType.ThrowIfCreated();
-
- if (m_retParam == null)
- {
- m_retParam = new ParameterBuilder(this, 0, 0, null);
- }
-
- m_retParam.SetMarshal(unmanagedMarshal);
- }
-
private List<SymCustomAttr> m_symCustomAttrs;
private struct SymCustomAttr
{
- public SymCustomAttr(String name, byte[] data)
- {
- m_name = name;
- m_data = data;
- }
public String m_name;
public byte[] m_data;
}
- public void SetSymCustomAttribute(String name, byte[] data)
- {
- // Note that this API is rarely used. Support for custom attributes in PDB files was added in
- // Whidbey and as of 8/2007 the only known user is the C# compiler. There seems to be little
- // value to this for Reflection.Emit users since they can always use metadata custom attributes.
- // Some versions of the symbol writer used in the CLR will ignore these entirely. This API has
- // been removed from the Silverlight API surface area, but we should also consider removing it
- // from future desktop product versions as well.
-
- ThrowIfGeneric ();
-
- // This is different from CustomAttribute. This is stored into the SymWriter.
- m_containingType.ThrowIfCreated();
-
- ModuleBuilder dynMod = (ModuleBuilder) m_module;
- if ( dynMod.GetSymWriter() == null)
- {
- // Cannot SetSymCustomAttribute when it is not a debug module
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule"));
- }
-
- if (m_symCustomAttrs == null)
- m_symCustomAttrs = new List<SymCustomAttr>();
-
- m_symCustomAttrs.Add(new SymCustomAttr(name, data));
- }
-
- public void SetMethodBody(byte[] il, int maxStack, byte[] localSignature, IEnumerable<ExceptionHandler> exceptionHandlers, IEnumerable<int> tokenFixups)
- {
- if (il == null)
- {
- throw new ArgumentNullException(nameof(il), Environment.GetResourceString("ArgumentNull_Array"));
- }
- if (maxStack < 0)
- {
- throw new ArgumentOutOfRangeException(nameof(maxStack), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- }
- Contract.EndContractBlock();
-
- if (m_bIsBaked)
- {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MethodBaked"));
- }
-
- m_containingType.ThrowIfCreated();
- ThrowIfGeneric();
-
- byte[] newLocalSignature = null;
- ExceptionHandler[] newHandlers = null;
- int[] newTokenFixups = null;
-
- byte[] newIL = (byte[])il.Clone();
-
- if (localSignature != null)
- {
- newLocalSignature = (byte[])localSignature.Clone();
- }
-
- if (exceptionHandlers != null)
- {
- newHandlers = ToArray(exceptionHandlers);
- CheckExceptionHandlerRanges(newHandlers, newIL.Length);
-
- // Note: Fixup entries for type tokens stored in ExceptionHandlers are added by the method body emitter.
- }
-
- if (tokenFixups != null)
- {
- newTokenFixups = ToArray(tokenFixups);
- int maxTokenOffset = newIL.Length - 4;
-
- for (int i = 0; i < newTokenFixups.Length; i++)
- {
- // Check that fixups are within the range of this method's IL, otherwise some random memory might get "fixed up".
- if (newTokenFixups[i] < 0 || newTokenFixups[i] > maxTokenOffset)
- {
- throw new ArgumentOutOfRangeException("tokenFixups[" + i + "]", Environment.GetResourceString("ArgumentOutOfRange_Range", 0, maxTokenOffset));
- }
- }
- }
-
- m_ubBody = newIL;
- m_localSignature = newLocalSignature;
- m_exceptions = newHandlers;
- m_mdMethodFixups = newTokenFixups;
- m_maxStack = maxStack;
-
- // discard IL generator, all information stored in it is now irrelevant
- m_ilGenerator = null;
- m_bIsBaked = true;
- }
-
- private static T[] ToArray<T>(IEnumerable<T> sequence)
- {
- T[] array = sequence as T[];
- if (array != null)
- {
- return (T[])array.Clone();
- }
-
- return new List<T>(sequence).ToArray();
- }
-
- private static void CheckExceptionHandlerRanges(ExceptionHandler[] exceptionHandlers, int maxOffset)
- {
- // Basic checks that the handler ranges are within the method body (ranges are end-exclusive).
- // Doesn't verify that the ranges are otherwise correct - it is very well possible to emit invalid IL.
- for (int i = 0; i < exceptionHandlers.Length; i++)
- {
- var handler = exceptionHandlers[i];
- if (handler.m_filterOffset > maxOffset || handler.m_tryEndOffset > maxOffset || handler.m_handlerEndOffset > maxOffset)
- {
- throw new ArgumentOutOfRangeException("exceptionHandlers[" + i + "]", Environment.GetResourceString("ArgumentOutOfRange_Range", 0, maxOffset));
- }
-
- // Type token might be 0 if the ExceptionHandler was created via a default constructor.
- // Other tokens migth also be invalid. We only check nil tokens as the implementation (SectEH_Emit in corhlpr.cpp) requires it,
- // and we can't check for valid tokens until the module is baked.
- if (handler.Kind == ExceptionHandlingClauseOptions.Clause && handler.ExceptionTypeToken == 0)
- {
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidTypeToken", handler.ExceptionTypeToken), "exceptionHandlers[" + i + "]");
- }
- }
- }
-
- /// <summary>
- /// Obsolete.
- /// </summary>
- public void CreateMethodBody(byte[] il, int count)
- {
- ThrowIfGeneric();
-
- // Note that when user calls this function, there are a few information that client is
- // not able to supply: local signature, exception handlers, max stack size, a list of Token fixup, a list of RVA fixup
-
- if (m_bIsBaked)
- {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MethodBaked"));
- }
-
- m_containingType.ThrowIfCreated();
-
- if (il != null && (count < 0 || count > il.Length))
- {
- throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Index"));
- }
-
- if (il == null)
- {
- m_ubBody = null;
- return;
- }
-
- m_ubBody = new byte[count];
- Buffer.BlockCopy(il, 0, m_ubBody, 0, count);
-
- m_localSignature = null;
- m_exceptions = null;
- m_mdMethodFixups = null;
- m_maxStack = DefaultMaxStack;
-
- m_bIsBaked = true;
- }
-
public void SetImplementationFlags(MethodImplAttributes attributes)
{
ThrowIfGeneric ();
@@ -1113,7 +913,6 @@ namespace System.Reflection.Emit
}
-[System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
if (con == null)
@@ -1314,8 +1113,7 @@ namespace System.Reflection.Emit
/// Describes exception handler in a method body.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
- [ComVisible(false)]
- public struct ExceptionHandler : IEquatable<ExceptionHandler>
+ internal struct ExceptionHandler : IEquatable<ExceptionHandler>
{
// Keep in sync with unmanged structure.
internal readonly int m_exceptionClass;
@@ -1326,118 +1124,7 @@ namespace System.Reflection.Emit
internal readonly int m_handlerEndOffset;
internal readonly ExceptionHandlingClauseOptions m_kind;
- public int ExceptionTypeToken
- {
- get { return m_exceptionClass; }
- }
-
- public int TryOffset
- {
- get { return m_tryStartOffset; }
- }
-
- public int TryLength
- {
- get { return m_tryEndOffset - m_tryStartOffset; }
- }
-
- public int FilterOffset
- {
- get { return m_filterOffset; }
- }
-
- public int HandlerOffset
- {
- get { return m_handlerStartOffset; }
- }
-
- public int HandlerLength
- {
- get { return m_handlerEndOffset - m_handlerStartOffset; }
- }
-
- public ExceptionHandlingClauseOptions Kind
- {
- get { return m_kind; }
- }
-
- #region Constructors
-
- /// <summary>
- /// Creates a description of an exception handler.
- /// </summary>
- /// <param name="tryOffset">The offset of the first instruction protected by this handler.</param>
- /// <param name="tryLength">The number of bytes protected by this handler.</param>
- /// <param name="filterOffset">The filter code begins at the specified offset and ends at the first instruction of the handler block. Specify 0 if not applicable (this is not a filter handler).</param>
- /// <param name="handlerOffset">The offset of the first instruction of this handler.</param>
- /// <param name="handlerLength">The number of bytes of the handler.</param>
- /// <param name="kind">The kind of handler, the handler might be a catch handler, filter handler, fault handler, or finally handler.</param>
- /// <param name="exceptionTypeToken">The token of the exception type handled by this handler. Specify 0 if not applicable (this is finally handler).</param>
- /// <exception cref="ArgumentOutOfRangeException">
- /// Some of the instruction offset is negative,
- /// the end offset of specified range is less than its start offset,
- /// or <paramref name="kind"/> has an invalid value.
- /// </exception>
- public ExceptionHandler(int tryOffset, int tryLength, int filterOffset, int handlerOffset, int handlerLength,
- ExceptionHandlingClauseOptions kind, int exceptionTypeToken)
- {
- if (tryOffset < 0)
- {
- throw new ArgumentOutOfRangeException(nameof(tryOffset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- }
-
- if (tryLength < 0)
- {
- throw new ArgumentOutOfRangeException(nameof(tryLength), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- }
-
- if (filterOffset < 0)
- {
- throw new ArgumentOutOfRangeException(nameof(filterOffset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- }
-
- if (handlerOffset < 0)
- {
- throw new ArgumentOutOfRangeException(nameof(handlerOffset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- }
-
- if (handlerLength < 0)
- {
- throw new ArgumentOutOfRangeException(nameof(handlerLength), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
- }
-
- if ((long)tryOffset + tryLength > Int32.MaxValue)
- {
- throw new ArgumentOutOfRangeException(nameof(tryLength), Environment.GetResourceString("ArgumentOutOfRange_Range", 0, Int32.MaxValue - tryOffset));
- }
-
- if ((long)handlerOffset + handlerLength > Int32.MaxValue)
- {
- throw new ArgumentOutOfRangeException(nameof(handlerLength), Environment.GetResourceString("ArgumentOutOfRange_Range", 0, Int32.MaxValue - handlerOffset));
- }
-
- // Other tokens migth also be invalid. We only check nil tokens as the implementation (SectEH_Emit in corhlpr.cpp) requires it,
- // and we can't check for valid tokens until the module is baked.
- if (kind == ExceptionHandlingClauseOptions.Clause && (exceptionTypeToken & 0x00FFFFFF) == 0)
- {
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidTypeToken", exceptionTypeToken), nameof(exceptionTypeToken));
- }
-
- Contract.EndContractBlock();
-
- if (!IsValidKind(kind))
- {
- throw new ArgumentOutOfRangeException(nameof(kind), Environment.GetResourceString("ArgumentOutOfRange_Enum"));
- }
-
- m_tryStartOffset = tryOffset;
- m_tryEndOffset = tryOffset + tryLength;
- m_filterOffset = filterOffset;
- m_handlerStartOffset = handlerOffset;
- m_handlerEndOffset = handlerOffset + handlerLength;
- m_kind = kind;
- m_exceptionClass = exceptionTypeToken;
- }
+#region Constructors
internal ExceptionHandler(int tryStartOffset, int tryEndOffset, int filterOffset, int handlerStartOffset, int handlerEndOffset,
int kind, int exceptionTypeToken)
diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs
index 5b69b6e..57ad166 100644
--- a/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs
@@ -53,7 +53,6 @@ namespace System.Reflection.Emit
public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_method.GetCustomAttributes(attributeType, inherit); }
public override bool IsDefined(Type attributeType, bool inherit) { return m_method.IsDefined(attributeType, inherit); }
public override Module Module { get { return m_method.Module; } }
- public new Type GetType() { return base.GetType(); }
#endregion
#region MethodBase Members
diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodToken.cs b/src/mscorlib/src/System/Reflection/Emit/MethodToken.cs
index cc28e17..76b7279 100644
--- a/src/mscorlib/src/System/Reflection/Emit/MethodToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/MethodToken.cs
@@ -16,10 +16,8 @@ namespace System.Reflection.Emit {
using System;
using System.Reflection;
- using System.Security.Permissions;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public struct MethodToken
{
public static readonly MethodToken Empty = new MethodToken();
diff --git a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs
index 6884f50..30e6382 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs
@@ -15,7 +15,6 @@ namespace System.Reflection.Emit
using System.IO;
using System.Resources;
using System.Security;
- using System.Security.Permissions;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
@@ -50,10 +49,7 @@ namespace System.Reflection.Emit
}
// deliberately not [serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_ModuleBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public class ModuleBuilder : Module, _ModuleBuilder
+ public class ModuleBuilder : Module
{
#region FCalls
@@ -248,61 +244,8 @@ namespace System.Reflection.Emit
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- private extern static void PreSavePEFile(RuntimeModule module, int portableExecutableKind, int imageFileMachine);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private extern static void SavePEFile(RuntimeModule module, String fileName, int entryPoint, int isExe, bool isManifestFile);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private extern static void AddResource(
- RuntimeModule module, String strName,
- byte[] resBytes, int resByteCount, int tkFile, int attribute,
- int portableExecutableKind, int imageFileMachine);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private extern static void SetModuleName(RuntimeModule module, String strModuleName);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
internal extern static void SetFieldRVAContent(RuntimeModule module, int fdToken, byte[] data, int length);
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private extern static void DefineNativeResourceFile(RuntimeModule module,
- String strFilename,
- int portableExecutableKind,
- int ImageFileMachine);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private extern static void DefineNativeResourceBytes(RuntimeModule module,
- byte[] pbResource, int cbResource,
- int portableExecutableKind,
- int imageFileMachine);
-
- internal void DefineNativeResource(PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
- {
- string strResourceFileName = m_moduleData.m_strResourceFileName;
- byte[] resourceBytes = m_moduleData.m_resourceBytes;
-
- if (strResourceFileName != null)
- {
- DefineNativeResourceFile(GetNativeHandle(),
- strResourceFileName,
- (int)portableExecutableKind, (int)imageFileMachine);
- }
- else
- if (resourceBytes != null)
- {
- DefineNativeResourceBytes(GetNativeHandle(),
- resourceBytes, resourceBytes.Length,
- (int)portableExecutableKind, (int)imageFileMachine);
- }
- }
-
#endregion
#region Internal Members
@@ -404,12 +347,11 @@ namespace System.Reflection.Emit
if (parameters == null)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidConstructorInfo"));
- int count = parameters.Length;
- Type[] parameterTypes = new Type[count];
- Type[][] requiredCustomModifiers = new Type[count][];
- Type[][] optionalCustomModifiers = new Type[count][];
+ Type[] parameterTypes = new Type[parameters.Length];
+ Type[][] requiredCustomModifiers = new Type[parameters.Length][];
+ Type[][] optionalCustomModifiers = new Type[parameters.Length][];
- for (int i = 0; i < count; i++)
+ for (int i = 0; i < parameters.Length; i++)
{
if (parameters[i] == null)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidConstructorInfo"));
@@ -437,17 +379,6 @@ namespace System.Reflection.Emit
m_TypeBuilderDict = new Dictionary<string, Type>();
}
- // This is a method for changing module and file name of the manifest module (created by default for
- // each assembly).
- internal void ModifyModuleName(string name)
- {
- // Reset the names in the managed ModuleBuilderData
- m_moduleData.ModifyModuleName(name);
-
- // Reset the name in the underlying metadata
- ModuleBuilder.SetModuleName(GetNativeHandle(), name);
- }
-
internal void SetSymWriter(ISymbolWriter writer)
{
m_iSymWriter = writer;
@@ -603,12 +534,14 @@ namespace System.Reflection.Emit
internal SignatureHelper GetMemberRefSignature(CallingConventions call, Type returnType,
Type[] parameterTypes, IEnumerable<Type> optionalParameterTypes, int cGenericParameters)
{
- int cParams = (parameterTypes == null) ? 0 : parameterTypes.Length;
SignatureHelper sig = SignatureHelper.GetMethodSigHelper(this, call, returnType, cGenericParameters);
- for (int i = 0; i < cParams; i++)
+ if (parameterTypes != null)
{
- sig.AddArgument(parameterTypes[i]);
+ foreach (Type t in parameterTypes)
+ {
+ sig.AddArgument(t);
+ }
}
if (optionalParameterTypes != null) {
@@ -699,19 +632,16 @@ namespace System.Reflection.Emit
return typeList;
}
- [System.Runtime.InteropServices.ComVisible(true)]
public override Type GetType(String className)
{
return GetType(className, false, false);
}
- [System.Runtime.InteropServices.ComVisible(true)]
public override Type GetType(String className, bool ignoreCase)
{
return GetType(className, false, ignoreCase);
}
- [System.Runtime.InteropServices.ComVisible(true)]
public override Type GetType(String className, bool throwOnError, bool ignoreCase)
{
lock(SyncRoot)
@@ -830,11 +760,6 @@ namespace System.Reflection.Emit
fullyQualifiedName = Path.Combine(ContainingAssemblyBuilder.m_assemblyData.m_strDir, fullyQualifiedName);
fullyQualifiedName = Path.GetFullPath(fullyQualifiedName);
}
-
- if (ContainingAssemblyBuilder.m_assemblyData.m_strDir != null && fullyQualifiedName != null)
- {
- new FileIOPermission( FileIOPermissionAccess.PathDiscovery, fullyQualifiedName ).Demand();
- }
return fullyQualifiedName;
}
@@ -1009,7 +934,6 @@ namespace System.Reflection.Emit
}
}
- [System.Runtime.InteropServices.ComVisible(true)]
public TypeBuilder DefineType(String name, TypeAttributes attr, Type parent, Type[] interfaces)
{
Contract.Ensures(Contract.Result<TypeBuilder>() != null);
@@ -1060,10 +984,16 @@ namespace System.Reflection.Emit
EnumBuilder enumBuilder = DefineEnumNoLock(name, visibility, underlyingType);
// This enum is not generic, nested, and cannot have any element type.
- Debug.Assert(name == enumBuilder.FullName);
+
+ // We ought to be able to make the following assertions:
+ //
+ // Debug.Assert(name == enumBuilder.FullName);
+ // Debug.Assert(enumBuilder.m_typeBuilder == m_TypeBuilderDict[name]);
+ //
+ // but we can't because an embedded null ('\0') in the name will cause it to be truncated
+ // incorrectly. Fixing that would be a breaking change.
// Replace the TypeBuilder object in m_TypeBuilderDict with this EnumBuilder object.
- Debug.Assert(enumBuilder.m_typeBuilder == m_TypeBuilderDict[name]);
m_TypeBuilderDict[name] = enumBuilder;
return enumBuilder;
@@ -1141,47 +1071,6 @@ namespace System.Reflection.Emit
parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
}
- public MethodBuilder DefinePInvokeMethod(String name, String dllName, MethodAttributes attributes,
- CallingConventions callingConvention, Type returnType, Type[] parameterTypes,
- CallingConvention nativeCallConv, CharSet nativeCharSet)
- {
- Contract.Ensures(Contract.Result<MethodBuilder>() != null);
-
- return DefinePInvokeMethod(name, dllName, name, attributes, callingConvention, returnType, parameterTypes, nativeCallConv, nativeCharSet);
- }
-
- public MethodBuilder DefinePInvokeMethod(String name, String dllName, String entryName, MethodAttributes attributes,
- CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv,
- CharSet nativeCharSet)
- {
- Contract.Ensures(Contract.Result<MethodBuilder>() != null);
-
- lock(SyncRoot)
- {
- return DefinePInvokeMethodNoLock(name, dllName, entryName, attributes, callingConvention,
- returnType, parameterTypes, nativeCallConv, nativeCharSet);
- }
- }
-
- private MethodBuilder DefinePInvokeMethodNoLock(String name, String dllName, String entryName, MethodAttributes attributes,
- CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv,
- CharSet nativeCharSet)
- {
- //Global methods must be static.
- if ((attributes & MethodAttributes.Static) == 0)
- {
- throw new ArgumentException(Environment.GetResourceString("Argument_GlobalFunctionHasToBeStatic"));
- }
- Contract.Ensures(Contract.Result<MethodBuilder>() != null);
- Contract.EndContractBlock();
-
- CheckContext(returnType);
- CheckContext(parameterTypes);
-
- m_moduleData.m_fHasGlobal = true;
- return m_moduleData.m_globalTypeBuilder.DefinePInvokeMethod(name, dllName, entryName, attributes, callingConvention, returnType, parameterTypes, nativeCallConv, nativeCharSet);
- }
-
public void CreateGlobalFunctions()
{
lock(SyncRoot)
@@ -1510,41 +1399,6 @@ namespace System.Reflection.Emit
return new MethodToken(mr);
}
- public MethodToken GetConstructorToken(ConstructorInfo constructor, IEnumerable<Type> optionalParameterTypes)
- {
- if (constructor == null)
- {
- throw new ArgumentNullException(nameof(constructor));
- }
-
- lock (SyncRoot)
- {
- // useMethodDef is not applicable - constructors aren't generic
- return new MethodToken(GetMethodTokenInternal(constructor, optionalParameterTypes, false));
- }
- }
-
- public MethodToken GetMethodToken(MethodInfo method, IEnumerable<Type> optionalParameterTypes)
- {
- if (method == null)
- {
- throw new ArgumentNullException(nameof(method));
- }
-
- // useMethodDef flag only affects the result if we pass in a generic method definition.
- // If the caller is looking for a token for an ldtoken/ldftn/ldvirtftn instruction and passes in a generic method definition info/builder,
- // we correclty return the MethodDef/Ref token of the generic definition that can be used with ldtoken/ldftn/ldvirtftn.
- //
- // If the caller is looking for a token for a call/callvirt/jmp instruction and passes in a generic method definition info/builder,
- // we also return the generic MethodDef/Ref token, which is indeed not acceptable for call/callvirt/jmp instruction.
- // But the caller can always instantiate the info/builder and pass it in. Then we build the right MethodSpec.
-
- lock (SyncRoot)
- {
- return new MethodToken(GetMethodTokenInternal(method, optionalParameterTypes, true));
- }
- }
-
internal int GetMethodTokenInternal(MethodBase method, IEnumerable<Type> optionalParameterTypes, bool useMethodDef)
{
int tk = 0;
@@ -1671,7 +1525,6 @@ namespace System.Reflection.Emit
return new SymbolMethod(this, token, arrayClass, methodName, callingConvention, returnType, parameterTypes);
}
- [System.Runtime.InteropServices.ComVisible(true)]
public MethodToken GetConstructorToken(ConstructorInfo con)
{
// Return a token for the ConstructorInfo relative to the Module.
@@ -1689,7 +1542,7 @@ namespace System.Reflection.Emit
private FieldToken GetFieldTokenNoLock(FieldInfo field)
{
if (field == null) {
- throw new ArgumentNullException("con");
+ throw new ArgumentNullException(nameof(field));
}
Contract.EndContractBlock();
@@ -1821,7 +1674,6 @@ namespace System.Reflection.Emit
#region Other
- [System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
if (con == null)
@@ -1878,7 +1730,7 @@ namespace System.Reflection.Emit
// For these reasons, we should consider making this API internal in Arrowhead
// (as it is in Silverlight), and consider validating that we're within a call
// to TypeBuilder.CreateType whenever this is used.
- public ISymbolWriter GetSymWriter()
+ internal ISymbolWriter GetSymWriter()
{
return m_iSymWriter;
}
@@ -1907,81 +1759,6 @@ namespace System.Reflection.Emit
return m_iSymWriter.DefineDocument(url, language, languageVendor, documentType);
}
- public void SetUserEntryPoint(MethodInfo entryPoint)
- {
- lock(SyncRoot)
- {
- SetUserEntryPointNoLock(entryPoint);
- }
- }
-
- private void SetUserEntryPointNoLock(MethodInfo entryPoint)
- {
- // Set the user entry point. Compiler may generate startup stub before calling user main.
- // The startup stub will be the entry point. While the user "main" will be the user entry
- // point so that debugger will not step into the compiler entry point.
-
- if (entryPoint == null)
- {
- throw new ArgumentNullException(nameof(entryPoint));
- }
- Contract.EndContractBlock();
-
- if (m_iSymWriter == null)
- {
- // Cannot set entry point when it is not a debug module
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule"));
- }
-
- if (entryPoint.DeclaringType != null)
- {
- if (!entryPoint.Module.Equals(this))
- {
- // you cannot pass in a MethodInfo that is not contained by this ModuleBuilder
- throw new InvalidOperationException(Environment.GetResourceString("Argument_NotInTheSameModuleBuilder"));
- }
- }
- else
- {
- // unfortunately this check is missing for global function passed in as RuntimeMethodInfo.
- // The problem is that Reflection does not
- // allow us to get the containing module giving a global function
- MethodBuilder mb = entryPoint as MethodBuilder;
- if (mb != null && mb.GetModuleBuilder() != this)
- {
- // you cannot pass in a MethodInfo that is not contained by this ModuleBuilder
- throw new InvalidOperationException(Environment.GetResourceString("Argument_NotInTheSameModuleBuilder"));
- }
- }
-
- // get the metadata token value and create the SymbolStore's token value class
- SymbolToken tkMethod = new SymbolToken(GetMethodTokenInternal(entryPoint).Token);
-
- // set the UserEntryPoint
- m_iSymWriter.SetUserEntryPoint(tkMethod);
- }
-
- public void SetSymCustomAttribute(String name, byte[] data)
- {
- lock(SyncRoot)
- {
- SetSymCustomAttributeNoLock(name, data);
- }
- }
-
- private void SetSymCustomAttributeNoLock(String name, byte[] data)
- {
- if (m_iSymWriter == null)
- {
- // Cannot SetSymCustomAttribute when it is not a debug module
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule"));
- }
-
- // This API has never worked. It seems like we might want to call m_iSymWriter.SetSymAttribute,
- // but we don't have a metadata token to associate the attribute with. Instead
- // MethodBuilder.SetSymCustomAttribute could be used to associate a symbol attribute with a specific method.
- }
-
[Pure]
public bool IsTransient()
{
diff --git a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs
index 96e60d9..4b6f8b4 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs
@@ -52,36 +52,6 @@ namespace System.Reflection.Emit
}
}
- // This is a method for changing module and file name of the manifest module (created by default for
- // each assembly).
- internal virtual void ModifyModuleName(String strModuleName)
- {
- Debug.Assert(m_strModuleName == AssemblyBuilder.MANIFEST_MODULE_NAME, "Changing names for non-manifest module");
- InitNames(strModuleName, null /*strFileName*/);
- }
-
- internal int FileToken
- {
- get
- {
- // Before save, the scope of m_tkFile is the in-memory assembly manifest
- // During save, the scope of m_tkFile is the on-disk assembly manifest
- // For transient modules m_tkFile never change.
-
- // Theoretically no one should emit anything after a dynamic assembly has
- // been saved. So m_tkFile shouldn't used when m_isSaved is true.
- // But that was never completely enforced: you can still emit everything after
- // the assembly has been saved (except for public types in persistent modules).
-
- return m_tkFile;
- }
-
- set
- {
- m_tkFile = value;
- }
- }
-
internal String m_strModuleName; // scope name (can be different from file name)
internal String m_strFileName;
internal bool m_fGlobalBeenCreated;
@@ -93,8 +63,6 @@ namespace System.Reflection.Emit
private int m_tkFile;
internal bool m_isSaved;
- [NonSerialized]
- internal ResWriterData m_embeddedRes;
internal const String MULTI_BYTE_VALUE_CLASS = "$ArrayType$";
internal String m_strResourceFileName;
internal byte[] m_resourceBytes;
diff --git a/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs b/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs
index 345694e..324fad9 100644
--- a/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs
@@ -13,7 +13,6 @@
namespace System.Reflection.Emit {
using System;
-using System.Security.Permissions;
//
// Internal enums for opcode values. Note that the value names are used to construct
@@ -250,7 +249,6 @@ internal enum OpCodeValues {
// If you add more opcodes here, modify OpCode.Name to handle them correctly
};
-[System.Runtime.InteropServices.ComVisible(true)]
public class OpCodes {
/// <summary>
@@ -1419,7 +1417,6 @@ public class OpCodes {
(1 << OpCode.StackChangeShift)
);
- [System.Runtime.InteropServices.ComVisible(true)]
public static readonly OpCode Castclass = new OpCode(OpCodeValues.Castclass,
((int)OperandType.InlineType) |
((int)FlowControl.Next << OpCode.FlowControlShift) |
diff --git a/src/mscorlib/src/System/Reflection/Emit/Opcode.cs b/src/mscorlib/src/System/Reflection/Emit/Opcode.cs
index d7bfacd..74a9de1 100644
--- a/src/mscorlib/src/System/Reflection/Emit/Opcode.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/Opcode.cs
@@ -5,10 +5,8 @@
namespace System.Reflection.Emit {
using System;
using System.Threading;
-using System.Security.Permissions;
using System.Diagnostics.Contracts;
-[System.Runtime.InteropServices.ComVisible(true)]
public struct OpCode
{
//
diff --git a/src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs b/src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs
index 3636cb7..87dea05 100644
--- a/src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs
@@ -17,7 +17,6 @@ namespace System.Reflection.Emit {
using System;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum OpCodeType
{
diff --git a/src/mscorlib/src/System/Reflection/Emit/OperandType.cs b/src/mscorlib/src/System/Reflection/Emit/OperandType.cs
index 808844a..e972e86 100644
--- a/src/mscorlib/src/System/Reflection/Emit/OperandType.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/OperandType.cs
@@ -17,7 +17,6 @@ namespace System.Reflection.Emit {
using System;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum OperandType
{
diff --git a/src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs b/src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs
index d9c9c03..531ff41 100644
--- a/src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs
@@ -7,7 +7,6 @@ namespace System.Reflection.Emit {
using System;
// This Enum matchs the CorFieldAttr defined in CorHdr.h
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum PEFileKinds
{
Dll = 0x0001,
diff --git a/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
index 7909562..1b3babf 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
@@ -16,31 +16,10 @@ namespace System.Reflection.Emit {
using System.Runtime.InteropServices;
using System;
using System.Reflection;
- using System.Security.Permissions;
using System.Diagnostics.Contracts;
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_ParameterBuilder))]
-[System.Runtime.InteropServices.ComVisible(true)]
- public class ParameterBuilder : _ParameterBuilder
+ public class ParameterBuilder
{
- // set ParamMarshal
- [Obsolete("An alternate API is available: Emit the MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- public virtual void SetMarshal(UnmanagedMarshal unmanagedMarshal)
- {
- if (unmanagedMarshal == null)
- {
- throw new ArgumentNullException(nameof(unmanagedMarshal));
- }
- Contract.EndContractBlock();
-
- byte [] ubMarshal = unmanagedMarshal.InternalGetBytes();
- TypeBuilder.SetFieldMarshal(
- m_methodBuilder.GetModuleBuilder().GetNativeHandle(),
- m_pdToken.Token,
- ubMarshal,
- ubMarshal.Length);
- }
// Set the default value of the parameter
public virtual void SetConstant(Object defaultValue)
@@ -54,7 +33,6 @@ namespace System.Reflection.Emit {
// Use this function if client decides to form the custom attribute blob themselves
- [System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
if (con == null)
@@ -111,8 +89,6 @@ namespace System.Reflection.Emit {
{
return m_pdToken;
}
-
- internal int MetadataTokenInternal { get { return m_pdToken.Token; } }
public virtual String Name {
get {return m_strParamName;}
diff --git a/src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs b/src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs
index d65368b..a4a32a5 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs
@@ -16,22 +16,15 @@ namespace System.Reflection.Emit {
using System;
using System.Reflection;
- using System.Security.Permissions;
// The ParameterToken class is an opaque representation of the Token returned
// by the Metadata to represent the parameter.
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public struct ParameterToken {
public static readonly ParameterToken Empty = new ParameterToken();
internal int m_tkParameter;
-#if false
- public ParameterToken() {
- m_tkParameter=0;
- }
-#endif
internal ParameterToken(int tkParam) {
m_tkParameter = tkParam;
diff --git a/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs
index e7442b4..7c4ed9d 100644
--- a/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs
@@ -17,7 +17,6 @@ namespace System.Reflection.Emit {
using System;
using System.Reflection;
using CultureInfo = System.Globalization.CultureInfo;
- using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
@@ -25,10 +24,7 @@ namespace System.Reflection.Emit {
// A PropertyBuilder is always associated with a TypeBuilder. The TypeBuilder.DefineProperty
// method will return a new PropertyBuilder to a client.
//
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_PropertyBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class PropertyBuilder : PropertyInfo, _PropertyBuilder
+ public sealed class PropertyBuilder : PropertyInfo
{
// Make a private constructor so these cannot be constructed externally.
@@ -84,14 +80,6 @@ namespace System.Reflection.Emit {
{
get {return m_prToken;}
}
-
- internal int MetadataTokenInternal
- {
- get
- {
- return m_tkProperty;
- }
- }
public override Module Module
{
@@ -135,7 +123,6 @@ namespace System.Reflection.Emit {
// Use this function if client decides to form the custom attribute blob themselves
-[System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
if (con == null)
diff --git a/src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs b/src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs
index d70cad0..72ab983 100644
--- a/src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs
@@ -16,10 +16,8 @@ namespace System.Reflection.Emit {
using System;
using System.Reflection;
- using System.Security.Permissions;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public struct PropertyToken {
public static readonly PropertyToken Empty = new PropertyToken();
diff --git a/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs b/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs
index c40035b..b43abcb 100644
--- a/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs
@@ -14,12 +14,8 @@ namespace System.Reflection.Emit
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
- using System.Security.Permissions;
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_SignatureHelper))]
-[System.Runtime.InteropServices.ComVisible(true)]
- public sealed class SignatureHelper : _SignatureHelper
+ public sealed class SignatureHelper
{
#region Consts Fields
private const int NO_SIZE_IN_SIG = -1;
@@ -186,15 +182,15 @@ namespace System.Reflection.Emit
return sigHelp;
}
- internal static SignatureHelper GetTypeSigToken(Module mod, Type type)
+ internal static SignatureHelper GetTypeSigToken(Module module, Type type)
{
- if (mod == null)
- throw new ArgumentNullException("module");
+ if (module == null)
+ throw new ArgumentNullException(nameof(module));
if (type == null)
throw new ArgumentNullException(nameof(type));
- return new SignatureHelper(mod, type);
+ return new SignatureHelper(module, type);
}
#endregion
@@ -518,36 +514,6 @@ namespace System.Reflection.Emit
}
}
-
- private void AddData(uint data)
- {
- if (m_currSig + 4 > m_signature.Length)
- {
- m_signature = ExpandArray(m_signature);
- }
-
- m_signature[m_currSig++] = (byte)((data) & 0xFF);
- m_signature[m_currSig++] = (byte)((data>>8) & 0xFF);
- m_signature[m_currSig++] = (byte)((data>>16) & 0xFF);
- m_signature[m_currSig++] = (byte)((data>>24) & 0xFF);
- }
-
- private void AddData(ulong data)
- {
- if (m_currSig + 8 > m_signature.Length)
- {
- m_signature = ExpandArray(m_signature);
- }
-
- m_signature[m_currSig++] = (byte)((data) & 0xFF);
- m_signature[m_currSig++] = (byte)((data>>8) & 0xFF);
- m_signature[m_currSig++] = (byte)((data>>16) & 0xFF);
- m_signature[m_currSig++] = (byte)((data>>24) & 0xFF);
- m_signature[m_currSig++] = (byte)((data>>32) & 0xFF);
- m_signature[m_currSig++] = (byte)((data>>40) & 0xFF);
- m_signature[m_currSig++] = (byte)((data>>48) & 0xFF);
- m_signature[m_currSig++] = (byte)((data>>56) & 0xFF);
- }
private void AddElementType(CorElementType cvt)
{
diff --git a/src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs b/src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs
index 0a87ac1..5c908b8 100644
--- a/src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs
@@ -17,9 +17,7 @@ namespace System.Reflection.Emit {
using System;
using System.Reflection;
- using System.Security.Permissions;
- [System.Runtime.InteropServices.ComVisible(true)]
public struct SignatureToken {
public static readonly SignatureToken Empty = new SignatureToken();
diff --git a/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs b/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs
index 2d2c35e..8a447d0 100644
--- a/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs
@@ -17,7 +17,6 @@ namespace System.Reflection.Emit {
using System;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum StackBehaviour
{
diff --git a/src/mscorlib/src/System/Reflection/Emit/StringToken.cs b/src/mscorlib/src/System/Reflection/Emit/StringToken.cs
index cb0e979..8522256 100644
--- a/src/mscorlib/src/System/Reflection/Emit/StringToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/StringToken.cs
@@ -16,10 +16,8 @@ namespace System.Reflection.Emit {
using System;
using System.Reflection;
- using System.Security.Permissions;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public struct StringToken {
internal int m_string;
diff --git a/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs b/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs
index 84ece90..2052991 100644
--- a/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs
@@ -419,7 +419,6 @@ namespace System.Reflection.Emit
throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
}
-[System.Runtime.InteropServices.ComVisible(true)]
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
{
throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
@@ -497,7 +496,6 @@ namespace System.Reflection.Emit
throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
}
-[System.Runtime.InteropServices.ComVisible(true)]
public override InterfaceMapping GetInterfaceMap(Type interfaceType)
{
throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
index 73778d5..88502cb 100644
--- a/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
@@ -9,7 +9,6 @@ namespace System.Reflection.Emit {
using System;
using System.Reflection;
using System.Security;
- using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Collections.Generic;
@@ -21,7 +20,6 @@ namespace System.Reflection.Emit {
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum PackingSize
{
Unspecified = 0,
@@ -35,10 +33,7 @@ namespace System.Reflection.Emit {
Size128 = 128,
}
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_TypeBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class TypeBuilder : TypeInfo, _TypeBuilder
+ public sealed class TypeBuilder : TypeInfo
{
public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
if(typeInfo==null) return false;
@@ -227,10 +222,6 @@ namespace System.Reflection.Emit {
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- internal static extern void SetPInvokeData(RuntimeModule module, String DllName, String name, int token, int linkFlags);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
internal static extern int DefineProperty(RuntimeModule module, int tkParent, String name, PropertyAttributes attributes,
byte[] signature, int sigLength);
@@ -270,42 +261,10 @@ namespace System.Reflection.Emit {
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- internal static extern void SetFieldMarshal(RuntimeModule module, int tk, byte[] ubMarshal, int ubSize);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
private static extern unsafe void SetConstantValue(RuntimeModule module, int tk, int corType, void* pValue);
- #endregion
-
- #region Internal\Private Static Members
- private static bool IsPublicComType(Type type)
- {
- // Internal Helper to determine if a type should be added to ComType table.
- // A top level type should be added if it is Public.
- // A nested type should be added if the top most enclosing type is Public
- // and all the enclosing types are NestedPublic
- Type enclosingType = type.DeclaringType;
- if (enclosingType != null)
- {
- if (IsPublicComType(enclosingType))
- {
- if ((type.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPublic)
- {
- return true;
- }
- }
- }
- else
- {
- if ((type.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public)
- {
- return true;
- }
- }
-
- return false;
- }
+#endregion
+#region Internal\Private Static Members
[Pure]
internal static bool IsTypeEqual(Type t1, Type t2)
@@ -656,127 +615,8 @@ namespace System.Reflection.Emit {
m_module.AddType(FullName, this);
}
- #endregion
-
- #region Private Members
- private MethodBuilder DefinePInvokeMethodHelper(
- String name, String dllName, String importName, MethodAttributes attributes, CallingConventions callingConvention,
- Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
- Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers,
- CallingConvention nativeCallConv, CharSet nativeCharSet)
- {
- CheckContext(returnType);
- CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
- CheckContext(parameterTypeRequiredCustomModifiers);
- CheckContext(parameterTypeOptionalCustomModifiers);
-
- AppDomain.CheckDefinePInvokeSupported();
-
- lock (SyncRoot)
- {
- return DefinePInvokeMethodHelperNoLock(name, dllName, importName, attributes, callingConvention,
- returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
- parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers,
- nativeCallConv, nativeCharSet);
- }
- }
-
- private MethodBuilder DefinePInvokeMethodHelperNoLock(
- String name, String dllName, String importName, MethodAttributes attributes, CallingConventions callingConvention,
- Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
- Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers,
- CallingConvention nativeCallConv, CharSet nativeCharSet)
- {
- if (name == null)
- throw new ArgumentNullException(nameof(name));
-
- if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
-
- if (dllName == null)
- throw new ArgumentNullException(nameof(dllName));
-
- if (dllName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(dllName));
-
- if (importName == null)
- throw new ArgumentNullException(nameof(importName));
-
- if (importName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(importName));
-
- if ((attributes & MethodAttributes.Abstract) != 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadPInvokeMethod"));
- Contract.EndContractBlock();
-
- if ((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadPInvokeOnInterface"));
-
- ThrowIfCreated();
-
- attributes = attributes | MethodAttributes.PinvokeImpl;
- MethodBuilder method = new MethodBuilder(name, attributes, callingConvention,
- returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
- parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers,
- m_module, this, false);
-
- //The signature grabbing code has to be up here or the signature won't be finished
- //and our equals check won't work.
- int sigLength;
- byte[] sigBytes = method.GetMethodSignature().InternalGetSignature(out sigLength);
-
- if (m_listMethods.Contains(method))
- {
- throw new ArgumentException(Environment.GetResourceString("Argument_MethodRedefined"));
- }
- m_listMethods.Add(method);
-
- MethodToken token = method.GetToken();
-
- int linkFlags = 0;
- switch(nativeCallConv)
- {
- case CallingConvention.Winapi:
- linkFlags =(int)PInvokeMap.CallConvWinapi;
- break;
- case CallingConvention.Cdecl:
- linkFlags =(int)PInvokeMap.CallConvCdecl;
- break;
- case CallingConvention.StdCall:
- linkFlags =(int)PInvokeMap.CallConvStdcall;
- break;
- case CallingConvention.ThisCall:
- linkFlags =(int)PInvokeMap.CallConvThiscall;
- break;
- case CallingConvention.FastCall:
- linkFlags =(int)PInvokeMap.CallConvFastcall;
- break;
- }
- switch(nativeCharSet)
- {
- case CharSet.None:
- linkFlags |=(int)PInvokeMap.CharSetNotSpec;
- break;
- case CharSet.Ansi:
- linkFlags |=(int)PInvokeMap.CharSetAnsi;
- break;
- case CharSet.Unicode:
- linkFlags |=(int)PInvokeMap.CharSetUnicode;
- break;
- case CharSet.Auto:
- linkFlags |=(int)PInvokeMap.CharSetAuto;
- break;
- }
-
- SetPInvokeData(m_module.GetNativeHandle(),
- dllName,
- importName,
- token.Token,
- linkFlags);
- method.SetToken(token);
-
- return method;
- }
+#endregion
+#region Private Members
private FieldBuilder DefineDataHelper(String name, byte[] data, int size, FieldAttributes attributes)
{
@@ -1050,7 +890,6 @@ namespace System.Reflection.Emit {
return m_bakedRuntimeType.GetConstructor(bindingAttr, binder, callConvention, types, modifiers);
}
- [System.Runtime.InteropServices.ComVisible(true)]
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
{
if (!IsCreated())
@@ -1188,7 +1027,6 @@ namespace System.Reflection.Emit {
return m_bakedRuntimeType.GetMember(name, type, bindingAttr);
}
- [System.Runtime.InteropServices.ComVisible(true)]
public override InterfaceMapping GetInterfaceMap(Type interfaceType)
{
if (!IsCreated())
@@ -1319,7 +1157,6 @@ namespace System.Reflection.Emit {
get { return false; }
}
- [System.Runtime.InteropServices.ComVisible(true)]
[Pure]
public override bool IsSubclassOf(Type c)
{
@@ -1642,7 +1479,6 @@ namespace System.Reflection.Emit {
#endregion
#region Define Constructor
- [System.Runtime.InteropServices.ComVisible(true)]
public ConstructorBuilder DefineTypeInitializer()
{
lock(SyncRoot)
@@ -1664,7 +1500,6 @@ namespace System.Reflection.Emit {
return constBuilder;
}
- [System.Runtime.InteropServices.ComVisible(true)]
public ConstructorBuilder DefineDefaultConstructor(MethodAttributes attributes)
{
if ((m_iAttr & TypeAttributes.Interface) == TypeAttributes.Interface)
@@ -1732,13 +1567,11 @@ namespace System.Reflection.Emit {
return constBuilder;
}
- [System.Runtime.InteropServices.ComVisible(true)]
public ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes)
{
return DefineConstructor(attributes, callingConvention, parameterTypes, null, null);
}
- [System.Runtime.InteropServices.ComVisible(true)]
public ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention,
Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers)
{
@@ -1786,41 +1619,6 @@ namespace System.Reflection.Emit {
#endregion
- #region Define PInvoke
- public MethodBuilder DefinePInvokeMethod(String name, String dllName, MethodAttributes attributes,
- CallingConventions callingConvention, Type returnType, Type[] parameterTypes,
- CallingConvention nativeCallConv, CharSet nativeCharSet)
- {
- MethodBuilder method = DefinePInvokeMethodHelper(
- name, dllName, name, attributes, callingConvention, returnType, null, null,
- parameterTypes, null, null, nativeCallConv, nativeCharSet);
- return method;
- }
-
- public MethodBuilder DefinePInvokeMethod(String name, String dllName, String entryName, MethodAttributes attributes,
- CallingConventions callingConvention, Type returnType, Type[] parameterTypes,
- CallingConvention nativeCallConv, CharSet nativeCharSet)
- {
- MethodBuilder method = DefinePInvokeMethodHelper(
- name, dllName, entryName, attributes, callingConvention, returnType, null, null,
- parameterTypes, null, null, nativeCallConv, nativeCharSet);
- return method;
- }
-
- public MethodBuilder DefinePInvokeMethod(String name, String dllName, String entryName, MethodAttributes attributes,
- CallingConventions callingConvention,
- Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
- Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers,
- CallingConvention nativeCallConv, CharSet nativeCharSet)
- {
- MethodBuilder method = DefinePInvokeMethodHelper(
- name, dllName, entryName, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
- parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers, nativeCallConv, nativeCharSet);
- return method;
- }
-
- #endregion
-
#region Define Nested Type
public TypeBuilder DefineNestedType(String name)
{
@@ -1830,7 +1628,6 @@ namespace System.Reflection.Emit {
}
}
- [System.Runtime.InteropServices.ComVisible(true)]
public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, Type[] interfaces)
{
lock(SyncRoot)
@@ -2343,7 +2140,6 @@ namespace System.Reflection.Emit {
}
}
- [System.Runtime.InteropServices.ComVisible(true)]
public void AddInterfaceImplementation(Type interfaceType)
{
if (interfaceType == null)
@@ -2374,7 +2170,6 @@ public TypeToken TypeToken
}
- [System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
if (con == null)
diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs
index 3bae585..da5a56b 100644
--- a/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs
@@ -168,7 +168,6 @@ namespace System.Reflection.Emit
}
protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); }
- [System.Runtime.InteropServices.ComVisible(true)]
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { throw new NotSupportedException(); }
protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); }
public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { throw new NotSupportedException(); }
@@ -184,7 +183,6 @@ namespace System.Reflection.Emit
public override Type GetNestedType(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) { throw new NotSupportedException(); }
- [System.Runtime.InteropServices.ComVisible(true)]
public override InterfaceMapping GetInterfaceMap(Type interfaceType) { throw new NotSupportedException(); }
public override EventInfo[] GetEvents(BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { throw new NotSupportedException(); }
@@ -222,7 +220,6 @@ namespace System.Reflection.Emit
public override Type MakeGenericType(params Type[] inst) { throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericTypeDefinition")); }
public override bool IsAssignableFrom(Type c) { throw new NotSupportedException(); }
- [System.Runtime.InteropServices.ComVisible(true)]
[Pure]
public override bool IsSubclassOf(Type c)
{
diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeToken.cs b/src/mscorlib/src/System/Reflection/Emit/TypeToken.cs
index 2287556..4fa851c 100644
--- a/src/mscorlib/src/System/Reflection/Emit/TypeToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/TypeToken.cs
@@ -17,21 +17,14 @@ namespace System.Reflection.Emit {
using System;
using System.Reflection;
using System.Threading;
- using System.Security.Permissions;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public struct TypeToken {
public static readonly TypeToken Empty = new TypeToken();
internal int m_class;
-#if false
- public TypeToken() {
- m_class=0;
- }
-#endif
internal TypeToken(int str) {
m_class=str;
diff --git a/src/mscorlib/src/System/Reflection/Emit/UnmanagedMarshal.cs b/src/mscorlib/src/System/Reflection/Emit/UnmanagedMarshal.cs
deleted file mode 100644
index 28e95e2..0000000
--- a/src/mscorlib/src/System/Reflection/Emit/UnmanagedMarshal.cs
+++ /dev/null
@@ -1,183 +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.
-
-namespace System.Reflection.Emit
-{
- using System.Runtime.InteropServices;
- using System;
- using System.Security.Permissions;
-
- // This class is describing the fieldmarshal.
- [Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
- [Obsolete("An alternate API is available: Emit the MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- public sealed class UnmanagedMarshal
- {
- /******************************
-[System.Runtime.InteropServices.ComVisible(true)]
- * public static constructors. You can only construct
- * UnmanagedMarshal using these static constructors.
- ******************************/
- public static UnmanagedMarshal DefineUnmanagedMarshal(UnmanagedType unmanagedType)
- {
- if (unmanagedType == UnmanagedType.ByValTStr ||
- unmanagedType == UnmanagedType.SafeArray ||
- unmanagedType == UnmanagedType.CustomMarshaler ||
- unmanagedType == UnmanagedType.ByValArray ||
- unmanagedType == UnmanagedType.LPArray)
- {
- // not a simple native marshal
- throw new ArgumentException(Environment.GetResourceString("Argument_NotASimpleNativeType"));
- }
- return new UnmanagedMarshal(unmanagedType, Guid.Empty, 0, (UnmanagedType) 0);
- }
- public static UnmanagedMarshal DefineByValTStr(int elemCount)
- {
- return new UnmanagedMarshal(UnmanagedType.ByValTStr, Guid.Empty, elemCount, (UnmanagedType) 0);
- }
-
- public static UnmanagedMarshal DefineSafeArray(UnmanagedType elemType)
- {
- return new UnmanagedMarshal(UnmanagedType.SafeArray, Guid.Empty, 0, elemType);
- }
-
- public static UnmanagedMarshal DefineByValArray(int elemCount)
- {
- return new UnmanagedMarshal(UnmanagedType.ByValArray, Guid.Empty, elemCount, (UnmanagedType) 0);
- }
-
- public static UnmanagedMarshal DefineLPArray(UnmanagedType elemType)
- {
- return new UnmanagedMarshal(UnmanagedType.LPArray, Guid.Empty, 0, elemType);
- }
-
-
-
-
-
-
- // accessor function for the native type
- public UnmanagedType GetUnmanagedType
- {
- get { return m_unmanagedType; }
- }
-
- public Guid IIDGuid
- {
- get
- {
- if (m_unmanagedType == UnmanagedType.CustomMarshaler)
- return m_guid;
-
- // throw exception here. There is Guid only if CustomMarshaler
- throw new ArgumentException(Environment.GetResourceString("Argument_NotACustomMarshaler"));
- }
- }
- public int ElementCount
- {
- get
- {
- if (m_unmanagedType != UnmanagedType.ByValArray &&
- m_unmanagedType != UnmanagedType.ByValTStr)
- {
- // throw exception here. There is NumElement only if NativeTypeFixedArray
- throw new ArgumentException(Environment.GetResourceString("Argument_NoUnmanagedElementCount"));
- }
- return m_numElem;
- }
- }
- public UnmanagedType BaseType
- {
- get
- {
- if (m_unmanagedType != UnmanagedType.LPArray && m_unmanagedType != UnmanagedType.SafeArray)
- {
- // throw exception here. There is NestedUnmanagedType only if LPArray or SafeArray
- throw new ArgumentException(Environment.GetResourceString("Argument_NoNestedMarshal"));
- }
- return m_baseType;
- }
- }
-
- private UnmanagedMarshal(UnmanagedType unmanagedType, Guid guid, int numElem, UnmanagedType type)
- {
- m_unmanagedType = unmanagedType;
- m_guid = guid;
- m_numElem = numElem;
- m_baseType = type;
- }
-
- /************************
- *
- * Data member
- *
- *************************/
- internal UnmanagedType m_unmanagedType;
- internal Guid m_guid;
- internal int m_numElem;
- internal UnmanagedType m_baseType;
-
-
- /************************
- * this function return the byte representation of the marshal info.
- *************************/
- internal byte[] InternalGetBytes()
- {
- byte[] buf;
- if (m_unmanagedType == UnmanagedType.SafeArray || m_unmanagedType == UnmanagedType.LPArray)
- {
-
- // syntax for NativeTypeSafeArray is
- // <SafeArray | LPArray> <base type>
- //
- int cBuf = 2;
- buf = new byte[cBuf];
- buf[0] = (byte) (m_unmanagedType);
- buf[1] = (byte) (m_baseType);
- return buf;
- }
- else
- if (m_unmanagedType == UnmanagedType.ByValArray ||
- m_unmanagedType == UnmanagedType.ByValTStr)
- {
- // <ByValArray | ByValTStr> <encoded integer>
- //
- int cBuf;
- int iBuf = 0;
-
- if (m_numElem <= 0x7f)
- cBuf = 1;
- else if (m_numElem <= 0x3FFF)
- cBuf = 2;
- else
- cBuf = 4;
-
- // the total buffer size is the one byte + encoded integer size
- cBuf = cBuf + 1;
- buf = new byte[cBuf];
-
-
- buf[iBuf++] = (byte) (m_unmanagedType);
- if (m_numElem <= 0x7F)
- {
- buf[iBuf++] = (byte)(m_numElem & 0xFF);
- } else if (m_numElem <= 0x3FFF)
- {
- buf[iBuf++] = (byte)((m_numElem >> 8) | 0x80);
- buf[iBuf++] = (byte)(m_numElem & 0xFF);
- } else if (m_numElem <= 0x1FFFFFFF)
- {
- buf[iBuf++] = (byte)((m_numElem >> 24) | 0xC0);
- buf[iBuf++] = (byte)((m_numElem >> 16) & 0xFF);
- buf[iBuf++] = (byte)((m_numElem >> 8) & 0xFF);
- buf[iBuf++] = (byte)((m_numElem) & 0xFF);
- }
- return buf;
- }
- buf = new byte[1];
- buf[0] = (byte) (m_unmanagedType);
- return buf;
- }
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs
index aaaffc0..ca0faf3 100644
--- a/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs
@@ -51,23 +51,7 @@ namespace System.Reflection.Emit
public override Object[] GetCustomAttributes(bool inherit) { return m_method.GetCustomAttributes(inherit); }
public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_method.GetCustomAttributes(attributeType, inherit); }
public override bool IsDefined(Type attributeType, bool inherit) { return m_method.IsDefined(attributeType, inherit); }
- internal int MetadataTokenInternal
- {
- get
- {
- MethodBuilder mb = m_method as MethodBuilder;
-
- if (mb != null)
- return mb.MetadataTokenInternal;
- else
- {
- Debug.Assert(m_method is RuntimeMethodInfo);
- return m_method.MetadataToken;
- }
- }
- }
public override Module Module { get { return m_method.Module; } }
- public new Type GetType() { return base.GetType(); }
#endregion
#region MethodBase Members
@@ -164,7 +148,6 @@ namespace System.Reflection.Emit
}
}
public override Module Module { get { return m_ctor.Module; } }
- public new Type GetType() { return base.GetType(); }
#endregion
#region MethodBase Members
@@ -265,7 +248,6 @@ namespace System.Reflection.Emit
}
}
public override Module Module { get { return m_field.Module; } }
- public new Type GetType() { return base.GetType(); }
#endregion
#region Public Abstract\Virtual Members