summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Reflection
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Reflection')
-rw-r--r--src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Assembly.cs507
-rw-r--r--src/mscorlib/src/System/Reflection/AssemblyAttributes.cs19
-rw-r--r--src/mscorlib/src/System/Reflection/AssemblyName.cs8
-rw-r--r--src/mscorlib/src/System/Reflection/AssemblyNameFlags.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/AssemblyNameProxy.cs28
-rw-r--r--src/mscorlib/src/System/Reflection/Binder.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/BindingFlags.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/CallingConventions.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/ComInterfaces.cs115
-rw-r--r--src/mscorlib/src/System/Reflection/ConstructorInfo.cs42
-rw-r--r--src/mscorlib/src/System/Reflection/CustomAttribute.cs44
-rw-r--r--src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/DefaultMemberAttribute.cs1
-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
-rw-r--r--src/mscorlib/src/System/Reflection/EventAttributes.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/EventInfo.cs7
-rw-r--r--src/mscorlib/src/System/Reflection/FieldAttributes.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/FieldInfo.cs9
-rw-r--r--src/mscorlib/src/System/Reflection/ICustomAttributeProvider.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/IReflect.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/InterfaceMapping.cs5
-rw-r--r--src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/ManifestResourceInfo.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/MdImport.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/MemberFilter.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/MemberInfo.cs6
-rw-r--r--src/mscorlib/src/System/Reflection/MemberTypes.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/MethodAttributes.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/MethodBase.cs28
-rw-r--r--src/mscorlib/src/System/Reflection/MethodBody.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/MethodImplAttributes.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/MethodInfo.cs31
-rw-r--r--src/mscorlib/src/System/Reflection/Missing.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/Module.cs30
-rw-r--r--src/mscorlib/src/System/Reflection/ObfuscateAssemblyAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/ObfuscationAttribute.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/ParameterAttributes.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/ParameterInfo.cs6
-rw-r--r--src/mscorlib/src/System/Reflection/ParameterModifier.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/Pointer.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/PropertyAttributes.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/PropertyInfo.cs7
-rw-r--r--src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs7
-rw-r--r--src/mscorlib/src/System/Reflection/ResourceAttributes.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs12
-rw-r--r--src/mscorlib/src/System/Reflection/StrongNameKeyPair.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/TargetException.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/TargetInvocationException.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/TargetParameterCountException.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/TypeAttributes.cs2
-rw-r--r--src/mscorlib/src/System/Reflection/TypeDelegator.cs3
-rw-r--r--src/mscorlib/src/System/Reflection/TypeFilter.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/TypeInfo.cs1
96 files changed, 135 insertions, 3352 deletions
diff --git a/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs b/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs
index 6df371bd11..795a8714d1 100644
--- a/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs
+++ b/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs
@@ -18,7 +18,6 @@ namespace System.Reflection {
using SystemException = System.SystemException;
using System.Runtime.Serialization;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class AmbiguousMatchException : SystemException
{
diff --git a/src/mscorlib/src/System/Reflection/Assembly.cs b/src/mscorlib/src/System/Reflection/Assembly.cs
index 677e4aa964..eaedc6ded4 100644
--- a/src/mscorlib/src/System/Reflection/Assembly.cs
+++ b/src/mscorlib/src/System/Reflection/Assembly.cs
@@ -22,15 +22,12 @@ namespace System.Reflection
using CultureInfo = System.Globalization.CultureInfo;
using System.Security;
using System.Security.Policy;
- using System.Security.Permissions;
using System.IO;
using StringBuilder = System.Text.StringBuilder;
using System.Configuration.Assemblies;
using StackCrawlMark = System.Threading.StackCrawlMark;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
- using SecurityZone = System.Security.SecurityZone;
- using IEvidenceFactory = System.Security.IEvidenceFactory;
using System.Runtime.Serialization;
using Microsoft.Win32;
using System.Threading;
@@ -40,15 +37,11 @@ namespace System.Reflection
using System.Runtime.Loader;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public delegate Module ModuleResolveEventHandler(Object sender, ResolveEventArgs e);
[Serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_Assembly))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public abstract class Assembly : _Assembly, IEvidenceFactory, ICustomAttributeProvider, ISerializable
+ public abstract class Assembly : ICustomAttributeProvider, ISerializable
{
protected Assembly() {}
@@ -112,24 +105,17 @@ namespace System.Reflection
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public static Assembly ReflectionOnlyLoadFrom(String assemblyFile)
{
- Contract.Ensures(Contract.Result<Assembly>() != null);
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-
- return RuntimeAssembly.InternalLoadFrom(
- assemblyFile,
- null, //securityEvidence
- null, //hashValue
- AssemblyHashAlgorithm.None,
- true, //forIntrospection
- false, //suppressSecurityChecks
- ref stackMark);
+ if (assemblyFile == null)
+ throw new ArgumentNullException(nameof(assemblyFile));
+ if (assemblyFile.Length == 0)
+ throw new ArgumentException(Environment.GetResourceString("Format_StringZeroLength"));
+ throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReflectionOnlyLoad"));
}
// Evidence is protected in Assembly.Load()
[Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of LoadFrom which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly LoadFrom(String assemblyFile,
+ internal static Assembly LoadFrom(String assemblyFile,
Evidence securityEvidence)
{
Contract.Ensures(Contract.Result<Assembly>() != null);
@@ -142,29 +128,6 @@ namespace System.Reflection
null, // hashValue
AssemblyHashAlgorithm.None,
false,// forIntrospection);
- false,// suppressSecurityChecks
- ref stackMark);
- }
-
- // Evidence is protected in Assembly.Load()
- [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of LoadFrom which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly LoadFrom(String assemblyFile,
- Evidence securityEvidence,
- byte[] hashValue,
- AssemblyHashAlgorithm hashAlgorithm)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-
- return RuntimeAssembly.InternalLoadFrom(
- assemblyFile,
- securityEvidence,
- hashValue,
- hashAlgorithm,
- false,
- false,
ref stackMark);
}
@@ -218,7 +181,7 @@ namespace System.Reflection
assembly = RuntimeAssembly.InternalLoadAssemblyName(
assemblyName, null, null, ref stackMark,
- true /*thrownOnFileNotFound*/, false /*forIntrospection*/, false /*suppressSecurityChecks*/);
+ true /*thrownOnFileNotFound*/, false /*forIntrospection*/);
}
return assembly.GetType(typeName, true /*throwOnError*/, false /*ignoreCase*/);
}
@@ -229,21 +192,11 @@ namespace System.Reflection
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public static Assembly ReflectionOnlyLoad(String assemblyString)
{
- Contract.Ensures(Contract.Result<Assembly>() != null);
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.InternalLoad(assemblyString, null, ref stackMark, true /*forIntrospection*/);
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
- public static Assembly Load(String assemblyString, Evidence assemblySecurity)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.InternalLoad(assemblyString, assemblySecurity, ref stackMark, false /*forIntrospection*/);
+ if (assemblyString == null)
+ throw new ArgumentNullException(nameof(assemblyString));
+ if (assemblyString.Length == 0)
+ throw new ArgumentException(Environment.GetResourceString("Format_StringZeroLength"));
+ throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReflectionOnlyLoad"));
}
// Locate an assembly by its name. The name can be strong or
@@ -254,15 +207,13 @@ namespace System.Reflection
Contract.Ensures(Contract.Result<Assembly>() != null);
Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-#if FEATURE_WINDOWSPHONE
if (assemblyRef != null && assemblyRef.CodeBase != null)
{
throw new NotSupportedException(Environment.GetResourceString("NotSupported_AssemblyLoadCodeBase"));
}
-#endif
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/, false /*suppressSecurityChecks*/);
+ return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/);
}
// Locate an assembly by its name. The name can be strong or
@@ -273,26 +224,13 @@ namespace System.Reflection
Contract.Ensures(Contract.Result<Assembly>() != null);
Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-#if FEATURE_WINDOWSPHONE
if (assemblyRef != null && assemblyRef.CodeBase != null)
{
throw new NotSupportedException(Environment.GetResourceString("NotSupported_AssemblyLoadCodeBase"));
}
-#endif
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/, false /*suppressSecurityChecks*/, ptrLoadContextBinder);
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
- public static Assembly Load(AssemblyName assemblyRef, Evidence assemblySecurity)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, assemblySecurity, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/, false /*suppressSecurityChecks*/);
+ return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/, ptrLoadContextBinder);
}
[Obsolete("This method has been deprecated. Please use Assembly.Load() instead. http://go.microsoft.com/fwlink/?linkid=14202")]
@@ -323,18 +261,9 @@ namespace System.Reflection
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public static Assembly ReflectionOnlyLoad(byte[] rawAssembly)
{
- Contract.Ensures(Contract.Result<Assembly>() != null);
-
- AppDomain.CheckReflectionOnlyLoadSupported();
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.nLoadImage(
- rawAssembly,
- null, // symbol store
- null, // evidence
- ref stackMark,
- true, // fIntrospection
- SecurityContextSource.CurrentAssembly);
+ if (rawAssembly == null)
+ throw new ArgumentNullException(nameof(rawAssembly));
+ throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReflectionOnlyLoad"));
}
// Loads the assembly with a COFF based IMAGE containing
@@ -358,33 +287,6 @@ namespace System.Reflection
return alc.LoadFromStream(assemblyStream, symbolStream);
}
- // Load an assembly from a byte array, controlling where the grant set of this assembly is
- // propigated from.
- [MethodImpl(MethodImplOptions.NoInlining)] // Due to the stack crawl mark
- public static Assembly Load(byte[] rawAssembly,
- byte[] rawSymbolStore,
- SecurityContextSource securityContextSource)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
- AppDomain.CheckLoadByteArraySupported();
-
- if (securityContextSource < SecurityContextSource.CurrentAppDomain ||
- securityContextSource > SecurityContextSource.CurrentAssembly)
- {
- throw new ArgumentOutOfRangeException(nameof(securityContextSource));
- }
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.nLoadImage(rawAssembly,
- rawSymbolStore,
- null, // evidence
- ref stackMark,
- false, // fIntrospection
- securityContextSource);
- }
-
private static Dictionary<string, Assembly> s_loadfile = new Dictionary<string, Assembly>();
public static Assembly LoadFile(String path)
@@ -416,25 +318,6 @@ namespace System.Reflection
return result;
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly Load(Stream assemblyStream, Stream pdbStream)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.InternalLoadFromStream(assemblyStream, pdbStream, ref stackMark);
- }
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly Load(Stream assemblyStream)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.InternalLoadFromStream(assemblyStream, null, ref stackMark);
- }
-
/*
* Get the assembly that the current code is running from.
*/
@@ -573,11 +456,10 @@ namespace System.Reflection
{
Module[] m = GetModules(false);
- int iNumModules = m.Length;
int iFinalLength = 0;
- Type[][] ModuleTypes = new Type[iNumModules][];
+ Type[][] ModuleTypes = new Type[m.Length][];
- for (int i = 0; i < iNumModules; i++)
+ for (int i = 0; i < ModuleTypes.Length; i++)
{
ModuleTypes[i] = m[i].GetTypes();
iFinalLength += ModuleTypes[i].Length;
@@ -585,7 +467,7 @@ namespace System.Reflection
int iCurrent = 0;
Type[] ret = new Type[iFinalLength];
- for (int i = 0; i < iNumModules; i++)
+ for (int i = 0; i < ModuleTypes.Length; i++)
{
int iLength = ModuleTypes[i].Length;
Array.Copy(ModuleTypes[i], 0, ret, iCurrent, iLength);
@@ -639,7 +521,6 @@ namespace System.Reflection
throw new NotImplementedException();
}
- [ComVisible(false)]
public virtual Module ManifestModule
{
get
@@ -684,9 +565,6 @@ namespace System.Reflection
throw new NotImplementedException();
}
- // To not break compatibility with the V1 _Assembly interface we need to make this
- // new member ComVisible(false).
- [ComVisible(false)]
public virtual bool ReflectionOnly
{
get
@@ -836,9 +714,6 @@ namespace System.Reflection
}
}
- // To not break compatibility with the V1 _Assembly interface we need to make this
- // new member ComVisible(false).
- [ComVisible(false)]
public virtual String ImageRuntimeVersion
{
get
@@ -858,7 +733,6 @@ namespace System.Reflection
}
}
- [ComVisible(false)]
public virtual Int64 HostContext
{
get
@@ -885,15 +759,6 @@ namespace System.Reflection
}
- // Keep this in sync with LOADCTX_TYPE defined in fusionpriv.idl
- internal enum LoadContext
- {
- DEFAULT,
- LOADFROM,
- UNKNOWN,
- HOSTED,
- }
-
[Serializable]
internal class RuntimeAssembly : Assembly
{
@@ -915,7 +780,6 @@ namespace System.Reflection
internal RuntimeAssembly() { throw new NotSupportedException(); }
#region private data members
- [method: System.Security.SecurityCritical]
private event ModuleResolveEventHandler _ModuleResolve;
private string m_fullname;
private object m_syncRoot; // Used to keep collectible types alive and as the syncroot for reflection.emit
@@ -997,7 +861,6 @@ namespace System.Reflection
{
get {
String codeBase = GetCodeBase(false);
- VerifyCodeBaseDiscovery(codeBase);
return codeBase;
}
}
@@ -1015,7 +878,6 @@ namespace System.Reflection
AssemblyName an = new AssemblyName();
String codeBase = GetCodeBase(copiedName);
- VerifyCodeBaseDiscovery(codeBase);
an.Init(GetSimpleName(),
GetPublicKey(),
@@ -1104,10 +966,6 @@ namespace System.Reflection
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- internal extern static void GetForwardedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
private extern static void GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes);
public override Type[] GetExportedTypes()
@@ -1217,7 +1075,6 @@ namespace System.Reflection
byte[] hashValue,
AssemblyHashAlgorithm hashAlgorithm,
bool forIntrospection,
- bool suppressSecurityChecks,
ref StackCrawlMark stackMark)
{
if (assemblyFile == null)
@@ -1229,7 +1086,7 @@ namespace System.Reflection
an.CodeBase = assemblyFile;
an.SetHashControl(hashValue, hashAlgorithm);
// The stack mark is used for MDA filtering
- return InternalLoadAssemblyName(an, securityEvidence, null, ref stackMark, true /*thrownOnFileNotFound*/, forIntrospection, suppressSecurityChecks);
+ return InternalLoadAssemblyName(an, securityEvidence, null, ref stackMark, true /*thrownOnFileNotFound*/, forIntrospection);
}
// Wrapper function to wrap the typical use of InternalLoad.
@@ -1258,7 +1115,7 @@ namespace System.Reflection
return InternalLoadAssemblyName(an, assemblySecurity, null, ref stackMark,
pPrivHostBinder,
- true /*thrownOnFileNotFound*/, forIntrospection, false /* suppressSecurityChecks */);
+ true /*thrownOnFileNotFound*/, forIntrospection);
}
// Creates AssemblyName. Fills assembly if AssemblyResolve event has been raised.
@@ -1294,10 +1151,9 @@ namespace System.Reflection
ref StackCrawlMark stackMark,
bool throwOnFileNotFound,
bool forIntrospection,
- bool suppressSecurityChecks,
IntPtr ptrLoadContextBinder = default(IntPtr))
{
- return InternalLoadAssemblyName(assemblyRef, assemblySecurity, reqAssembly, ref stackMark, IntPtr.Zero, true /*throwOnError*/, forIntrospection, suppressSecurityChecks, ptrLoadContextBinder);
+ return InternalLoadAssemblyName(assemblyRef, assemblySecurity, reqAssembly, ref stackMark, IntPtr.Zero, true /*throwOnError*/, forIntrospection, ptrLoadContextBinder);
}
internal static RuntimeAssembly InternalLoadAssemblyName(
@@ -1308,7 +1164,6 @@ namespace System.Reflection
IntPtr pPrivHostBinder,
bool throwOnFileNotFound,
bool forIntrospection,
- bool suppressSecurityChecks,
IntPtr ptrLoadContextBinder = default(IntPtr))
{
@@ -1322,42 +1177,17 @@ namespace System.Reflection
}
assemblyRef = (AssemblyName)assemblyRef.Clone();
-#if FEATURE_VERSIONING
if (!forIntrospection &&
(assemblyRef.ProcessorArchitecture != ProcessorArchitecture.None)) {
// PA does not have a semantics for by-name binds for execution
assemblyRef.ProcessorArchitecture = ProcessorArchitecture.None;
}
-#endif
-
- if (assemblySecurity != null)
- {
- if (!suppressSecurityChecks)
- {
-#pragma warning disable 618
- new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
-#pragma warning restore 618
- }
- }
String codeBase = VerifyCodeBase(assemblyRef.CodeBase);
- if (codeBase != null && !suppressSecurityChecks)
- {
- if (String.Compare( codeBase, 0, s_localFilePrefix, 0, 5, StringComparison.OrdinalIgnoreCase) != 0)
- {
- // Of all the binders, Fusion is the only one that understands Web locations
- throw new ArgumentException(Environment.GetResourceString("Arg_InvalidFileName"), "assemblyRef.CodeBase");
- }
- else
- {
- System.Security.Util.URLString urlString = new System.Security.Util.URLString( codeBase, true );
- new FileIOPermission( FileIOPermissionAccess.PathDiscovery | FileIOPermissionAccess.Read , urlString.GetFileName() ).Demand();
- }
- }
return nLoad(assemblyRef, codeBase, assemblySecurity, reqAssembly, ref stackMark,
pPrivHostBinder,
- throwOnFileNotFound, forIntrospection, suppressSecurityChecks, ptrLoadContextBinder);
+ throwOnFileNotFound, forIntrospection, ptrLoadContextBinder);
}
// These are the framework assemblies that does reflection invocation
@@ -1383,15 +1213,6 @@ namespace System.Reflection
ASSEMBLY_FLAGS flags = Flags;
return (flags & ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_SAFE_REFLECTION) != 0;
}
-
- private bool IsDesignerBindingContext()
- {
- return RuntimeAssembly.nIsDesignerBindingContext(this);
- }
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private extern static bool nIsDesignerBindingContext(RuntimeAssembly assembly);
#endif
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -1414,19 +1235,16 @@ namespace System.Reflection
IntPtr pPrivHostBinder,
bool throwOnFileNotFound,
bool forIntrospection,
- bool suppressSecurityChecks, IntPtr ptrLoadContextBinder = default(IntPtr))
+ IntPtr ptrLoadContextBinder = default(IntPtr))
{
return _nLoad(fileName, codeBase, assemblySecurity, locationHint, ref stackMark,
pPrivHostBinder,
- throwOnFileNotFound, forIntrospection, suppressSecurityChecks, ptrLoadContextBinder);
+ throwOnFileNotFound, forIntrospection, true /* suppressSecurityChecks */, ptrLoadContextBinder);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern bool IsReflectionOnly(RuntimeAssembly assembly);
- // To not break compatibility with the V1 _Assembly interface we need to make this
- // new member ComVisible(false).
- [ComVisible(false)]
public override bool ReflectionOnly
{
get
@@ -1435,57 +1253,6 @@ namespace System.Reflection
}
}
- // Loads the assembly with a COFF based IMAGE containing
- // an emitted assembly. The assembly is loaded into the domain
- // of the caller. Currently is implemented only for UnmanagedMemoryStream
- // (no derived classes since we are not calling Read())
- internal static RuntimeAssembly InternalLoadFromStream(Stream assemblyStream, Stream pdbStream, ref StackCrawlMark stackMark)
- {
- if (assemblyStream == null)
- throw new ArgumentNullException(nameof(assemblyStream));
-
- if (assemblyStream.GetType()!=typeof(UnmanagedMemoryStream))
- throw new NotSupportedException();
-
- if (pdbStream!= null && pdbStream.GetType()!=typeof(UnmanagedMemoryStream))
- throw new NotSupportedException();
-
- AppDomain.CheckLoadFromSupported();
-
- UnmanagedMemoryStream umAssemblyStream = (UnmanagedMemoryStream)assemblyStream;
- UnmanagedMemoryStream umPdbStream = (UnmanagedMemoryStream)pdbStream;
-
- unsafe
- {
- byte* umAssemblyStreamBuffer=umAssemblyStream.PositionPointer;
- byte* umPdbStreamBuffer=(umPdbStream!=null)?umPdbStream.PositionPointer:null;
- long assemblyDataLength = umAssemblyStream.Length-umAssemblyStream.Position;
- long pdbDataLength = (umPdbStream!=null)?(umPdbStream.Length-umPdbStream.Position):0;
-
- // use Seek() to benefit from boundary checking, the actual read is done using *StreamBuffer
- umAssemblyStream.Seek(assemblyDataLength,SeekOrigin.Current);
-
- if(umPdbStream != null)
- {
- umPdbStream.Seek(pdbDataLength,SeekOrigin.Current);
- }
-
- BCLDebug.Assert(assemblyDataLength > 0L, "assemblyDataLength > 0L");
-
- RuntimeAssembly assembly = null;
-
- nLoadFromUnmanagedArray(false,
- umAssemblyStreamBuffer,
- (ulong)assemblyDataLength,
- umPdbStreamBuffer,
- (ulong)pdbDataLength,
- JitHelpers.GetStackCrawlMarkHandle(ref stackMark),
- JitHelpers.GetObjectHandleOnStack(ref assembly));
-
- return assembly;
- }
- }
-
// Returns the module in this assembly with name 'name'
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
@@ -1515,13 +1282,14 @@ namespace System.Reflection
public override FileStream[] GetFiles(bool getResourceModules)
{
Module[] m = GetModules(getResourceModules);
- int iLength = m.Length;
- FileStream[] fs = new FileStream[iLength];
+ FileStream[] fs = new FileStream[m.Length];
- for(int i = 0; i < iLength; i++)
+ for (int i = 0; i < fs.Length; i++)
+ {
fs[i] = new FileStream(((RuntimeModule)m[i]).GetFullyQualifiedName(),
FileMode.Open,
FileAccess.Read, FileShare.Read, FileStream.DefaultBufferSize, false);
+ }
return fs;
}
@@ -1593,9 +1361,6 @@ namespace System.Reflection
GetLocation(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref location));
- if (location != null)
- new FileIOPermission( FileIOPermissionAccess.PathDiscovery, location ).Demand();
-
return location;
}
}
@@ -1604,9 +1369,6 @@ namespace System.Reflection
[SuppressUnmanagedCodeSecurity]
private extern static void GetImageRuntimeVersion(RuntimeAssembly assembly, StringHandleOnStack retString);
- // To not break compatibility with the V1 _Assembly interface we need to make this
- // new member ComVisible(false).
- [ComVisible(false)]
public override String ImageRuntimeVersion
{
get{
@@ -1616,10 +1378,6 @@ namespace System.Reflection
}
}
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern static bool IsGlobalAssemblyCache(RuntimeAssembly assembly);
-
public override bool GlobalAssemblyCache
{
get
@@ -1628,10 +1386,6 @@ namespace System.Reflection
}
}
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private extern static Int64 GetHostContext(RuntimeAssembly assembly);
-
public override Int64 HostContext
{
get
@@ -1713,7 +1467,7 @@ namespace System.Reflection
if (length > Int64.MaxValue)
throw new NotImplementedException(Environment.GetResourceString("NotImplemented_ResourcesLongerThan2^63"));
- return new UnmanagedMemoryStream(pbInMemoryResource, (long)length, (long)length, FileAccess.Read, true);
+ return new UnmanagedMemoryStream(pbInMemoryResource, (long)length, (long)length, FileAccess.Read);
}
//Console.WriteLine("GetManifestResourceStream: Blob "+name+" not found...");
@@ -1761,15 +1515,6 @@ namespace System.Reflection
}
}
- private void VerifyCodeBaseDiscovery(String codeBase)
- {
- if ((codeBase != null) &&
- (String.Compare( codeBase, 0, s_localFilePrefix, 0, 5, StringComparison.OrdinalIgnoreCase) == 0)) {
- System.Security.Util.URLString urlString = new System.Security.Util.URLString( codeBase, true );
- new FileIOPermission( FileIOPermissionAccess.PathDiscovery, urlString.GetFileName() ).Demand();
- }
- }
-
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void GetSimpleName(RuntimeAssembly assembly, StringHandleOnStack retSimpleName);
@@ -1801,19 +1546,6 @@ namespace System.Reflection
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- private static extern void GetRawBytes(RuntimeAssembly assembly, ObjectHandleOnStack retRawBytes);
-
- // Get the raw bytes of the assembly
- internal byte[] GetRawBytes()
- {
- byte[] rawBytes = null;
-
- GetRawBytes(GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref rawBytes));
- return rawBytes;
- }
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
private static extern void GetPublicKey(RuntimeAssembly assembly, ObjectHandleOnStack retPublicKey);
internal byte[] GetPublicKey()
@@ -1825,50 +1557,6 @@ namespace System.Reflection
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- private extern static void GetGrantSet(RuntimeAssembly assembly, ObjectHandleOnStack granted, ObjectHandleOnStack denied);
-
- internal void GetGrantSet(out PermissionSet newGrant, out PermissionSet newDenied)
- {
- PermissionSet granted = null, denied = null;
- GetGrantSet(GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref granted), JitHelpers.GetObjectHandleOnStack(ref denied));
- newGrant = granted; newDenied = denied;
- }
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- [return: MarshalAs(UnmanagedType.Bool)]
- private extern static bool IsAllSecurityCritical(RuntimeAssembly assembly);
-
- // Is everything introduced by this assembly critical
- internal bool IsAllSecurityCritical()
- {
- return IsAllSecurityCritical(GetNativeHandle());
- }
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- [return: MarshalAs(UnmanagedType.Bool)]
- private extern static bool IsAllSecuritySafeCritical(RuntimeAssembly assembly);
-
- // Is everything introduced by this assembly safe critical
- internal bool IsAllSecuritySafeCritical()
- {
- return IsAllSecuritySafeCritical(GetNativeHandle());
- }
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- [return: MarshalAs(UnmanagedType.Bool)]
- private extern static bool IsAllPublicAreaSecuritySafeCritical(RuntimeAssembly assembly);
-
- // Is everything introduced by this assembly safe critical
- internal bool IsAllPublicAreaSecuritySafeCritical()
- {
- return IsAllPublicAreaSecuritySafeCritical(GetNativeHandle());
- }
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
private extern static bool IsAllSecurityTransparent(RuntimeAssembly assembly);
@@ -1948,7 +1636,7 @@ namespace System.Reflection
RuntimeAssembly retAssembly = nLoad(an, null, null, this, ref stackMark,
IntPtr.Zero,
- throwOnFileNotFound, false, false);
+ throwOnFileNotFound, false);
if (retAssembly == this || (retAssembly == null && throwOnFileNotFound))
{
@@ -1958,135 +1646,6 @@ namespace System.Reflection
return retAssembly;
}
- // Helper method used by InternalGetSatelliteAssembly only. Not abstracted for use elsewhere.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- private RuntimeAssembly InternalProbeForSatelliteAssemblyNextToParentAssembly(AssemblyName an,
- String name,
- String codeBase,
- CultureInfo culture,
- bool throwOnFileNotFound,
- bool useLoadFile,
- ref StackCrawlMark stackMark)
- {
- // if useLoadFile == false, we do LoadFrom binds
-
- RuntimeAssembly retAssembly = null;
- String location = null;
-
- if (useLoadFile)
- location = Location;
-
- FileNotFoundException dllNotFoundException = null;
-
- StringBuilder assemblyFile = new StringBuilder(useLoadFile ? location : codeBase,
- 0,
- useLoadFile ? location.LastIndexOf('\\') + 1 : codeBase.LastIndexOf('/') + 1,
- Path.MaxPath);
- assemblyFile.Append(an.CultureInfo.Name);
- assemblyFile.Append(useLoadFile ? '\\' : '/');
- assemblyFile.Append(name);
- assemblyFile.Append(".DLL");
-
- string fileNameOrCodeBase = assemblyFile.ToString();
-
- AssemblyName loadFromAsmName = null;
-
- if (useLoadFile == false)
- {
- loadFromAsmName = new AssemblyName();
- // set just the codebase - we want this to be a pure LoadFrom
- loadFromAsmName.CodeBase = fileNameOrCodeBase;
- }
-
- try
- {
- try
- {
- retAssembly = useLoadFile ? nLoadFile(fileNameOrCodeBase, null) :
- nLoad(loadFromAsmName, fileNameOrCodeBase, null, this, ref stackMark,
- IntPtr.Zero,
- throwOnFileNotFound, false, false);
- }
- catch (FileNotFoundException)
- {
- // Create our own exception since the one caught doesn't have a filename associated with it, making it less useful for debugging.
- dllNotFoundException = new FileNotFoundException(String.Format(culture,
- Environment.GetResourceString("IO.FileNotFound_FileName"),
- fileNameOrCodeBase),
- fileNameOrCodeBase); // Save this exception so we can throw it if we also don't find the .EXE
- retAssembly = null;
- }
-
- if (retAssembly == null)
- {
- // LoadFile will always throw, but LoadFrom will only throw if throwOnFileNotFound is true.
- // If an exception was thrown, we must have a dllNotFoundException ready for throwing later.
- BCLDebug.Assert((useLoadFile == false && throwOnFileNotFound == false) || dllNotFoundException != null,
- "(useLoadFile == false && throwOnFileNotFound == false) || dllNotFoundException != null");
-
- assemblyFile.Remove(assemblyFile.Length - 4, 4);
- assemblyFile.Append(".EXE");
- fileNameOrCodeBase = assemblyFile.ToString();
-
- if (useLoadFile == false)
- loadFromAsmName.CodeBase = fileNameOrCodeBase;
-
- try
- {
- retAssembly = useLoadFile ? nLoadFile(fileNameOrCodeBase, null) :
- nLoad(loadFromAsmName, fileNameOrCodeBase, null, this, ref stackMark,
- IntPtr.Zero,
- false /* do not throw on file not found */, false, false);
-
- }
- catch (FileNotFoundException)
- {
- retAssembly = null;
- }
-
- // It would be messy to have a FileNotFoundException that reports both .DLL and .EXE not found.
- // Using a .DLL extension for satellite assemblies is the more common scenario,
- // so just throw that exception.
-
- // In classic (i.e. non-AppX) mode, if binder logging is turned on, there will be separate logs for
- // the .DLL and .EXE load attempts if the user is interested in digging deeper.
-
- if (retAssembly == null && throwOnFileNotFound)
- throw dllNotFoundException;
- }
- }
- catch (DirectoryNotFoundException)
- {
- if (throwOnFileNotFound)
- throw;
- retAssembly = null;
- }
- // No other exceptions should be caught here.
-
- return retAssembly;
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern RuntimeAssembly nLoadFile(String path, Evidence evidence);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern RuntimeAssembly nLoadImage(byte[] rawAssembly,
- byte[] rawSymbolStore,
- Evidence evidence,
- ref StackCrawlMark stackMark,
- bool fIntrospection,
- SecurityContextSource securityContextSource);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- static internal extern unsafe void nLoadFromUnmanagedArray(bool fIntrospection,
- byte* assemblyContent,
- ulong assemblySize,
- byte* pdbContent,
- ulong pdbSize,
- StackCrawlMarkHandle stackMark,
- ObjectHandleOnStack retAssembly);
-
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private extern static void GetModules(RuntimeAssembly assembly,
diff --git a/src/mscorlib/src/System/Reflection/AssemblyAttributes.cs b/src/mscorlib/src/System/Reflection/AssemblyAttributes.cs
index b2e44b0034..1e6688d1f4 100644
--- a/src/mscorlib/src/System/Reflection/AssemblyAttributes.cs
+++ b/src/mscorlib/src/System/Reflection/AssemblyAttributes.cs
@@ -20,7 +20,6 @@ namespace System.Reflection {
using System.Diagnostics.Contracts;
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyCopyrightAttribute : Attribute
{
private String m_copyright;
@@ -38,7 +37,6 @@ namespace System.Reflection {
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyTrademarkAttribute : Attribute
{
private String m_trademark;
@@ -56,7 +54,6 @@ namespace System.Reflection {
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyProductAttribute : Attribute
{
private String m_product;
@@ -74,7 +71,6 @@ namespace System.Reflection {
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyCompanyAttribute : Attribute
{
private String m_company;
@@ -92,7 +88,6 @@ namespace System.Reflection {
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyDescriptionAttribute : Attribute
{
private String m_description;
@@ -110,7 +105,6 @@ namespace System.Reflection {
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyTitleAttribute : Attribute
{
private String m_title;
@@ -128,7 +122,6 @@ namespace System.Reflection {
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyConfigurationAttribute : Attribute
{
private String m_configuration;
@@ -146,7 +139,6 @@ namespace System.Reflection {
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyDefaultAliasAttribute : Attribute
{
private String m_defaultAlias;
@@ -164,7 +156,6 @@ namespace System.Reflection {
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyInformationalVersionAttribute : Attribute
{
private String m_informationalVersion;
@@ -182,7 +173,6 @@ namespace System.Reflection {
[AttributeUsage(AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyFileVersionAttribute : Attribute
{
private String _version;
@@ -202,7 +192,6 @@ namespace System.Reflection {
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public unsafe sealed class AssemblyCultureAttribute : Attribute
{
private String m_culture;
@@ -220,7 +209,6 @@ namespace System.Reflection {
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public unsafe sealed class AssemblyVersionAttribute : Attribute
{
private String m_version;
@@ -238,7 +226,6 @@ namespace System.Reflection {
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyKeyFileAttribute : Attribute
{
private String m_keyFile;
@@ -256,7 +243,6 @@ namespace System.Reflection {
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyDelaySignAttribute : Attribute
{
private bool m_delaySign;
@@ -274,7 +260,6 @@ namespace System.Reflection {
[AttributeUsage(AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public unsafe sealed class AssemblyAlgorithmIdAttribute : Attribute
{
private uint m_algId;
@@ -299,7 +284,6 @@ namespace System.Reflection {
[AttributeUsage(AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public unsafe sealed class AssemblyFlagsAttribute : Attribute
{
private AssemblyNameFlags m_flags;
@@ -360,7 +344,6 @@ namespace System.Reflection {
}
}
-#if FEATURE_STRONGNAME_MIGRATION
[AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple=false)]
public sealed class AssemblySignatureKeyAttribute : Attribute
{
@@ -383,10 +366,8 @@ namespace System.Reflection {
get { return _countersignature; }
}
}
-#endif
[AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AssemblyKeyNameAttribute : Attribute
{
private String m_keyName;
diff --git a/src/mscorlib/src/System/Reflection/AssemblyName.cs b/src/mscorlib/src/System/Reflection/AssemblyName.cs
index 48eab33ee5..01be855646 100644
--- a/src/mscorlib/src/System/Reflection/AssemblyName.cs
+++ b/src/mscorlib/src/System/Reflection/AssemblyName.cs
@@ -20,17 +20,13 @@ namespace System.Reflection {
using System.Runtime.CompilerServices;
using CultureInfo = System.Globalization.CultureInfo;
using System.Runtime.Serialization;
- using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
using System.Text;
[Serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_AssemblyName))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class AssemblyName : _AssemblyName, ICloneable, ISerializable, IDeserializationCallback
+ public sealed class AssemblyName : ICloneable, ISerializable, IDeserializationCallback
{
//
// READ ME
@@ -136,7 +132,6 @@ namespace System.Reflection {
}
}
- [System.Runtime.InteropServices.ComVisible(false)]
public AssemblyContentType ContentType
{
get
@@ -192,7 +187,6 @@ namespace System.Reflection {
// Assembly.GetNameInternal() will not demand path discovery
// permission, so do that first.
string fullPath = Path.GetFullPath(assemblyFile);
- new FileIOPermission( FileIOPermissionAccess.PathDiscovery, fullPath ).Demand();
return nGetFileInformation(fullPath);
}
diff --git a/src/mscorlib/src/System/Reflection/AssemblyNameFlags.cs b/src/mscorlib/src/System/Reflection/AssemblyNameFlags.cs
index 35a5370cc6..b86955efa5 100644
--- a/src/mscorlib/src/System/Reflection/AssemblyNameFlags.cs
+++ b/src/mscorlib/src/System/Reflection/AssemblyNameFlags.cs
@@ -19,7 +19,6 @@ namespace System.Reflection {
using System;
[Serializable]
[FlagsAttribute()]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum AssemblyNameFlags
{
None = 0x0000,
@@ -35,7 +34,6 @@ namespace System.Reflection {
}
[Serializable]
- [System.Runtime.InteropServices.ComVisible(false)]
public enum AssemblyContentType
{
Default = 0x0000,
@@ -43,7 +41,6 @@ namespace System.Reflection {
}
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum ProcessorArchitecture
{
None = 0x0000,
diff --git a/src/mscorlib/src/System/Reflection/AssemblyNameProxy.cs b/src/mscorlib/src/System/Reflection/AssemblyNameProxy.cs
deleted file mode 100644
index 8c8fa8d286..0000000000
--- a/src/mscorlib/src/System/Reflection/AssemblyNameProxy.cs
+++ /dev/null
@@ -1,28 +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.
-
-/*============================================================
-**
-**
-**
-**
-**
-**
-** Purpose: Remotable version the AssemblyName
-**
-**
-===========================================================*/
-namespace System.Reflection {
- using System;
- using System.Runtime.Versioning;
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public class AssemblyNameProxy : MarshalByRefObject
- {
- public AssemblyName GetAssemblyName(String assemblyFile)
- {
- return AssemblyName.GetAssemblyName(assemblyFile);
- }
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/Binder.cs b/src/mscorlib/src/System/Reflection/Binder.cs
index d06899f6c6..bf4545fe81 100644
--- a/src/mscorlib/src/System/Reflection/Binder.cs
+++ b/src/mscorlib/src/System/Reflection/Binder.cs
@@ -16,8 +16,6 @@ namespace System.Reflection {
using CultureInfo = System.Globalization.CultureInfo;
[Serializable]
- [ClassInterface(ClassInterfaceType.AutoDual)]
-[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Binder
{
// Given a set of methods that match the basic criteria, select a method to
diff --git a/src/mscorlib/src/System/Reflection/BindingFlags.cs b/src/mscorlib/src/System/Reflection/BindingFlags.cs
index 591dfbb249..ae0a6d68d3 100644
--- a/src/mscorlib/src/System/Reflection/BindingFlags.cs
+++ b/src/mscorlib/src/System/Reflection/BindingFlags.cs
@@ -17,7 +17,6 @@ namespace System.Reflection {
using System;
[Serializable]
[Flags]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum BindingFlags
{
diff --git a/src/mscorlib/src/System/Reflection/CallingConventions.cs b/src/mscorlib/src/System/Reflection/CallingConventions.cs
index 6ca11c9021..266dd55184 100644
--- a/src/mscorlib/src/System/Reflection/CallingConventions.cs
+++ b/src/mscorlib/src/System/Reflection/CallingConventions.cs
@@ -15,7 +15,6 @@ namespace System.Reflection {
using System;
[Serializable]
[Flags]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum CallingConventions
{
//NOTE: If you change this please update COMMember.cpp. These
diff --git a/src/mscorlib/src/System/Reflection/ComInterfaces.cs b/src/mscorlib/src/System/Reflection/ComInterfaces.cs
deleted file mode 100644
index 6e4b0cc19a..0000000000
--- a/src/mscorlib/src/System/Reflection/ComInterfaces.cs
+++ /dev/null
@@ -1,115 +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("BCA8B44D-AAD6-3A86-8AB7-03349F4F2DA2")]
- [CLSCompliant(false)]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [TypeLibImportClassAttribute(typeof(System.Type))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _Type
- {
- }
-
- [GuidAttribute("17156360-2f1a-384a-bc52-fde93c215c5b")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsDual)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Assembly))]
- [CLSCompliant(false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _Assembly
- {
- }
-
- [GuidAttribute("f7102fa9-cabb-3a74-a6da-b4567ef1b079")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.MemberInfo))]
- [CLSCompliant(false)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _MemberInfo
- {
- }
-
- [GuidAttribute("6240837A-707F-3181-8E98-A36AE086766B")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.MethodBase))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _MethodBase
- {
- }
-
- [GuidAttribute("FFCC1B5D-ECB8-38DD-9B01-3DC8ABC2AA5F")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.MethodInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _MethodInfo
- {
- }
-
- [GuidAttribute("E9A19478-9646-3679-9B10-8411AE1FD57D")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.ConstructorInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _ConstructorInfo
- {
- }
-
- [GuidAttribute("8A7C1442-A9FB-366B-80D8-4939FFA6DBE0")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.FieldInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _FieldInfo
- {
- }
-
- [GuidAttribute("F59ED4E4-E68F-3218-BD77-061AA82824BF")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.PropertyInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _PropertyInfo
- {
- }
-
- [GuidAttribute("9DE59C64-D889-35A1-B897-587D74469E5B")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.EventInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _EventInfo
- {
- }
-
- [GuidAttribute("993634C4-E47A-32CC-BE08-85F567DC27D6")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.ParameterInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _ParameterInfo
- {
- }
-
- [GuidAttribute("D002E9BA-D9E3-3749-B1D3-D565A08B13E7")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.Module))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _Module
- {
- }
-
- [GuidAttribute("B42B6AAC-317E-34D5-9FA9-093BB4160C50")]
- [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- [CLSCompliant(false)]
- [TypeLibImportClassAttribute(typeof(System.Reflection.AssemblyName))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public interface _AssemblyName
- {
- }
-}
-
diff --git a/src/mscorlib/src/System/Reflection/ConstructorInfo.cs b/src/mscorlib/src/System/Reflection/ConstructorInfo.cs
index 3d927fc85c..c8d71bc1f9 100644
--- a/src/mscorlib/src/System/Reflection/ConstructorInfo.cs
+++ b/src/mscorlib/src/System/Reflection/ConstructorInfo.cs
@@ -16,23 +16,17 @@ namespace System.Reflection
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security;
- using System.Security.Permissions;
using System.Threading;
using MemberListType = System.RuntimeType.MemberListType;
using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
using System.Runtime.CompilerServices;
[Serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_ConstructorInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public abstract class ConstructorInfo : MethodBase, _ConstructorInfo
+ public abstract class ConstructorInfo : MethodBase
{
#region Static Members
- [System.Runtime.InteropServices.ComVisible(true)]
public readonly static String ConstructorName = ".ctor";
- [System.Runtime.InteropServices.ComVisible(true)]
public readonly static String TypeConstructorName = ".cctor";
#endregion
@@ -73,7 +67,6 @@ namespace System.Reflection
#endregion
#region MemberInfo Overrides
- [System.Runtime.InteropServices.ComVisible(true)]
public override MemberTypes MemberType { get { return System.Reflection.MemberTypes.Constructor; } }
#endregion
@@ -136,14 +129,6 @@ namespace System.Reflection
return false;
}
-
- internal override bool IsDynamicallyInvokable
- {
- get
- {
- return !AppDomain.ProfileAPICheck || !IsNonW8PFrameworkAPI();
- }
- }
#endif // FEATURE_APPX
internal INVOCATION_FLAGS InvocationFlags
@@ -226,7 +211,6 @@ namespace System.Reflection
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
RuntimeConstructorInfo m = o as RuntimeConstructorInfo;
@@ -271,20 +255,6 @@ namespace System.Reflection
}
internal BindingFlags BindingFlags { get { return m_bindingFlags; } }
-
- // Differs from MethodHandle in that it will return a valid handle even for reflection only loaded types
- internal RuntimeMethodHandle GetMethodHandle()
- {
- return new RuntimeMethodHandle(this);
- }
-
- internal bool IsOverloaded
- {
- get
- {
- return m_reflectedTypeCache.GetConstructorList(MemberListType.CaseSensitive, Name).Length > 1;
- }
- }
#endregion
#region Object Overrides
@@ -344,7 +314,6 @@ namespace System.Reflection
{
get { return RuntimeMethodHandle.GetName(this); }
}
-[System.Runtime.InteropServices.ComVisible(true)]
public override MemberTypes MemberType { get { return MemberTypes.Constructor; } }
public override Type DeclaringType
@@ -537,11 +506,7 @@ namespace System.Reflection
}
return RuntimeMethodHandle.InvokeMethod(obj, null, sig, false);
}
-
-#pragma warning disable 618
- [ReflectionPermissionAttribute(SecurityAction.Demand, Flags = ReflectionPermissionFlag.MemberAccess)]
-#pragma warning restore 618
public override MethodBody GetMethodBody()
{
MethodBody mb = RuntimeMethodHandle.GetMethodBody(this, ReflectedTypeInternal);
@@ -644,11 +609,6 @@ namespace System.Reflection
// We don't need the return type for constructors.
return FormatNameAndSig(true);
}
-
- internal void SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
- {
- RuntimeMethodHandle.SerializationInvoke(this, target, info, ref context);
- }
#endregion
}
}
diff --git a/src/mscorlib/src/System/Reflection/CustomAttribute.cs b/src/mscorlib/src/System/Reflection/CustomAttribute.cs
index e568a1702f..b71c7bbff3 100644
--- a/src/mscorlib/src/System/Reflection/CustomAttribute.cs
+++ b/src/mscorlib/src/System/Reflection/CustomAttribute.cs
@@ -14,7 +14,6 @@ using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Globalization;
using System.Security;
-using System.Security.Permissions;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
@@ -22,7 +21,6 @@ using System.Diagnostics.Contracts;
namespace System.Reflection
{
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public class CustomAttributeData
{
#region Public Static Members
@@ -515,10 +513,8 @@ namespace System.Reflection
#region Public Members
public Type AttributeType { get { return Constructor.DeclaringType; } }
- [System.Runtime.InteropServices.ComVisible(true)]
public virtual ConstructorInfo Constructor { get { return m_ctor; } }
- [System.Runtime.InteropServices.ComVisible(true)]
public virtual IList<CustomAttributeTypedArgument> ConstructorArguments
{
get
@@ -576,7 +572,6 @@ namespace System.Reflection
}
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public struct CustomAttributeNamedArgument
{
#region Public Static Members
@@ -666,7 +661,6 @@ namespace System.Reflection
}
[Serializable]
- [ComVisible(true)]
public struct CustomAttributeTypedArgument
{
#region Public Static Members
@@ -1106,24 +1100,6 @@ namespace System.Reflection
#endregion
}
- // Note: This is a managed representation of a frame type defined in vm\frames.h; please ensure the layout remains
- // synchronized.
- [StructLayout(LayoutKind.Sequential)]
- internal struct SecurityContextFrame
- {
- IntPtr m_GSCookie; // This is actually at a negative offset in the real frame definition
- IntPtr __VFN_table; // This is the real start of the SecurityContextFrame
- IntPtr m_Next;
- IntPtr m_Assembly;
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public extern void Push(RuntimeAssembly assembly);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- public extern void Pop();
- }
-
[Serializable]
[StructLayout(LayoutKind.Auto)]
internal struct CustomAttributeType
@@ -1153,7 +1129,6 @@ namespace System.Reflection
public CustomAttributeEncoding EncodedType { get { return m_encodedType; } }
public CustomAttributeEncoding EncodedEnumType { get { return m_encodedEnumType; } }
public CustomAttributeEncoding EncodedArrayType { get { return m_encodedArrayType; } }
- [System.Runtime.InteropServices.ComVisible(true)]
public string EnumName { get { return m_enumName; } }
#endregion
}
@@ -1621,16 +1596,6 @@ namespace System.Reflection
object[] attributes = CreateAttributeArrayHelper(arrayType, car.Length);
int cAttributes = 0;
- // Custom attribute security checks are done with respect to the assembly *decorated* with the
- // custom attribute as opposed to the *caller of GetCustomAttributes*.
- // Since this assembly might not be on the stack and the attribute ctor or property setters we're about to invoke may
- // make security demands, we push a frame on the stack as a proxy for the decorated assembly (this frame will be picked
- // up an interpreted by the security stackwalker).
- // Once we push the frame it will be automatically popped in the event of an exception, so no need to use CERs or the
- // like.
- SecurityContextFrame frame = new SecurityContextFrame();
- frame.Push(decoratedModule.GetRuntimeAssembly());
-
// Optimization for the case where attributes decorate entities in the same assembly in which case
// we can cache the successful APTCA check between the decorated and the declared assembly.
Assembly lastAptcaOkAssembly = null;
@@ -1780,10 +1745,6 @@ namespace System.Reflection
attributes[cAttributes++] = attribute;
}
- // The frame will be popped automatically if we take an exception any time after we pushed it. So no need of a catch or
- // finally or CERs here.
- frame.Pop();
-
if (cAttributes == car.Length && pcaCount == 0)
return attributes;
@@ -2069,9 +2030,8 @@ namespace System.Reflection
#region Internal Static
internal static bool IsSecurityAttribute(RuntimeType type)
{
-#pragma warning disable 618
- return type == (RuntimeType)typeof(SecurityAttribute) || type.IsSubclassOf(typeof(SecurityAttribute));
-#pragma warning restore 618
+ // TODO: Cleanup
+ return false;
}
internal static Attribute[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool includeSecCa, out int count)
diff --git a/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs b/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs
index 3eb8b1f1ef..9aee911a6c 100644
--- a/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs
+++ b/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs
@@ -15,7 +15,6 @@ namespace System.Reflection {
using ApplicationException = System.ApplicationException;
using System.Runtime.Serialization;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public class CustomAttributeFormatException : FormatException {
public CustomAttributeFormatException()
diff --git a/src/mscorlib/src/System/Reflection/DefaultMemberAttribute.cs b/src/mscorlib/src/System/Reflection/DefaultMemberAttribute.cs
index 1fec75906a..4232fcd2a1 100644
--- a/src/mscorlib/src/System/Reflection/DefaultMemberAttribute.cs
+++ b/src/mscorlib/src/System/Reflection/DefaultMemberAttribute.cs
@@ -19,7 +19,6 @@ namespace System.Reflection {
[Serializable]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class DefaultMemberAttribute : Attribute
{
// The name of the member
diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
index 9331ae193c..5575e28917 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 5c86d8ec87..b3d1711307 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 f0f83e7d2a..7ac9daeac0 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 8dba934bde..0000000000
--- 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 ef76adcf80..3bc02860a1 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 545657a053..5d08ca08f0 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 9e1d82986a..cb2667a104 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 1b8c97de65..f1d99d3c2c 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 82dc2828ca..96564d537b 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 449b20824c..34c76b93d1 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 0642cec822..8ffdce9732 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 595d60ada0..5953b67173 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 42fd684e7c..add428f96e 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 31bb564cf4..9e528b2551 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 6987ea139d..894f57d49c 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 ed0763bfda..2cee63ff2e 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 a737895829..e6f4622f0e 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 dd248b62fe..c7b987ff10 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 a34d5ebe5d..fe4c33160a 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 654e166a05..17c8ce074d 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 5b69b6e607..57ad1665c0 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 cc28e173d7..76b7279f30 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 6884f50b0e..30e6382550 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 96e60d9a4e..4b6f8b4efe 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 345694ec80..324fad9ceb 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 d7bfacd568..74a9de16b6 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 3636cb7377..87dea058e5 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 808844a017..e972e8603d 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 d9c9c0327c..531ff41dd7 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 7909562baa..1b3babf595 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 d65368bf0d..a4a32a51fb 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 e7442b4e02..7c4ed9dc0f 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 d70cad057a..72ab983bb9 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 c40035bc40..b43abcb51c 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 0a87ac1398..5c908b89c7 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 2d2c35ef26..8a447d03fc 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 cb0e979a7a..852225697c 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 84ece90982..205299125b 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 73778d5f27..88502cb096 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 3bae585953..da5a56ba28 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 228755641c..4fa851c529 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 28e95e2456..0000000000
--- 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 aaaffc0df6..ca0faf31ca 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
diff --git a/src/mscorlib/src/System/Reflection/EventAttributes.cs b/src/mscorlib/src/System/Reflection/EventAttributes.cs
index c0285652ff..4cc08f62d3 100644
--- a/src/mscorlib/src/System/Reflection/EventAttributes.cs
+++ b/src/mscorlib/src/System/Reflection/EventAttributes.cs
@@ -16,7 +16,6 @@ namespace System.Reflection {
using System;
[Serializable]
[Flags]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum EventAttributes {
None = 0x0000,
diff --git a/src/mscorlib/src/System/Reflection/EventInfo.cs b/src/mscorlib/src/System/Reflection/EventInfo.cs
index 0eabb9d03a..9b529c2960 100644
--- a/src/mscorlib/src/System/Reflection/EventInfo.cs
+++ b/src/mscorlib/src/System/Reflection/EventInfo.cs
@@ -13,14 +13,10 @@ namespace System.Reflection
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.ConstrainedExecution;
- using System.Security.Permissions;
using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
[Serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_EventInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public abstract class EventInfo : MemberInfo, _EventInfo
+ public abstract class EventInfo : MemberInfo
{
#region Constructor
protected EventInfo() { }
@@ -236,7 +232,6 @@ namespace System.Reflection
#endregion
#region Internal Members
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
RuntimeEventInfo m = o as RuntimeEventInfo;
diff --git a/src/mscorlib/src/System/Reflection/FieldAttributes.cs b/src/mscorlib/src/System/Reflection/FieldAttributes.cs
index 48c90a1a38..e49a0a45b1 100644
--- a/src/mscorlib/src/System/Reflection/FieldAttributes.cs
+++ b/src/mscorlib/src/System/Reflection/FieldAttributes.cs
@@ -8,7 +8,6 @@ namespace System.Reflection
// This Enum matchs the CorFieldAttr defined in CorHdr.h
[Serializable]
[Flags()]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum FieldAttributes
{
// member access mask - Use this mask to retrieve accessibility information.
diff --git a/src/mscorlib/src/System/Reflection/FieldInfo.cs b/src/mscorlib/src/System/Reflection/FieldInfo.cs
index e61207a686..7b6517c2bb 100644
--- a/src/mscorlib/src/System/Reflection/FieldInfo.cs
+++ b/src/mscorlib/src/System/Reflection/FieldInfo.cs
@@ -16,15 +16,11 @@ namespace System.Reflection
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
- using System.Security.Permissions;
using System.Threading;
using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
[Serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_FieldInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public abstract class FieldInfo : MemberInfo, _FieldInfo
+ public abstract class FieldInfo : MemberInfo
{
#region Static Members
public static FieldInfo GetFieldFromHandle(RuntimeFieldHandle handle)
@@ -43,7 +39,6 @@ namespace System.Reflection
return f;
}
- [System.Runtime.InteropServices.ComVisible(false)]
public static FieldInfo GetFieldFromHandle(RuntimeFieldHandle handle, RuntimeTypeHandle declaringType)
{
if (handle.IsNullHandle())
@@ -454,7 +449,6 @@ namespace System.Reflection
}
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
RtFieldInfo m = o as RtFieldInfo;
@@ -757,7 +751,6 @@ namespace System.Reflection
#endregion
#region Internal Members
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
MdFieldInfo m = o as MdFieldInfo;
diff --git a/src/mscorlib/src/System/Reflection/ICustomAttributeProvider.cs b/src/mscorlib/src/System/Reflection/ICustomAttributeProvider.cs
index 1fd361c889..faea91a81e 100644
--- a/src/mscorlib/src/System/Reflection/ICustomAttributeProvider.cs
+++ b/src/mscorlib/src/System/Reflection/ICustomAttributeProvider.cs
@@ -15,7 +15,6 @@ namespace System.Reflection {
using System;
// Interface does not need to be marked with the serializable attribute
-[System.Runtime.InteropServices.ComVisible(true)]
public interface ICustomAttributeProvider
{
diff --git a/src/mscorlib/src/System/Reflection/IReflect.cs b/src/mscorlib/src/System/Reflection/IReflect.cs
index 92ce3412fc..1c3c57613b 100644
--- a/src/mscorlib/src/System/Reflection/IReflect.cs
+++ b/src/mscorlib/src/System/Reflection/IReflect.cs
@@ -20,7 +20,6 @@ namespace System.Reflection {
// Interface does not need to be marked with the serializable attribute
[Guid("AFBF15E5-C37C-11d2-B88E-00A0C9B471B8")]
-[System.Runtime.InteropServices.ComVisible(true)]
public interface IReflect
{
// Return the requested method if it is implemented by the Reflection object. The
diff --git a/src/mscorlib/src/System/Reflection/InterfaceMapping.cs b/src/mscorlib/src/System/Reflection/InterfaceMapping.cs
index 488ef4484d..bf994f7b47 100644
--- a/src/mscorlib/src/System/Reflection/InterfaceMapping.cs
+++ b/src/mscorlib/src/System/Reflection/InterfaceMapping.cs
@@ -13,15 +13,10 @@
namespace System.Reflection {
using System;
-[System.Runtime.InteropServices.ComVisible(true)]
public struct InterfaceMapping {
-[System.Runtime.InteropServices.ComVisible(true)]
public Type TargetType; // The type implementing the interface
-[System.Runtime.InteropServices.ComVisible(true)]
public Type InterfaceType; // The type representing the interface
-[System.Runtime.InteropServices.ComVisible(true)]
public MethodInfo[] TargetMethods; // The methods implementing the interface
-[System.Runtime.InteropServices.ComVisible(true)]
public MethodInfo[] InterfaceMethods; // The methods defined on the interface
}
}
diff --git a/src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs b/src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs
index fa95e37ad5..8b8c06d9cf 100644
--- a/src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs
+++ b/src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs
@@ -18,7 +18,6 @@ namespace System.Reflection {
using System.Runtime.Serialization;
using ApplicationException = System.ApplicationException;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public class InvalidFilterCriteriaException : ApplicationException {
public InvalidFilterCriteriaException()
: base(Environment.GetResourceString("Arg_InvalidFilterCriteriaException")) {
diff --git a/src/mscorlib/src/System/Reflection/ManifestResourceInfo.cs b/src/mscorlib/src/System/Reflection/ManifestResourceInfo.cs
index a53d32abdb..91c7ceb2ea 100644
--- a/src/mscorlib/src/System/Reflection/ManifestResourceInfo.cs
+++ b/src/mscorlib/src/System/Reflection/ManifestResourceInfo.cs
@@ -16,7 +16,6 @@
namespace System.Reflection {
using System;
-[System.Runtime.InteropServices.ComVisible(true)]
public class ManifestResourceInfo {
private Assembly _containingAssembly;
private String _containingFileName;
@@ -57,7 +56,6 @@ namespace System.Reflection {
// Linked means not Embedded.
[Serializable]
[Flags]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum ResourceLocation
{
Embedded = 0x1,
diff --git a/src/mscorlib/src/System/Reflection/MdImport.cs b/src/mscorlib/src/System/Reflection/MdImport.cs
index bbdf948f99..b1d9c5eae8 100644
--- a/src/mscorlib/src/System/Reflection/MdImport.cs
+++ b/src/mscorlib/src/System/Reflection/MdImport.cs
@@ -9,7 +9,6 @@ using System.Reflection;
using System.Globalization;
using System.Threading;
using System.Diagnostics;
-using System.Security.Permissions;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Security;
@@ -408,7 +407,7 @@ namespace System.Reflection
return null;
char[] c = new char[length];
- for (int i = 0; i < length; i ++)
+ for (int i = 0; i < c.Length; i ++)
{
#if ALIGN_ACCESS
c[i] = (char)Marshal.ReadInt16( (IntPtr) (((char*)name) + i) );
diff --git a/src/mscorlib/src/System/Reflection/MemberFilter.cs b/src/mscorlib/src/System/Reflection/MemberFilter.cs
index b476409d5d..56fc9c0804 100644
--- a/src/mscorlib/src/System/Reflection/MemberFilter.cs
+++ b/src/mscorlib/src/System/Reflection/MemberFilter.cs
@@ -14,6 +14,5 @@ namespace System.Reflection {
// Define the delegate
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public delegate bool MemberFilter(MemberInfo m, Object filterCriteria);
}
diff --git a/src/mscorlib/src/System/Reflection/MemberInfo.cs b/src/mscorlib/src/System/Reflection/MemberInfo.cs
index 96a89ad37b..5ecbfe06a1 100644
--- a/src/mscorlib/src/System/Reflection/MemberInfo.cs
+++ b/src/mscorlib/src/System/Reflection/MemberInfo.cs
@@ -11,13 +11,9 @@ namespace System.Reflection
using System.Diagnostics.Contracts;
using System.Runtime;
using System.Runtime.InteropServices;
- using System.Security.Permissions;
[Serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_MemberInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public abstract class MemberInfo : ICustomAttributeProvider, _MemberInfo
+ public abstract class MemberInfo : ICustomAttributeProvider
{
#region Constructor
protected MemberInfo() { }
diff --git a/src/mscorlib/src/System/Reflection/MemberTypes.cs b/src/mscorlib/src/System/Reflection/MemberTypes.cs
index 352a80244e..95c41022f1 100644
--- a/src/mscorlib/src/System/Reflection/MemberTypes.cs
+++ b/src/mscorlib/src/System/Reflection/MemberTypes.cs
@@ -17,7 +17,6 @@ namespace System.Reflection {
// This Enum matchs the CorTypeAttr defined in CorHdr.h
[Serializable]
[Flags()]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum MemberTypes
{
// The following are the known classes which extend MemberInfo
diff --git a/src/mscorlib/src/System/Reflection/MethodAttributes.cs b/src/mscorlib/src/System/Reflection/MethodAttributes.cs
index 92b637b9c0..7e4391cccd 100644
--- a/src/mscorlib/src/System/Reflection/MethodAttributes.cs
+++ b/src/mscorlib/src/System/Reflection/MethodAttributes.cs
@@ -10,7 +10,6 @@ namespace System.Reflection
using System;
[Serializable]
[Flags]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum MethodAttributes
{
// NOTE: This Enum matchs the CorMethodAttr defined in CorHdr.h
diff --git a/src/mscorlib/src/System/Reflection/MethodBase.cs b/src/mscorlib/src/System/Reflection/MethodBase.cs
index 644a1ac0b0..3109821ac9 100644
--- a/src/mscorlib/src/System/Reflection/MethodBase.cs
+++ b/src/mscorlib/src/System/Reflection/MethodBase.cs
@@ -11,7 +11,6 @@ namespace System.Reflection
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
- using System.Security.Permissions;
using System.Text;
using System.Threading;
@@ -48,10 +47,7 @@ namespace System.Reflection
}
[Serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_MethodBase))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public abstract class MethodBase : MemberInfo, _MethodBase
+ public abstract class MethodBase : MemberInfo
{
#region Static Members
public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
@@ -70,7 +66,6 @@ namespace System.Reflection
return m;
}
- [System.Runtime.InteropServices.ComVisible(false)]
public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType)
{
if (handle.IsNullHandle())
@@ -131,20 +126,6 @@ namespace System.Reflection
private IntPtr GetMethodDesc() { return MethodHandle.Value; }
#if FEATURE_APPX
-
- // The C# dynamic and VB late bound binders need to call this API. Since we don't have time to make this
- // public in Dev11, the C# and VB binders currently call this through a delegate.
- // When we make this API public (hopefully) in Dev12 we need to change the C# and VB binders to call this
- // probably statically. The code is located in:
- // C#: ndp\fx\src\CSharp\Microsoft\CSharp\SymbolTable.cs - Microsoft.CSharp.RuntimeBinder.SymbolTable..cctor
- // VB: vb\runtime\msvbalib\helpers\Symbols.vb - Microsoft.VisualBasic.CompilerServices.Symbols..cctor
- internal virtual bool IsDynamicallyInvokable
- {
- get
- {
- return true;
- }
- }
#endif
#endregion
@@ -172,7 +153,6 @@ namespace System.Reflection
public virtual CallingConventions CallingConvention { get { return CallingConventions.Standard; } }
- [System.Runtime.InteropServices.ComVisible(true)]
public virtual Type[] GetGenericArguments() { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride")); }
public virtual bool IsGenericMethodDefinition { get { return false; } }
@@ -227,7 +207,6 @@ namespace System.Reflection
public bool IsSpecialName { get { return(Attributes & MethodAttributes.SpecialName) != 0; } }
- [System.Runtime.InteropServices.ComVisible(true)]
public bool IsConstructor
{
get
@@ -239,9 +218,6 @@ namespace System.Reflection
}
}
-#pragma warning disable 618
- [ReflectionPermissionAttribute(SecurityAction.Demand, Flags=ReflectionPermissionFlag.MemberAccess)]
-#pragma warning restore 618
public virtual MethodBody GetMethodBody()
{
throw new InvalidOperationException();
@@ -269,7 +245,7 @@ namespace System.Reflection
// Why don't we just use "&"?
if (t.IsByRef && !serialization)
{
- sbParamList.Append(typeName.TrimEnd(new char[] { '&' }));
+ sbParamList.Append(typeName.TrimEnd('&'));
sbParamList.Append(" ByRef");
}
else
diff --git a/src/mscorlib/src/System/Reflection/MethodBody.cs b/src/mscorlib/src/System/Reflection/MethodBody.cs
index 4634623e26..7cbaeaf9b9 100644
--- a/src/mscorlib/src/System/Reflection/MethodBody.cs
+++ b/src/mscorlib/src/System/Reflection/MethodBody.cs
@@ -13,7 +13,6 @@ using System.Diagnostics.Contracts;
namespace System.Reflection
{
[Flags()]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum ExceptionHandlingClauseOptions: int
{
Clause = 0x0,
@@ -22,7 +21,6 @@ namespace System.Reflection
Fault = 0x4,
}
- [System.Runtime.InteropServices.ComVisible(true)]
public class ExceptionHandlingClause
{
#region costructor
@@ -107,7 +105,6 @@ namespace System.Reflection
#endregion
}
- [System.Runtime.InteropServices.ComVisible(true)]
public class MethodBody
{
#region costructor
@@ -135,7 +132,6 @@ namespace System.Reflection
#endregion
}
- [System.Runtime.InteropServices.ComVisible(true)]
public class LocalVariableInfo
{
#region Private Data Members
diff --git a/src/mscorlib/src/System/Reflection/MethodImplAttributes.cs b/src/mscorlib/src/System/Reflection/MethodImplAttributes.cs
index 0fa4d00f19..1bd6b9dbd1 100644
--- a/src/mscorlib/src/System/Reflection/MethodImplAttributes.cs
+++ b/src/mscorlib/src/System/Reflection/MethodImplAttributes.cs
@@ -10,7 +10,6 @@ namespace System.Reflection
using System;
// This Enum matchs the CorMethodImpl defined in CorHdr.h
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum MethodImplAttributes
{
// code impl mask
@@ -36,7 +35,6 @@ namespace System.Reflection
Synchronized = 0x0020, // Method is single threaded through the body.
NoInlining = 0x0008, // Method may not be inlined.
- [System.Runtime.InteropServices.ComVisible(false)]
AggressiveInlining = 0x0100, // Method should be inlined if possible.
NoOptimization = 0x0040, // Method may not be optimized.
diff --git a/src/mscorlib/src/System/Reflection/MethodInfo.cs b/src/mscorlib/src/System/Reflection/MethodInfo.cs
index 39387b1f8f..5ce124614c 100644
--- a/src/mscorlib/src/System/Reflection/MethodInfo.cs
+++ b/src/mscorlib/src/System/Reflection/MethodInfo.cs
@@ -16,7 +16,6 @@ namespace System.Reflection
using System.Runtime.ConstrainedExecution;
using System.Runtime.Serialization;
using System.Security;
- using System.Security.Permissions;
using System.Text;
using System.Threading;
using MemberListType = System.RuntimeType.MemberListType;
@@ -24,10 +23,7 @@ namespace System.Reflection
using System.Runtime.CompilerServices;
[Serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_MethodInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public abstract class MethodInfo : MethodBase, _MethodInfo
+ public abstract class MethodInfo : MethodBase
{
#region Constructor
protected MethodInfo() { }
@@ -74,10 +70,8 @@ namespace System.Reflection
public abstract MethodInfo GetBaseDefinition();
- [System.Runtime.InteropServices.ComVisible(true)]
public override Type[] GetGenericArguments() { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride")); }
- [System.Runtime.InteropServices.ComVisible(true)]
public virtual MethodInfo GetGenericMethodDefinition() { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride")); }
public virtual MethodInfo MakeGenericMethod(params Type[] typeArguments) { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride")); }
@@ -133,14 +127,6 @@ namespace System.Reflection
return false;
}
-
- internal override bool IsDynamicallyInvokable
- {
- get
- {
- return !AppDomain.ProfileAPICheck || !IsNonW8PFrameworkAPI();
- }
- }
#endif
internal INVOCATION_FLAGS InvocationFlags
@@ -279,7 +265,6 @@ namespace System.Reflection
return sbName.ToString();
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
RuntimeMethodInfo m = o as RuntimeMethodInfo;
@@ -303,12 +288,6 @@ namespace System.Reflection
internal BindingFlags BindingFlags { get { return m_bindingFlags; } }
- // Differs from MethodHandle in that it will return a valid handle even for reflection only loaded types
- internal RuntimeMethodHandle GetMethodHandle()
- {
- return new RuntimeMethodHandle(this);
- }
-
internal RuntimeMethodInfo GetParentDefinition()
{
if (!IsVirtual || m_declaringType.IsInterface)
@@ -522,14 +501,6 @@ namespace System.Reflection
return RuntimeMethodHandle.GetImplAttributes(this);
}
- internal bool IsOverloaded
- {
- get
- {
- return m_reflectedTypeCache.GetMethodList(MemberListType.CaseSensitive, Name).Length > 1;
- }
- }
-
public override RuntimeMethodHandle MethodHandle
{
get
diff --git a/src/mscorlib/src/System/Reflection/Missing.cs b/src/mscorlib/src/System/Reflection/Missing.cs
index 24bf77bd4e..f62c5b538c 100644
--- a/src/mscorlib/src/System/Reflection/Missing.cs
+++ b/src/mscorlib/src/System/Reflection/Missing.cs
@@ -9,12 +9,10 @@ namespace System.Reflection
using System;
using System.Runtime.Remoting;
using System.Runtime.Serialization;
- using System.Security.Permissions;
using System.Diagnostics.Contracts;
// This is not serializable because it is a reflection command.
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class Missing : ISerializable
{
public static readonly Missing Value = new Missing();
diff --git a/src/mscorlib/src/System/Reflection/Module.cs b/src/mscorlib/src/System/Reflection/Module.cs
index b6be38e434..bdf95fca26 100644
--- a/src/mscorlib/src/System/Reflection/Module.cs
+++ b/src/mscorlib/src/System/Reflection/Module.cs
@@ -17,7 +17,6 @@ namespace System.Reflection
using System.Threading;
using System.Runtime.CompilerServices;
using System.Security;
- using System.Security.Permissions;
using System.IO;
using System.Globalization;
using System.Runtime.Versioning;
@@ -25,7 +24,6 @@ namespace System.Reflection
[Serializable]
[Flags]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum PortableExecutableKinds
{
NotAPortableExecutableImage = 0x0,
@@ -38,12 +36,10 @@ namespace System.Reflection
Unmanaged32Bit = 0x8,
- [ComVisible(false)]
Preferred32Bit = 0x10,
}
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum ImageFileMachine
{
I386 = 0x014c,
@@ -56,10 +52,7 @@ namespace System.Reflection
}
[Serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_Module))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public abstract class Module : _Module, ISerializable, ICustomAttributeProvider
+ public abstract class Module : ISerializable, ICustomAttributeProvider
{
#region Static Constructor
static Module()
@@ -276,18 +269,15 @@ namespace System.Reflection
throw new NotImplementedException();
}
- [System.Runtime.InteropServices.ComVisible(true)]
public virtual Type GetType(String className, bool ignoreCase)
{
return GetType(className, false, ignoreCase);
}
- [System.Runtime.InteropServices.ComVisible(true)]
public virtual Type GetType(String className) {
return GetType(className, false, false);
}
- [System.Runtime.InteropServices.ComVisible(true)]
public virtual Type GetType(String className, bool throwOnError, bool ignoreCase)
{
throw new NotImplementedException();
@@ -983,7 +973,6 @@ namespace System.Reflection
UnitySerializationHolder.GetUnitySerializationInfo(info, UnitySerializationHolder.ModuleUnity, this.ScopeName, this.GetRuntimeAssembly());
}
- [System.Runtime.InteropServices.ComVisible(true)]
public override Type GetType(String className, bool throwOnError, bool ignoreCase)
{
// throw on null strings regardless of the value of "throwOnError"
@@ -1008,22 +997,7 @@ namespace System.Reflection
{
get
{
- String fullyQualifiedName = GetFullyQualifiedName();
-
- if (fullyQualifiedName != null) {
- bool checkPermission = true;
- try {
- Path.GetFullPath(fullyQualifiedName);
- }
- catch(ArgumentException) {
- checkPermission = false;
- }
- if (checkPermission) {
- new FileIOPermission( FileIOPermissionAccess.PathDiscovery, fullyQualifiedName ).Demand();
- }
- }
-
- return fullyQualifiedName;
+ return GetFullyQualifiedName();
}
}
diff --git a/src/mscorlib/src/System/Reflection/ObfuscateAssemblyAttribute.cs b/src/mscorlib/src/System/Reflection/ObfuscateAssemblyAttribute.cs
index b852e5a4c2..787f37bced 100644
--- a/src/mscorlib/src/System/Reflection/ObfuscateAssemblyAttribute.cs
+++ b/src/mscorlib/src/System/Reflection/ObfuscateAssemblyAttribute.cs
@@ -11,7 +11,6 @@ using System.Reflection;
namespace System.Reflection
{
[AttributeUsage (AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ObfuscateAssemblyAttribute : Attribute
{
private bool m_assemblyIsPrivate;
diff --git a/src/mscorlib/src/System/Reflection/ObfuscationAttribute.cs b/src/mscorlib/src/System/Reflection/ObfuscationAttribute.cs
index 0b987ce06d..c7c7c18550 100644
--- a/src/mscorlib/src/System/Reflection/ObfuscationAttribute.cs
+++ b/src/mscorlib/src/System/Reflection/ObfuscationAttribute.cs
@@ -11,7 +11,6 @@ namespace System.Reflection
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Delegate,
AllowMultiple = true, Inherited = false)]
-[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ObfuscationAttribute: Attribute
{
private bool m_strip = true;
diff --git a/src/mscorlib/src/System/Reflection/ParameterAttributes.cs b/src/mscorlib/src/System/Reflection/ParameterAttributes.cs
index 12f8145ddd..acae3a6ec1 100644
--- a/src/mscorlib/src/System/Reflection/ParameterAttributes.cs
+++ b/src/mscorlib/src/System/Reflection/ParameterAttributes.cs
@@ -16,7 +16,6 @@ namespace System.Reflection {
// This Enum matchs the CorParamAttr defined in CorHdr.h
[Serializable]
[Flags]
- [System.Runtime.InteropServices.ComVisible(true)]
public enum ParameterAttributes
{
None = 0x0000, // no flag is specified
diff --git a/src/mscorlib/src/System/Reflection/ParameterInfo.cs b/src/mscorlib/src/System/Reflection/ParameterInfo.cs
index 6592e5aa20..fad4402aff 100644
--- a/src/mscorlib/src/System/Reflection/ParameterInfo.cs
+++ b/src/mscorlib/src/System/Reflection/ParameterInfo.cs
@@ -13,15 +13,11 @@ namespace System.Reflection
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.CompilerServices;
- using System.Security.Permissions;
using System.Threading;
using MdToken = System.Reflection.MetadataToken;
[Serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_ParameterInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public class ParameterInfo : _ParameterInfo, ICustomAttributeProvider, IObjectReference
+ public class ParameterInfo : ICustomAttributeProvider, IObjectReference
{
#region Legacy Protected Members
protected String NameImpl;
diff --git a/src/mscorlib/src/System/Reflection/ParameterModifier.cs b/src/mscorlib/src/System/Reflection/ParameterModifier.cs
index 97da1b9e00..a2bfeab934 100644
--- a/src/mscorlib/src/System/Reflection/ParameterModifier.cs
+++ b/src/mscorlib/src/System/Reflection/ParameterModifier.cs
@@ -7,7 +7,6 @@ namespace System.Reflection
using System;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public struct ParameterModifier
{
#region Private Data Members
diff --git a/src/mscorlib/src/System/Reflection/Pointer.cs b/src/mscorlib/src/System/Reflection/Pointer.cs
index 95025b20ed..9f1a38366a 100644
--- a/src/mscorlib/src/System/Reflection/Pointer.cs
+++ b/src/mscorlib/src/System/Reflection/Pointer.cs
@@ -19,7 +19,6 @@ namespace System.Reflection {
[CLSCompliant(false)]
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class Pointer : ISerializable
{
unsafe private void* _ptr;
diff --git a/src/mscorlib/src/System/Reflection/PropertyAttributes.cs b/src/mscorlib/src/System/Reflection/PropertyAttributes.cs
index d7c3d79b6a..4a5617ba5e 100644
--- a/src/mscorlib/src/System/Reflection/PropertyAttributes.cs
+++ b/src/mscorlib/src/System/Reflection/PropertyAttributes.cs
@@ -16,7 +16,6 @@ namespace System.Reflection {
// This Enum matchs the CorPropertyAttr defined in CorHdr.h
[Serializable]
[Flags]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum PropertyAttributes
{
None = 0x0000,
diff --git a/src/mscorlib/src/System/Reflection/PropertyInfo.cs b/src/mscorlib/src/System/Reflection/PropertyInfo.cs
index e31b378924..e8c2837785 100644
--- a/src/mscorlib/src/System/Reflection/PropertyInfo.cs
+++ b/src/mscorlib/src/System/Reflection/PropertyInfo.cs
@@ -15,15 +15,11 @@ namespace System.Reflection
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
- using System.Security.Permissions;
using System.Text;
using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
[Serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_PropertyInfo))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public abstract class PropertyInfo : MemberInfo, _PropertyInfo
+ public abstract class PropertyInfo : MemberInfo
{
#region Constructor
protected PropertyInfo() { }
@@ -196,7 +192,6 @@ namespace System.Reflection
#endregion
#region Internal Members
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal override bool CacheEquals(object o)
{
RuntimePropertyInfo m = o as RuntimePropertyInfo;
diff --git a/src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs b/src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs
index 70681138c5..cccf060645 100644
--- a/src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs
+++ b/src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs
@@ -19,10 +19,8 @@ namespace System.Reflection {
using System;
using System.Runtime.Serialization;
- using System.Security.Permissions;
using System.Diagnostics.Contracts;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class ReflectionTypeLoadException : SystemException, ISerializable {
private Type[] _classes;
private Exception[] _exceptions;
@@ -33,11 +31,6 @@ namespace System.Reflection {
SetErrorCode(__HResults.COR_E_REFLECTIONTYPELOAD);
}
- // private constructor. This is called from inside the runtime.
- private ReflectionTypeLoadException(String message) : base(message) {
- SetErrorCode(__HResults.COR_E_REFLECTIONTYPELOAD);
- }
-
public ReflectionTypeLoadException(Type[] classes, Exception[] exceptions) : base(null)
{
_classes = classes;
diff --git a/src/mscorlib/src/System/Reflection/ResourceAttributes.cs b/src/mscorlib/src/System/Reflection/ResourceAttributes.cs
index 646572677f..5c419ebb2d 100644
--- a/src/mscorlib/src/System/Reflection/ResourceAttributes.cs
+++ b/src/mscorlib/src/System/Reflection/ResourceAttributes.cs
@@ -15,7 +15,6 @@ namespace System.Reflection {
using System;
[Serializable]
[Flags]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum ResourceAttributes
{
Public = 0x0001,
diff --git a/src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs b/src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs
index 00ab975842..49262634e3 100644
--- a/src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs
@@ -10,16 +10,16 @@ namespace System.Reflection
{
private const BindingFlags everything = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
- private static void CheckAndThrow(Type t)
+ private static void CheckAndThrow(Type type)
{
- if (t == null) throw new ArgumentNullException("type");
- if (!(t is RuntimeType)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
+ if (type == null) throw new ArgumentNullException(nameof(type));
+ if (!(type is RuntimeType)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
}
- private static void CheckAndThrow(MethodInfo m)
+ private static void CheckAndThrow(MethodInfo method)
{
- if (m == null) throw new ArgumentNullException("method");
- if (!(m is RuntimeMethodInfo)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"));
+ if (method == null) throw new ArgumentNullException(nameof(method));
+ if (!(method is RuntimeMethodInfo)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"));
}
public static IEnumerable<PropertyInfo> GetRuntimeProperties(this Type type)
diff --git a/src/mscorlib/src/System/Reflection/StrongNameKeyPair.cs b/src/mscorlib/src/System/Reflection/StrongNameKeyPair.cs
index 8107cf4159..0121982489 100644
--- a/src/mscorlib/src/System/Reflection/StrongNameKeyPair.cs
+++ b/src/mscorlib/src/System/Reflection/StrongNameKeyPair.cs
@@ -22,13 +22,11 @@ namespace System.Reflection
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security;
- using System.Security.Permissions;
using System.Runtime.Versioning;
using Microsoft.Win32;
using System.Diagnostics.Contracts;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public class StrongNameKeyPair : IDeserializationCallback, ISerializable
{
private bool _keyPairExported;
diff --git a/src/mscorlib/src/System/Reflection/TargetException.cs b/src/mscorlib/src/System/Reflection/TargetException.cs
index 9c56c121cc..dcbb38833e 100644
--- a/src/mscorlib/src/System/Reflection/TargetException.cs
+++ b/src/mscorlib/src/System/Reflection/TargetException.cs
@@ -18,7 +18,6 @@ namespace System.Reflection {
using System;
using System.Runtime.Serialization;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public class TargetException : ApplicationException {
public TargetException() : base() {
SetErrorCode(__HResults.COR_E_TARGET);
diff --git a/src/mscorlib/src/System/Reflection/TargetInvocationException.cs b/src/mscorlib/src/System/Reflection/TargetInvocationException.cs
index 4a32ed245d..7bbc93df2a 100644
--- a/src/mscorlib/src/System/Reflection/TargetInvocationException.cs
+++ b/src/mscorlib/src/System/Reflection/TargetInvocationException.cs
@@ -18,7 +18,6 @@ namespace System.Reflection {
using System;
using System.Runtime.Serialization;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class TargetInvocationException : ApplicationException {
// This exception is not creatable without specifying the
// inner exception.
diff --git a/src/mscorlib/src/System/Reflection/TargetParameterCountException.cs b/src/mscorlib/src/System/Reflection/TargetParameterCountException.cs
index 846732b449..7a07b20acd 100644
--- a/src/mscorlib/src/System/Reflection/TargetParameterCountException.cs
+++ b/src/mscorlib/src/System/Reflection/TargetParameterCountException.cs
@@ -18,7 +18,6 @@ namespace System.Reflection {
using SystemException = System.SystemException;
using System.Runtime.Serialization;
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public sealed class TargetParameterCountException : ApplicationException {
public TargetParameterCountException()
: base(Environment.GetResourceString("Arg_TargetParameterCountException")) {
diff --git a/src/mscorlib/src/System/Reflection/TypeAttributes.cs b/src/mscorlib/src/System/Reflection/TypeAttributes.cs
index 4fa6fb06ba..25aa113d2e 100644
--- a/src/mscorlib/src/System/Reflection/TypeAttributes.cs
+++ b/src/mscorlib/src/System/Reflection/TypeAttributes.cs
@@ -8,7 +8,6 @@ namespace System.Reflection {
// This Enum matchs the CorTypeAttr defined in CorHdr.h
[Serializable]
[Flags]
-[System.Runtime.InteropServices.ComVisible(true)]
public enum TypeAttributes
{
VisibilityMask = 0x00000007,
@@ -43,7 +42,6 @@ namespace System.Reflection {
Import = 0x00001000, // Class / interface is imported
Serializable = 0x00002000, // The class is Serializable.
- [ComVisible(false)]
WindowsRuntime = 0x00004000, // Type is a Windows Runtime type.
// Use tdStringFormatMask to retrieve string information for native interop
diff --git a/src/mscorlib/src/System/Reflection/TypeDelegator.cs b/src/mscorlib/src/System/Reflection/TypeDelegator.cs
index d715df8950..6a77a95853 100644
--- a/src/mscorlib/src/System/Reflection/TypeDelegator.cs
+++ b/src/mscorlib/src/System/Reflection/TypeDelegator.cs
@@ -14,7 +14,6 @@ namespace System.Reflection {
using CultureInfo = System.Globalization.CultureInfo;
[Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
public class TypeDelegator : TypeInfo
{
public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
@@ -86,7 +85,6 @@ namespace System.Reflection {
return typeImpl.GetConstructor(bindingAttr,binder,callConvention,types,modifiers);
}
-[System.Runtime.InteropServices.ComVisible(true)]
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
{
return typeImpl.GetConstructors(bindingAttr);
@@ -251,7 +249,6 @@ namespace System.Reflection {
return typeImpl.IsDefined(attributeType, inherit);
}
-[System.Runtime.InteropServices.ComVisible(true)]
public override InterfaceMapping GetInterfaceMap(Type interfaceType)
{
return typeImpl.GetInterfaceMap(interfaceType);
diff --git a/src/mscorlib/src/System/Reflection/TypeFilter.cs b/src/mscorlib/src/System/Reflection/TypeFilter.cs
index 560618ff79..4837a303a1 100644
--- a/src/mscorlib/src/System/Reflection/TypeFilter.cs
+++ b/src/mscorlib/src/System/Reflection/TypeFilter.cs
@@ -14,6 +14,5 @@ namespace System.Reflection {
// Define the delegate
[Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
public delegate bool TypeFilter(Type m, Object filterCriteria);
}
diff --git a/src/mscorlib/src/System/Reflection/TypeInfo.cs b/src/mscorlib/src/System/Reflection/TypeInfo.cs
index 706fb0a61a..61d7bb27a9 100644
--- a/src/mscorlib/src/System/Reflection/TypeInfo.cs
+++ b/src/mscorlib/src/System/Reflection/TypeInfo.cs
@@ -22,7 +22,6 @@ namespace System.Reflection
//all today's runtime Type derivations derive now from TypeInfo
//we make TypeInfo implement IRCT - simplifies work
- [System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public abstract class TypeInfo:Type,IReflectableType
{