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.cs41
-rw-r--r--src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs211
-rw-r--r--src/mscorlib/src/System/Reflection/AssemblyAttributes.cs387
-rw-r--r--src/mscorlib/src/System/Reflection/AssemblyName.cs191
-rw-r--r--src/mscorlib/src/System/Reflection/AssemblyNameFlags.cs53
-rw-r--r--src/mscorlib/src/System/Reflection/Associates.cs35
-rw-r--r--src/mscorlib/src/System/Reflection/Binder.cs49
-rw-r--r--src/mscorlib/src/System/Reflection/BindingFlags.cs63
-rw-r--r--src/mscorlib/src/System/Reflection/CallingConventions.cs28
-rw-r--r--src/mscorlib/src/System/Reflection/ConstructorInfo.CoreCLR.cs11
-rw-r--r--src/mscorlib/src/System/Reflection/CustomAttribute.cs166
-rw-r--r--src/mscorlib/src/System/Reflection/CustomAttributeExtensions.cs1
-rw-r--r--src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs37
-rw-r--r--src/mscorlib/src/System/Reflection/DefaultMemberAttribute.cs39
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs18
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs155
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs5
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs126
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs92
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs88
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs126
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs484
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs223
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs54
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/EventToken.cs37
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs77
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/FieldToken.cs34
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/FlowControl.cs30
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs55
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs774
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs188
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/Label.cs38
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs44
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs304
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs28
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/MethodToken.cs30
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs267
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs36
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/OpCodes.cs5063
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/Opcode.cs271
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs24
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/OperandType.cs48
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs10
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs93
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs36
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs130
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs34
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs308
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs36
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs68
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/StringToken.cs46
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs66
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/SymbolType.cs269
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs614
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs60
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/TypeToken.cs40
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs56
-rw-r--r--src/mscorlib/src/System/Reflection/EventAttributes.cs29
-rw-r--r--src/mscorlib/src/System/Reflection/EventInfo.cs401
-rw-r--r--src/mscorlib/src/System/Reflection/ExceptionHandlingClause.cs93
-rw-r--r--src/mscorlib/src/System/Reflection/FieldAttributes.cs42
-rw-r--r--src/mscorlib/src/System/Reflection/FieldInfo.CoreCLR.cs35
-rw-r--r--src/mscorlib/src/System/Reflection/FieldInfo.cs862
-rw-r--r--src/mscorlib/src/System/Reflection/GenericParameterAttributes.cs22
-rw-r--r--src/mscorlib/src/System/Reflection/ICustomAttributeProvider.cs33
-rw-r--r--src/mscorlib/src/System/Reflection/INVOCATION_FLAGS.cs38
-rw-r--r--src/mscorlib/src/System/Reflection/IReflect.cs116
-rw-r--r--src/mscorlib/src/System/Reflection/IReflectableType.cs20
-rw-r--r--src/mscorlib/src/System/Reflection/InterfaceMapping.cs22
-rw-r--r--src/mscorlib/src/System/Reflection/IntrospectionExtensions.cs28
-rw-r--r--src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs39
-rw-r--r--src/mscorlib/src/System/Reflection/LoaderAllocator.cs11
-rw-r--r--src/mscorlib/src/System/Reflection/LocalVariableInfo.cs40
-rw-r--r--src/mscorlib/src/System/Reflection/ManifestResourceInfo.cs65
-rw-r--r--src/mscorlib/src/System/Reflection/MdConstant.cs35
-rw-r--r--src/mscorlib/src/System/Reflection/MdFieldInfo.cs141
-rw-r--r--src/mscorlib/src/System/Reflection/MdImport.cs476
-rw-r--r--src/mscorlib/src/System/Reflection/MemberFilter.cs18
-rw-r--r--src/mscorlib/src/System/Reflection/MemberInfo.Internal.cs11
-rw-r--r--src/mscorlib/src/System/Reflection/MemberInfo.cs113
-rw-r--r--src/mscorlib/src/System/Reflection/MemberInfoSerializationHolder.cs285
-rw-r--r--src/mscorlib/src/System/Reflection/MemberSerializationStringGenerator.cs39
-rw-r--r--src/mscorlib/src/System/Reflection/MemberTypes.cs33
-rw-r--r--src/mscorlib/src/System/Reflection/MethodAttributes.cs55
-rw-r--r--src/mscorlib/src/System/Reflection/MethodBase.CoreCLR.cs157
-rw-r--r--src/mscorlib/src/System/Reflection/MethodBase.cs330
-rw-r--r--src/mscorlib/src/System/Reflection/MethodBody.cs136
-rw-r--r--src/mscorlib/src/System/Reflection/MethodImplAttributes.cs43
-rw-r--r--src/mscorlib/src/System/Reflection/Missing.cs35
-rw-r--r--src/mscorlib/src/System/Reflection/Module.cs1120
-rw-r--r--src/mscorlib/src/System/Reflection/ObfuscateAssemblyAttribute.cs45
-rw-r--r--src/mscorlib/src/System/Reflection/ObfuscationAttribute.cs74
-rw-r--r--src/mscorlib/src/System/Reflection/ParameterAttributes.cs35
-rw-r--r--src/mscorlib/src/System/Reflection/ParameterModifier.cs45
-rw-r--r--src/mscorlib/src/System/Reflection/Pointer.cs75
-rw-r--r--src/mscorlib/src/System/Reflection/PropertyAttributes.cs32
-rw-r--r--src/mscorlib/src/System/Reflection/ReflectionContext.cs36
-rw-r--r--src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs72
-rw-r--r--src/mscorlib/src/System/Reflection/ResourceAttributes.cs23
-rw-r--r--src/mscorlib/src/System/Reflection/RtFieldInfo.cs390
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeAssembly.cs (renamed from src/mscorlib/src/System/Reflection/Assembly.cs)987
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs (renamed from src/mscorlib/src/System/Reflection/ConstructorInfo.cs)267
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs220
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs136
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs (renamed from src/mscorlib/src/System/Reflection/MethodInfo.cs)333
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeModule.cs602
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs (renamed from src/mscorlib/src/System/Reflection/ParameterInfo.cs)259
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs (renamed from src/mscorlib/src/System/Reflection/PropertyInfo.cs)252
-rw-r--r--src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs88
-rw-r--r--src/mscorlib/src/System/Reflection/StrongNameKeyPair.cs95
-rw-r--r--src/mscorlib/src/System/Reflection/TargetException.cs37
-rw-r--r--src/mscorlib/src/System/Reflection/TargetInvocationException.cs46
-rw-r--r--src/mscorlib/src/System/Reflection/TargetParameterCountException.cs40
-rw-r--r--src/mscorlib/src/System/Reflection/TypeAttributes.cs64
-rw-r--r--src/mscorlib/src/System/Reflection/TypeDelegator.cs257
-rw-r--r--src/mscorlib/src/System/Reflection/TypeFilter.cs18
-rw-r--r--src/mscorlib/src/System/Reflection/TypeInfo.cs194
-rw-r--r--src/mscorlib/src/System/Reflection/__Filters.cs67
118 files changed, 8222 insertions, 13387 deletions
diff --git a/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs b/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs
deleted file mode 100644
index 795a8714d1..0000000000
--- a/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs
+++ /dev/null
@@ -1,41 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// AmbiguousMatchException is thrown when binding to a method results in more
-//
-// than one method matching the binding criteria. This exception is thrown in
-// general when something is Ambiguous.
-//
-//
-//
-//
-namespace System.Reflection {
- using System;
- using SystemException = System.SystemException;
- using System.Runtime.Serialization;
- [Serializable]
- public sealed class AmbiguousMatchException : SystemException
- {
-
- public AmbiguousMatchException()
- : base(Environment.GetResourceString("RFLCT.Ambiguous")) {
- SetErrorCode(__HResults.COR_E_AMBIGUOUSMATCH);
- }
-
- public AmbiguousMatchException(String message) : base(message) {
- SetErrorCode(__HResults.COR_E_AMBIGUOUSMATCH);
- }
-
- public AmbiguousMatchException(String message, Exception inner) : base(message, inner) {
- SetErrorCode(__HResults.COR_E_AMBIGUOUSMATCH);
- }
-
- internal AmbiguousMatchException(SerializationInfo info, StreamingContext context) : base(info, context) {
- }
-
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs b/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs
new file mode 100644
index 0000000000..82966dba60
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs
@@ -0,0 +1,211 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Collections.Generic;
+using System.Security.Policy;
+using System.IO;
+using System.Configuration.Assemblies;
+using StackCrawlMark = System.Threading.StackCrawlMark;
+using System.Runtime.Serialization;
+using System.Diagnostics.Contracts;
+using System.Runtime.Loader;
+
+namespace System.Reflection
+{
+ public abstract partial class Assembly : ICustomAttributeProvider, ISerializable
+ {
+ public static Assembly LoadFrom(String assemblyFile)
+ {
+ if (assemblyFile == null)
+ throw new ArgumentNullException(nameof(assemblyFile));
+ string fullPath = Path.GetFullPath(assemblyFile);
+ return AssemblyLoadContext.Default.LoadFromAssemblyPath(fullPath);
+ }
+
+ // 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.")]
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
+ internal static Assembly LoadFrom(String assemblyFile,
+ Evidence securityEvidence)
+ {
+ Contract.Ensures(Contract.Result<Assembly>() != null);
+
+ StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
+
+ return RuntimeAssembly.InternalLoadFrom(
+ assemblyFile,
+ securityEvidence,
+ null, // hashValue
+ AssemblyHashAlgorithm.None,
+ false,// forIntrospection);
+ ref stackMark);
+ }
+
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
+ public static Assembly LoadFrom(String assemblyFile,
+ byte[] hashValue,
+ AssemblyHashAlgorithm hashAlgorithm)
+ {
+ throw new NotSupportedException(SR.NotSupported_AssemblyLoadFromHash);
+ }
+
+ // Locate an assembly by the long form of the assembly name.
+ // eg. "Toolbox.dll, version=1.1.10.1220, locale=en, publickey=1234567890123456789012345678901234567890"
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
+ public static Assembly Load(String assemblyString)
+ {
+ Contract.Ensures(Contract.Result<Assembly>() != null);
+ Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
+
+ StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
+ return RuntimeAssembly.InternalLoad(assemblyString, null, ref stackMark, false /*forIntrospection*/);
+ }
+
+ // Returns type from the assembly while keeping compatibility with Assembly.Load(assemblyString).GetType(typeName) for managed types.
+ // Calls Type.GetType for WinRT types.
+ // Note: Type.GetType fails for assembly names that start with weird characters like '['. By calling it for managed types we would
+ // break AppCompat.
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
+ internal static Type GetType_Compat(String assemblyString, String typeName)
+ {
+ // Normally we would get the stackMark only in public APIs. This is internal API, but it is AppCompat replacement of public API
+ // call Assembly.Load(assemblyString).GetType(typeName), therefore we take the stackMark here as well, to be fully compatible with
+ // the call sequence.
+ StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
+
+ RuntimeAssembly assembly;
+ AssemblyName assemblyName = RuntimeAssembly.CreateAssemblyName(
+ assemblyString,
+ false /*forIntrospection*/,
+ out assembly);
+
+ if (assembly == null)
+ {
+ if (assemblyName.ContentType == AssemblyContentType.WindowsRuntime)
+ {
+ return Type.GetType(typeName + ", " + assemblyString, true /*throwOnError*/, false /*ignoreCase*/);
+ }
+
+ assembly = RuntimeAssembly.InternalLoadAssemblyName(
+ assemblyName, null, null, ref stackMark,
+ true /*thrownOnFileNotFound*/, false /*forIntrospection*/);
+ }
+ return assembly.GetType(typeName, true /*throwOnError*/, false /*ignoreCase*/);
+ }
+
+ // Locate an assembly by its name. The name can be strong or
+ // weak. The assembly is loaded into the domain of the caller.
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
+ public static Assembly Load(AssemblyName assemblyRef)
+ {
+ Contract.Ensures(Contract.Result<Assembly>() != null);
+ Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
+
+ if (assemblyRef != null && assemblyRef.CodeBase != null)
+ {
+ throw new NotSupportedException(SR.NotSupported_AssemblyLoadCodeBase);
+ }
+
+ StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
+ return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/);
+ }
+
+ // Locate an assembly by its name. The name can be strong or
+ // weak. The assembly is loaded into the domain of the caller.
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
+ internal static Assembly Load(AssemblyName assemblyRef, IntPtr ptrLoadContextBinder)
+ {
+ Contract.Ensures(Contract.Result<Assembly>() != null);
+ Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
+
+ if (assemblyRef != null && assemblyRef.CodeBase != null)
+ {
+ throw new NotSupportedException(SR.NotSupported_AssemblyLoadCodeBase);
+ }
+
+ StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
+ return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/, ptrLoadContextBinder);
+ }
+
+ // Loads the assembly with a COFF based IMAGE containing
+ // an emitted assembly. The assembly is loaded into the domain
+ // of the caller. The second parameter is the raw bytes
+ // representing the symbol store that matches the assembly.
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
+ public static Assembly Load(byte[] rawAssembly,
+ byte[] rawSymbolStore)
+ {
+ Contract.Ensures(Contract.Result<Assembly>() != null);
+ Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
+
+ AppDomain.CheckLoadByteArraySupported();
+
+ if (rawAssembly == null)
+ throw new ArgumentNullException(nameof(rawAssembly));
+ AssemblyLoadContext alc = new IndividualAssemblyLoadContext();
+ MemoryStream assemblyStream = new MemoryStream(rawAssembly);
+ MemoryStream symbolStream = (rawSymbolStore != null) ? new MemoryStream(rawSymbolStore) : null;
+ return alc.LoadFromStream(assemblyStream, symbolStream);
+ }
+
+ private static Dictionary<string, Assembly> s_loadfile = new Dictionary<string, Assembly>();
+
+ public static Assembly LoadFile(String path)
+ {
+ Contract.Ensures(Contract.Result<Assembly>() != null);
+ Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
+
+ AppDomain.CheckLoadFileSupported();
+
+ Assembly result = null;
+ if (path == null)
+ throw new ArgumentNullException(nameof(path));
+
+ if (PathInternal.IsPartiallyQualified(path))
+ {
+ throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(path));
+ }
+
+ string normalizedPath = Path.GetFullPath(path);
+
+ lock (s_loadfile)
+ {
+ if (s_loadfile.TryGetValue(normalizedPath, out result))
+ return result;
+ AssemblyLoadContext alc = new IndividualAssemblyLoadContext();
+ result = alc.LoadFromAssemblyPath(normalizedPath);
+ s_loadfile.Add(normalizedPath, result);
+ }
+ return result;
+ }
+
+ /*
+ * Get the assembly that the current code is running from.
+ */
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
+ public static Assembly GetExecutingAssembly()
+ {
+ StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
+ return RuntimeAssembly.GetExecutingAssembly(ref stackMark);
+ }
+
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
+ public static Assembly GetCallingAssembly()
+ {
+ // LookForMyCallersCaller is not guarantee to return the correct stack frame
+ // because of inlining, tail calls, etc. As a result GetCallingAssembly is not
+ // ganranteed to return the correct result. We should document it as such.
+ StackCrawlMark stackMark = StackCrawlMark.LookForMyCallersCaller;
+ return RuntimeAssembly.GetExecutingAssembly(ref stackMark);
+ }
+
+ public static Assembly GetEntryAssembly()
+ {
+ AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager;
+ if (domainManager == null)
+ domainManager = new AppDomainManager();
+ return domainManager.EntryAssembly;
+ }
+ }
+}
diff --git a/src/mscorlib/src/System/Reflection/AssemblyAttributes.cs b/src/mscorlib/src/System/Reflection/AssemblyAttributes.cs
deleted file mode 100644
index 1e6688d1f4..0000000000
--- a/src/mscorlib/src/System/Reflection/AssemblyAttributes.cs
+++ /dev/null
@@ -1,387 +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: For Assembly-related custom attributes.
-**
-**
-=============================================================================*/
-
-namespace System.Reflection {
-
- using System;
- using System.Configuration.Assemblies;
- using System.Diagnostics.Contracts;
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyCopyrightAttribute : Attribute
- {
- private String m_copyright;
-
- public AssemblyCopyrightAttribute(String copyright)
- {
- m_copyright = copyright;
- }
-
- public String Copyright
- {
- get { return m_copyright; }
- }
- }
-
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyTrademarkAttribute : Attribute
- {
- private String m_trademark;
-
- public AssemblyTrademarkAttribute(String trademark)
- {
- m_trademark = trademark;
- }
-
- public String Trademark
- {
- get { return m_trademark; }
- }
- }
-
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyProductAttribute : Attribute
- {
- private String m_product;
-
- public AssemblyProductAttribute(String product)
- {
- m_product = product;
- }
-
- public String Product
- {
- get { return m_product; }
- }
- }
-
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyCompanyAttribute : Attribute
- {
- private String m_company;
-
- public AssemblyCompanyAttribute(String company)
- {
- m_company = company;
- }
-
- public String Company
- {
- get { return m_company; }
- }
- }
-
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyDescriptionAttribute : Attribute
- {
- private String m_description;
-
- public AssemblyDescriptionAttribute(String description)
- {
- m_description = description;
- }
-
- public String Description
- {
- get { return m_description; }
- }
- }
-
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyTitleAttribute : Attribute
- {
- private String m_title;
-
- public AssemblyTitleAttribute(String title)
- {
- m_title = title;
- }
-
- public String Title
- {
- get { return m_title; }
- }
- }
-
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyConfigurationAttribute : Attribute
- {
- private String m_configuration;
-
- public AssemblyConfigurationAttribute(String configuration)
- {
- m_configuration = configuration;
- }
-
- public String Configuration
- {
- get { return m_configuration; }
- }
- }
-
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyDefaultAliasAttribute : Attribute
- {
- private String m_defaultAlias;
-
- public AssemblyDefaultAliasAttribute(String defaultAlias)
- {
- m_defaultAlias = defaultAlias;
- }
-
- public String DefaultAlias
- {
- get { return m_defaultAlias; }
- }
- }
-
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyInformationalVersionAttribute : Attribute
- {
- private String m_informationalVersion;
-
- public AssemblyInformationalVersionAttribute(String informationalVersion)
- {
- m_informationalVersion = informationalVersion;
- }
-
- public String InformationalVersion
- {
- get { return m_informationalVersion; }
- }
- }
-
-
- [AttributeUsage(AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyFileVersionAttribute : Attribute
- {
- private String _version;
-
- public AssemblyFileVersionAttribute(String version)
- {
- if (version == null)
- throw new ArgumentNullException(nameof(version));
- Contract.EndContractBlock();
- _version = version;
- }
-
- public String Version {
- get { return _version; }
- }
- }
-
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public unsafe sealed class AssemblyCultureAttribute : Attribute
- {
- private String m_culture;
-
- public AssemblyCultureAttribute(String culture)
- {
- m_culture = culture;
- }
-
- public String Culture
- {
- get { return m_culture; }
- }
- }
-
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public unsafe sealed class AssemblyVersionAttribute : Attribute
- {
- private String m_version;
-
- public AssemblyVersionAttribute(String version)
- {
- m_version = version;
- }
-
- public String Version
- {
- get { return m_version; }
- }
- }
-
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyKeyFileAttribute : Attribute
- {
- private String m_keyFile;
-
- public AssemblyKeyFileAttribute(String keyFile)
- {
- m_keyFile = keyFile;
- }
-
- public String KeyFile
- {
- get { return m_keyFile; }
- }
- }
-
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyDelaySignAttribute : Attribute
- {
- private bool m_delaySign;
-
- public AssemblyDelaySignAttribute(bool delaySign)
- {
- m_delaySign = delaySign;
- }
-
- public bool DelaySign
- { get
- { return m_delaySign; }
- }
- }
-
-
- [AttributeUsage(AttributeTargets.Assembly, Inherited=false)]
- public unsafe sealed class AssemblyAlgorithmIdAttribute : Attribute
- {
- private uint m_algId;
-
- public AssemblyAlgorithmIdAttribute(AssemblyHashAlgorithm algorithmId)
- {
- m_algId = (uint) algorithmId;
- }
-
- [CLSCompliant(false)]
- public AssemblyAlgorithmIdAttribute(uint algorithmId)
- {
- m_algId = algorithmId;
- }
-
- [CLSCompliant(false)]
- public uint AlgorithmId
- {
- get { return m_algId; }
- }
- }
-
-
- [AttributeUsage(AttributeTargets.Assembly, Inherited=false)]
- public unsafe sealed class AssemblyFlagsAttribute : Attribute
- {
- private AssemblyNameFlags m_flags;
-
- [Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- [CLSCompliant(false)]
- public AssemblyFlagsAttribute(uint flags)
- {
- m_flags = (AssemblyNameFlags)flags;
- }
-
- [Obsolete("This property has been deprecated. Please use AssemblyFlags instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- [CLSCompliant(false)]
- public uint Flags
- {
- get { return (uint)m_flags; }
- }
-
- // This, of course, should be typed as AssemblyNameFlags. The compat police don't allow such changes.
- public int AssemblyFlags
- {
- get { return (int)m_flags; }
- }
-
- [Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- public AssemblyFlagsAttribute(int assemblyFlags)
- {
- m_flags = (AssemblyNameFlags)assemblyFlags;
- }
-
-
- public AssemblyFlagsAttribute(AssemblyNameFlags assemblyFlags)
- {
- m_flags = assemblyFlags;
- }
- }
-
- [AttributeUsage(AttributeTargets.Assembly, AllowMultiple=true, Inherited=false)]
- public sealed class AssemblyMetadataAttribute : Attribute
- {
- private String m_key;
- private String m_value;
-
- public AssemblyMetadataAttribute(string key, string value)
- {
- m_key = key;
- m_value = value;
- }
-
- public string Key
- {
- get { return m_key; }
- }
-
- public string Value
- {
- get { return m_value;}
- }
- }
-
- [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple=false)]
- public sealed class AssemblySignatureKeyAttribute : Attribute
- {
- private String _publicKey;
- private String _countersignature;
-
- public AssemblySignatureKeyAttribute(String publicKey, String countersignature)
- {
- _publicKey = publicKey;
- _countersignature = countersignature;
- }
-
- public String PublicKey
- {
- get { return _publicKey; }
- }
-
- public String Countersignature
- {
- get { return _countersignature; }
- }
- }
-
- [AttributeUsage (AttributeTargets.Assembly, Inherited=false)]
- public sealed class AssemblyKeyNameAttribute : Attribute
- {
- private String m_keyName;
-
- public AssemblyKeyNameAttribute(String keyName)
- {
- m_keyName = keyName;
- }
-
- public String KeyName
- {
- get { return m_keyName; }
- }
- }
-
-}
-
diff --git a/src/mscorlib/src/System/Reflection/AssemblyName.cs b/src/mscorlib/src/System/Reflection/AssemblyName.cs
index 01be855646..80fdf5d162 100644
--- a/src/mscorlib/src/System/Reflection/AssemblyName.cs
+++ b/src/mscorlib/src/System/Reflection/AssemblyName.cs
@@ -13,7 +13,9 @@
**
**
===========================================================*/
-namespace System.Reflection {
+
+namespace System.Reflection
+{
using System;
using System.IO;
using System.Configuration.Assemblies;
@@ -33,31 +35,31 @@ namespace System.Reflection {
// If you modify any of these fields, you must also update the
// AssemblyBaseObject structure in object.h
//
- private String _Name; // Name
- private byte[] _PublicKey;
- private byte[] _PublicKeyToken;
- private CultureInfo _CultureInfo;
- private String _CodeBase; // Potential location to get the file
- private Version _Version;
-
- private StrongNameKeyPair _StrongNameKeyPair;
+ private String _Name; // Name
+ private byte[] _PublicKey;
+ private byte[] _PublicKeyToken;
+ private CultureInfo _CultureInfo;
+ private String _CodeBase; // Potential location to get the file
+ private Version _Version;
+
+ private StrongNameKeyPair _StrongNameKeyPair;
private SerializationInfo m_siInfo; //A temporary variable which we need during deserialization.
- private byte[] _HashForControl;
+ private byte[] _HashForControl;
private AssemblyHashAlgorithm _HashAlgorithm;
private AssemblyHashAlgorithm _HashAlgorithmForControl;
private AssemblyVersionCompatibility _VersionCompatibility;
- private AssemblyNameFlags _Flags;
-
+ private AssemblyNameFlags _Flags;
+
public AssemblyName()
- {
+ {
_HashAlgorithm = AssemblyHashAlgorithm.None;
_VersionCompatibility = AssemblyVersionCompatibility.SameMachine;
_Flags = AssemblyNameFlags.None;
}
-
+
// Set and get the name of the assembly. If this is a weak Name
// then it optionally contains a site. For strong assembly names,
// the name partitions up the strong name's namespace
@@ -69,10 +71,12 @@ namespace System.Reflection {
public Version Version
{
- get {
+ get
+ {
return _Version;
}
- set {
+ set
+ {
_Version = value;
}
}
@@ -80,30 +84,34 @@ namespace System.Reflection {
// Locales, internally the LCID is used for the match.
public CultureInfo CultureInfo
{
- get {
+ get
+ {
return _CultureInfo;
}
- set {
- _CultureInfo = value;
+ set
+ {
+ _CultureInfo = value;
}
}
public String CultureName
{
- get {
+ get
+ {
return (_CultureInfo == null) ? null : _CultureInfo.Name;
}
- set {
+ set
+ {
_CultureInfo = (value == null) ? null : new CultureInfo(value);
}
}
-
+
public String CodeBase
{
get { return _CodeBase; }
set { _CodeBase = value; }
}
-
+
public String EscapedCodeBase
{
get
@@ -114,18 +122,21 @@ namespace System.Reflection {
return EscapeCodeBase(_CodeBase);
}
}
-
- public ProcessorArchitecture ProcessorArchitecture
+
+ public ProcessorArchitecture ProcessorArchitecture
{
- get {
+ get
+ {
int x = (((int)_Flags) & 0x70) >> 4;
- if(x > 5)
+ if (x > 5)
x = 0;
return (ProcessorArchitecture)x;
}
- set {
+ set
+ {
int x = ((int)value) & 0x07;
- if(x <= 5) {
+ if (x <= 5)
+ {
_Flags = (AssemblyNameFlags)((int)_Flags & 0xFFFFFF0F);
_Flags |= (AssemblyNameFlags)(x << 4);
}
@@ -151,8 +162,8 @@ namespace System.Reflection {
}
}
}
-
-
+
+
// Make a copy of this assembly name.
public Object Clone()
@@ -168,8 +179,8 @@ namespace System.Reflection {
_CodeBase,
_Flags,
_StrongNameKeyPair);
- name._HashForControl=_HashForControl;
- name._HashAlgorithmForControl=_HashAlgorithmForControl;
+ name._HashForControl = _HashForControl;
+ name._HashAlgorithmForControl = _HashAlgorithmForControl;
return name;
}
@@ -180,7 +191,7 @@ namespace System.Reflection {
*/
static public AssemblyName GetAssemblyName(String assemblyFile)
{
- if(assemblyFile == null)
+ if (assemblyFile == null)
throw new ArgumentNullException(nameof(assemblyFile));
Contract.EndContractBlock();
@@ -189,11 +200,11 @@ namespace System.Reflection {
string fullPath = Path.GetFullPath(assemblyFile);
return nGetFileInformation(fullPath);
}
-
+
internal void SetHashControl(byte[] hash, AssemblyHashAlgorithm hashAlgorithm)
{
- _HashForControl=hash;
- _HashAlgorithmForControl=hashAlgorithm;
+ _HashForControl = hash;
+ _HashAlgorithmForControl = hashAlgorithm;
}
// The public key that is used to verify an assemblies
@@ -239,7 +250,8 @@ namespace System.Reflection {
public AssemblyNameFlags Flags
{
get { return (AssemblyNameFlags)((uint)_Flags & 0xFFFFF10F); }
- set {
+ set
+ {
_Flags &= unchecked((AssemblyNameFlags)0x00000EF0);
_Flags |= (value & unchecked((AssemblyNameFlags)0xFFFFF10F));
}
@@ -250,7 +262,7 @@ namespace System.Reflection {
get { return _HashAlgorithm; }
set { _HashAlgorithm = value; }
}
-
+
public AssemblyVersionCompatibility VersionCompatibility
{
get { return _VersionCompatibility; }
@@ -262,21 +274,22 @@ namespace System.Reflection {
get { return _StrongNameKeyPair; }
set { _StrongNameKeyPair = value; }
}
-
+
public String FullName
{
- get {
+ get
+ {
return nToString();
}
}
-
+
// Returns the stringized version of the assembly name.
public override String ToString()
{
String s = FullName;
- if(s == null)
+ if (s == null)
return base.ToString();
- else
+ else
return s;
}
@@ -291,7 +304,7 @@ namespace System.Reflection {
info.AddValue("_PublicKey", _PublicKey, typeof(byte[]));
info.AddValue("_PublicKeyToken", _PublicKeyToken, typeof(byte[]));
#if FEATURE_USE_LCID
- info.AddValue("_CultureInfo", (_CultureInfo == null) ? -1 :_CultureInfo.LCID);
+ info.AddValue("_CultureInfo", (_CultureInfo == null) ? -1 : _CultureInfo.LCID);
#endif
info.AddValue("_CodeBase", _CodeBase);
info.AddValue("_Version", _Version);
@@ -300,8 +313,8 @@ namespace System.Reflection {
info.AddValue("_StrongNameKeyPair", _StrongNameKeyPair, typeof(StrongNameKeyPair));
info.AddValue("_VersionCompatibility", _VersionCompatibility, typeof(AssemblyVersionCompatibility));
info.AddValue("_Flags", _Flags, typeof(AssemblyNameFlags));
- info.AddValue("_HashForControl",_HashForControl,typeof(byte[]));
- }
+ info.AddValue("_HashForControl", _HashForControl, typeof(byte[]));
+ }
public void OnDeserialization(Object sender)
{
@@ -310,8 +323,8 @@ namespace System.Reflection {
return;
_Name = m_siInfo.GetString("_Name");
- _PublicKey = (byte[]) m_siInfo.GetValue("_PublicKey", typeof(byte[]));
- _PublicKeyToken = (byte[]) m_siInfo.GetValue("_PublicKeyToken", typeof(byte[]));
+ _PublicKey = (byte[])m_siInfo.GetValue("_PublicKey", typeof(byte[]));
+ _PublicKeyToken = (byte[])m_siInfo.GetValue("_PublicKeyToken", typeof(byte[]));
#if FEATURE_USE_LCID
int lcid = (int)m_siInfo.GetInt32("_CultureInfo");
if (lcid != -1)
@@ -319,17 +332,19 @@ namespace System.Reflection {
#endif
_CodeBase = m_siInfo.GetString("_CodeBase");
- _Version = (Version) m_siInfo.GetValue("_Version", typeof(Version));
- _HashAlgorithm = (AssemblyHashAlgorithm) m_siInfo.GetValue("_HashAlgorithm", typeof(AssemblyHashAlgorithm));
- _StrongNameKeyPair = (StrongNameKeyPair) m_siInfo.GetValue("_StrongNameKeyPair", typeof(StrongNameKeyPair));
+ _Version = (Version)m_siInfo.GetValue("_Version", typeof(Version));
+ _HashAlgorithm = (AssemblyHashAlgorithm)m_siInfo.GetValue("_HashAlgorithm", typeof(AssemblyHashAlgorithm));
+ _StrongNameKeyPair = (StrongNameKeyPair)m_siInfo.GetValue("_StrongNameKeyPair", typeof(StrongNameKeyPair));
_VersionCompatibility = (AssemblyVersionCompatibility)m_siInfo.GetValue("_VersionCompatibility", typeof(AssemblyVersionCompatibility));
- _Flags = (AssemblyNameFlags) m_siInfo.GetValue("_Flags", typeof(AssemblyNameFlags));
+ _Flags = (AssemblyNameFlags)m_siInfo.GetValue("_Flags", typeof(AssemblyNameFlags));
- try {
- _HashAlgorithmForControl = (AssemblyHashAlgorithm) m_siInfo.GetValue("_HashAlgorithmForControl", typeof(AssemblyHashAlgorithm));
- _HashForControl = (byte[]) m_siInfo.GetValue("_HashForControl", typeof(byte[]));
+ try
+ {
+ _HashAlgorithmForControl = (AssemblyHashAlgorithm)m_siInfo.GetValue("_HashAlgorithmForControl", typeof(AssemblyHashAlgorithm));
+ _HashForControl = (byte[])m_siInfo.GetValue("_HashForControl", typeof(byte[]));
}
- catch (SerializationException) { // RTM did not have these defined
+ catch (SerializationException)
+ { // RTM did not have these defined
_HashAlgorithmForControl = AssemblyHashAlgorithm.None;
_HashForControl = null;
}
@@ -341,7 +356,7 @@ namespace System.Reflection {
internal AssemblyName(SerializationInfo info, StreamingContext context)
{
//The graph is not valid until OnDeserialization() has been called.
- m_siInfo = info;
+ m_siInfo = info;
}
public AssemblyName(String assemblyName)
@@ -351,32 +366,32 @@ namespace System.Reflection {
Contract.EndContractBlock();
if ((assemblyName.Length == 0) ||
(assemblyName[0] == '\0'))
- throw new ArgumentException(Environment.GetResourceString("Format_StringZeroLength"));
+ throw new ArgumentException(SR.Format_StringZeroLength);
_Name = assemblyName;
nInit();
}
- static public bool ReferenceMatchesDefinition(AssemblyName reference,
- AssemblyName definition)
+ /// <summary>
+ /// Compares the simple names disregarding Version, Culture and PKT. While this clearly does not
+ /// match the intent of this api, this api has been broken this way since its debut and we cannot
+ /// change its behavior now.
+ /// </summary>
+ public static bool ReferenceMatchesDefinition(AssemblyName reference, AssemblyName definition)
{
- // Optimization for common use case
- if (Object.ReferenceEquals(reference, definition))
- {
+ if (object.ReferenceEquals(reference, definition))
return true;
- }
- return ReferenceMatchesDefinitionInternal(reference, definition, true);
- }
-
- /// "parse" tells us to parse the simple name of the assembly as if it was the full name
- /// almost never the right thing to do, but needed for compat
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static internal extern bool ReferenceMatchesDefinitionInternal(AssemblyName reference,
- AssemblyName definition,
- bool parse);
+ if (reference == null)
+ throw new ArgumentNullException(nameof(reference));
+ if (definition == null)
+ throw new ArgumentNullException(nameof(definition));
+ string refName = reference.Name ?? string.Empty;
+ string defName = definition.Name ?? string.Empty;
+ return refName.Equals(defName, StringComparison.OrdinalIgnoreCase);
+ }
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern void nInit(out RuntimeAssembly assembly, bool forIntrospection, bool raiseResolveEvent);
@@ -431,7 +446,7 @@ namespace System.Reflection {
return ProcessorArchitecture.None;
}
- internal void Init(String name,
+ internal void Init(String name,
byte[] publicKey,
byte[] publicKeyToken,
Version version,
@@ -444,18 +459,20 @@ namespace System.Reflection {
{
_Name = name;
- if (publicKey != null) {
+ if (publicKey != null)
+ {
_PublicKey = new byte[publicKey.Length];
Array.Copy(publicKey, _PublicKey, publicKey.Length);
}
-
- if (publicKeyToken != null) {
+
+ if (publicKeyToken != null)
+ {
_PublicKeyToken = new byte[publicKeyToken.Length];
Array.Copy(publicKeyToken, _PublicKeyToken, publicKeyToken.Length);
}
-
+
if (version != null)
- _Version = (Version) version.Clone();
+ _Version = (Version)version.Clone();
_CultureInfo = cultureInfo;
_HashAlgorithm = hashAlgorithm;
@@ -480,7 +497,7 @@ namespace System.Reflection {
{
if (codebase == null)
return string.Empty;
-
+
int position = 0;
char[] dest = EscapeString(codebase, 0, codebase.Length, null, ref position, true, c_DummyChar, c_DummyChar, c_DummyChar);
if (dest == null)
@@ -528,7 +545,7 @@ namespace System.Reflection {
{
// Should be a rare case where the app tries to feed an invalid Unicode surrogates pair
if (count == 1 || count == end - i)
- throw new FormatException(Environment.GetResourceString("Arg_FormatException"));
+ throw new FormatException(SR.Arg_FormatException);
// need to grab one more char as a Surrogate except when it's a bogus input
++count;
}
@@ -544,7 +561,7 @@ namespace System.Reflection {
// This is the only exception that built in UriParser can throw after a Uri ctor.
// Should not happen unless the app tries to feed an invalid Unicode String
if (numberOfBytes == 0)
- throw new FormatException(Environment.GetResourceString("Arg_FormatException"));
+ throw new FormatException(SR.Arg_FormatException);
i += (count - 1);
@@ -620,7 +637,7 @@ namespace System.Reflection {
dest[destPos++] = pStr[prevInputPos++];
return dest;
}
-
+
internal static void EscapeAsciiChar(char ch, char[] to, ref int pos)
{
to[pos++] = '%';
@@ -657,7 +674,7 @@ namespace System.Reflection {
? ((int)next - (int)'A')
: ((int)next - (int)'a'))
+ 10)));
- }
+ }
private static unsafe bool IsReservedUnreservedOrHash(char c)
{
@@ -688,7 +705,7 @@ namespace System.Reflection {
{
return IsAsciiLetter(character) || (character >= '0' && character <= '9');
}
-
+
private static readonly char[] s_hexUpperChars = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
@@ -696,7 +713,7 @@ namespace System.Reflection {
private const short c_MaxAsciiCharsReallocate = 40;
private const short c_MaxUnicodeCharsReallocate = 40;
private const short c_MaxUTF_8BytesPerUnicodeChar = 4;
- private const short c_EncodedCharsPerByte = 3;
+ private const short c_EncodedCharsPerByte = 3;
private const string RFC3986ReservedMarks = @":/?#[]@!$&'()*+,;=";
private const string RFC3986UnreservedMarks = @"-._~";
}
diff --git a/src/mscorlib/src/System/Reflection/AssemblyNameFlags.cs b/src/mscorlib/src/System/Reflection/AssemblyNameFlags.cs
deleted file mode 100644
index b86955efa5..0000000000
--- a/src/mscorlib/src/System/Reflection/AssemblyNameFlags.cs
+++ /dev/null
@@ -1,53 +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: Flags controlling how an AssemblyName is used
-** during binding
-**
-**
-===========================================================*/
-namespace System.Reflection {
-
- using System;
- [Serializable]
- [FlagsAttribute()]
- public enum AssemblyNameFlags
- {
- None = 0x0000,
- // Flag used to indicate that an assembly ref contains the full public key, not the compressed token.
- // Must match afPublicKey in CorHdr.h.
- PublicKey = 0x0001,
- //ProcArchMask = 0x00F0, // Bits describing the processor architecture
- // Accessible via AssemblyName.ProcessorArchitecture
- EnableJITcompileOptimizer = 0x4000,
- EnableJITcompileTracking = 0x8000,
- Retargetable = 0x0100,
- //ContentType = 0x0E00, // Bits describing the ContentType are accessible via AssemblyName.ContentType
- }
-
- [Serializable]
- public enum AssemblyContentType
- {
- Default = 0x0000,
- WindowsRuntime = 0x0001
- }
-
- [Serializable]
- public enum ProcessorArchitecture
- {
- None = 0x0000,
- MSIL = 0x0001,
- X86 = 0x0002,
- IA64 = 0x0003,
- Amd64 = 0x0004,
- Arm = 0x0005
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/Associates.cs b/src/mscorlib/src/System/Reflection/Associates.cs
index 9eaf74a6e9..ed06cb46fc 100644
--- a/src/mscorlib/src/System/Reflection/Associates.cs
+++ b/src/mscorlib/src/System/Reflection/Associates.cs
@@ -4,22 +4,22 @@
//
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+
namespace System.Reflection
{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
-
internal static class Associates
{
[Flags]
internal enum Attributes
{
ComposedOfAllVirtualMethods = 0x1,
- ComposedOfAllPrivateMethods = 0x2,
- ComposedOfNoPublicMembers = 0x4,
- ComposedOfNoStaticMembers = 0x8,
+ ComposedOfAllPrivateMethods = 0x2,
+ ComposedOfNoPublicMembers = 0x4,
+ ComposedOfNoStaticMembers = 0x8,
}
internal static bool IncludeAccessor(MethodInfo associate, bool nonPublic)
@@ -51,7 +51,7 @@ namespace System.Reflection
IntPtr[] genericArgumentHandles = null;
int genericArgumentCount = 0;
- RuntimeType [] genericArguments = declaredType.GetTypeHandleInternal().GetInstantiationInternal();
+ RuntimeType[] genericArguments = declaredType.GetTypeHandleInternal().GetInstantiationInternal();
if (genericArguments != null)
{
genericArgumentCount = genericArguments.Length;
@@ -85,7 +85,7 @@ namespace System.Reflection
// the same or any property in the derived class.
if ((methAttr & MethodAttributes.Virtual) != 0)
{
- bool declaringTypeIsClass =
+ bool declaringTypeIsClass =
(RuntimeTypeHandle.GetAttributes(declaredType) & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Class;
// It makes no sense to search for a virtual override of a method declared on an interface.
@@ -99,7 +99,7 @@ namespace System.Reflection
}
}
- RuntimeMethodInfo associateMethod =
+ RuntimeMethodInfo associateMethod =
RuntimeType.GetMethodBase(reflectedType, associateMethodHandle) as RuntimeMethodInfo;
// suppose a property was mapped to a method not in the derivation hierarchy of the reflectedTypeHandle
@@ -125,13 +125,13 @@ namespace System.Reflection
{
addOn = removeOn = fireOn = getter = setter = null;
- Attributes attributes =
+ Attributes attributes =
Attributes.ComposedOfAllPrivateMethods |
Attributes.ComposedOfAllVirtualMethods |
Attributes.ComposedOfNoPublicMembers |
Attributes.ComposedOfNoStaticMembers;
- while(RuntimeTypeHandle.IsGenericVariable(reflectedType))
+ while (RuntimeTypeHandle.IsGenericVariable(reflectedType))
reflectedType = (RuntimeType)reflectedType.BaseType;
bool isInherited = declaringType != reflectedType;
@@ -156,12 +156,12 @@ namespace System.Reflection
continue;
MethodAttributes methAttr = associateMethod.Attributes;
- bool isPrivate =(methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private;
- bool isVirtual =(methAttr & MethodAttributes.Virtual) != 0;
+ bool isPrivate = (methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private;
+ bool isVirtual = (methAttr & MethodAttributes.Virtual) != 0;
MethodAttributes visibility = methAttr & MethodAttributes.MemberAccessMask;
bool isPublic = visibility == MethodAttributes.Public;
- bool isStatic =(methAttr & MethodAttributes.Static) != 0;
+ bool isStatic = (methAttr & MethodAttributes.Static) != 0;
if (isPublic)
{
@@ -202,10 +202,9 @@ namespace System.Reflection
bool isPseudoStatic = (attributes & Attributes.ComposedOfNoStaticMembers) == 0;
bindingFlags = RuntimeType.FilterPreCalculate(isPseudoPublic, isInherited, isPseudoStatic);
- composedOfAllPrivateMethods =(attributes & Attributes.ComposedOfAllPrivateMethods) != 0;
+ composedOfAllPrivateMethods = (attributes & Attributes.ComposedOfAllPrivateMethods) != 0;
other = (otherList != null) ? otherList.ToArray() : null;
}
}
-
}
diff --git a/src/mscorlib/src/System/Reflection/Binder.cs b/src/mscorlib/src/System/Reflection/Binder.cs
deleted file mode 100644
index bf4545fe81..0000000000
--- a/src/mscorlib/src/System/Reflection/Binder.cs
+++ /dev/null
@@ -1,49 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-//
-//
-// This interface defines a set of methods which interact with reflection
-// during the binding process. This control allows systems to apply language
-// specific semantics to the binding and invocation process.
-//
-//
-namespace System.Reflection {
- using System;
- using System.Runtime.InteropServices;
- using CultureInfo = System.Globalization.CultureInfo;
-
- [Serializable]
- public abstract class Binder
- {
- // Given a set of methods that match the basic criteria, select a method to
- // invoke. When this method is finished, we should have
- public abstract MethodBase BindToMethod(BindingFlags bindingAttr,MethodBase[] match,ref Object[] args,
- ParameterModifier[] modifiers,CultureInfo culture,String[] names, out Object state);
-
- // Given a set of methods that match the basic criteria, select a method to
- // invoke. When this method is finished, we should have
- public abstract FieldInfo BindToField(BindingFlags bindingAttr,FieldInfo[] match,
- Object value,CultureInfo culture);
-
- // Given a set of methods that match the base criteria, select a method based
- // upon an array of types. This method should return null if no method matchs
- // the criteria.
- public abstract MethodBase SelectMethod(BindingFlags bindingAttr,MethodBase[] match,
- Type[] types,ParameterModifier[] modifiers);
-
-
- // Given a set of propreties that match the base criteria, select one.
- public abstract PropertyInfo SelectProperty(BindingFlags bindingAttr,PropertyInfo[] match,
- Type returnType,Type[] indexes,ParameterModifier[] modifiers);
-
- // ChangeType
- // This method will convert the value into the property type.
- // It throws a cast exception if this fails.
- public abstract Object ChangeType(Object value,Type type,CultureInfo culture);
-
- public abstract void ReorderArgumentArray(ref Object[] args, Object state);
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/BindingFlags.cs b/src/mscorlib/src/System/Reflection/BindingFlags.cs
deleted file mode 100644
index ae0a6d68d3..0000000000
--- a/src/mscorlib/src/System/Reflection/BindingFlags.cs
+++ /dev/null
@@ -1,63 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// BindingFlags are a set of flags that control the binding and invocation process
-//
-// in Reflection. There are two processes. The first is selection of a Member which
-// is the binding phase. The second, is invocation. These flags control how this
-// process works.
-//
-//
-namespace System.Reflection {
-
- using System;
- [Serializable]
- [Flags]
- public enum BindingFlags
- {
-
- // NOTES: We have lookup masks defined in RuntimeType and Activator. If we
- // change the lookup values then these masks may need to change also.
-
- // a place holder for no flag specifed
- Default = 0x00,
-
- // These flags indicate what to search for when binding
- IgnoreCase = 0x01, // Ignore the case of Names while searching
- DeclaredOnly = 0x02, // Only look at the members declared on the Type
- Instance = 0x04, // Include Instance members in search
- Static = 0x08, // Include Static members in search
- Public = 0x10, // Include Public members in search
- NonPublic = 0x20, // Include Non-Public members in search
- FlattenHierarchy = 0x40, // Rollup the statics into the class.
-
- // These flags are used by InvokeMember to determine
- // what type of member we are trying to Invoke.
- // BindingAccess = 0xFF00;
- InvokeMethod = 0x0100,
- CreateInstance = 0x0200,
- GetField = 0x0400,
- SetField = 0x0800,
- GetProperty = 0x1000,
- SetProperty = 0x2000,
-
- // These flags are also used by InvokeMember but they should only
- // be used when calling InvokeMember on a COM object.
- PutDispProperty = 0x4000,
- PutRefDispProperty = 0x8000,
-
- ExactBinding = 0x010000, // Bind with Exact Type matching, No Change type
- SuppressChangeType = 0x020000,
-
- // DefaultValueBinding will return the set of methods having ArgCount or
- // more parameters. This is used for default values, etc.
- OptionalParamBinding = 0x040000,
-
- // These are a couple of misc attributes used
- IgnoreReturn = 0x01000000, // This is used in COM Interop
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/CallingConventions.cs b/src/mscorlib/src/System/Reflection/CallingConventions.cs
deleted file mode 100644
index 266dd55184..0000000000
--- a/src/mscorlib/src/System/Reflection/CallingConventions.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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// CallingConventions is a set of Bits representing the calling conventions
-//
-// in the system.
-//
-//
-namespace System.Reflection {
- using System.Runtime.InteropServices;
- using System;
- [Serializable]
- [Flags]
- public enum CallingConventions
- {
- //NOTE: If you change this please update COMMember.cpp. These
- // are defined there.
- Standard = 0x0001,
- VarArgs = 0x0002,
- Any = Standard | VarArgs,
- HasThis = 0x0020,
- ExplicitThis = 0x0040,
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/ConstructorInfo.CoreCLR.cs b/src/mscorlib/src/System/Reflection/ConstructorInfo.CoreCLR.cs
new file mode 100644
index 0000000000..c96bfb5ac1
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/ConstructorInfo.CoreCLR.cs
@@ -0,0 +1,11 @@
+// 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
+{
+ public abstract partial class ConstructorInfo : MethodBase
+ {
+ internal virtual Type GetReturnType() { throw new NotImplementedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Reflection/CustomAttribute.cs b/src/mscorlib/src/System/Reflection/CustomAttribute.cs
index b71c7bbff3..96eb45f3e4 100644
--- a/src/mscorlib/src/System/Reflection/CustomAttribute.cs
+++ b/src/mscorlib/src/System/Reflection/CustomAttribute.cs
@@ -18,7 +18,7 @@ using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
-namespace System.Reflection
+namespace System.Reflection
{
[Serializable]
public class CustomAttributeData
@@ -268,7 +268,7 @@ namespace System.Reflection
if (type.IsValueType)
return CustomAttributeEncoding.Undefined;
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidKindOfTypeForCA"), nameof(type));
+ throw new ArgumentException(SR.Argument_InvalidKindOfTypeForCA, nameof(type));
}
private static CustomAttributeType InitCustomAttributeType(RuntimeType parameterType)
{
@@ -300,8 +300,8 @@ namespace System.Reflection
customAttributes[i] = new CustomAttributeData(module, records[i]);
return Array.AsReadOnly(customAttributes);
- }
- #endregion
+ }
+ #endregion
#region Internal Static Members
internal unsafe static CustomAttributeRecord[] GetCustomAttributeRecords(RuntimeModule module, int targetToken)
@@ -361,7 +361,7 @@ namespace System.Reflection
m_scope = scope;
m_ctor = (RuntimeConstructorInfo)RuntimeType.GetMethodBase(scope, caRecord.tkCtor);
- ParameterInfo[] parameters = m_ctor.GetParametersNoCopy();
+ ParameterInfo[] parameters = m_ctor.GetParametersNoCopy();
m_ctorParams = new CustomAttributeCtorParameter[parameters.Length];
for (int i = 0; i < parameters.Length; i++)
m_ctorParams[i] = new CustomAttributeCtorParameter(InitCustomAttributeType((RuntimeType)parameters[i].ParameterType));
@@ -417,8 +417,7 @@ namespace System.Reflection
new CustomAttributeNamedArgument(type.GetField("CallingConvention"), dllImport.CallingConvention),
new CustomAttributeNamedArgument(type.GetField("BestFitMapping"), dllImport.BestFitMapping),
new CustomAttributeNamedArgument(type.GetField("ThrowOnUnmappableChar"), dllImport.ThrowOnUnmappableChar)
-
- });
+});
}
private void Init(FieldOffsetAttribute fieldOffset)
{
@@ -491,11 +490,11 @@ namespace System.Reflection
public override string ToString()
{
string ctorArgs = "";
- for (int i = 0; i < ConstructorArguments.Count; i ++)
+ for (int i = 0; i < ConstructorArguments.Count; i++)
ctorArgs += String.Format(CultureInfo.CurrentCulture, i == 0 ? "{0}" : ", {0}", ConstructorArguments[i]);
string namedArgs = "";
- for (int i = 0; i < NamedArguments.Count; i ++)
+ for (int i = 0; i < NamedArguments.Count; i++)
namedArgs += String.Format(CultureInfo.CurrentCulture, i == 0 && ctorArgs.Length == 0 ? "{0}" : ", {0}", NamedArguments[i]);
return String.Format(CultureInfo.CurrentCulture, "[{0}({1}{2})]", Constructor.DeclaringType.FullName, ctorArgs, namedArgs);
@@ -514,7 +513,7 @@ namespace System.Reflection
public Type AttributeType { get { return Constructor.DeclaringType; } }
public virtual ConstructorInfo Constructor { get { return m_ctor; } }
-
+
public virtual IList<CustomAttributeTypedArgument> ConstructorArguments
{
get
@@ -605,7 +604,7 @@ namespace System.Reflection
else if (property != null)
type = property.PropertyType;
else
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidMemberForNamedArgument"));
+ throw new ArgumentException(SR.Argument_InvalidMemberForNamedArgument);
m_memberInfo = memberInfo;
m_value = new CustomAttributeTypedArgument(type, value);
@@ -627,7 +626,7 @@ namespace System.Reflection
if (m_memberInfo == null)
return base.ToString();
- return String.Format(CultureInfo.CurrentCulture, "{0} = {1}", MemberInfo.Name, TypedValue.ToString(ArgumentType != typeof(object)));
+ return String.Format(CultureInfo.CurrentCulture, "{0} = {1}", MemberInfo.Name, TypedValue.ToString(ArgumentType != typeof(object)));
}
public override int GetHashCode()
{
@@ -640,14 +639,14 @@ namespace System.Reflection
#endregion
#region Internal Members
- internal Type ArgumentType
- {
- get
- {
- return m_memberInfo is FieldInfo ?
- ((FieldInfo)m_memberInfo).FieldType :
- ((PropertyInfo)m_memberInfo).PropertyType;
- }
+ internal Type ArgumentType
+ {
+ get
+ {
+ return m_memberInfo is FieldInfo ?
+ ((FieldInfo)m_memberInfo).FieldType :
+ ((PropertyInfo)m_memberInfo).PropertyType;
+ }
}
#endregion
@@ -730,8 +729,8 @@ namespace System.Reflection
case (CustomAttributeEncoding.Object):
return typeof(object);
- default :
- throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)encodedType), nameof(encodedType));
+ default:
+ throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)encodedType), nameof(encodedType));
}
}
@@ -776,7 +775,7 @@ namespace System.Reflection
unsafe { return *(double*)&val; }
default:
- throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)val), nameof(val));
+ throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)val), nameof(val));
}
}
private static RuntimeType ResolveType(RuntimeModule scope, string typeName)
@@ -785,7 +784,7 @@ namespace System.Reflection
if (type == null)
throw new InvalidOperationException(
- String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Arg_CATypeResolutionFailed"), typeName));
+ String.Format(CultureInfo.CurrentUICulture, SR.Arg_CATypeResolutionFailed, typeName));
return type;
}
@@ -848,17 +847,17 @@ namespace System.Reflection
else if (encodedType == CustomAttributeEncoding.Type)
{
m_argumentType = typeof(Type);
-
+
m_value = null;
if (encodedArg.StringValue != null)
m_value = ResolveType(scope, encodedArg.StringValue);
}
else if (encodedType == CustomAttributeEncoding.Array)
- {
+ {
encodedType = encodedArg.CustomAttributeType.EncodedArrayType;
Type elementType;
-
+
if (encodedType == CustomAttributeEncoding.Enum)
{
elementType = ResolveType(scope, encodedArg.CustomAttributeType.EnumName);
@@ -869,10 +868,10 @@ namespace System.Reflection
}
m_argumentType = elementType.MakeArrayType();
-
+
if (encodedArg.ArrayValue == null)
{
- m_value = null;
+ m_value = null;
}
else
{
@@ -949,12 +948,12 @@ namespace System.Reflection
return m_argumentType;
}
}
- public object Value
- {
- get
+ public object Value
+ {
+ get
{
return m_value;
- }
+ }
}
#endregion
}
@@ -994,17 +993,17 @@ namespace System.Reflection
[Serializable]
[StructLayout(LayoutKind.Auto)]
internal struct CustomAttributeEncodedArgument
- {
+ {
#region Parser
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void ParseAttributeArguments(
- IntPtr pCa,
- int cCa,
+ IntPtr pCa,
+ int cCa,
ref CustomAttributeCtorParameter[] CustomAttributeCtorParameters,
ref CustomAttributeNamedParameter[] CustomAttributeTypedArgument,
RuntimeAssembly assembly);
- internal static void ParseAttributeArguments(ConstArray attributeBlob,
+ internal static void ParseAttributeArguments(ConstArray attributeBlob,
ref CustomAttributeCtorParameter[] customAttributeCtorParameters,
ref CustomAttributeNamedParameter[] customAttributeNamedParameters,
RuntimeModule customAttributeModule)
@@ -1045,7 +1044,7 @@ namespace System.Reflection
public string StringValue { get { return m_stringValue; } }
#endregion
}
-
+
[Serializable]
[StructLayout(LayoutKind.Auto)]
internal struct CustomAttributeNamedParameter
@@ -1077,7 +1076,7 @@ namespace System.Reflection
public CustomAttributeEncodedArgument EncodedArgument { get { return m_encodedArgument; } }
#endregion
}
-
+
[Serializable]
[StructLayout(LayoutKind.Auto)]
internal struct CustomAttributeCtorParameter
@@ -1110,18 +1109,18 @@ namespace System.Reflection
private CustomAttributeEncoding m_encodedType; // ...array
private CustomAttributeEncoding m_encodedEnumType; // ...enum
private CustomAttributeEncoding m_encodedArrayType; // ...enum type
- private CustomAttributeEncoding m_padding;
+ private CustomAttributeEncoding m_padding;
#endregion
#region Constructor
- public CustomAttributeType(CustomAttributeEncoding encodedType, CustomAttributeEncoding encodedArrayType,
+ public CustomAttributeType(CustomAttributeEncoding encodedType, CustomAttributeEncoding encodedArrayType,
CustomAttributeEncoding encodedEnumType, string enumName)
{
m_encodedType = encodedType;
m_encodedArrayType = encodedArrayType;
m_encodedEnumType = encodedEnumType;
m_enumName = enumName;
- m_padding = m_encodedType;
+ m_padding = m_encodedType;
}
#endregion
@@ -1145,7 +1144,7 @@ namespace System.Reflection
{
Contract.Requires(type != null);
- if (type.GetElementType() != null)
+ if (type.GetElementType() != null)
return false;
if (PseudoCustomAttribute.IsDefined(type, caType))
@@ -1252,7 +1251,7 @@ namespace System.Reflection
return IsCustomAttributeDefined(parameter.GetRuntimeModule(), parameter.MetadataToken, caType);
}
- internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType)
+ internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType)
{
Contract.Requires(assembly != null);
Contract.Requires(caType != null);
@@ -1279,8 +1278,8 @@ namespace System.Reflection
Contract.Requires(type != null);
Contract.Requires(caType != null);
- if (type.GetElementType() != null)
- return (caType.IsValueType) ? EmptyArray<Object>.Value : CreateAttributeArrayHelper(caType, 0);
+ if (type.GetElementType() != null)
+ return (caType.IsValueType) ? Array.Empty<Object>() : CreateAttributeArrayHelper(caType, 0);
if (type.IsGenericType && !type.IsGenericTypeDefinition)
type = type.GetGenericTypeDefinition() as RuntimeType;
@@ -1323,7 +1322,7 @@ namespace System.Reflection
private static bool AllowCriticalCustomAttributes(RuntimeType type)
{
- if (type.IsGenericParameter)
+ if (type.IsGenericParameter)
{
// Generic parameters don't have transparency state, so look at the
// declaring method/type. One of declaringMethod or declaringType
@@ -1331,7 +1330,7 @@ namespace System.Reflection
MethodBase declaringMethod = type.DeclaringMethod;
if (declaringMethod != null)
{
- return AllowCriticalCustomAttributes(declaringMethod);
+ return AllowCriticalCustomAttributes(declaringMethod);
}
else
{
@@ -1394,9 +1393,9 @@ namespace System.Reflection
bool useObjectArray = (caType == null || caType.IsValueType || caType.ContainsGenericParameters);
Type arrayType = useObjectArray ? typeof(object) : caType;
- while (pcaCount > 0)
+ while (pcaCount > 0)
result.Add(pca[--pcaCount]);
-
+
while (method != null)
{
object[] attributes = GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, 0, caType, mustBeInheritable, result, !AllowCriticalCustomAttributes(method));
@@ -1478,12 +1477,12 @@ namespace System.Reflection
int pcaCount = 0;
Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(parameter, caType, out pcaCount);
- object[] attributes = GetCustomAttributes(parameter.GetRuntimeModule(), parameter.MetadataToken, pcaCount, caType, !AllowCriticalCustomAttributes(parameter));
+ object[] attributes = GetCustomAttributes(parameter.GetRuntimeModule(), parameter.MetadataToken, pcaCount, caType, !AllowCriticalCustomAttributes(parameter));
if (pcaCount > 0) Array.Copy(pca, 0, attributes, attributes.Length - pcaCount, pcaCount);
return attributes;
}
- internal static Object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
+ internal static Object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
{
Contract.Requires(assembly != null);
Contract.Requires(caType != null);
@@ -1497,7 +1496,7 @@ namespace System.Reflection
return attributes;
}
- internal static Object[] GetCustomAttributes(RuntimeModule module, RuntimeType caType)
+ internal static Object[] GetCustomAttributes(RuntimeModule module, RuntimeType caType)
{
Contract.Requires(module != null);
Contract.Requires(caType != null);
@@ -1525,7 +1524,7 @@ namespace System.Reflection
RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType attributeFilterType, int attributeCtorToken, bool mustBeInheritable)
{
if (decoratedModule.Assembly.ReflectionOnly)
- throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyCA"));
+ throw new InvalidOperationException(SR.Arg_ReflectionOnlyCA);
Contract.EndContractBlock();
CustomAttributeRecord[] car = CustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedMetadataToken);
@@ -1577,11 +1576,11 @@ namespace System.Reflection
}
private unsafe static object[] GetCustomAttributes(
- RuntimeModule decoratedModule, int decoratedMetadataToken, int pcaCount,
+ RuntimeModule decoratedModule, int decoratedMetadataToken, int pcaCount,
RuntimeType attributeFilterType, bool mustBeInheritable, IList derivedAttributes, bool isDecoratedTargetSecurityTransparent)
{
if (decoratedModule.Assembly.ReflectionOnly)
- throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyCA"));
+ throw new InvalidOperationException(SR.Arg_ReflectionOnlyCA);
Contract.EndContractBlock();
MetadataImport scope = decoratedModule.MetadataImport;
@@ -1614,8 +1613,8 @@ namespace System.Reflection
IntPtr blobEnd = (IntPtr)((byte*)blobStart + caRecord.blob.Length);
int blobLen = (int)((byte*)blobEnd - (byte*)blobStart);
- if (!FilterCustomAttributeRecord(caRecord, scope, ref lastAptcaOkAssembly,
- decoratedModule, decoratedMetadataToken, attributeFilterType, mustBeInheritable,
+ if (!FilterCustomAttributeRecord(caRecord, scope, ref lastAptcaOkAssembly,
+ decoratedModule, decoratedMetadataToken, attributeFilterType, mustBeInheritable,
attributes, derivedAttributes,
out attributeType, out ctor, out ctorHasParameters, out isVarArg))
continue;
@@ -1628,16 +1627,15 @@ namespace System.Reflection
}
else
{
-
}
// Leverage RuntimeConstructorInfo standard .ctor verfication
- RuntimeConstructorInfo.CheckCanCreateInstance(attributeType, isVarArg);
+ RuntimeConstructorInfo.CheckCanCreateInstance(attributeType, isVarArg);
// Create custom attribute object
if (ctorHasParameters)
{
- attribute = CreateCaObject(decoratedModule, ctor, ref blobStart, blobEnd, out cNamedArgs);
+ attribute = CreateCaObject(decoratedModule, ctor, ref blobStart, blobEnd, out cNamedArgs);
}
else
{
@@ -1674,7 +1672,7 @@ namespace System.Reflection
bool isProperty;
RuntimeType type;
object value;
-
+
IntPtr blobItr = caRecord.blob.Signature;
GetPropertyOrFieldData(decoratedModule, ref blobStart, blobEnd, out name, out isProperty, out type, out value);
@@ -1702,12 +1700,12 @@ namespace System.Reflection
if (property == null)
{
throw new CustomAttributeFormatException(
- String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString(
- isProperty ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), name));
+ String.Format(CultureInfo.CurrentUICulture,
+ isProperty ? SR.RFLCT_InvalidPropFail : SR.RFLCT_InvalidFieldFail, name));
}
RuntimeMethodInfo setMethod = property.GetSetMethod(true) as RuntimeMethodInfo;
-
+
// Public properties may have non-public setter methods
if (!setMethod.IsPublic)
continue;
@@ -1733,8 +1731,8 @@ namespace System.Reflection
catch (Exception e)
{
throw new CustomAttributeFormatException(
- String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString(
- isProperty ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), name), e);
+ String.Format(CultureInfo.CurrentUICulture,
+ isProperty ? SR.RFLCT_InvalidPropFail : SR.RFLCT_InvalidFieldFail, name), e);
}
#endregion
}
@@ -1756,7 +1754,7 @@ namespace System.Reflection
private unsafe static bool FilterCustomAttributeRecord(
CustomAttributeRecord caRecord,
MetadataImport scope,
- ref Assembly lastAptcaOkAssembly,
+ ref Assembly lastAptcaOkAssembly,
RuntimeModule decoratedModule,
MetadataToken decoratedToken,
RuntimeType attributeFilterType,
@@ -1772,7 +1770,7 @@ namespace System.Reflection
attributeType = null;
ctorHasParameters = false;
isVarArg = false;
-
+
IntPtr blobStart = caRecord.blob.Signature;
IntPtr blobEnd = (IntPtr)((byte*)blobStart + caRecord.blob.Length);
@@ -1817,13 +1815,13 @@ namespace System.Reflection
// Visibility checks
MetadataToken tkParent = new MetadataToken();
-
+
if (decoratedToken.IsParamDef)
{
tkParent = new MetadataToken(scope.GetParentToken(decoratedToken));
tkParent = new MetadataToken(scope.GetParentToken(tkParent));
- }
- else if (decoratedToken.IsMethodDef || decoratedToken.IsProperty || decoratedToken.IsEvent || decoratedToken.IsFieldDef)
+ }
+ else if (decoratedToken.IsMethodDef || decoratedToken.IsProperty || decoratedToken.IsEvent || decoratedToken.IsFieldDef)
{
tkParent = new MetadataToken(scope.GetParentToken(decoratedToken));
}
@@ -1842,7 +1840,7 @@ namespace System.Reflection
else
{
// We need to relax this when we add support for other types of decorated tokens.
- Debug.Assert(decoratedToken.IsModule || decoratedToken.IsAssembly,
+ Debug.Assert(decoratedToken.IsModule || decoratedToken.IsAssembly,
"The decoratedToken must be either an assembly, a module, a type, or a member.");
}
@@ -1907,7 +1905,7 @@ namespace System.Reflection
if (attributeUsageAttribute != null)
throw new FormatException(String.Format(
- CultureInfo.CurrentUICulture, Environment.GetResourceString("Format_AttributeUsage"), attributeType));
+ CultureInfo.CurrentUICulture, SR.Format_AttributeUsage, attributeType));
AttributeTargets targets;
bool inherited, allowMultiple;
@@ -1940,7 +1938,7 @@ namespace System.Reflection
{
byte* pBlob = (byte*)blob;
byte* pBlobEnd = (byte*)blobEnd;
- int cNamedArgs;
+ int cNamedArgs;
object ca = _CreateCaObject(module, ctor, &pBlob, pBlobEnd, &cNamedArgs);
blob = (IntPtr)pBlob;
namedArgs = cNamedArgs;
@@ -2025,9 +2023,9 @@ namespace System.Reflection
//AllowMultiple is true for TypeForwardedToAttribute
//Debug.Assert(usage.AllowMultiple == false, "Pseudo CA Error");
}
-#endregion
+ #endregion
-#region Internal Static
+ #region Internal Static
internal static bool IsSecurityAttribute(RuntimeType type)
{
// TODO: Cleanup
@@ -2083,12 +2081,12 @@ namespace System.Reflection
if (!all && s_pca.GetValueOrDefault(caType) == null && !IsSecurityAttribute(caType))
return false;
- if (all || caType == (RuntimeType)typeof(SerializableAttribute))
- {
+ if (all || caType == (RuntimeType)typeof(SerializableAttribute))
+ {
if (SerializableAttribute.IsDefined(type)) return true;
}
- if (all || caType == (RuntimeType)typeof(ComImportAttribute))
- {
+ if (all || caType == (RuntimeType)typeof(ComImportAttribute))
+ {
if (ComImportAttribute.IsDefined(type)) return true;
}
if (all || IsSecurityAttribute(caType))
@@ -2322,8 +2320,8 @@ namespace System.Reflection
{
if (FieldOffsetAttribute.IsDefined(field)) return true;
}
- if (all || caType == (RuntimeType)typeof(NonSerializedAttribute))
- {
+ if (all || caType == (RuntimeType)typeof(NonSerializedAttribute))
+ {
if (NonSerializedAttribute.IsDefined(field)) return true;
}
@@ -2392,6 +2390,6 @@ namespace System.Reflection
{
return false;
}
-#endregion
+ #endregion
}
}
diff --git a/src/mscorlib/src/System/Reflection/CustomAttributeExtensions.cs b/src/mscorlib/src/System/Reflection/CustomAttributeExtensions.cs
index c3287e17d1..24e5055b8d 100644
--- a/src/mscorlib/src/System/Reflection/CustomAttributeExtensions.cs
+++ b/src/mscorlib/src/System/Reflection/CustomAttributeExtensions.cs
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+
using System.Collections.Generic;
namespace System.Reflection
diff --git a/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs b/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs
deleted file mode 100644
index 9aee911a6c..0000000000
--- a/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs
+++ /dev/null
@@ -1,37 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// CustomAttributeFormatException is thrown when the binary format of a
-//
-// custom attribute is invalid.
-//
-//
-namespace System.Reflection {
- using System;
- using ApplicationException = System.ApplicationException;
- using System.Runtime.Serialization;
- [Serializable]
- public class CustomAttributeFormatException : FormatException {
-
- public CustomAttributeFormatException()
- : base(Environment.GetResourceString("Arg_CustomAttributeFormatException")) {
- SetErrorCode(__HResults.COR_E_CUSTOMATTRIBUTEFORMAT);
- }
-
- public CustomAttributeFormatException(String message) : base(message) {
- SetErrorCode(__HResults.COR_E_CUSTOMATTRIBUTEFORMAT);
- }
-
- public CustomAttributeFormatException(String message, Exception inner) : base(message, inner) {
- SetErrorCode(__HResults.COR_E_CUSTOMATTRIBUTEFORMAT);
- }
-
- protected CustomAttributeFormatException(SerializationInfo info, StreamingContext context) : base(info, context) {
- }
-
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/DefaultMemberAttribute.cs b/src/mscorlib/src/System/Reflection/DefaultMemberAttribute.cs
deleted file mode 100644
index 4232fcd2a1..0000000000
--- a/src/mscorlib/src/System/Reflection/DefaultMemberAttribute.cs
+++ /dev/null
@@ -1,39 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// DefaultMemberAttribute is defines the Member of a Type that is the "default"
-//
-// member used by Type.InvokeMember. The default member is simply a name given
-// to a type.
-//
-//
-//
-//
-namespace System.Reflection {
-
- using System;
-
-[Serializable]
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface)]
- public sealed class DefaultMemberAttribute : Attribute
- {
- // The name of the member
- private String m_memberName;
-
- // You must provide the name of the member, this is required
- public DefaultMemberAttribute(String memberName) {
- m_memberName = memberName;
- }
-
- // A get accessor to return the name from the attribute.
- // NOTE: There is no setter because the name must be provided
- // to the constructor. The name is not optional.
- public String MemberName {
- get {return m_memberName;}
- }
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs
index fb9324902a..e7499e57f0 100644
--- a/src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs
@@ -20,7 +20,7 @@ namespace System.Reflection.Emit
FullName,
AssemblyQualifiedName,
}
-
+
#region QCalls
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
@@ -76,7 +76,7 @@ namespace System.Reflection.Emit
if (!type.IsGenericTypeDefinition && type.ContainsGenericParameters)
return null;
}
-
+
TypeNameBuilder tnb = new TypeNameBuilder(CreateTypeNameBuilder());
tnb.Clear();
tnb.ConstructAssemblyQualifiedNameWorker(type, format);
@@ -100,20 +100,20 @@ namespace System.Reflection.Emit
{
if (elementType.HasElementType)
AddElementType(elementType.GetElementType());
-
+
if (elementType.IsPointer)
AddPointer();
else if (elementType.IsByRef)
AddByRef();
- else if (elementType.IsSzArray)
+ else if (elementType.IsSZArray)
AddSzArray();
else if (elementType.IsArray)
AddArray(elementType.GetArrayRank());
}
-
+
private void ConstructAssemblyQualifiedNameWorker(Type type, Format format)
{
Type rootType = type;
@@ -125,13 +125,13 @@ namespace System.Reflection.Emit
List<Type> nestings = new List<Type>();
for (Type t = rootType; t != null; t = t.IsGenericParameter ? null : t.DeclaringType)
nestings.Add(t);
-
+
for (int i = nestings.Count - 1; i >= 0; i--)
{
Type enclosingType = nestings[i];
string name = enclosingType.Name;
- if (i == nestings.Count - 1 && enclosingType.Namespace != null && enclosingType.Namespace.Length != 0)
+ if (i == nestings.Count - 1 && enclosingType.Namespace != null && enclosingType.Namespace.Length != 0)
name = enclosingType.Namespace + "." + name;
AddName(name);
@@ -146,7 +146,7 @@ namespace System.Reflection.Emit
for (int i = 0; i < genericArguments.Length; i++)
{
Format genericArgumentsFormat = format == Format.FullName ? Format.AssemblyQualifiedName : format;
-
+
OpenGenericArgument();
ConstructAssemblyQualifiedNameWorker(genericArguments[i], genericArgumentsFormat);
CloseGenericArgument();
@@ -160,7 +160,7 @@ namespace System.Reflection.Emit
if (format == Format.AssemblyQualifiedName)
AddAssemblySpec(type.Module.Assembly.FullName);
}
-
+
private void OpenGenericArguments() { OpenGenericArguments(m_typeNameBuilder); }
private void CloseGenericArguments() { CloseGenericArguments(m_typeNameBuilder); }
private void OpenGenericArgument() { OpenGenericArgument(m_typeNameBuilder); }
diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
index 5575e28917..6d9cb0db2f 100644
--- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
@@ -48,11 +48,11 @@ namespace System.Reflection.Emit
None = 0x00000000,
// Security attributes which affect the module security descriptor
- AllCritical = 0x00000001,
- Aptca = 0x00000002,
- Critical = 0x00000004,
- Transparent = 0x00000008,
- TreatAsSafe = 0x00000010,
+ AllCritical = 0x00000001,
+ Aptca = 0x00000002,
+ Critical = 0x00000004,
+ Transparent = 0x00000008,
+ TreatAsSafe = 0x00000010,
}
// When the user calls AppDomain.DefineDynamicAssembly the loader creates a new InternalAssemblyBuilder.
@@ -61,7 +61,7 @@ namespace System.Reflection.Emit
// Assembly to an AssemblyBuilder and emit code with the elevated permissions of the trusted code which
// origionally created the AssemblyBuilder via DefineDynamicAssembly. Today, this can no longer happen
// because the Assembly returned via AssemblyGetAssemblies() will be an InternalAssemblyBuilder.
-
+
// Only the caller of DefineDynamicAssembly will get an AssemblyBuilder.
// There is a 1-1 relationship between InternalAssemblyBuilder and AssemblyBuilder.
// AssemblyBuilder is composed of its InternalAssemblyBuilder.
@@ -94,39 +94,39 @@ namespace System.Reflection.Emit
#region Methods inherited from Assembly
public override String[] GetManifestResourceNames()
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly"));
+ throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
}
public override FileStream GetFile(String name)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly"));
+ throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
}
public override FileStream[] GetFiles(bool getResourceModules)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly"));
+ throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
}
public override Stream GetManifestResourceStream(Type type, String name)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly"));
+ throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
}
public override Stream GetManifestResourceStream(String name)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly"));
+ throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
}
public override ManifestResourceInfo GetManifestResourceInfo(String resourceName)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly"));
+ throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
}
public override String Location
{
get
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly"));
+ throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
}
}
@@ -134,13 +134,13 @@ namespace System.Reflection.Emit
{
get
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly"));
+ throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
}
}
public override Type[] GetExportedTypes()
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly"));
+ throw new NotSupportedException(SR.NotSupported_DynamicAssembly);
}
public override String ImageRuntimeVersion
@@ -177,16 +177,12 @@ namespace System.Reflection.Emit
private bool m_fManifestModuleUsedAsDefinedModule;
internal const string MANIFEST_MODULE_NAME = "RefEmit_InMemoryManifestModule";
-#if FEATURE_APPX
- private bool m_profileAPICheck;
-#endif
-
internal ModuleBuilder GetModuleBuilder(InternalModuleBuilder module)
{
Contract.Requires(module != null);
Debug.Assert(this.InternalAssembly == module.Assembly);
- lock(SyncRoot)
+ lock (SyncRoot)
{
// in CoreCLR there is only one module in each dynamic assembly, the manifest module
if (m_manifestModuleBuilder.InternalModule == module)
@@ -216,16 +212,6 @@ namespace System.Reflection.Emit
{
return InternalAssembly.GetNativeHandle();
}
-
-#if FEATURE_APPX
- internal bool ProfileAPICheck
- {
- get
- {
- return m_profileAPICheck;
- }
- }
-#endif
#endregion
#region Constructor
@@ -242,13 +228,10 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(name));
if (access != AssemblyBuilderAccess.Run
-#if FEATURE_REFLECTION_ONLY_LOAD
- && access != AssemblyBuilderAccess.ReflectionOnly
-#endif // FEATURE_REFLECTION_ONLY_LOAD
&& access != AssemblyBuilderAccess.RunAndCollect
)
{
- throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)access), nameof(access));
+ throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)access), nameof(access));
}
if (securityContextSource < SecurityContextSource.CurrentAppDomain ||
@@ -304,14 +287,7 @@ namespace System.Reflection.Emit
name.Name,
access,
dir);
-#if FEATURE_APPX
- if (AppDomain.ProfileAPICheck)
- {
- RuntimeAssembly creator = RuntimeAssembly.GetExecutingAssembly(ref stackMark);
- if (creator != null && !creator.IsFrameworkAssembly())
- m_profileAPICheck = true;
- }
-#endif
+
// Make sure that ManifestModule is properly initialized
// We need to do this before setting any CustomAttribute
InitManifestModule();
@@ -331,7 +307,7 @@ namespace System.Reflection.Emit
// because it hasn't been initialized.
// However, it can be used to set the custom attribute on the Assembly
m_manifestModuleBuilder = new ModuleBuilder(this, modBuilder);
-
+
// We are only setting the name in the managed ModuleBuilderData here.
// The name in the underlying metadata will be set when the
// manifest module is created during nCreateDynamicAssembly.
@@ -351,7 +327,7 @@ namespace System.Reflection.Emit
* to have a strong name and a hash will be computed when the assembly
* is saved.
**********************************************/
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static AssemblyBuilder DefineDynamicAssembly(
AssemblyName name,
AssemblyBuilderAccess access)
@@ -363,7 +339,7 @@ namespace System.Reflection.Emit
null, ref stackMark, null, SecurityContextSource.CurrentAssembly);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static AssemblyBuilder DefineDynamicAssembly(
AssemblyName name,
AssemblyBuilderAccess access,
@@ -425,9 +401,9 @@ namespace System.Reflection.Emit
* a transient module.
*
**********************************************/
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public ModuleBuilder DefineDynamicModule(
- String name)
+ String name)
{
Contract.Ensures(Contract.Result<ModuleBuilder>() != null);
@@ -435,39 +411,39 @@ namespace System.Reflection.Emit
return DefineDynamicModuleInternal(name, false, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public ModuleBuilder DefineDynamicModule(
- String name,
- bool emitSymbolInfo) // specify if emit symbol info or not
+ String name,
+ bool emitSymbolInfo) // specify if emit symbol info or not
{
Contract.Ensures(Contract.Result<ModuleBuilder>() != null);
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return DefineDynamicModuleInternal( name, emitSymbolInfo, ref stackMark );
+ return DefineDynamicModuleInternal(name, emitSymbolInfo, ref stackMark);
}
private ModuleBuilder DefineDynamicModuleInternal(
- String name,
- bool emitSymbolInfo, // specify if emit symbol info or not
+ String name,
+ bool emitSymbolInfo, // specify if emit symbol info or not
ref StackCrawlMark stackMark)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineDynamicModuleInternalNoLock(name, emitSymbolInfo, ref stackMark);
}
}
private ModuleBuilder DefineDynamicModuleInternalNoLock(
- String name,
- bool emitSymbolInfo, // specify if emit symbol info or not
+ String name,
+ bool emitSymbolInfo, // specify if emit symbol info or not
ref StackCrawlMark stackMark)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
if (name[0] == '\0')
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidName"), nameof(name));
+ throw new ArgumentException(SR.Argument_InvalidName, nameof(name));
Contract.Ensures(Contract.Result<ModuleBuilder>() != null);
Contract.EndContractBlock();
@@ -481,7 +457,7 @@ namespace System.Reflection.Emit
// create the dynamic module- only one ModuleBuilder per AssemblyBuilder can be created
if (m_fManifestModuleUsedAsDefinedModule == true)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoMultiModuleAssembly"));
+ throw new InvalidOperationException(SR.InvalidOperation_NoMultiModuleAssembly);
// Init(...) has already been called on m_manifestModuleBuilder in InitManifestModule()
dynModule = m_manifestModuleBuilder;
@@ -492,7 +468,7 @@ namespace System.Reflection.Emit
writer = SymWrapperCore.SymWriter.CreateSymWriter();
String fileName = "Unused"; // this symfile is never written to disk so filename does not matter.
-
+
// Pass the "real" module to the VM
pInternalSymWriter = ModuleBuilder.nCreateISymWriterForDynamicModule(dynModule.InternalModule, fileName);
@@ -512,14 +488,14 @@ namespace System.Reflection.Emit
return dynModule;
} // DefineDynamicModuleInternalNoLock
-#endregion
+ #endregion
internal void CheckContext(params Type[][] typess)
{
if (typess == null)
return;
-
- foreach(Type[] types in typess)
+
+ foreach (Type[] types in typess)
if (types != null)
CheckContext(types);
}
@@ -528,23 +504,23 @@ namespace System.Reflection.Emit
{
if (types == null)
return;
-
+
foreach (Type type in types)
{
if (type == null)
continue;
if (type.Module == null || type.Module.Assembly == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_TypeNotValid"));
+ throw new ArgumentException(SR.Argument_TypeNotValid);
if (type.Module.Assembly == typeof(object).Module.Assembly)
continue;
if (type.Module.Assembly.ReflectionOnly && !ReflectionOnly)
- throw new InvalidOperationException(Environment.GetResourceString("Arugment_EmitMixedContext1", type.AssemblyQualifiedName));
+ throw new InvalidOperationException(SR.Format(SR.Arugment_EmitMixedContext1, type.AssemblyQualifiedName));
if (!type.Module.Assembly.ReflectionOnly && ReflectionOnly)
- throw new InvalidOperationException(Environment.GetResourceString("Arugment_EmitMixedContext2", type.AssemblyQualifiedName));
+ throw new InvalidOperationException(SR.Format(SR.Arugment_EmitMixedContext2, type.AssemblyQualifiedName));
}
}
@@ -585,27 +561,27 @@ namespace System.Reflection.Emit
{
return InternalAssembly.GetManifestResourceNames();
}
-
+
public override FileStream GetFile(String name)
{
return InternalAssembly.GetFile(name);
}
-
+
public override FileStream[] GetFiles(bool getResourceModules)
{
return InternalAssembly.GetFiles(getResourceModules);
}
-
+
public override Stream GetManifestResourceStream(Type type, String name)
{
return InternalAssembly.GetManifestResourceStream(type, name);
}
-
+
public override Stream GetManifestResourceStream(String name)
{
return InternalAssembly.GetManifestResourceStream(name);
}
-
+
public override ManifestResourceInfo GetManifestResourceInfo(String resourceName)
{
return InternalAssembly.GetManifestResourceInfo(resourceName);
@@ -626,7 +602,7 @@ namespace System.Reflection.Emit
return InternalAssembly.ImageRuntimeVersion;
}
}
-
+
public override String CodeBase
{
get
@@ -637,9 +613,9 @@ namespace System.Reflection.Emit
// Override the EntryPoint method on Assembly.
// This doesn't need to be synchronized because it is simple enough
- public override MethodInfo EntryPoint
+ public override MethodInfo EntryPoint
{
- get
+ get
{
return m_assemblyData.m_entryPointMethod;
}
@@ -721,7 +697,7 @@ namespace System.Reflection.Emit
return InternalAssembly.GetLoadedModules(getResourceModules);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Assembly GetSatelliteAssembly(CultureInfo culture)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
@@ -729,7 +705,7 @@ namespace System.Reflection.Emit
}
// Useful for binding to a very specific version of a satellite assembly
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Assembly GetSatelliteAssembly(CultureInfo culture, Version version)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
@@ -738,7 +714,8 @@ namespace System.Reflection.Emit
public override bool IsDynamic
{
- get {
+ get
+ {
return true;
}
}
@@ -751,28 +728,28 @@ namespace System.Reflection.Emit
*
**********************************************/
public ModuleBuilder GetDynamicModule(
- String name) // the name of module for the look up
+ String name) // the name of module for the look up
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return GetDynamicModuleNoLock(name);
}
}
private ModuleBuilder GetDynamicModuleNoLock(
- String name) // the name of module for the look up
+ String name) // the name of module for the look up
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
Contract.EndContractBlock();
BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.GetDynamicModule( " + name + " )");
int size = m_assemblyData.m_moduleBuilderList.Count;
for (int i = 0; i < size; i++)
{
- ModuleBuilder moduleBuilder = (ModuleBuilder) m_assemblyData.m_moduleBuilderList[i];
+ ModuleBuilder moduleBuilder = (ModuleBuilder)m_assemblyData.m_moduleBuilderList[i];
if (moduleBuilder.m_moduleData.m_strModuleName.Equals(name))
{
return moduleBuilder;
@@ -792,8 +769,8 @@ namespace System.Reflection.Emit
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
Contract.EndContractBlock();
-
- lock(SyncRoot)
+
+ lock (SyncRoot)
{
SetCustomAttributeNoLock(con, binaryAttribute);
}
@@ -828,7 +805,7 @@ namespace System.Reflection.Emit
}
Contract.EndContractBlock();
- lock(SyncRoot)
+ lock (SyncRoot)
{
SetCustomAttributeNoLock(customBuilder);
}
@@ -837,7 +814,7 @@ namespace System.Reflection.Emit
private void SetCustomAttributeNoLock(CustomAttributeBuilder customBuilder)
{
customBuilder.CreateCustomAttribute(
- m_manifestModuleBuilder,
+ m_manifestModuleBuilder,
AssemblyBuilderData.m_tkAssembly); // This is the AssemblyDef token
// Track the CA for persistence
@@ -852,11 +829,11 @@ namespace System.Reflection.Emit
* Private methods
*
**********************************************/
-
+
/**********************************************
* Make a private constructor so these cannot be constructed externally.
* @internonly
**********************************************/
- private AssemblyBuilder() {}
+ private AssemblyBuilder() { }
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs
index b3d1711307..ead2fafcef 100644
--- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs
@@ -7,16 +7,13 @@ using System;
// This enumeration defines the access modes for a dynamic assembly.
// EE uses these enum values..look for m_dwDynamicAssemblyAccess in Assembly.hpp
-namespace System.Reflection.Emit
+namespace System.Reflection.Emit
{
[Serializable]
[Flags]
public enum AssemblyBuilderAccess
{
Run = 1,
-#if FEATURE_REFLECTION_ONLY_LOAD
- ReflectionOnly = 6, // 4 | Save,
-#endif // FEATURE_REFLECTION_ONLY_LOAD
RunAndCollect = 8 | Run
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs
index 7ac9daeac0..529ba54514 100644
--- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs
@@ -6,7 +6,8 @@
////////////////////////////////////////////////////////////////////////////////
//
-namespace System.Reflection.Emit {
+namespace System.Reflection.Emit
+{
using System;
using IList = System.Collections.IList;
using System.Collections.Generic;
@@ -25,10 +26,10 @@ namespace System.Reflection.Emit {
internal class AssemblyBuilderData
{
internal AssemblyBuilderData(
- InternalAssemblyBuilder assembly,
- String strAssemblyName,
- AssemblyBuilderAccess access,
- String dir)
+ InternalAssemblyBuilder assembly,
+ String strAssemblyName,
+ AssemblyBuilderAccess access,
+ String dir)
{
m_assembly = assembly;
m_strAssemblyName = strAssemblyName;
@@ -44,8 +45,8 @@ namespace System.Reflection.Emit {
m_strDir = dir;
m_peFileKind = PEFileKinds.Dll;
- }
-
+ }
+
// Helper to add a dynamic module into the tracking list
internal void AddModule(ModuleBuilder dynModule)
{
@@ -56,7 +57,6 @@ namespace System.Reflection.Emit {
// Helper to track CAs to persist onto disk
internal void AddCustomAttribute(CustomAttributeBuilder customBuilder)
{
-
// make sure we have room for this CA
if (m_CABuilders == null)
{
@@ -64,31 +64,30 @@ namespace System.Reflection.Emit {
}
if (m_iCABuilder == m_CABuilders.Length)
{
- CustomAttributeBuilder[] tempCABuilders = new CustomAttributeBuilder[m_iCABuilder * 2];
+ CustomAttributeBuilder[] tempCABuilders = new CustomAttributeBuilder[m_iCABuilder * 2];
Array.Copy(m_CABuilders, 0, tempCABuilders, 0, m_iCABuilder);
- m_CABuilders = tempCABuilders;
+ m_CABuilders = tempCABuilders;
}
m_CABuilders[m_iCABuilder] = customBuilder;
-
+
m_iCABuilder++;
}
// Helper to track CAs to persist onto disk
internal void AddCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
-
// make sure we have room for this CA
if (m_CABytes == null)
{
m_CABytes = new byte[m_iInitialSize][];
- m_CACons = new ConstructorInfo[m_iInitialSize];
+ m_CACons = new ConstructorInfo[m_iInitialSize];
}
if (m_iCAs == m_CABytes.Length)
{
// enlarge the arrays
- byte[][] temp = new byte[m_iCAs * 2][];
+ byte[][] temp = new byte[m_iCAs * 2][];
ConstructorInfo[] tempCon = new ConstructorInfo[m_iCAs * 2];
- for (int i=0; i < m_iCAs; i++)
+ for (int i = 0; i < m_iCAs; i++)
{
temp[i] = m_CABytes[i];
tempCon[i] = m_CACons[i];
@@ -103,12 +102,12 @@ namespace System.Reflection.Emit {
m_CACons[m_iCAs] = con;
m_iCAs++;
}
-
+
// Helper to ensure the type name is unique underneath assemblyBuilder
internal void CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType)
{
- BCLDebug.Log("DYNIL","## DYNIL LOGGING: AssemblyBuilderData.CheckTypeNameConflict( " + strTypeName + " )");
- for (int i = 0; i < m_moduleBuilderList.Count; i++)
+ BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilderData.CheckTypeNameConflict( " + strTypeName + " )");
+ for (int i = 0; i < m_moduleBuilderList.Count; i++)
{
ModuleBuilder curModule = m_moduleBuilderList[i];
curModule.CheckTypeNameConflict(strTypeName, enclosingType);
@@ -121,60 +120,59 @@ namespace System.Reflection.Emit {
// if (enclosingType == null && m_assembly.GetType(strTypeName, false, false) != null)
// {
// // Cannot have two types with the same name
- // throw new ArgumentException(Environment.GetResourceString("Argument_DuplicateTypeName"));
+ // throw new ArgumentException(SR.Argument_DuplicateTypeName);
// }
}
-
- internal List<ModuleBuilder> m_moduleBuilderList;
- internal List<ResWriterData> m_resWriterList;
- internal String m_strAssemblyName;
- internal AssemblyBuilderAccess m_access;
+
+ internal List<ModuleBuilder> m_moduleBuilderList;
+ internal List<ResWriterData> m_resWriterList;
+ internal String m_strAssemblyName;
+ internal AssemblyBuilderAccess m_access;
private InternalAssemblyBuilder m_assembly;
-
- internal Type[] m_publicComTypeList;
- internal int m_iPublicComTypeCount;
-
- internal bool m_isSaved;
- internal const int m_iInitialSize = 16;
- internal String m_strDir;
+
+ internal Type[] m_publicComTypeList;
+ internal int m_iPublicComTypeCount;
+
+ internal bool m_isSaved;
+ internal const int m_iInitialSize = 16;
+ internal String m_strDir;
// hard coding the assembly def token
- internal const int m_tkAssembly = 0x20000001;
-
+ internal const int m_tkAssembly = 0x20000001;
+
// tracking AssemblyDef's CAs for persistence to disk
internal CustomAttributeBuilder[] m_CABuilders;
- internal int m_iCABuilder;
- internal byte[][] m_CABytes;
- internal ConstructorInfo[] m_CACons;
- internal int m_iCAs;
- internal PEFileKinds m_peFileKind; // assembly file kind
- internal MethodInfo m_entryPointMethod;
- internal Assembly m_ISymWrapperAssembly;
+ internal int m_iCABuilder;
+ internal byte[][] m_CABytes;
+ internal ConstructorInfo[] m_CACons;
+ internal int m_iCAs;
+ internal PEFileKinds m_peFileKind; // assembly file kind
+ internal MethodInfo m_entryPointMethod;
+ internal Assembly m_ISymWrapperAssembly;
// For unmanaged resources
- internal String m_strResourceFileName;
- internal byte[] m_resourceBytes;
- internal NativeVersionInfo m_nativeVersion;
- internal bool m_hasUnmanagedVersionInfo;
- internal bool m_OverrideUnmanagedVersionInfo;
-
+ internal String m_strResourceFileName;
+ internal byte[] m_resourceBytes;
+ internal NativeVersionInfo m_nativeVersion;
+ internal bool m_hasUnmanagedVersionInfo;
+ internal bool m_OverrideUnmanagedVersionInfo;
}
-
+
/**********************************************
*
* Internal structure to track the list of ResourceWriter for
* AssemblyBuilder & ModuleBuilder.
*
**********************************************/
- internal class ResWriterData
+ internal class ResWriterData
{
- internal String m_strName;
- internal String m_strFileName;
- internal String m_strFullFileName;
- internal Stream m_memoryStream;
- internal ResWriterData m_nextResWriter;
- internal ResourceAttributes m_attribute;
+ internal String m_strName;
+ internal String m_strFileName;
+ internal String m_strFullFileName;
+ internal Stream m_memoryStream;
+ internal ResWriterData m_nextResWriter;
+ internal ResourceAttributes m_attribute;
}
internal class NativeVersionInfo
@@ -191,15 +189,15 @@ namespace System.Reflection.Emit {
m_strFileVersion = null;
m_lcid = -1;
}
-
- internal String m_strDescription;
- internal String m_strCompany;
- internal String m_strTitle;
- internal String m_strCopyright;
- internal String m_strTrademark;
- internal String m_strProduct;
- internal String m_strProductVersion;
- internal String m_strFileVersion;
- internal int m_lcid;
+
+ internal String m_strDescription;
+ internal String m_strCompany;
+ internal String m_strTitle;
+ internal String m_strCopyright;
+ internal String m_strTrademark;
+ internal String m_strProduct;
+ internal String m_strProductVersion;
+ internal String m_strFileVersion;
+ internal int m_lcid;
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs
index 3bc02860a1..3ca9b2eb9d 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs
@@ -4,8 +4,8 @@
//
-namespace System.Reflection.Emit
-{
+namespace System.Reflection.Emit
+{
using System;
using System.Reflection;
using CultureInfo = System.Globalization.CultureInfo;
@@ -14,9 +14,9 @@ namespace System.Reflection.Emit
using System.Security;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
-
+
public sealed class ConstructorBuilder : ConstructorInfo
- {
+ {
private readonly MethodBuilder m_methodBuilder;
internal bool m_isDefaultConstructor;
@@ -25,7 +25,7 @@ namespace System.Reflection.Emit
private ConstructorBuilder()
{
}
-
+
internal ConstructorBuilder(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers, ModuleBuilder mod, TypeBuilder type)
{
@@ -33,18 +33,18 @@ namespace System.Reflection.Emit
byte[] sigBytes;
MethodToken token;
- m_methodBuilder = new MethodBuilder(name, attributes, callingConvention, null, null, null,
+ m_methodBuilder = new MethodBuilder(name, attributes, callingConvention, null, null, null,
parameterTypes, requiredCustomModifiers, optionalCustomModifiers, mod, type, false);
type.m_listMethods.Add(m_methodBuilder);
-
+
sigBytes = m_methodBuilder.GetMethodSignature().InternalGetSignature(out sigLength);
-
+
token = m_methodBuilder.GetToken();
}
internal ConstructorBuilder(String name, MethodAttributes attributes, CallingConventions callingConvention,
- Type[] parameterTypes, ModuleBuilder mod, TypeBuilder type) :
+ Type[] parameterTypes, ModuleBuilder mod, TypeBuilder type) :
this(name, attributes, callingConvention, parameterTypes, null, null, mod, type)
{
}
@@ -68,7 +68,7 @@ namespace System.Reflection.Emit
{
return m_methodBuilder.ToString();
}
-
+
#endregion
#region MemberInfo Overrides
@@ -76,12 +76,12 @@ namespace System.Reflection.Emit
{
get { return m_methodBuilder.MetadataTokenInternal; }
}
-
+
public override Module Module
{
get { return m_methodBuilder.Module; }
}
-
+
public override Type ReflectedType
{
get { return m_methodBuilder.ReflectedType; }
@@ -91,8 +91,8 @@ namespace System.Reflection.Emit
{
get { return m_methodBuilder.DeclaringType; }
}
-
- public override String Name
+
+ public override String Name
{
get { return m_methodBuilder.Name; }
}
@@ -100,9 +100,9 @@ namespace System.Reflection.Emit
#endregion
#region MethodBase Overrides
- public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
+ public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
[Pure]
@@ -111,7 +111,7 @@ namespace System.Reflection.Emit
ConstructorInfo rci = GetTypeBuilder().GetConstructor(m_methodBuilder.m_parameterTypes);
return rci.GetParameters();
}
-
+
public override MethodAttributes Attributes
{
get { return m_methodBuilder.Attributes; }
@@ -121,20 +121,20 @@ namespace System.Reflection.Emit
{
return m_methodBuilder.GetMethodImplementationFlags();
}
-
- public override RuntimeMethodHandle MethodHandle
+
+ public override RuntimeMethodHandle MethodHandle
{
get { return m_methodBuilder.MethodHandle; }
}
-
+
#endregion
#region ConstructorInfo Overrides
public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
-
+
#endregion
#region ICustomAttributeProvider Implementation
@@ -147,8 +147,8 @@ namespace System.Reflection.Emit
{
return m_methodBuilder.GetCustomAttributes(attributeType, inherit);
}
-
- public override bool IsDefined (Type attributeType, bool inherit)
+
+ public override bool IsDefined(Type attributeType, bool inherit)
{
return m_methodBuilder.IsDefined(attributeType, inherit);
}
@@ -160,7 +160,7 @@ namespace System.Reflection.Emit
{
return m_methodBuilder.GetToken();
}
-
+
public ParameterBuilder DefineParameter(int iSequence, ParameterAttributes attributes, String strParamName)
{
// Theoretically we shouldn't allow iSequence to be 0 because in reflection ctors don't have
@@ -171,50 +171,50 @@ namespace System.Reflection.Emit
attributes = attributes & ~ParameterAttributes.ReservedMask;
return m_methodBuilder.DefineParameter(iSequence, attributes, strParamName);
}
-
- public ILGenerator GetILGenerator()
+
+ public ILGenerator GetILGenerator()
{
if (m_isDefaultConstructor)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_DefaultConstructorILGen"));
+ throw new InvalidOperationException(SR.InvalidOperation_DefaultConstructorILGen);
return m_methodBuilder.GetILGenerator();
}
-
+
public ILGenerator GetILGenerator(int streamSize)
{
if (m_isDefaultConstructor)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_DefaultConstructorILGen"));
+ throw new InvalidOperationException(SR.InvalidOperation_DefaultConstructorILGen);
return m_methodBuilder.GetILGenerator(streamSize);
}
- public override CallingConventions CallingConvention
- {
- get
- {
+ public override CallingConventions CallingConvention
+ {
+ get
+ {
if (DeclaringType.IsGenericType)
return CallingConventions.HasThis;
-
- return CallingConventions.Standard;
- }
+
+ return CallingConventions.Standard;
+ }
}
-
+
public Module GetModule()
{
return m_methodBuilder.GetModule();
}
-
+
// This always returns null. Is that what we want?
- internal override Type GetReturnType()
+ internal override Type GetReturnType()
{
return m_methodBuilder.ReturnType;
}
-
- public String Signature
+
+ public String Signature
{
get { return m_methodBuilder.Signature; }
}
-
+
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
m_methodBuilder.SetCustomAttribute(con, binaryAttribute);
@@ -225,12 +225,12 @@ namespace System.Reflection.Emit
m_methodBuilder.SetCustomAttribute(customBuilder);
}
- public void SetImplementationFlags(MethodImplAttributes attributes)
+ public void SetImplementationFlags(MethodImplAttributes attributes)
{
m_methodBuilder.SetImplementationFlags(attributes);
}
-
- public bool InitLocals
+
+ public bool InitLocals
{
get { return m_methodBuilder.InitLocals; }
set { m_methodBuilder.InitLocals = value; }
diff --git a/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
index 5d08ca08f0..cf5bd11de6 100644
--- a/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
@@ -12,18 +12,19 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
-
-
- using System;
- using System.Reflection;
- using System.IO;
- using System.Text;
- using System.Runtime.InteropServices;
- using System.Globalization;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
-
+
+
+using System;
+using System.Reflection;
+using System.IO;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.Globalization;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+
+namespace System.Reflection.Emit
+{
public class CustomAttributeBuilder
{
// public constructor to form the custom attribute with constructor and constructor
@@ -31,17 +32,17 @@ namespace System.Reflection.Emit {
public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs)
{
InitCustomAttributeBuilder(con, constructorArgs,
- new PropertyInfo[]{}, new Object[]{},
- new FieldInfo[]{}, new Object[]{});
+ new PropertyInfo[] { }, new Object[] { },
+ new FieldInfo[] { }, new Object[] { });
}
-
+
// public constructor to form the custom attribute with constructor, constructor
// parameters and named properties.
public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs,
PropertyInfo[] namedProperties, Object[] propertyValues)
{
InitCustomAttributeBuilder(con, constructorArgs, namedProperties,
- propertyValues, new FieldInfo[]{}, new Object[]{});
+ propertyValues, new FieldInfo[] { }, new Object[] { });
}
// public constructor to form the custom attribute with constructor and constructor
@@ -49,8 +50,8 @@ namespace System.Reflection.Emit {
public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs,
FieldInfo[] namedFields, Object[] fieldValues)
{
- InitCustomAttributeBuilder(con, constructorArgs, new PropertyInfo[]{},
- new Object[]{}, namedFields, fieldValues);
+ InitCustomAttributeBuilder(con, constructorArgs, new PropertyInfo[] { },
+ new Object[] { }, namedFields, fieldValues);
}
// public constructor to form the custom attribute with constructor and constructor
@@ -117,17 +118,17 @@ namespace System.Reflection.Emit {
if (fieldValues == null)
throw new ArgumentNullException(nameof(fieldValues));
if (namedProperties.Length != propertyValues.Length)
- throw new ArgumentException(Environment.GetResourceString("Arg_ArrayLengthsDiffer"), "namedProperties, propertyValues");
+ throw new ArgumentException(SR.Arg_ArrayLengthsDiffer, "namedProperties, propertyValues");
if (namedFields.Length != fieldValues.Length)
- throw new ArgumentException(Environment.GetResourceString("Arg_ArrayLengthsDiffer"), "namedFields, fieldValues");
+ throw new ArgumentException(SR.Arg_ArrayLengthsDiffer, "namedFields, fieldValues");
Contract.EndContractBlock();
if ((con.Attributes & MethodAttributes.Static) == MethodAttributes.Static ||
(con.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadConstructor"));
+ throw new ArgumentException(SR.Argument_BadConstructor);
if ((con.CallingConvention & CallingConventions.Standard) != CallingConventions.Standard)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadConstructorCallConv"));
+ throw new ArgumentException(SR.Argument_BadConstructorCallConv);
// Cache information used elsewhere.
m_con = con;
@@ -142,12 +143,12 @@ namespace System.Reflection.Emit {
// Since we're guaranteed a non-var calling convention, the number of arguments must equal the number of parameters.
if (paramTypes.Length != constructorArgs.Length)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadParameterCountsForConstructor"));
+ throw new ArgumentException(SR.Argument_BadParameterCountsForConstructor);
// Verify that the constructor has a valid signature (custom attributes only support a subset of our type system).
for (i = 0; i < paramTypes.Length; i++)
if (!ValidateType(paramTypes[i]))
- throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeInCustomAttribute"));
+ throw new ArgumentException(SR.Argument_BadTypeInCustomAttribute);
// Now verify that the types of the actual parameters are compatible with the types of the formal parameters.
for (i = 0; i < paramTypes.Length; i++)
@@ -194,11 +195,11 @@ namespace System.Reflection.Emit {
// Validate property type.
if (!ValidateType(propType))
- throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeInCustomAttribute"));
+ throw new ArgumentException(SR.Argument_BadTypeInCustomAttribute);
// Property has to be writable.
if (!property.CanWrite)
- throw new ArgumentException(Environment.GetResourceString("Argument_NotAWritableProperty"));
+ throw new ArgumentException(SR.Argument_NotAWritableProperty);
// Property has to be from the same class or base class as ConstructorInfo.
if (property.DeclaringType != con.DeclaringType
@@ -216,7 +217,7 @@ namespace System.Reflection.Emit {
// type is one.
if (!(property.DeclaringType is TypeBuilder) ||
!con.DeclaringType.IsSubclassOf(((TypeBuilder)property.DeclaringType).BakedRuntimeType))
- throw new ArgumentException(Environment.GetResourceString("Argument_BadPropertyForConstructorBuilder"));
+ throw new ArgumentException(SR.Argument_BadPropertyForConstructorBuilder);
}
}
@@ -252,7 +253,7 @@ namespace System.Reflection.Emit {
// Validate field type.
if (!ValidateType(fldType))
- throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeInCustomAttribute"));
+ throw new ArgumentException(SR.Argument_BadTypeInCustomAttribute);
// Field has to be from the same class or base class as ConstructorInfo.
if (namedField.DeclaringType != con.DeclaringType
@@ -270,7 +271,7 @@ namespace System.Reflection.Emit {
// type is one.
if (!(namedField.DeclaringType is TypeBuilder) ||
!con.DeclaringType.IsSubclassOf(((TypeBuilder)namedFields[i].DeclaringType).BakedRuntimeType))
- throw new ArgumentException(Environment.GetResourceString("Argument_BadFieldForConstructorBuilder"));
+ throw new ArgumentException(SR.Argument_BadFieldForConstructorBuilder);
}
}
@@ -280,7 +281,7 @@ namespace System.Reflection.Emit {
{
VerifyTypeAndPassedObjectType(fldType, fieldValue.GetType(), $"{nameof(fieldValues)}[{i}]");
}
-
+
// First a byte indicating that this is a field.
writer.Write((byte)CustomAttributeEncoding.Field);
@@ -298,11 +299,11 @@ namespace System.Reflection.Emit {
{
if (type != typeof(object) && Type.GetTypeCode(passedType) != Type.GetTypeCode(type))
{
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch"));
+ throw new ArgumentException(SR.Argument_ConstantDoesntMatch);
}
if (passedType == typeof(IntPtr) || passedType == typeof(UIntPtr))
{
- throw new ArgumentException(Environment.GetResourceString("Argument_BadParameterTypeForCAB"), paramName);
+ throw new ArgumentException(SR.Argument_BadParameterTypeForCAB, paramName);
}
}
@@ -452,8 +453,7 @@ namespace System.Reflection.Emit {
{
String typeName = TypeNameBuilder.ToString((Type)value, TypeNameBuilder.Format.AssemblyQualifiedName);
if (typeName == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidTypeForCA",
- value.GetType()));
+ throw new ArgumentException(SR.Format(SR.Argument_InvalidTypeForCA, value.GetType()));
EmitString(writer, typeName);
}
}
@@ -526,8 +526,8 @@ namespace System.Reflection.Emit {
// value cannot be a "System.Object" object.
// If we allow this we will get into an infinite recursion
if (ot == typeof(object))
- throw new ArgumentException(Environment.GetResourceString("Argument_BadParameterTypeForCAB", ot.ToString()));
-
+ throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, ot.ToString()));
+
EmitType(writer, ot);
EmitValue(writer, ot, value);
}
@@ -537,13 +537,13 @@ namespace System.Reflection.Emit {
if (value != null)
typename = value.GetType().ToString();
-
- throw new ArgumentException(Environment.GetResourceString("Argument_BadParameterTypeForCAB", typename));
+
+ throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, typename));
}
}
-
-
+
+
// return the byte interpretation of the custom attribute
internal void CreateCustomAttribute(ModuleBuilder mod, int tkOwner)
@@ -556,12 +556,12 @@ namespace System.Reflection.Emit {
//*************************************************
internal void CreateCustomAttribute(ModuleBuilder mod, int tkOwner, int tkAttrib, bool toDisk)
{
- TypeBuilder.DefineCustomAttribute(mod, tkOwner, tkAttrib, m_blob, toDisk,
+ TypeBuilder.DefineCustomAttribute(mod, tkOwner, tkAttrib, m_blob, toDisk,
typeof(System.Diagnostics.DebuggableAttribute) == m_con.DeclaringType);
}
- internal ConstructorInfo m_con;
- internal Object[] m_constructorArgs;
- internal byte[] m_blob;
+ internal ConstructorInfo m_con;
+ internal Object[] m_constructorArgs;
+ internal byte[] m_blob;
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
index cb2667a104..b592053f9f 100644
--- a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
@@ -6,7 +6,6 @@
namespace System.Reflection.Emit
{
-
using System;
using System.Globalization;
using System.Diagnostics.SymbolStore;
@@ -22,7 +21,6 @@ namespace System.Reflection.Emit
internal class DynamicILGenerator : ILGenerator
{
-
internal DynamicScope m_scope;
private int m_methodSigToken;
@@ -44,16 +42,6 @@ namespace System.Reflection.Emit
new DynamicResolver(this));
}
-#if FEATURE_APPX
- private bool ProfileAPICheck
- {
- get
- {
- return ((DynamicMethod)m_methodBuilder).ProfileAPICheck;
- }
- }
-#endif // FEATURE_APPX
-
// *** ILGenerator api ***
public override LocalBuilder DeclareLocal(Type localType, bool pinned)
@@ -66,12 +54,7 @@ namespace System.Reflection.Emit
RuntimeType rtType = localType as RuntimeType;
if (rtType == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
-
-#if FEATURE_APPX
- if (ProfileAPICheck && (rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName));
-#endif
+ throw new ArgumentException(SR.Argument_MustBeRuntimeType);
localBuilder = new LocalBuilder(m_localCount, localType, m_methodBuilder);
// add the localType to local signature
@@ -98,7 +81,7 @@ namespace System.Reflection.Emit
{
RuntimeMethodInfo rtMeth = meth as RuntimeMethodInfo;
if (rtMeth == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(meth));
+ throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(meth));
RuntimeType declaringType = rtMeth.GetRuntimeType();
if (declaringType != null && (declaringType.IsGenericType || declaringType.IsArray))
@@ -111,7 +94,7 @@ namespace System.Reflection.Emit
// rule out not allowed operations on DynamicMethods
if (opcode.Equals(OpCodes.Ldtoken) || opcode.Equals(OpCodes.Ldftn) || opcode.Equals(OpCodes.Ldvirtftn))
{
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOpCodeOnDynamicMethod"));
+ throw new ArgumentException(SR.Argument_InvalidOpCodeOnDynamicMethod);
}
token = GetTokenFor(dynMeth);
}
@@ -149,7 +132,7 @@ namespace System.Reflection.Emit
RuntimeConstructorInfo rtConstructor = con as RuntimeConstructorInfo;
if (rtConstructor == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(con));
+ throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(con));
RuntimeType declaringType = rtConstructor.GetRuntimeType();
int token;
@@ -178,7 +161,7 @@ namespace System.Reflection.Emit
RuntimeType rtType = type as RuntimeType;
if (rtType == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
+ throw new ArgumentException(SR.Argument_MustBeRuntimeType);
int token = GetTokenFor(rtType);
EnsureCapacity(7);
@@ -194,7 +177,7 @@ namespace System.Reflection.Emit
RuntimeFieldInfo runtimeField = field as RuntimeFieldInfo;
if (runtimeField == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo"), nameof(field));
+ throw new ArgumentException(SR.Argument_MustBeRuntimeFieldInfo, nameof(field));
int token;
if (field.DeclaringType == null)
@@ -235,7 +218,7 @@ namespace System.Reflection.Emit
if (optionalParameterTypes != null)
if ((callingConvention & CallingConventions.VarArgs) == 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention"));
+ throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention);
sig = GetMemberRefSignature(callingConvention,
returnType,
@@ -271,13 +254,13 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(methodInfo));
if (!(opcode.Equals(OpCodes.Call) || opcode.Equals(OpCodes.Callvirt) || opcode.Equals(OpCodes.Newobj)))
- throw new ArgumentException(Environment.GetResourceString("Argument_NotMethodCallOpcode"), nameof(opcode));
+ throw new ArgumentException(SR.Argument_NotMethodCallOpcode, nameof(opcode));
if (methodInfo.ContainsGenericParameters)
- throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(methodInfo));
+ throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(methodInfo));
if (methodInfo.DeclaringType != null && methodInfo.DeclaringType.ContainsGenericParameters)
- throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(methodInfo));
+ throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(methodInfo));
Contract.EndContractBlock();
int tk;
@@ -345,7 +328,7 @@ namespace System.Reflection.Emit
// Begins an exception filter block. Emits a branch instruction to the end of the current exception block.
if (CurrExcStackCount == 0)
- throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock"));
+ throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
__ExceptionInfo current = CurrExcStack[CurrExcStackCount - 1];
@@ -359,7 +342,7 @@ namespace System.Reflection.Emit
public override void BeginCatchBlock(Type exceptionType)
{
if (CurrExcStackCount == 0)
- throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock"));
+ throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
Contract.EndContractBlock();
__ExceptionInfo current = CurrExcStack[CurrExcStackCount - 1];
@@ -370,7 +353,7 @@ namespace System.Reflection.Emit
{
if (exceptionType != null)
{
- throw new ArgumentException(Environment.GetResourceString("Argument_ShouldNotSpecifyExceptionType"));
+ throw new ArgumentException(SR.Argument_ShouldNotSpecifyExceptionType);
}
this.Emit(OpCodes.Endfilter);
@@ -384,7 +367,7 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(exceptionType));
if (rtType == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
+ throw new ArgumentException(SR.Argument_MustBeRuntimeType);
Label endLabel = current.GetEndLabel();
this.Emit(OpCodes.Leave, endLabel);
@@ -409,7 +392,7 @@ namespace System.Reflection.Emit
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
public override void UsingNamespace(String ns)
{
- throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod"));
+ throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod);
}
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems.
@@ -419,17 +402,17 @@ namespace System.Reflection.Emit
int endLine,
int endColumn)
{
- throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod"));
+ throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod);
}
public override void BeginScope()
{
- throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod"));
+ throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod);
}
public override void EndScope()
{
- throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod"));
+ throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod);
}
private int GetMemberRefToken(MethodBase methodInfo, Type[] optionalParameterTypes)
@@ -437,13 +420,13 @@ namespace System.Reflection.Emit
Type[] parameterTypes;
if (optionalParameterTypes != null && (methodInfo.CallingConvention & CallingConventions.VarArgs) == 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention"));
+ throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention);
RuntimeMethodInfo rtMeth = methodInfo as RuntimeMethodInfo;
DynamicMethod dm = methodInfo as DynamicMethod;
if (rtMeth == null && dm == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(methodInfo));
+ throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(methodInfo));
ParameterInfo[] paramInfo = methodInfo.GetParametersNoCopy();
if (paramInfo != null && paramInfo.Length != 0)
@@ -498,94 +481,36 @@ namespace System.Reflection.Emit
#region GetTokenFor helpers
private int GetTokenFor(RuntimeType rtType)
{
-#if FEATURE_APPX
- if (ProfileAPICheck && (rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName));
-#endif
-
return m_scope.GetTokenFor(rtType.TypeHandle);
}
private int GetTokenFor(RuntimeFieldInfo runtimeField)
{
-#if FEATURE_APPX
- if (ProfileAPICheck)
- {
- RtFieldInfo rtField = runtimeField as RtFieldInfo;
- if (rtField != null && (rtField.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtField.FullName));
- }
-#endif
-
return m_scope.GetTokenFor(runtimeField.FieldHandle);
}
private int GetTokenFor(RuntimeFieldInfo runtimeField, RuntimeType rtType)
{
-#if FEATURE_APPX
- if (ProfileAPICheck)
- {
- RtFieldInfo rtField = runtimeField as RtFieldInfo;
- if (rtField != null && (rtField.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtField.FullName));
-
- if ((rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName));
- }
-#endif
-
return m_scope.GetTokenFor(runtimeField.FieldHandle, rtType.TypeHandle);
}
private int GetTokenFor(RuntimeConstructorInfo rtMeth)
{
-#if FEATURE_APPX
- if (ProfileAPICheck && (rtMeth.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtMeth.FullName));
-#endif
-
return m_scope.GetTokenFor(rtMeth.MethodHandle);
}
private int GetTokenFor(RuntimeConstructorInfo rtMeth, RuntimeType rtType)
{
-#if FEATURE_APPX
- if (ProfileAPICheck)
- {
- if ((rtMeth.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtMeth.FullName));
-
- if ((rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName));
- }
-#endif
-
return m_scope.GetTokenFor(rtMeth.MethodHandle, rtType.TypeHandle);
}
private int GetTokenFor(RuntimeMethodInfo rtMeth)
{
-#if FEATURE_APPX
- if (ProfileAPICheck && (rtMeth.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtMeth.FullName));
-#endif
-
return m_scope.GetTokenFor(rtMeth.MethodHandle);
}
private int GetTokenFor(RuntimeMethodInfo rtMeth, RuntimeType rtType)
{
-#if FEATURE_APPX
- if (ProfileAPICheck)
- {
- if ((rtMeth.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtMeth.FullName));
-
- if ((rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName));
- }
-#endif
-
return m_scope.GetTokenFor(rtMeth.MethodHandle, rtType.TypeHandle);
}
@@ -596,10 +521,6 @@ namespace System.Reflection.Emit
private int GetTokenForVarArgMethod(RuntimeMethodInfo rtMeth, SignatureHelper sig)
{
-#if FEATURE_APPX
- if (ProfileAPICheck && (rtMeth.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtMeth.FullName));
-#endif
VarArgMethod varArgMeth = new VarArgMethod(rtMeth, sig);
return m_scope.GetTokenFor(varArgMeth);
}
@@ -962,8 +883,8 @@ namespace System.Reflection.Emit
public DynamicMethod DynamicMethod { get { return m_method; } }
internal DynamicScope DynamicScope { get { return m_scope; } }
-#endregion
-#region Public Scope Methods
+ #endregion
+ #region Public Scope Methods
#endregion
}
@@ -1032,7 +953,7 @@ namespace System.Reflection.Emit
Type t = m.DeclaringType.GetGenericTypeDefinition();
throw new ArgumentException(String.Format(
- CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGenericLcg"), m, t));
+ CultureInfo.CurrentCulture, SR.Argument_MethodDeclaringTypeGenericLcg, m, t));
}
}
@@ -1119,5 +1040,4 @@ namespace System.Reflection.Emit
m_signature = signature;
}
}
-
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
index f1d99d3c2c..2d2d3097a1 100644
--- a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs
@@ -42,13 +42,6 @@ namespace System.Reflection.Emit
// assigned by the DynamicResolver ctor
internal DynamicResolver m_resolver;
- // Always false unless we are in an immersive (non dev mode) process.
-#if FEATURE_APPX
- private bool m_profileAPICheck;
-
- private RuntimeAssembly m_creatorAssembly;
-#endif
-
internal bool m_restrictedSkipVisibility;
// The context when the method was created. We use this to do the RestrictedMemberAccess checks.
// These checks are done when the method is compiled. This can happen at an arbitrary time,
@@ -58,40 +51,33 @@ namespace System.Reflection.Emit
// it is ready for use since there is not API which indictates that IL generation has completed.
private static volatile InternalModuleBuilder s_anonymouslyHostedDynamicMethodsModule;
private static readonly object s_anonymouslyHostedDynamicMethodsModuleLock = new object();
-
+
//
// class initialization (ctor and init)
//
private DynamicMethod() { }
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public DynamicMethod(string name,
Type returnType,
Type[] parameterTypes)
{
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-
- Init(name,
- MethodAttributes.Public | MethodAttributes.Static,
- CallingConventions.Standard,
- returnType,
+ Init(name,
+ MethodAttributes.Public | MethodAttributes.Static,
+ CallingConventions.Standard,
+ returnType,
parameterTypes,
null, // owner
null, // m
false, // skipVisibility
- true,
- ref stackMark); // transparentMethod
+ true);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public DynamicMethod(string name,
Type returnType,
Type[] parameterTypes,
bool restrictedSkipVisibility)
{
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-
Init(name,
MethodAttributes.Public | MethodAttributes.Static,
CallingConventions.Standard,
@@ -100,17 +86,17 @@ namespace System.Reflection.Emit
null, // owner
null, // m
restrictedSkipVisibility,
- true,
- ref stackMark); // transparentMethod
+ true);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public DynamicMethod(string name,
- Type returnType,
- Type[] parameterTypes,
- Module m) {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- PerformSecurityCheck(m, ref stackMark, false);
+ public DynamicMethod(string name,
+ Type returnType,
+ Type[] parameterTypes,
+ Module m)
+ {
+ if (m == null)
+ throw new ArgumentNullException(nameof(m));
+
Init(name,
MethodAttributes.Public | MethodAttributes.Static,
CallingConventions.Standard,
@@ -119,18 +105,18 @@ namespace System.Reflection.Emit
null, // owner
m, // m
false, // skipVisibility
- false,
- ref stackMark); // transparentMethod
+ false);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public DynamicMethod(string name,
- Type returnType,
- Type[] parameterTypes,
- Module m,
- bool skipVisibility) {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- PerformSecurityCheck(m, ref stackMark, skipVisibility);
+ public DynamicMethod(string name,
+ Type returnType,
+ Type[] parameterTypes,
+ Module m,
+ bool skipVisibility)
+ {
+ if (m == null)
+ throw new ArgumentNullException(nameof(m));
+
Init(name,
MethodAttributes.Public | MethodAttributes.Static,
CallingConventions.Standard,
@@ -139,20 +125,20 @@ namespace System.Reflection.Emit
null, // owner
m, // m
skipVisibility,
- false,
- ref stackMark); // transparentMethod
+ false);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public DynamicMethod(string name,
- MethodAttributes attributes,
- CallingConventions callingConvention,
- Type returnType,
- Type[] parameterTypes,
- Module m,
- bool skipVisibility) {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- PerformSecurityCheck(m, ref stackMark, skipVisibility);
+ public DynamicMethod(string name,
+ MethodAttributes attributes,
+ CallingConventions callingConvention,
+ Type returnType,
+ Type[] parameterTypes,
+ Module m,
+ bool skipVisibility)
+ {
+ if (m == null)
+ throw new ArgumentNullException(nameof(m));
+
Init(name,
attributes,
callingConvention,
@@ -161,93 +147,93 @@ namespace System.Reflection.Emit
null, // owner
m, // m
skipVisibility,
- false,
- ref stackMark); // transparentMethod
+ false);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public DynamicMethod(string name,
- Type returnType,
- Type[] parameterTypes,
- Type owner) {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- PerformSecurityCheck(owner, ref stackMark, false);
- Init(name,
- MethodAttributes.Public | MethodAttributes.Static,
- CallingConventions.Standard,
- returnType,
+ public DynamicMethod(string name,
+ Type returnType,
+ Type[] parameterTypes,
+ Type owner)
+ {
+ if (owner == null)
+ throw new ArgumentNullException(nameof(owner));
+
+ Init(name,
+ MethodAttributes.Public | MethodAttributes.Static,
+ CallingConventions.Standard,
+ returnType,
parameterTypes,
owner, // owner
null, // m
false, // skipVisibility
- false,
- ref stackMark); // transparentMethod
+ false);
}
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public DynamicMethod(string name,
- Type returnType,
- Type[] parameterTypes,
- Type owner,
- bool skipVisibility) {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- PerformSecurityCheck(owner, ref stackMark, skipVisibility);
- Init(name,
- MethodAttributes.Public | MethodAttributes.Static,
- CallingConventions.Standard,
- returnType,
- parameterTypes,
+
+ public DynamicMethod(string name,
+ Type returnType,
+ Type[] parameterTypes,
+ Type owner,
+ bool skipVisibility)
+ {
+ if (owner == null)
+ throw new ArgumentNullException(nameof(owner));
+
+ Init(name,
+ MethodAttributes.Public | MethodAttributes.Static,
+ CallingConventions.Standard,
+ returnType,
+ parameterTypes,
owner, // owner
null, // m
skipVisibility,
- false,
- ref stackMark); // transparentMethod
+ false);
}
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public DynamicMethod(string name,
- MethodAttributes attributes,
- CallingConventions callingConvention,
- Type returnType,
- Type[] parameterTypes,
- Type owner,
- bool skipVisibility) {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- PerformSecurityCheck(owner, ref stackMark, skipVisibility);
- Init(name,
- attributes,
- callingConvention,
- returnType,
- parameterTypes,
+
+ public DynamicMethod(string name,
+ MethodAttributes attributes,
+ CallingConventions callingConvention,
+ Type returnType,
+ Type[] parameterTypes,
+ Type owner,
+ bool skipVisibility)
+ {
+ if (owner == null)
+ throw new ArgumentNullException(nameof(owner));
+
+ Init(name,
+ attributes,
+ callingConvention,
+ returnType,
+ parameterTypes,
owner, // owner
null, // m
- skipVisibility,
- false,
- ref stackMark); // transparentMethod
+ skipVisibility,
+ false);
}
// helpers for intialization
- static private void CheckConsistency(MethodAttributes attributes, CallingConventions callingConvention) {
+ static private void CheckConsistency(MethodAttributes attributes, CallingConventions callingConvention)
+ {
// only static public for method attributes
if ((attributes & ~MethodAttributes.MemberAccessMask) != MethodAttributes.Static)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicMethodFlags"));
+ throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags);
if ((attributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Public)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicMethodFlags"));
+ throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags);
Contract.EndContractBlock();
// only standard or varargs supported
if (callingConvention != CallingConventions.Standard && callingConvention != CallingConventions.VarArgs)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicMethodFlags"));
-
+ throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags);
+
// vararg is not supported at the moment
if (callingConvention == CallingConventions.VarArgs)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicMethodFlags"));
+ throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags);
}
// We create a transparent assembly to host DynamicMethods. Since the assembly does not have any
// non-public fields (or any fields at all), it is a safe anonymous assembly to host DynamicMethods
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
private static RuntimeModule GetDynamicMethodsModule()
{
if (s_anonymouslyHostedDynamicMethodsModule != null)
@@ -259,7 +245,7 @@ namespace System.Reflection.Emit
return s_anonymouslyHostedDynamicMethodsModule;
ConstructorInfo transparencyCtor = typeof(SecurityTransparentAttribute).GetConstructor(Type.EmptyTypes);
- CustomAttributeBuilder transparencyAttribute = new CustomAttributeBuilder(transparencyCtor, EmptyArray<Object>.Value);
+ CustomAttributeBuilder transparencyAttribute = new CustomAttributeBuilder(transparencyCtor, Array.Empty<Object>());
List<CustomAttributeBuilder> assemblyAttributes = new List<CustomAttributeBuilder>();
assemblyAttributes.Add(transparencyAttribute);
@@ -283,38 +269,40 @@ namespace System.Reflection.Emit
return s_anonymouslyHostedDynamicMethodsModule;
}
- private unsafe void Init(String name,
- MethodAttributes attributes,
- CallingConventions callingConvention,
- Type returnType,
- Type[] signature,
- Type owner,
- Module m,
+ private unsafe void Init(String name,
+ MethodAttributes attributes,
+ CallingConventions callingConvention,
+ Type returnType,
+ Type[] signature,
+ Type owner,
+ Module m,
bool skipVisibility,
- bool transparentMethod,
- ref StackCrawlMark stackMark)
+ bool transparentMethod)
{
DynamicMethod.CheckConsistency(attributes, callingConvention);
// check and store the signature
- if (signature != null) {
+ if (signature != null)
+ {
m_parameterTypes = new RuntimeType[signature.Length];
- for (int i = 0; i < signature.Length; i++) {
- if (signature[i] == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_InvalidTypeInSignature"));
+ for (int i = 0; i < signature.Length; i++)
+ {
+ if (signature[i] == null)
+ throw new ArgumentException(SR.Arg_InvalidTypeInSignature);
m_parameterTypes[i] = signature[i].UnderlyingSystemType as RuntimeType;
- if ( m_parameterTypes[i] == null || !(m_parameterTypes[i] is RuntimeType) || m_parameterTypes[i] == (RuntimeType)typeof(void) )
- throw new ArgumentException(Environment.GetResourceString("Arg_InvalidTypeInSignature"));
+ if (m_parameterTypes[i] == null || !(m_parameterTypes[i] is RuntimeType) || m_parameterTypes[i] == (RuntimeType)typeof(void))
+ throw new ArgumentException(SR.Arg_InvalidTypeInSignature);
}
}
- else {
+ else
+ {
m_parameterTypes = Array.Empty<RuntimeType>();
}
-
+
// check and store the return value
m_returnType = (returnType == null) ? (RuntimeType)typeof(void) : returnType.UnderlyingSystemType as RuntimeType;
- if ( (m_returnType == null) || !(m_returnType is RuntimeType) || m_returnType.IsByRef )
- throw new NotSupportedException(Environment.GetResourceString("Arg_InvalidTypeInRetType"));
+ if ((m_returnType == null) || !(m_returnType is RuntimeType) || m_returnType.IsByRef)
+ throw new NotSupportedException(SR.Arg_InvalidTypeInRetType);
if (transparentMethod)
{
@@ -324,11 +312,10 @@ namespace System.Reflection.Emit
{
m_restrictedSkipVisibility = true;
}
-
}
else
{
- Debug.Assert(m != null || owner != null, "PerformSecurityCheck should ensure that either m or owner is set");
+ Debug.Assert(m != null || owner != null, "Constructor should ensure that either m or owner is set");
Debug.Assert(m == null || !m.Equals(s_anonymouslyHostedDynamicMethodsModule), "The user cannot explicitly use this assembly");
Debug.Assert(m == null || owner == null, "m and owner cannot both be set");
@@ -344,7 +331,7 @@ namespace System.Reflection.Emit
{
if (rtOwner.HasElementType || rtOwner.ContainsGenericParameters
|| rtOwner.IsGenericParameter || rtOwner.IsInterface)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidTypeForDynamicMethod"));
+ throw new ArgumentException(SR.Argument_InvalidTypeForDynamicMethod);
m_typeOwner = rtOwner;
m_module = rtOwner.GetRuntimeModule();
@@ -359,41 +346,18 @@ namespace System.Reflection.Emit
m_fInitLocals = true;
m_methodHandle = null;
- if (name == null)
+ if (name == null)
throw new ArgumentNullException(nameof(name));
-#if FEATURE_APPX
- if (AppDomain.ProfileAPICheck)
- {
- if (m_creatorAssembly == null)
- m_creatorAssembly = RuntimeAssembly.GetExecutingAssembly(ref stackMark);
-
- if (m_creatorAssembly != null && !m_creatorAssembly.IsFrameworkAssembly())
- m_profileAPICheck = true;
- }
-#endif // FEATURE_APPX
-
m_dynMethod = new RTDynamicMethod(this, name, attributes, callingConvention);
}
- private void PerformSecurityCheck(Module m, ref StackCrawlMark stackMark, bool skipVisibility)
- {
- if (m == null)
- throw new ArgumentNullException(nameof(m));
- Contract.EndContractBlock();
- }
-
- private void PerformSecurityCheck(Type owner, ref StackCrawlMark stackMark, bool skipVisibility)
- {
- if (owner == null)
- throw new ArgumentNullException(nameof(owner));
- }
-
//
// Delegate and method creation
//
- public sealed override Delegate CreateDelegate(Type delegateType) {
+ public sealed override Delegate CreateDelegate(Type delegateType)
+ {
if (m_restrictedSkipVisibility)
{
// Compile the method since accessibility checks are done as part of compilation.
@@ -407,7 +371,8 @@ namespace System.Reflection.Emit
return d;
}
- public sealed override Delegate CreateDelegate(Type delegateType, Object target) {
+ public sealed override Delegate CreateDelegate(Type delegateType, Object target)
+ {
if (m_restrictedSkipVisibility)
{
// Compile the method since accessibility checks are done as part of compilation
@@ -421,33 +386,22 @@ namespace System.Reflection.Emit
return d;
}
-#if FEATURE_APPX
- internal bool ProfileAPICheck
+ // This is guaranteed to return a valid handle
+ internal unsafe RuntimeMethodHandle GetMethodDescriptor()
{
- get
- {
- return m_profileAPICheck;
- }
-
- [FriendAccessAllowed]
- set
+ if (m_methodHandle == null)
{
- m_profileAPICheck = value;
- }
- }
-#endif
-
- // This is guaranteed to return a valid handle
- internal unsafe RuntimeMethodHandle GetMethodDescriptor() {
- if (m_methodHandle == null) {
- lock (this) {
- if (m_methodHandle == null) {
+ lock (this)
+ {
+ if (m_methodHandle == null)
+ {
if (m_DynamicILInfo != null)
m_DynamicILInfo.GetCallableMethod(m_module, this);
- else {
+ else
+ {
if (m_ilGenerator == null || m_ilGenerator.ILOffset == 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadEmptyMethodBody", Name));
-
+ throw new InvalidOperationException(SR.Format(SR.InvalidOperation_BadEmptyMethodBody, Name));
+
m_ilGenerator.GetCallableMethod(m_module, this);
}
}
@@ -471,7 +425,7 @@ namespace System.Reflection.Emit
public override Module Module { get { return m_dynMethod.Module; } }
// we cannot return a MethodHandle because we cannot track it via GC so this method is off limits
- public override RuntimeMethodHandle MethodHandle { get { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); } }
+ public override RuntimeMethodHandle MethodHandle { get { throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInDynamicMethod); } }
public override MethodAttributes Attributes { get { return m_dynMethod.Attributes; } }
@@ -508,9 +462,10 @@ namespace System.Reflection.Emit
get { return false; }
}
- public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) {
+ public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
+ {
if ((CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_CallToVarArg"));
+ throw new NotSupportedException(SR.NotSupported_CallToVarArg);
Contract.EndContractBlock();
//
@@ -531,7 +486,7 @@ namespace System.Reflection.Emit
int formalCount = sig.Arguments.Length;
int actualCount = (parameters != null) ? parameters.Length : 0;
if (formalCount != actualCount)
- throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt"));
+ throw new TargetParameterCountException(SR.Arg_ParmCnt);
// if we are here we passed all the previous checks. Time to look at the arguments
Object retValue = null;
@@ -554,7 +509,7 @@ namespace System.Reflection.Emit
public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
{
- return m_dynMethod.GetCustomAttributes(attributeType, inherit);
+ return m_dynMethod.GetCustomAttributes(attributeType, inherit);
}
public override Object[] GetCustomAttributes(bool inherit) { return m_dynMethod.GetCustomAttributes(inherit); }
@@ -571,24 +526,27 @@ namespace System.Reflection.Emit
// DynamicMethod specific methods
//
- public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, String parameterName) {
+ public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, String parameterName)
+ {
if (position < 0 || position > m_parameterTypes.Length)
- throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_ParamSequence"));
+ throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_ParamSequence);
position--; // it's 1 based. 0 is the return value
-
- if (position >= 0) {
- ParameterInfo[] parameters = m_dynMethod.LoadParameters();
+
+ if (position >= 0)
+ {
+ RuntimeParameterInfo[] parameters = m_dynMethod.LoadParameters();
parameters[position].SetName(parameterName);
parameters[position].SetAttributes(attributes);
}
return null;
}
- public ILGenerator GetILGenerator() {
+ public ILGenerator GetILGenerator()
+ {
return GetILGenerator(64);
}
- public ILGenerator GetILGenerator(int streamSize)
+ public ILGenerator GetILGenerator(int streamSize)
{
if (m_ilGenerator == null)
{
@@ -599,16 +557,18 @@ namespace System.Reflection.Emit
return m_ilGenerator;
}
- public bool InitLocals {
- get {return m_fInitLocals;}
- set {m_fInitLocals = value;}
+ public bool InitLocals
+ {
+ get { return m_fInitLocals; }
+ set { m_fInitLocals = value; }
}
//
// Internal API
//
-
- internal MethodInfo GetMethodInfo() {
+
+ internal MethodInfo GetMethodInfo()
+ {
return m_dynMethod;
}
@@ -620,109 +580,125 @@ namespace System.Reflection.Emit
// This way the DynamicMethod creator is the only one responsible for DynamicMethod access,
// and can control exactly who gets access to it.
//
- internal class RTDynamicMethod : MethodInfo {
-
+ internal class RTDynamicMethod : MethodInfo
+ {
internal DynamicMethod m_owner;
- ParameterInfo[] m_parameters;
- String m_name;
- MethodAttributes m_attributes;
- CallingConventions m_callingConvention;
+ private RuntimeParameterInfo[] m_parameters;
+ private String m_name;
+ private MethodAttributes m_attributes;
+ private CallingConventions m_callingConvention;
//
// ctors
//
- private RTDynamicMethod() {}
+ private RTDynamicMethod() { }
- internal RTDynamicMethod(DynamicMethod owner, String name, MethodAttributes attributes, CallingConventions callingConvention) {
+ internal RTDynamicMethod(DynamicMethod owner, String name, MethodAttributes attributes, CallingConventions callingConvention)
+ {
m_owner = owner;
m_name = name;
m_attributes = attributes;
m_callingConvention = callingConvention;
}
-
+
//
// MethodInfo api
//
- public override String ToString() {
+ public override String ToString()
+ {
return ReturnType.FormatTypeName() + " " + FormatNameAndSig();
}
- public override String Name {
+ public override String Name
+ {
get { return m_name; }
}
- public override Type DeclaringType {
+ public override Type DeclaringType
+ {
get { return null; }
}
- public override Type ReflectedType {
+ public override Type ReflectedType
+ {
get { return null; }
}
- public override Module Module {
+ public override Module Module
+ {
get { return m_owner.m_module; }
}
- public override RuntimeMethodHandle MethodHandle {
- get { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); }
+ public override RuntimeMethodHandle MethodHandle
+ {
+ get { throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInDynamicMethod); }
}
- public override MethodAttributes Attributes {
+ public override MethodAttributes Attributes
+ {
get { return m_attributes; }
- }
+ }
- public override CallingConventions CallingConvention {
+ public override CallingConventions CallingConvention
+ {
get { return m_callingConvention; }
}
-
- public override MethodInfo GetBaseDefinition() {
+
+ public override MethodInfo GetBaseDefinition()
+ {
return this;
}
-
+
[Pure]
- public override ParameterInfo[] GetParameters() {
+ public override ParameterInfo[] GetParameters()
+ {
ParameterInfo[] privateParameters = LoadParameters();
ParameterInfo[] parameters = new ParameterInfo[privateParameters.Length];
Array.Copy(privateParameters, 0, parameters, 0, privateParameters.Length);
return parameters;
}
-
- public override MethodImplAttributes GetMethodImplementationFlags() {
+
+ public override MethodImplAttributes GetMethodImplementationFlags()
+ {
return MethodImplAttributes.IL | MethodImplAttributes.NoInlining;
}
- public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) {
+ public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
+ {
// We want the creator of the DynamicMethod to control who has access to the
// DynamicMethod (just like we do for delegates). However, a user can get to
// the corresponding RTDynamicMethod using Exception.TargetSite, StackFrame.GetMethod, etc.
// If we allowed use of RTDynamicMethod, the creator of the DynamicMethod would
// not be able to bound access to the DynamicMethod. Hence, we do not allow
// direct use of RTDynamicMethod.
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), "this");
+ throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, "this");
}
- public override Object[] GetCustomAttributes(Type attributeType, bool inherit) {
+ public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
+ {
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
Contract.EndContractBlock();
- if (attributeType.IsAssignableFrom(typeof(MethodImplAttribute)))
+ if (attributeType.IsAssignableFrom(typeof(MethodImplAttribute)))
return new Object[] { new MethodImplAttribute(GetMethodImplementationFlags()) };
else
- return EmptyArray<Object>.Value;
+ return Array.Empty<Object>();
}
- public override Object[] GetCustomAttributes(bool inherit) {
+ public override Object[] GetCustomAttributes(bool inherit)
+ {
// support for MethodImplAttribute PCA
return new Object[] { new MethodImplAttribute(GetMethodImplementationFlags()) };
}
-
- public override bool IsDefined(Type attributeType, bool inherit) {
+
+ public override bool IsDefined(Type attributeType, bool inherit)
+ {
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
Contract.EndContractBlock();
- if (attributeType.IsAssignableFrom(typeof(MethodImplAttribute)))
+ if (attributeType.IsAssignableFrom(typeof(MethodImplAttribute)))
return true;
else
return false;
@@ -751,11 +727,13 @@ namespace System.Reflection.Emit
}
}
- public override ParameterInfo ReturnParameter {
- get { return null; }
+ public override ParameterInfo ReturnParameter
+ {
+ get { return null; }
}
- public override ICustomAttributeProvider ReturnTypeCustomAttributes {
+ public override ICustomAttributeProvider ReturnTypeCustomAttributes
+ {
get { return GetEmptyCAHolder(); }
}
@@ -763,45 +741,49 @@ namespace System.Reflection.Emit
// private implementation
//
- internal ParameterInfo[] LoadParameters() {
- if (m_parameters == null) {
+ internal RuntimeParameterInfo[] LoadParameters()
+ {
+ if (m_parameters == null)
+ {
Type[] parameterTypes = m_owner.m_parameterTypes;
- ParameterInfo[] parameters = new ParameterInfo[parameterTypes.Length];
- for (int i = 0; i < parameterTypes.Length; i++)
+ RuntimeParameterInfo[] parameters = new RuntimeParameterInfo[parameterTypes.Length];
+ for (int i = 0; i < parameterTypes.Length; i++)
parameters[i] = new RuntimeParameterInfo(this, null, parameterTypes[i], i);
- if (m_parameters == null)
+ if (m_parameters == null)
// should we interlockexchange?
m_parameters = parameters;
}
return m_parameters;
}
-
+
// private implementation of CA for the return type
- private ICustomAttributeProvider GetEmptyCAHolder() {
+ private ICustomAttributeProvider GetEmptyCAHolder()
+ {
return new EmptyCAHolder();
}
///////////////////////////////////////////////////
// EmptyCAHolder
- private class EmptyCAHolder : ICustomAttributeProvider {
- internal EmptyCAHolder() {}
+ private class EmptyCAHolder : ICustomAttributeProvider
+ {
+ internal EmptyCAHolder() { }
- Object[] ICustomAttributeProvider.GetCustomAttributes(Type attributeType, bool inherit) {
- return EmptyArray<Object>.Value;
+ Object[] ICustomAttributeProvider.GetCustomAttributes(Type attributeType, bool inherit)
+ {
+ return Array.Empty<Object>();
}
- Object[] ICustomAttributeProvider.GetCustomAttributes(bool inherit) {
- return EmptyArray<Object>.Value;
+ Object[] ICustomAttributeProvider.GetCustomAttributes(bool inherit)
+ {
+ return Array.Empty<Object>();
}
- bool ICustomAttributeProvider.IsDefined (Type attributeType, bool inherit) {
+ bool ICustomAttributeProvider.IsDefined(Type attributeType, bool inherit)
+ {
return false;
}
}
-
}
-
}
-
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs
index 96564d537b..55aa5c5a8f 100644
--- a/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs
@@ -12,8 +12,9 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
-
+
+namespace System.Reflection.Emit
+{
using System;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
@@ -23,21 +24,22 @@ namespace System.Reflection.Emit {
sealed public class EnumBuilder : TypeInfo
{
- public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
- if(typeInfo==null) return false;
+ public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo)
+ {
+ if (typeInfo == null) return false;
return IsAssignableFrom(typeInfo.AsType());
}
// Define literal for enum
public FieldBuilder DefineLiteral(String literalName, Object literalValue)
- {
- BCLDebug.Log("DYNIL","## DYNIL LOGGING: EnumBuilder.DefineLiteral( " + literalName + " )");
+ {
+ BCLDebug.Log("DYNIL", "## DYNIL LOGGING: EnumBuilder.DefineLiteral( " + literalName + " )");
// Define the underlying field for the enum. It will be a non-static, private field with special name bit set.
FieldBuilder fieldBuilder = m_typeBuilder.DefineField(
- literalName,
- this,
+ literalName,
+ this,
FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
fieldBuilder.SetConstant(literalValue);
return fieldBuilder;
@@ -50,143 +52,156 @@ namespace System.Reflection.Emit {
}
// CreateType cause EnumBuilder to be baked.
- public Type CreateType()
+ public Type CreateType()
{
- BCLDebug.Log("DYNIL","## DYNIL LOGGING: EnumBuilder.CreateType() ");
+ BCLDebug.Log("DYNIL", "## DYNIL LOGGING: EnumBuilder.CreateType() ");
return m_typeBuilder.CreateType();
}
-
+
// Get the internal metadata token for this class.
- public TypeToken TypeToken {
- get {return m_typeBuilder.TypeToken; }
+ public TypeToken TypeToken
+ {
+ get { return m_typeBuilder.TypeToken; }
}
-
+
// return the underlying field for the enum
- public FieldBuilder UnderlyingField {
- get {return m_underlyingField; }
+ public FieldBuilder UnderlyingField
+ {
+ get { return m_underlyingField; }
}
- public override String Name {
+ public override String Name
+ {
get { return m_typeBuilder.Name; }
}
-
+
/****************************************************
*
* abstract methods defined in the base class
*
*/
- public override Guid GUID {
- get {
+ public override Guid GUID
+ {
+ get
+ {
return m_typeBuilder.GUID;
}
}
public override Object InvokeMember(
- String name,
+ String name,
BindingFlags invokeAttr,
- Binder binder,
- Object target,
- Object[] args,
- ParameterModifier[] modifiers,
+ Binder binder,
+ Object target,
+ Object[] args,
+ ParameterModifier[] modifiers,
CultureInfo culture,
- String[] namedParameters)
+ String[] namedParameters)
{
return m_typeBuilder.InvokeMember(name, invokeAttr, binder, target, args, modifiers, culture, namedParameters);
}
-
- public override Module Module {
- get {return m_typeBuilder.Module;}
+
+ public override Module Module
+ {
+ get { return m_typeBuilder.Module; }
}
-
- public override Assembly Assembly {
- get {return m_typeBuilder.Assembly;}
+
+ public override Assembly Assembly
+ {
+ get { return m_typeBuilder.Assembly; }
}
- public override RuntimeTypeHandle TypeHandle {
- get {return m_typeBuilder.TypeHandle;}
+ public override RuntimeTypeHandle TypeHandle
+ {
+ get { return m_typeBuilder.TypeHandle; }
}
-
- public override String FullName {
- get { return m_typeBuilder.FullName;}
+
+ public override String FullName
+ {
+ get { return m_typeBuilder.FullName; }
}
-
- public override String AssemblyQualifiedName {
- get {
+
+ public override String AssemblyQualifiedName
+ {
+ get
+ {
return m_typeBuilder.AssemblyQualifiedName;
}
}
-
- public override String Namespace {
- get { return m_typeBuilder.Namespace;}
+
+ public override String Namespace
+ {
+ get { return m_typeBuilder.Namespace; }
}
-
- public override Type BaseType {
- get{return m_typeBuilder.BaseType;}
+
+ public override Type BaseType
+ {
+ get { return m_typeBuilder.BaseType; }
}
-
- protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr,Binder binder,
- CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers)
+
+ protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
+ CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
return m_typeBuilder.GetConstructor(bindingAttr, binder, callConvention,
types, modifiers);
}
-
+
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
{
return m_typeBuilder.GetConstructors(bindingAttr);
}
-
- protected override MethodInfo GetMethodImpl(String name,BindingFlags bindingAttr,Binder binder,
- CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers)
+
+ protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder,
+ CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
if (types == null)
return m_typeBuilder.GetMethod(name, bindingAttr);
else
return m_typeBuilder.GetMethod(name, bindingAttr, binder, callConvention, types, modifiers);
}
-
+
public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
{
return m_typeBuilder.GetMethods(bindingAttr);
}
-
+
public override FieldInfo GetField(String name, BindingFlags bindingAttr)
{
return m_typeBuilder.GetField(name, bindingAttr);
}
-
+
public override FieldInfo[] GetFields(BindingFlags bindingAttr)
{
return m_typeBuilder.GetFields(bindingAttr);
}
-
+
public override Type GetInterface(String name, bool ignoreCase)
{
return m_typeBuilder.GetInterface(name, ignoreCase);
}
-
+
public override Type[] GetInterfaces()
{
return m_typeBuilder.GetInterfaces();
}
-
+
public override EventInfo GetEvent(String name, BindingFlags bindingAttr)
{
return m_typeBuilder.GetEvent(name, bindingAttr);
}
-
+
public override EventInfo[] GetEvents()
{
return m_typeBuilder.GetEvents();
}
-
- protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder,
+
+ protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder,
Type returnType, Type[] types, ParameterModifier[] modifiers)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
-
+
public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
{
return m_typeBuilder.GetProperties(bindingAttr);
@@ -199,14 +214,14 @@ namespace System.Reflection.Emit {
public override Type GetNestedType(String name, BindingFlags bindingAttr)
{
- return m_typeBuilder.GetNestedType(name,bindingAttr);
+ return m_typeBuilder.GetNestedType(name, bindingAttr);
}
-
- public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr)
+
+ public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr)
{
return m_typeBuilder.GetMember(name, type, bindingAttr);
}
-
+
public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
{
return m_typeBuilder.GetMembers(bindingAttr);
@@ -221,12 +236,14 @@ namespace System.Reflection.Emit {
{
return m_typeBuilder.GetEvents(bindingAttr);
}
-
+
protected override TypeAttributes GetAttributeFlagsImpl()
{
return m_typeBuilder.Attributes;
}
-
+
+ public override bool IsSZArray => false;
+
protected override bool IsArrayImpl()
{
return false;
@@ -236,7 +253,7 @@ namespace System.Reflection.Emit {
return false;
}
- protected override bool IsValueTypeImpl()
+ protected override bool IsValueTypeImpl()
{
return true;
}
@@ -250,7 +267,7 @@ namespace System.Reflection.Emit {
{
return false;
}
-
+
protected override bool IsCOMObjectImpl()
{
return false;
@@ -290,7 +307,7 @@ namespace System.Reflection.Emit {
return GetEnumUnderlyingType();
}
}
-
+
//ICustomAttributeProvider
public override Object[] GetCustomAttributes(bool inherit)
{
@@ -303,64 +320,66 @@ namespace System.Reflection.Emit {
return m_typeBuilder.GetCustomAttributes(attributeType, inherit);
}
- // Use this function if client decides to form the custom attribute blob themselves
+ // Use this function if client decides to form the custom attribute blob themselves
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
- m_typeBuilder.SetCustomAttribute(con, binaryAttribute);
+ m_typeBuilder.SetCustomAttribute(con, binaryAttribute);
}
- // Use this function if client wishes to build CustomAttribute using CustomAttributeBuilder
+ // Use this function if client wishes to build CustomAttribute using CustomAttributeBuilder
public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
{
m_typeBuilder.SetCustomAttribute(customBuilder);
}
// Return the class that declared this Field.
- public override Type DeclaringType {
- get {return m_typeBuilder.DeclaringType;}
+ public override Type DeclaringType
+ {
+ get { return m_typeBuilder.DeclaringType; }
}
// Return the class that was used to obtain this field.
-
- public override Type ReflectedType {
- get {return m_typeBuilder.ReflectedType;}
+
+ public override Type ReflectedType
+ {
+ get { return m_typeBuilder.ReflectedType; }
}
- // Returns true if one or more instance of attributeType is defined on this member.
- public override bool IsDefined (Type attributeType, bool inherit)
+ // Returns true if one or more instance of attributeType is defined on this member.
+ public override bool IsDefined(Type attributeType, bool inherit)
{
return m_typeBuilder.IsDefined(attributeType, inherit);
}
-
+
/*****************************************************
*
* private/protected functions
*
*/
-
+
//*******************************
// Make a private constructor so these cannot be constructed externally.
//*******************************
- private EnumBuilder() {}
-
- public override Type MakePointerType()
- {
- return SymbolType.FormCompoundType("*", this, 0);
+ private EnumBuilder() { }
+
+ public override Type MakePointerType()
+ {
+ return SymbolType.FormCompoundType("*", this, 0);
}
- public override Type MakeByRefType()
+ public override Type MakeByRefType()
{
return SymbolType.FormCompoundType("&", this, 0);
}
- public override Type MakeArrayType()
+ public override Type MakeArrayType()
{
return SymbolType.FormCompoundType("[]", this, 0);
}
- public override Type MakeArrayType(int rank)
+ public override Type MakeArrayType(int rank)
{
if (rank <= 0)
throw new IndexOutOfRangeException();
@@ -370,9 +389,9 @@ namespace System.Reflection.Emit {
{
szrank = "*";
}
- else
+ else
{
- for(int i = 1; i < rank; i++)
+ for (int i = 1; i < rank; i++)
szrank += ",";
}
@@ -380,18 +399,18 @@ namespace System.Reflection.Emit {
return SymbolType.FormCompoundType(s, this, 0);
}
-
+
// Constructs a EnumBuilder.
// EnumBuilder can only be a top-level (not nested) enum type.
internal EnumBuilder(
- String name, // name of type
- Type underlyingType, // underlying type for an Enum
+ String name, // name of type
+ Type underlyingType, // underlying type for an Enum
TypeAttributes visibility, // any bits on TypeAttributes.VisibilityMask)
- ModuleBuilder module) // module containing this type
+ ModuleBuilder module) // module containing this type
{
// Client should not set any bits other than the visibility bits.
if ((visibility & ~TypeAttributes.VisibilityMask) != 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_ShouldOnlySetVisibilityFlags"), nameof(name));
+ throw new ArgumentException(SR.Argument_ShouldOnlySetVisibilityFlags, nameof(name));
m_typeBuilder = new TypeBuilder(name, visibility | TypeAttributes.Sealed, typeof(System.Enum), null, module, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize, null);
// Define the underlying field for the enum. It will be a non-static, private field with special name bit set.
@@ -403,7 +422,7 @@ namespace System.Reflection.Emit {
* private data members
*
*/
- internal TypeBuilder m_typeBuilder;
- private FieldBuilder m_underlyingField;
+ internal TypeBuilder m_typeBuilder;
+ private FieldBuilder m_underlyingField;
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs
index 34c76b93d1..ef60d05172 100644
--- a/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs
@@ -12,40 +12,40 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
-
- using System;
- using System.Reflection;
- using System.Runtime.InteropServices;
- using System.Diagnostics.Contracts;
-
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Diagnostics.Contracts;
+
+namespace System.Reflection.Emit
+{
//
// A EventBuilder is always associated with a TypeBuilder. The TypeBuilder.DefineEvent
// method will return a new EventBuilder to a client.
//
public sealed class EventBuilder
- {
-
+ {
// Make a private constructor so these cannot be constructed externally.
- private EventBuilder() {}
-
+ private EventBuilder() { }
+
// Constructs a EventBuilder.
//
internal EventBuilder(
- ModuleBuilder mod, // the module containing this EventBuilder
- String name, // Event name
+ ModuleBuilder mod, // the module containing this EventBuilder
+ String name, // Event name
EventAttributes attr, // event attribute such as Public, Private, and Protected defined above
- //int eventType, // event type
- TypeBuilder type, // containing type
- EventToken evToken)
- {
+ //int eventType, // event type
+ TypeBuilder type, // containing type
+ EventToken evToken)
+ {
m_name = name;
m_module = mod;
m_attributes = attr;
m_evToken = evToken;
m_type = type;
}
-
+
// Return the Token for this event within the TypeBuilder that the
// event is defined within.
public EventToken GetEventToken()
@@ -73,22 +73,22 @@ namespace System.Reflection.Emit {
{
SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.AddOn);
}
-
+
public void SetRemoveOnMethod(MethodBuilder mdBuilder)
{
SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.RemoveOn);
}
-
+
public void SetRaiseMethod(MethodBuilder mdBuilder)
{
SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.Fire);
}
-
+
public void AddOtherMethod(MethodBuilder mdBuilder)
{
SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.Other);
}
-
+
// Use this function if client decides to form the custom attribute blob themselves
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
@@ -121,10 +121,10 @@ namespace System.Reflection.Emit {
}
// These are package private so that TypeBuilder can access them.
- private String m_name; // The name of the event
- private EventToken m_evToken; // The token of this event
- private ModuleBuilder m_module;
- private EventAttributes m_attributes;
- private TypeBuilder m_type;
+ private String m_name; // The name of the event
+ private EventToken m_evToken; // The token of this event
+ private ModuleBuilder m_module;
+ private EventAttributes m_attributes;
+ private TypeBuilder m_type;
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/EventToken.cs b/src/mscorlib/src/System/Reflection/Emit/EventToken.cs
index 8ffdce9732..18ec630b5f 100644
--- a/src/mscorlib/src/System/Reflection/Emit/EventToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/EventToken.cs
@@ -12,30 +12,34 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
-
- using System;
- using System.Reflection;
+
+using System;
+using System.Reflection;
+
+namespace System.Reflection.Emit
+{
[Serializable]
public struct EventToken
{
public static readonly EventToken Empty = new EventToken();
-
+
internal int m_event;
- internal EventToken(int str) {
- m_event=str;
+ internal EventToken(int str)
+ {
+ m_event = str;
}
-
- public int Token {
+
+ public int Token
+ {
get { return m_event; }
}
-
+
public override int GetHashCode()
{
return m_event;
}
-
+
public override bool Equals(Object obj)
{
if (obj is EventToken)
@@ -43,25 +47,20 @@ namespace System.Reflection.Emit {
else
return false;
}
-
+
public bool Equals(EventToken obj)
{
return obj.m_event == m_event;
}
-
+
public static bool operator ==(EventToken a, EventToken b)
{
return a.Equals(b);
}
-
+
public static bool operator !=(EventToken a, EventToken b)
{
return !(a == b);
}
-
}
-
-
-
-
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
index 5953b67173..d0e9d3483c 100644
--- a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
@@ -4,14 +4,14 @@
//
-namespace System.Reflection.Emit
+namespace System.Reflection.Emit
{
using System.Runtime.InteropServices;
using System;
using CultureInfo = System.Globalization.CultureInfo;
using System.Reflection;
using System.Diagnostics.Contracts;
-
+
public sealed class FieldBuilder : FieldInfo
{
#region Private Data Members
@@ -24,36 +24,36 @@ namespace System.Reflection.Emit
#endregion
#region Constructor
- internal FieldBuilder(TypeBuilder typeBuilder, String fieldName, Type type,
+ internal FieldBuilder(TypeBuilder typeBuilder, String fieldName, Type type,
Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes)
{
if (fieldName == null)
throw new ArgumentNullException(nameof(fieldName));
if (fieldName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(fieldName));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(fieldName));
if (fieldName[0] == '\0')
- throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(fieldName));
+ throw new ArgumentException(SR.Argument_IllegalName, nameof(fieldName));
if (type == null)
throw new ArgumentNullException(nameof(type));
if (type == typeof(void))
- throw new ArgumentException(Environment.GetResourceString("Argument_BadFieldType"));
+ throw new ArgumentException(SR.Argument_BadFieldType);
Contract.EndContractBlock();
m_fieldName = fieldName;
m_typeBuilder = typeBuilder;
m_fieldType = type;
m_Attributes = attributes & ~FieldAttributes.ReservedMask;
-
+
SignatureHelper sigHelp = SignatureHelper.GetFieldSigHelper(m_typeBuilder.Module);
sigHelp.AddArgument(type, requiredCustomModifiers, optionalCustomModifiers);
int sigLength;
byte[] signature = sigHelp.InternalGetSignature(out sigLength);
-
+
m_fieldTok = TypeBuilder.DefineField(m_typeBuilder.GetModuleBuilder().GetNativeHandle(),
typeBuilder.TypeToken.Token, fieldName, signature, sigLength, m_Attributes);
@@ -74,20 +74,20 @@ namespace System.Reflection.Emit
{
get { return m_fieldTok; }
}
-
+
public override Module Module
{
get { return m_typeBuilder.Module; }
}
- public override String Name
+ public override String Name
{
- get {return m_fieldName; }
+ get { return m_fieldName; }
}
- public override Type DeclaringType
+ public override Type DeclaringType
{
- get
+ get
{
if (m_typeBuilder.m_isHiddenGlobalType == true)
return null;
@@ -95,10 +95,10 @@ namespace System.Reflection.Emit
return m_typeBuilder;
}
}
-
- public override Type ReflectedType
+
+ public override Type ReflectedType
{
- get
+ get
{
if (m_typeBuilder.m_isHiddenGlobalType == true)
return null;
@@ -110,35 +110,35 @@ namespace System.Reflection.Emit
#endregion
#region FieldInfo Overrides
- public override Type FieldType
+ public override Type FieldType
{
get { return m_fieldType; }
}
public override Object GetValue(Object obj)
- {
+ {
// NOTE!! If this is implemented, make sure that this throws
// a NotSupportedException for Save-only dynamic assemblies.
// Otherwise, it could cause the .cctor to be executed.
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
- public override void SetValue(Object obj,Object val,BindingFlags invokeAttr,Binder binder,CultureInfo culture)
- {
+ public override void SetValue(Object obj, Object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
+ {
// NOTE!! If this is implemented, make sure that this throws
// a NotSupportedException for Save-only dynamic assemblies.
// Otherwise, it could cause the .cctor to be executed.
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
- public override RuntimeFieldHandle FieldHandle
+ public override RuntimeFieldHandle FieldHandle
{
- get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); }
+ get { throw new NotSupportedException(SR.NotSupported_DynamicModule); }
}
- public override FieldAttributes Attributes
+ public override FieldAttributes Attributes
{
get { return m_Attributes; }
}
@@ -148,44 +148,41 @@ namespace System.Reflection.Emit
#region ICustomAttributeProvider Implementation
public override Object[] GetCustomAttributes(bool inherit)
{
-
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
-
+
public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
{
-
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
public override bool IsDefined(Type attributeType, bool inherit)
{
-
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
#endregion
#region Public Members
- public FieldToken GetToken()
+ public FieldToken GetToken()
{
return m_tkField;
}
- public void SetOffset(int iOffset)
+ public void SetOffset(int iOffset)
{
- m_typeBuilder.ThrowIfCreated();
-
+ m_typeBuilder.ThrowIfCreated();
+
TypeBuilder.SetFieldLayoutOffset(m_typeBuilder.GetModuleBuilder().GetNativeHandle(), GetToken().Token, iOffset);
}
- public void SetConstant(Object defaultValue)
+ public void SetConstant(Object defaultValue)
{
- m_typeBuilder.ThrowIfCreated();
-
+ m_typeBuilder.ThrowIfCreated();
+
TypeBuilder.SetConstantValue(m_typeBuilder.GetModuleBuilder(), GetToken().Token, m_fieldType, defaultValue);
}
-
+
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
diff --git a/src/mscorlib/src/System/Reflection/Emit/FieldToken.cs b/src/mscorlib/src/System/Reflection/Emit/FieldToken.cs
index add428f96e..6c5d778d8f 100644
--- a/src/mscorlib/src/System/Reflection/Emit/FieldToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/FieldToken.cs
@@ -12,11 +12,12 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
-
- using System;
- using System.Reflection;
+using System;
+using System.Reflection;
+
+namespace System.Reflection.Emit
+{
// 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,
@@ -28,7 +29,7 @@ namespace System.Reflection.Emit {
internal int m_fieldTok;
internal Object m_class;
-
+
// Creates an empty FieldToken. A publicly visible constructor so that
// it can be created on the stack.
//public FieldToken() {
@@ -38,23 +39,25 @@ namespace System.Reflection.Emit {
//}
// The actual constructor. Sets the field, attributes and class
// variables
-
- internal FieldToken (int field, Type fieldClass) {
- m_fieldTok=field;
+
+ internal FieldToken(int field, Type fieldClass)
+ {
+ m_fieldTok = field;
m_class = fieldClass;
}
-
- public int Token {
+
+ public int Token
+ {
get { return m_fieldTok; }
}
-
-
+
+
// Generates the hash code for this field.
public override int GetHashCode()
{
return (m_fieldTok);
}
-
+
// Returns true if obj is an instance of FieldToken and is
// equal to this instance.
public override bool Equals(Object obj)
@@ -69,16 +72,15 @@ namespace System.Reflection.Emit {
{
return obj.m_fieldTok == m_fieldTok && obj.m_class == m_class;
}
-
+
public static bool operator ==(FieldToken a, FieldToken b)
{
return a.Equals(b);
}
-
+
public static bool operator !=(FieldToken a, FieldToken b)
{
return !(a == b);
}
-
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs b/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs
index 9e528b2551..fb8564652f 100644
--- a/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs
@@ -11,23 +11,23 @@
** THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND!
** See clrsrcincopcodegen.pl for more information.**
============================================================*/
-namespace System.Reflection.Emit {
using System;
-[Serializable]
-public enum FlowControl
+namespace System.Reflection.Emit
{
-
- Branch = 0,
- Break = 1,
- Call = 2,
- Cond_Branch = 3,
- Meta = 4,
- Next = 5,
- [Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")]
- Phi = 6,
- Return = 7,
- Throw = 8,
-}
+ [Serializable]
+ public enum FlowControl
+ {
+ Branch = 0,
+ Break = 1,
+ Call = 2,
+ Cond_Branch = 3,
+ Meta = 4,
+ Next = 5,
+ [Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")]
+ Phi = 6,
+ Return = 7,
+ Throw = 8,
+ }
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs
index 894f57d49c..dd5ffa92a9 100644
--- a/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs
@@ -4,19 +4,20 @@
//
+using System;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Diagnostics.Contracts;
+
namespace System.Reflection.Emit
{
- using System;
- using System.Reflection;
- using System.Collections;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Diagnostics.Contracts;
-
- public sealed class GenericTypeParameterBuilder: TypeInfo
+ public sealed class GenericTypeParameterBuilder : TypeInfo
{
- public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
- if(typeInfo==null) return false;
+ public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo)
+ {
+ if (typeInfo == null) return false;
return IsAssignableFrom(typeInfo.AsType());
}
@@ -32,14 +33,14 @@ namespace System.Reflection.Emit
#endregion
#region Object Overrides
- public override String ToString()
- {
+ public override String ToString()
+ {
return m_type.Name;
}
- public override bool Equals(object o)
- {
+ public override bool Equals(object o)
+ {
GenericTypeParameterBuilder g = o as GenericTypeParameterBuilder;
-
+
if (g == null)
return false;
@@ -62,22 +63,22 @@ namespace System.Reflection.Emit
#region Type Overrides
- public override Type MakePointerType()
- {
- return SymbolType.FormCompoundType("*", this, 0);
+ public override Type MakePointerType()
+ {
+ return SymbolType.FormCompoundType("*", this, 0);
}
- public override Type MakeByRefType()
+ public override Type MakeByRefType()
{
return SymbolType.FormCompoundType("&", this, 0);
}
- public override Type MakeArrayType()
+ public override Type MakeArrayType()
{
return SymbolType.FormCompoundType("[]", this, 0);
}
- public override Type MakeArrayType(int rank)
+ public override Type MakeArrayType(int rank)
{
if (rank <= 0)
throw new IndexOutOfRangeException();
@@ -88,9 +89,9 @@ namespace System.Reflection.Emit
{
szrank = "*";
}
- else
+ else
{
- for(int i = 1; i < rank; i++)
+ for (int i = 1; i < rank; i++)
szrank += ",";
}
@@ -113,7 +114,7 @@ namespace System.Reflection.Emit
public override String AssemblyQualifiedName { get { return null; } }
- public override Type BaseType { get { return m_type.BaseType; } }
+ public override Type BaseType { get { return m_type.BaseType; } }
protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); }
@@ -153,6 +154,8 @@ namespace System.Reflection.Emit
protected override TypeAttributes GetAttributeFlagsImpl() { return TypeAttributes.Public; }
+ public override bool IsSZArray => false;
+
protected override bool IsArrayImpl() { return false; }
protected override bool IsByRefImpl() { return false; }
@@ -189,7 +192,7 @@ namespace System.Reflection.Emit
public override Type GetGenericTypeDefinition() { throw new InvalidOperationException(); }
- public override Type MakeGenericType(params Type[] typeArguments) { throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericTypeDefinition")); }
+ public override Type MakeGenericType(params Type[] typeArguments) { throw new InvalidOperationException(SR.Arg_NotGenericTypeDefinition); }
protected override bool IsValueTypeImpl() { return false; }
@@ -209,7 +212,7 @@ namespace System.Reflection.Emit
#region Public Members
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
- {
+ {
m_type.SetGenParamCustomAttribute(con, binaryAttribute);
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
index 2cee63ff2e..4021410a33 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
@@ -4,16 +4,16 @@
//
-namespace System.Reflection.Emit
+using System;
+using System.Diagnostics.SymbolStore;
+using System.Runtime.InteropServices;
+using System.Reflection;
+using System.Globalization;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+
+namespace System.Reflection.Emit
{
- using System;
- using System.Diagnostics.SymbolStore;
- using System.Runtime.InteropServices;
- using System.Reflection;
- using System.Globalization;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
-
public class ILGenerator
{
#region Const Members
@@ -28,18 +28,18 @@ namespace System.Reflection.Emit
{
return EnlargeArray(incoming, incoming.Length * 2);
}
-
+
internal static T[] EnlargeArray<T>(T[] incoming, int requiredSize)
{
Contract.Requires(incoming != null);
Contract.Ensures(Contract.Result<T[]>() != null);
Contract.Ensures(Contract.Result<T[]>().Length == requiredSize);
-
+
T[] temp = new T[requiredSize];
Array.Copy(incoming, 0, temp, 0, incoming.Length);
return temp;
}
-
+
private static byte[] EnlargeArray(byte[] incoming)
{
return EnlargeArray(incoming, incoming.Length * 2);
@@ -50,7 +50,7 @@ namespace System.Reflection.Emit
Contract.Requires(incoming != null);
Contract.Ensures(Contract.Result<byte[]>() != null);
Contract.Ensures(Contract.Result<byte[]>().Length == requiredSize);
-
+
byte[] temp = new byte[requiredSize];
Buffer.BlockCopy(incoming, 0, temp, 0, incoming.Length);
return temp;
@@ -58,35 +58,35 @@ namespace System.Reflection.Emit
#endregion
#region Internal Data Members
- private int m_length;
- private byte[] m_ILStream;
+ private int m_length;
+ private byte[] m_ILStream;
+
+ private int[] m_labelList;
+ private int m_labelCount;
- private int[] m_labelList;
- private int m_labelCount;
+ private __FixupData[] m_fixupData;
- private __FixupData[] m_fixupData;
-
- private int m_fixupCount;
+ private int m_fixupCount;
- private int[] m_RelocFixupList;
- private int m_RelocFixupCount;
+ private int[] m_RelocFixupList;
+ private int m_RelocFixupCount;
- private int m_exceptionCount;
- private int m_currExcStackCount;
- private __ExceptionInfo[] m_exceptions; //This is the list of all of the exceptions in this ILStream.
- private __ExceptionInfo[] m_currExcStack; //This is the stack of exceptions which we're currently in.
+ private int m_exceptionCount;
+ private int m_currExcStackCount;
+ private __ExceptionInfo[] m_exceptions; //This is the list of all of the exceptions in this ILStream.
+ private __ExceptionInfo[] m_currExcStack; //This is the stack of exceptions which we're currently in.
- internal ScopeTree m_ScopeTree; // this variable tracks all debugging scope information
- internal LineNumberInfo m_LineNumberInfo; // this variable tracks all line number information
+ internal ScopeTree m_ScopeTree; // this variable tracks all debugging scope information
+ internal LineNumberInfo m_LineNumberInfo; // this variable tracks all line number information
- internal MethodInfo m_methodBuilder;
- internal int m_localCount;
- internal SignatureHelper m_localSignature;
+ internal MethodInfo m_methodBuilder;
+ internal int m_localCount;
+ internal SignatureHelper m_localSignature;
- private int m_maxStackSize = 0; // Maximum stack size not counting the exceptions.
+ private int m_maxStackSize = 0; // Maximum stack size not counting the exceptions.
- private int m_maxMidStack = 0; // Maximum stack size for a given basic block.
- private int m_maxMidStackCur = 0; // Running count of the maximum stack size for the current basic block.
+ private int m_maxMidStack = 0; // Maximum stack size for a given basic block.
+ private int m_maxMidStackCur = 0; // Running count of the maximum stack size for the current basic block.
internal int CurrExcStackCount
{
@@ -128,9 +128,9 @@ namespace System.Reflection.Emit
m_fixupData = null;
- m_exceptions = null;
+ m_exceptions = null;
m_exceptionCount = 0;
- m_currExcStack = null;
+ m_currExcStack = null;
m_currExcStackCount = 0;
m_RelocFixupList = null;
@@ -144,7 +144,7 @@ namespace System.Reflection.Emit
// initialize local signature
m_localCount = 0;
MethodBuilder mb = m_methodBuilder as MethodBuilder;
- if (mb == null)
+ if (mb == null)
m_localSignature = SignatureHelper.GetLocalVarSigHelper(null);
else
m_localSignature = SignatureHelper.GetLocalVarSigHelper(mb.GetTypeBuilder().Module);
@@ -173,7 +173,6 @@ namespace System.Reflection.Emit
m_ILStream[m_length++] = (byte)opcode.Value;
UpdateStackSize(opcode, opcode.StackChange());
-
}
internal void UpdateStackSize(OpCode opcode, int stackchange)
@@ -211,13 +210,13 @@ namespace System.Reflection.Emit
return ((ModuleBuilder)m_methodBuilder.Module).GetMethodTokenInternal(method, optionalParameterTypes, useMethodDef);
}
- internal virtual SignatureHelper GetMemberRefSignature(CallingConventions call, Type returnType,
+ internal virtual SignatureHelper GetMemberRefSignature(CallingConventions call, Type returnType,
Type[] parameterTypes, Type[] optionalParameterTypes)
{
return GetMemberRefSignature(call, returnType, parameterTypes, optionalParameterTypes, 0);
}
- private SignatureHelper GetMemberRefSignature(CallingConventions call, Type returnType,
+ private SignatureHelper GetMemberRefSignature(CallingConventions call, Type returnType,
Type[] parameterTypes, Type[] optionalParameterTypes, int cGenericParameters)
{
return ((ModuleBuilder)m_methodBuilder.Module).GetMemberRefSignature(call, returnType, parameterTypes, optionalParameterTypes, cGenericParameters);
@@ -234,7 +233,7 @@ namespace System.Reflection.Emit
if (m_currExcStackCount != 0)
{
- throw new ArgumentException(Environment.GetResourceString("Argument_UnclosedExceptionBlock"));
+ throw new ArgumentException(SR.Argument_UnclosedExceptionBlock);
}
if (m_length == 0)
return null;
@@ -251,7 +250,7 @@ namespace System.Reflection.Emit
//Do the fixups.
//This involves iterating over all of the labels and
//replacing them with their proper values.
- for (int i =0; i < m_fixupCount; i++)
+ for (int i = 0; i < m_fixupCount; i++)
{
updateAddr = GetLabelPos(m_fixupData[i].m_fixupLabel) - (m_fixupData[i].m_fixupPos + m_fixupData[i].m_fixupInstSize);
@@ -259,11 +258,10 @@ namespace System.Reflection.Emit
//Throw an exception if they're trying to store a jump in a single byte instruction that doesn't fit.
if (m_fixupData[i].m_fixupInstSize == 1)
{
-
//Verify that our one-byte arg will fit into a Signed Byte.
if (updateAddr < SByte.MinValue || updateAddr > SByte.MaxValue)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_IllegalOneByteBranch",m_fixupData[i].m_fixupPos, updateAddr));
+ throw new NotSupportedException(SR.Format(SR.NotSupported_IllegalOneByteBranch, m_fixupData[i].m_fixupPos, updateAddr));
}
//Place the one-byte arg
@@ -287,17 +285,17 @@ namespace System.Reflection.Emit
internal __ExceptionInfo[] GetExceptions()
{
- __ExceptionInfo []temp;
+ __ExceptionInfo[] temp;
if (m_currExcStackCount != 0)
{
- throw new NotSupportedException(Environment.GetResourceString(ResId.Argument_UnclosedExceptionBlock));
+ throw new NotSupportedException(SR.GetResourceString(ResId.Argument_UnclosedExceptionBlock));
}
-
+
if (m_exceptionCount == 0)
{
return null;
}
-
+
temp = new __ExceptionInfo[m_exceptionCount];
Array.Copy(m_exceptions, 0, temp, 0, m_exceptionCount);
SortExceptions(temp);
@@ -325,14 +323,14 @@ namespace System.Reflection.Emit
m_length = PutInteger4InArray(value, m_length, m_ILStream);
}
- private static int PutInteger4InArray(int value, int startPos, byte []array)
+ private static int PutInteger4InArray(int value, int startPos, byte[] array)
{
// Puts an Int32 onto the stream. This is an internal routine, so it does not do any error checking.
array[startPos++] = (byte)value;
- array[startPos++] = (byte)(value >>8);
- array[startPos++] = (byte)(value >>16);
- array[startPos++] = (byte)(value >>24);
+ array[startPos++] = (byte)(value >> 8);
+ array[startPos++] = (byte)(value >> 16);
+ array[startPos++] = (byte)(value >> 24);
return startPos;
}
@@ -342,12 +340,12 @@ namespace System.Reflection.Emit
// Verifies that the label exists and that it has been given a value.
int index = lbl.GetLabelValue();
-
+
if (index < 0 || index >= m_labelCount)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadLabel"));
+ throw new ArgumentException(SR.Argument_BadLabel);
if (m_labelList[index] < 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadLabelContent"));
+ throw new ArgumentException(SR.Argument_BadLabelContent);
return m_labelList[index];
}
@@ -378,7 +376,7 @@ namespace System.Reflection.Emit
return m_maxStackSize;
}
- private static void SortExceptions(__ExceptionInfo []exceptions)
+ private static void SortExceptions(__ExceptionInfo[] exceptions)
{
// In order to call exceptions properly we have to sort them in ascending order by their end position.
// Just a cheap insertion sort. We don't expect many exceptions (<10), where InsertionSort beats QuickSort.
@@ -421,40 +419,42 @@ namespace System.Reflection.Emit
{
EnsureCapacity(3);
InternalEmit(opcode);
-
}
- public virtual void Emit(OpCode opcode, byte arg)
+ public virtual void Emit(OpCode opcode, byte arg)
{
EnsureCapacity(4);
InternalEmit(opcode);
- m_ILStream[m_length++]=arg;
+ m_ILStream[m_length++] = arg;
}
[CLSCompliant(false)]
- public void Emit(OpCode opcode, sbyte arg)
+ public void Emit(OpCode opcode, sbyte arg)
{
// Puts opcode onto the stream of instructions followed by arg
EnsureCapacity(4);
InternalEmit(opcode);
- if (arg<0) {
- m_ILStream[m_length++]=(byte)(256+arg);
- } else {
- m_ILStream[m_length++]=(byte) arg;
+ if (arg < 0)
+ {
+ m_ILStream[m_length++] = (byte)(256 + arg);
+ }
+ else
+ {
+ m_ILStream[m_length++] = (byte)arg;
}
}
- public virtual void Emit(OpCode opcode, short arg)
+ public virtual void Emit(OpCode opcode, short arg)
{
// Puts opcode onto the stream of instructions followed by arg
EnsureCapacity(5);
InternalEmit(opcode);
- m_ILStream[m_length++]=(byte) arg;
- m_ILStream[m_length++]=(byte) (arg>>8);
+ m_ILStream[m_length++] = (byte)arg;
+ m_ILStream[m_length++] = (byte)(arg >> 8);
}
- public virtual void Emit(OpCode opcode, int arg)
+ public virtual void Emit(OpCode opcode, int arg)
{
// Puts opcode onto the stream of instructions followed by arg
EnsureCapacity(7);
@@ -488,26 +488,26 @@ namespace System.Reflection.Emit
UpdateStackSize(opcode, stackchange);
RecordTokenFixup();
- PutInteger4(tk);
+ PutInteger4(tk);
}
}
- public virtual void EmitCalli(OpCode opcode, CallingConventions callingConvention,
+ public virtual void EmitCalli(OpCode opcode, CallingConventions callingConvention,
Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes)
{
int stackchange = 0;
- SignatureHelper sig;
+ SignatureHelper sig;
if (optionalParameterTypes != null)
{
if ((callingConvention & CallingConventions.VarArgs) == 0)
{
// Client should not supply optional parameter in default calling convention
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention"));
+ throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention);
}
}
- ModuleBuilder modBuilder = (ModuleBuilder) m_methodBuilder.Module;
+ ModuleBuilder modBuilder = (ModuleBuilder)m_methodBuilder.Module;
sig = GetMemberRefSignature(callingConvention,
returnType,
parameterTypes,
@@ -542,7 +542,7 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(methodInfo));
if (!(opcode.Equals(OpCodes.Call) || opcode.Equals(OpCodes.Callvirt) || opcode.Equals(OpCodes.Newobj)))
- throw new ArgumentException(Environment.GetResourceString("Argument_NotMethodCallOpcode"), nameof(opcode));
+ throw new ArgumentException(SR.Argument_NotMethodCallOpcode, nameof(opcode));
Contract.EndContractBlock();
@@ -657,11 +657,11 @@ namespace System.Reflection.Emit
// patched if necessary when persisting the module to a PE.
int tempVal = 0;
- ModuleBuilder modBuilder = (ModuleBuilder) m_methodBuilder.Module;
+ ModuleBuilder modBuilder = (ModuleBuilder)m_methodBuilder.Module;
if (opcode == OpCodes.Ldtoken && cls != null && cls.IsGenericTypeDefinition)
{
// This gets the token for the generic type definition if cls is one.
- tempVal = modBuilder.GetTypeToken( cls ).Token;
+ tempVal = modBuilder.GetTypeToken(cls).Token;
}
else
{
@@ -676,44 +676,47 @@ namespace System.Reflection.Emit
PutInteger4(tempVal);
}
- public virtual void Emit(OpCode opcode, long arg) {
+ public virtual void Emit(OpCode opcode, long arg)
+ {
EnsureCapacity(11);
InternalEmit(opcode);
- m_ILStream[m_length++] = (byte) arg;
- m_ILStream[m_length++] = (byte) (arg>>8);
- m_ILStream[m_length++] = (byte) (arg>>16);
- m_ILStream[m_length++] = (byte) (arg>>24);
- m_ILStream[m_length++] = (byte) (arg>>32);
- m_ILStream[m_length++] = (byte) (arg>>40);
- m_ILStream[m_length++] = (byte) (arg>>48);
- m_ILStream[m_length++] = (byte) (arg>>56);
+ m_ILStream[m_length++] = (byte)arg;
+ m_ILStream[m_length++] = (byte)(arg >> 8);
+ m_ILStream[m_length++] = (byte)(arg >> 16);
+ m_ILStream[m_length++] = (byte)(arg >> 24);
+ m_ILStream[m_length++] = (byte)(arg >> 32);
+ m_ILStream[m_length++] = (byte)(arg >> 40);
+ m_ILStream[m_length++] = (byte)(arg >> 48);
+ m_ILStream[m_length++] = (byte)(arg >> 56);
}
- unsafe public virtual void Emit(OpCode opcode, float arg) {
+ unsafe public virtual void Emit(OpCode opcode, float arg)
+ {
EnsureCapacity(7);
InternalEmit(opcode);
uint tempVal = *(uint*)&arg;
- m_ILStream[m_length++] = (byte) tempVal;
- m_ILStream[m_length++] = (byte) (tempVal>>8);
- m_ILStream[m_length++] = (byte) (tempVal>>16);
- m_ILStream[m_length++] = (byte) (tempVal>>24);
+ m_ILStream[m_length++] = (byte)tempVal;
+ m_ILStream[m_length++] = (byte)(tempVal >> 8);
+ m_ILStream[m_length++] = (byte)(tempVal >> 16);
+ m_ILStream[m_length++] = (byte)(tempVal >> 24);
}
- unsafe public virtual void Emit(OpCode opcode, double arg) {
+ unsafe public virtual void Emit(OpCode opcode, double arg)
+ {
EnsureCapacity(11);
InternalEmit(opcode);
- ulong tempVal = *(ulong*)&arg;
- m_ILStream[m_length++] = (byte) tempVal;
- m_ILStream[m_length++] = (byte) (tempVal>>8);
- m_ILStream[m_length++] = (byte) (tempVal>>16);
- m_ILStream[m_length++] = (byte) (tempVal>>24);
- m_ILStream[m_length++] = (byte) (tempVal>>32);
- m_ILStream[m_length++] = (byte) (tempVal>>40);
- m_ILStream[m_length++] = (byte) (tempVal>>48);
- m_ILStream[m_length++] = (byte) (tempVal>>56);
+ ulong tempVal = *(ulong*)&arg;
+ m_ILStream[m_length++] = (byte)tempVal;
+ m_ILStream[m_length++] = (byte)(tempVal >> 8);
+ m_ILStream[m_length++] = (byte)(tempVal >> 16);
+ m_ILStream[m_length++] = (byte)(tempVal >> 24);
+ m_ILStream[m_length++] = (byte)(tempVal >> 32);
+ m_ILStream[m_length++] = (byte)(tempVal >> 40);
+ m_ILStream[m_length++] = (byte)(tempVal >> 48);
+ m_ILStream[m_length++] = (byte)(tempVal >> 56);
}
- public virtual void Emit(OpCode opcode, Label label)
+ public virtual void Emit(OpCode opcode, Label label)
{
// Puts opcode onto the stream and leaves space to include label
// when fixups are done. Labels are created using ILGenerator.DefineLabel and
@@ -724,18 +727,21 @@ namespace System.Reflection.Emit
// opcode must represent a branch instruction (although we don't explicitly
// verify this). Since branches are relative instructions, label will be replaced with the
// correct offset to branch during the fixup process.
-
+
int tempVal = label.GetLabelValue();
EnsureCapacity(7);
-
+
InternalEmit(opcode);
- if (OpCodes.TakesSingleByteArgument(opcode)) {
+ if (OpCodes.TakesSingleByteArgument(opcode))
+ {
AddFixup(label, m_length, 1);
m_length++;
- } else {
+ }
+ else
+ {
AddFixup(label, m_length, 4);
- m_length+=4;
+ m_length += 4;
}
}
@@ -753,32 +759,33 @@ namespace System.Reflection.Emit
int count = labels.Length;
- EnsureCapacity( count * 4 + 7 );
+ EnsureCapacity(count * 4 + 7);
InternalEmit(opcode);
PutInteger4(count);
- for ( remaining = count * 4, i = 0; remaining > 0; remaining -= 4, i++ ) {
- AddFixup( labels[i], m_length, remaining );
+ for (remaining = count * 4, i = 0; remaining > 0; remaining -= 4, i++)
+ {
+ AddFixup(labels[i], m_length, remaining);
m_length += 4;
}
}
public virtual void Emit(OpCode opcode, FieldInfo field)
{
- ModuleBuilder modBuilder = (ModuleBuilder) m_methodBuilder.Module;
- int tempVal = modBuilder.GetFieldToken( field ).Token;
+ ModuleBuilder modBuilder = (ModuleBuilder)m_methodBuilder.Module;
+ int tempVal = modBuilder.GetFieldToken(field).Token;
EnsureCapacity(7);
InternalEmit(opcode);
RecordTokenFixup();
PutInteger4(tempVal);
}
- public virtual void Emit(OpCode opcode, String str)
+ public virtual void Emit(OpCode opcode, String str)
{
// Puts the opcode onto the IL stream followed by the metadata token
// represented by str. The location of str is recorded for future
// fixups if the module is persisted to a PE.
- ModuleBuilder modBuilder = (ModuleBuilder) m_methodBuilder.Module;
+ ModuleBuilder modBuilder = (ModuleBuilder)m_methodBuilder.Module;
int tempVal = modBuilder.GetStringConstant(str).Token;
EnsureCapacity(7);
InternalEmit(opcode);
@@ -797,12 +804,12 @@ namespace System.Reflection.Emit
int tempVal = local.GetLocalIndex();
if (local.GetMethodBuilder() != m_methodBuilder)
{
- throw new ArgumentException(Environment.GetResourceString("Argument_UnmatchedMethodForLocal"), nameof(local));
+ throw new ArgumentException(SR.Argument_UnmatchedMethodForLocal, nameof(local));
}
// If the instruction is a ldloc, ldloca a stloc, morph it to the optimal form.
if (opcode.Equals(OpCodes.Ldloc))
{
- switch(tempVal)
+ switch (tempVal)
{
case 0:
opcode = OpCodes.Ldloc_0;
@@ -824,7 +831,7 @@ namespace System.Reflection.Emit
}
else if (opcode.Equals(OpCodes.Stloc))
{
- switch(tempVal)
+ switch (tempVal)
{
case 0:
opcode = OpCodes.Stloc_0;
@@ -852,28 +859,28 @@ namespace System.Reflection.Emit
EnsureCapacity(7);
InternalEmit(opcode);
-
+
if (opcode.OperandType == OperandType.InlineNone)
return;
else if (!OpCodes.TakesSingleByteArgument(opcode))
{
- m_ILStream[m_length++]=(byte) tempVal;
- m_ILStream[m_length++]=(byte) (tempVal>>8);
+ m_ILStream[m_length++] = (byte)tempVal;
+ m_ILStream[m_length++] = (byte)(tempVal >> 8);
}
else
{
//Handle stloc_1, ldloc_1
if (tempVal > Byte.MaxValue)
{
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadInstructionOrIndexOutOfBound"));
+ throw new InvalidOperationException(SR.InvalidOperation_BadInstructionOrIndexOutOfBound);
}
- m_ILStream[m_length++]=(byte)tempVal;
+ m_ILStream[m_length++] = (byte)tempVal;
}
}
#endregion
#region Exceptions
- public virtual Label BeginExceptionBlock()
+ public virtual Label BeginExceptionBlock()
{
// Begin an Exception block. Creating an Exception block records some information,
// but does not actually emit any IL onto the stream. Exceptions should be created and
@@ -898,11 +905,13 @@ namespace System.Reflection.Emit
m_currExcStack = new __ExceptionInfo[DefaultExceptionArraySize];
}
- if (m_exceptionCount>=m_exceptions.Length) {
- m_exceptions=EnlargeArray(m_exceptions);
+ if (m_exceptionCount >= m_exceptions.Length)
+ {
+ m_exceptions = EnlargeArray(m_exceptions);
}
- if (m_currExcStackCount>=m_currExcStack.Length) {
+ if (m_currExcStackCount >= m_currExcStack.Length)
+ {
m_currExcStack = EnlargeArray(m_currExcStack);
}
@@ -917,14 +926,16 @@ namespace System.Reflection.Emit
return endLabel;
}
- public virtual void EndExceptionBlock() {
- if (m_currExcStackCount==0) {
- throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock"));
+ public virtual void EndExceptionBlock()
+ {
+ if (m_currExcStackCount == 0)
+ {
+ throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
}
- // Pop the current exception block
- __ExceptionInfo current = m_currExcStack[m_currExcStackCount-1];
- m_currExcStack[m_currExcStackCount-1] = null;
+ // Pop the current exception block
+ __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1];
+ m_currExcStack[m_currExcStackCount - 1] = null;
m_currExcStackCount--;
Label endLabel = current.GetEndLabel();
@@ -933,36 +944,40 @@ namespace System.Reflection.Emit
if (state == __ExceptionInfo.State_Filter ||
state == __ExceptionInfo.State_Try)
{
-
-
- throw new InvalidOperationException(Environment.GetResourceString("Argument_BadExceptionCodeGen"));
+ throw new InvalidOperationException(SR.Argument_BadExceptionCodeGen);
}
- if (state == __ExceptionInfo.State_Catch) {
+ if (state == __ExceptionInfo.State_Catch)
+ {
this.Emit(OpCodes.Leave, endLabel);
- } else if (state == __ExceptionInfo.State_Finally || state == __ExceptionInfo.State_Fault) {
+ }
+ else if (state == __ExceptionInfo.State_Finally || state == __ExceptionInfo.State_Fault)
+ {
this.Emit(OpCodes.Endfinally);
}
//Check if we've alredy set this label.
//The only reason why we might have set this is if we have a finally block.
- if (m_labelList[endLabel.GetLabelValue()]==-1) {
+ if (m_labelList[endLabel.GetLabelValue()] == -1)
+ {
MarkLabel(endLabel);
- } else {
+ }
+ else
+ {
MarkLabel(current.GetFinallyEndLabel());
}
current.Done(m_length);
}
- public virtual void BeginExceptFilterBlock()
+ public virtual void BeginExceptFilterBlock()
{
// Begins an exception filter block. Emits a branch instruction to the end of the current exception block.
if (m_currExcStackCount == 0)
- throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock"));
+ throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
- __ExceptionInfo current = m_currExcStack[m_currExcStackCount-1];
+ __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1];
Label endLabel = current.GetEndLabel();
this.Emit(OpCodes.Leave, endLabel);
@@ -970,30 +985,35 @@ namespace System.Reflection.Emit
current.MarkFilterAddr(m_length);
}
- public virtual void BeginCatchBlock(Type exceptionType)
+ public virtual void BeginCatchBlock(Type exceptionType)
{
// Begins a catch block. Emits a branch instruction to the end of the current exception block.
- if (m_currExcStackCount==0) {
- throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock"));
+ if (m_currExcStackCount == 0)
+ {
+ throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
}
- __ExceptionInfo current = m_currExcStack[m_currExcStackCount-1];
+ __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1];
- if (current.GetCurrentState() == __ExceptionInfo.State_Filter) {
- if (exceptionType != null) {
- throw new ArgumentException(Environment.GetResourceString("Argument_ShouldNotSpecifyExceptionType"));
+ if (current.GetCurrentState() == __ExceptionInfo.State_Filter)
+ {
+ if (exceptionType != null)
+ {
+ throw new ArgumentException(SR.Argument_ShouldNotSpecifyExceptionType);
}
this.Emit(OpCodes.Endfilter);
- } else {
+ }
+ else
+ {
// execute this branch if previous clause is Catch or Fault
- if (exceptionType==null) {
+ if (exceptionType == null)
+ {
throw new ArgumentNullException(nameof(exceptionType));
}
Label endLabel = current.GetEndLabel();
this.Emit(OpCodes.Leave, endLabel);
-
}
current.MarkCatchAddr(m_length, exceptionType);
@@ -1001,10 +1021,11 @@ namespace System.Reflection.Emit
public virtual void BeginFaultBlock()
{
- if (m_currExcStackCount==0) {
- throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock"));
+ if (m_currExcStackCount == 0)
+ {
+ throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
}
- __ExceptionInfo current = m_currExcStack[m_currExcStackCount-1];
+ __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1];
// emit the leave for the clause before this one.
Label endLabel = current.GetEndLabel();
@@ -1013,28 +1034,29 @@ namespace System.Reflection.Emit
current.MarkFaultAddr(m_length);
}
- public virtual void BeginFinallyBlock()
+ public virtual void BeginFinallyBlock()
{
- if (m_currExcStackCount==0) {
- throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock"));
+ if (m_currExcStackCount == 0)
+ {
+ throw new NotSupportedException(SR.Argument_NotInExceptionBlock);
}
- __ExceptionInfo current = m_currExcStack[m_currExcStackCount-1];
- int state = current.GetCurrentState();
- Label endLabel = current.GetEndLabel();
- int catchEndAddr = 0;
+ __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1];
+ int state = current.GetCurrentState();
+ Label endLabel = current.GetEndLabel();
+ int catchEndAddr = 0;
if (state != __ExceptionInfo.State_Try)
{
// generate leave for any preceeding catch clause
- this.Emit(OpCodes.Leave, endLabel);
+ this.Emit(OpCodes.Leave, endLabel);
catchEndAddr = m_length;
}
-
+
MarkLabel(endLabel);
Label finallyEndLabel = this.DefineLabel();
current.SetFinallyEndLabel(finallyEndLabel);
-
+
// generate leave for try clause
this.Emit(OpCodes.Leave, finallyEndLabel);
if (catchEndAddr == 0)
@@ -1045,25 +1067,27 @@ namespace System.Reflection.Emit
#endregion
#region Labels
- public virtual Label DefineLabel()
+ public virtual Label DefineLabel()
{
// Declares a new Label. This is just a token and does not yet represent any particular location
// within the stream. In order to set the position of the label within the stream, you must call
// Mark Label.
// Delay init the lable array in case we dont use it
- if (m_labelList == null){
+ if (m_labelList == null)
+ {
m_labelList = new int[DefaultLabelArraySize];
}
- if (m_labelCount>=m_labelList.Length) {
+ if (m_labelCount >= m_labelList.Length)
+ {
m_labelList = EnlargeArray(m_labelList);
}
- m_labelList[m_labelCount]=-1;
+ m_labelList[m_labelCount] = -1;
return new Label(m_labelCount++);
}
- public virtual void MarkLabel(Label loc)
+ public virtual void MarkLabel(Label loc)
{
// Defines a label by setting the position where that label is found within the stream.
// Does not allow a label to be defined more than once.
@@ -1071,15 +1095,17 @@ namespace System.Reflection.Emit
int labelIndex = loc.GetLabelValue();
//This should never happen.
- if (labelIndex<0 || labelIndex>=m_labelList.Length) {
- throw new ArgumentException (Environment.GetResourceString("Argument_InvalidLabel"));
+ if (labelIndex < 0 || labelIndex >= m_labelList.Length)
+ {
+ throw new ArgumentException(SR.Argument_InvalidLabel);
}
- if (m_labelList[labelIndex]!=-1) {
- throw new ArgumentException (Environment.GetResourceString("Argument_RedefinedLabel"));
+ if (m_labelList[labelIndex] != -1)
+ {
+ throw new ArgumentException(SR.Argument_RedefinedLabel);
}
- m_labelList[labelIndex]=m_length;
+ m_labelList[labelIndex] = m_length;
}
#endregion
@@ -1089,17 +1115,20 @@ namespace System.Reflection.Emit
{
// Emits the il to throw an exception
- if (excType==null) {
+ if (excType == null)
+ {
throw new ArgumentNullException(nameof(excType));
}
- if (!excType.IsSubclassOf(typeof(Exception)) && excType!=typeof(Exception)) {
- throw new ArgumentException(Environment.GetResourceString("Argument_NotExceptionType"));
+ if (!excType.IsSubclassOf(typeof(Exception)) && excType != typeof(Exception))
+ {
+ throw new ArgumentException(SR.Argument_NotExceptionType);
}
Contract.EndContractBlock();
ConstructorInfo con = excType.GetConstructor(Type.EmptyTypes);
- if (con==null) {
- throw new ArgumentException(Environment.GetResourceString("Argument_MissingDefaultConstructor"));
+ if (con == null)
+ {
+ throw new ArgumentException(SR.Argument_MissingDefaultConstructor);
}
this.Emit(OpCodes.Newobj, con);
this.Emit(OpCodes.Throw);
@@ -1108,7 +1137,7 @@ namespace System.Reflection.Emit
private static Type GetConsoleType()
{
return Type.GetType(
- "System.Console, System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
+ "System.Console, System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
throwOnError: true);
}
@@ -1123,17 +1152,17 @@ namespace System.Reflection.Emit
Emit(OpCodes.Call, mi);
}
- public virtual void EmitWriteLine(LocalBuilder localBuilder)
+ public virtual void EmitWriteLine(LocalBuilder localBuilder)
{
// Emits the IL necessary to call WriteLine with lcl. It is
// an error to call EmitWriteLine with a lcl which is not of
// one of the types for which Console.WriteLine implements overloads. (e.g.
// we do *not* call ToString on the locals.
- Object cls;
- if (m_methodBuilder==null)
+ Object cls;
+ if (m_methodBuilder == null)
{
- throw new ArgumentException(Environment.GetResourceString("InvalidOperation_BadILGeneratorUsage"));
+ throw new ArgumentException(SR.InvalidOperation_BadILGeneratorUsage);
}
MethodInfo prop = GetConsoleType().GetMethod("get_Out");
@@ -1141,13 +1170,15 @@ namespace System.Reflection.Emit
Emit(OpCodes.Ldloc, localBuilder);
Type[] parameterTypes = new Type[1];
cls = localBuilder.LocalType;
- if (cls is TypeBuilder || cls is EnumBuilder) {
- throw new ArgumentException(Environment.GetResourceString("NotSupported_OutputStreamUsingTypeBuilder"));
+ if (cls is TypeBuilder || cls is EnumBuilder)
+ {
+ throw new ArgumentException(SR.NotSupported_OutputStreamUsingTypeBuilder);
}
parameterTypes[0] = (Type)cls;
MethodInfo mi = prop.ReturnType.GetMethod("WriteLine", parameterTypes);
- if (mi==null) {
- throw new ArgumentException(Environment.GetResourceString("Argument_EmitWriteLineType"), nameof(localBuilder));
+ if (mi == null)
+ {
+ throw new ArgumentException(SR.Argument_EmitWriteLineType, nameof(localBuilder));
}
Emit(OpCodes.Callvirt, mi);
@@ -1167,25 +1198,30 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(fld));
}
Contract.EndContractBlock();
-
+
MethodInfo prop = GetConsoleType().GetMethod("get_Out");
Emit(OpCodes.Call, prop);
- if ((fld.Attributes & FieldAttributes.Static)!=0) {
+ if ((fld.Attributes & FieldAttributes.Static) != 0)
+ {
Emit(OpCodes.Ldsfld, fld);
- } else {
+ }
+ else
+ {
Emit(OpCodes.Ldarg, (short)0); //Load the this ref.
Emit(OpCodes.Ldfld, fld);
}
Type[] parameterTypes = new Type[1];
cls = fld.FieldType;
- if (cls is TypeBuilder || cls is EnumBuilder) {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_OutputStreamUsingTypeBuilder"));
+ if (cls is TypeBuilder || cls is EnumBuilder)
+ {
+ throw new NotSupportedException(SR.NotSupported_OutputStreamUsingTypeBuilder);
}
parameterTypes[0] = (Type)cls;
MethodInfo mi = prop.ReturnType.GetMethod("WriteLine", parameterTypes);
- if (mi==null) {
- throw new ArgumentException(Environment.GetResourceString("Argument_EmitWriteLineType"), nameof(fld));
+ if (mi == null)
+ {
+ throw new ArgumentException(SR.Argument_EmitWriteLineType, nameof(fld));
}
Emit(OpCodes.Callvirt, mi);
}
@@ -1203,24 +1239,26 @@ namespace System.Reflection.Emit
// Declare a local of type "local". The current active lexical scope
// will be the scope that local will live.
- LocalBuilder localBuilder;
+ LocalBuilder localBuilder;
MethodBuilder methodBuilder = m_methodBuilder as MethodBuilder;
- if (methodBuilder == null)
+ if (methodBuilder == null)
throw new NotSupportedException();
if (methodBuilder.IsTypeCreated())
{
// cannot change method after its containing type has been created
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated"));
+ throw new InvalidOperationException(SR.InvalidOperation_TypeHasBeenCreated);
}
- if (localType==null) {
+ if (localType == null)
+ {
throw new ArgumentNullException(nameof(localType));
}
- if (methodBuilder.m_bIsBaked) {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MethodBaked"));
+ if (methodBuilder.m_bIsBaked)
+ {
+ throw new InvalidOperationException(SR.InvalidOperation_MethodBaked);
}
// add the localType to local signature
@@ -1240,12 +1278,12 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(usingNamespace));
if (usingNamespace.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(usingNamespace));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(usingNamespace));
Contract.EndContractBlock();
int index;
MethodBuilder methodBuilder = m_methodBuilder as MethodBuilder;
- if (methodBuilder == null)
+ if (methodBuilder == null)
throw new NotSupportedException();
index = methodBuilder.GetILGenerator().m_ScopeTree.GetCurrentActiveScopeIndex();
@@ -1301,43 +1339,44 @@ namespace System.Reflection.Emit
{
internal Label m_fixupLabel;
internal int m_fixupPos;
-
+
internal int m_fixupInstSize;
}
- internal sealed class __ExceptionInfo {
-
- internal const int None = 0x0000; //COR_ILEXCEPTION_CLAUSE_NONE
- internal const int Filter = 0x0001; //COR_ILEXCEPTION_CLAUSE_FILTER
- internal const int Finally = 0x0002; //COR_ILEXCEPTION_CLAUSE_FINALLY
- internal const int Fault = 0x0004; //COR_ILEXCEPTION_CLAUSE_FAULT
- internal const int PreserveStack = 0x0004; //COR_ILEXCEPTION_CLAUSE_PRESERVESTACK
+ internal sealed class __ExceptionInfo
+ {
+ internal const int None = 0x0000; //COR_ILEXCEPTION_CLAUSE_NONE
+ internal const int Filter = 0x0001; //COR_ILEXCEPTION_CLAUSE_FILTER
+ internal const int Finally = 0x0002; //COR_ILEXCEPTION_CLAUSE_FINALLY
+ internal const int Fault = 0x0004; //COR_ILEXCEPTION_CLAUSE_FAULT
+ internal const int PreserveStack = 0x0004; //COR_ILEXCEPTION_CLAUSE_PRESERVESTACK
internal const int State_Try = 0;
- internal const int State_Filter =1;
+ internal const int State_Filter = 1;
internal const int State_Catch = 2;
internal const int State_Finally = 3;
internal const int State_Fault = 4;
internal const int State_Done = 5;
internal int m_startAddr;
- internal int []m_filterAddr;
- internal int []m_catchAddr;
- internal int []m_catchEndAddr;
- internal int []m_type;
- internal Type []m_catchClass;
+ internal int[] m_filterAddr;
+ internal int[] m_catchAddr;
+ internal int[] m_catchEndAddr;
+ internal int[] m_type;
+ internal Type[] m_catchClass;
internal Label m_endLabel;
internal Label m_finallyEndLabel;
internal int m_endAddr;
internal int m_endFinally;
internal int m_currentCatch;
- int m_currentState;
+ private int m_currentState;
//This will never get called. The values exist merely to keep the
//compiler happy.
- private __ExceptionInfo() {
+ private __ExceptionInfo()
+ {
m_startAddr = 0;
m_filterAddr = null;
m_catchAddr = null;
@@ -1349,68 +1388,70 @@ namespace System.Reflection.Emit
m_currentState = State_Try;
}
- internal __ExceptionInfo(int startAddr, Label endLabel) {
- m_startAddr=startAddr;
- m_endAddr=-1;
- m_filterAddr=new int[4];
- m_catchAddr=new int[4];
- m_catchEndAddr=new int[4];
- m_catchClass=new Type[4];
- m_currentCatch=0;
- m_endLabel=endLabel;
- m_type=new int[4];
- m_endFinally=-1;
+ internal __ExceptionInfo(int startAddr, Label endLabel)
+ {
+ m_startAddr = startAddr;
+ m_endAddr = -1;
+ m_filterAddr = new int[4];
+ m_catchAddr = new int[4];
+ m_catchEndAddr = new int[4];
+ m_catchClass = new Type[4];
+ m_currentCatch = 0;
+ m_endLabel = endLabel;
+ m_type = new int[4];
+ m_endFinally = -1;
m_currentState = State_Try;
}
private void MarkHelper(
- int catchorfilterAddr, // the starting address of a clause
- int catchEndAddr, // the end address of a previous catch clause. Only use when finally is following a catch
- Type catchClass, // catch exception type
- int type) // kind of clause
- {
- if (m_currentCatch>=m_catchAddr.Length) {
- m_filterAddr=ILGenerator.EnlargeArray(m_filterAddr);
- m_catchAddr=ILGenerator.EnlargeArray(m_catchAddr);
- m_catchEndAddr=ILGenerator.EnlargeArray(m_catchEndAddr);
- m_catchClass=ILGenerator.EnlargeArray(m_catchClass);
+ int catchorfilterAddr, // the starting address of a clause
+ int catchEndAddr, // the end address of a previous catch clause. Only use when finally is following a catch
+ Type catchClass, // catch exception type
+ int type) // kind of clause
+ {
+ if (m_currentCatch >= m_catchAddr.Length)
+ {
+ m_filterAddr = ILGenerator.EnlargeArray(m_filterAddr);
+ m_catchAddr = ILGenerator.EnlargeArray(m_catchAddr);
+ m_catchEndAddr = ILGenerator.EnlargeArray(m_catchEndAddr);
+ m_catchClass = ILGenerator.EnlargeArray(m_catchClass);
m_type = ILGenerator.EnlargeArray(m_type);
}
if (type == Filter)
{
- m_type[m_currentCatch]=type;
+ m_type[m_currentCatch] = type;
m_filterAddr[m_currentCatch] = catchorfilterAddr;
m_catchAddr[m_currentCatch] = -1;
if (m_currentCatch > 0)
{
- Debug.Assert(m_catchEndAddr[m_currentCatch-1] == -1,"m_catchEndAddr[m_currentCatch-1] == -1");
- m_catchEndAddr[m_currentCatch-1] = catchorfilterAddr;
+ Debug.Assert(m_catchEndAddr[m_currentCatch - 1] == -1, "m_catchEndAddr[m_currentCatch-1] == -1");
+ m_catchEndAddr[m_currentCatch - 1] = catchorfilterAddr;
}
}
else
{
// catch or Fault clause
- m_catchClass[m_currentCatch]=catchClass;
+ m_catchClass[m_currentCatch] = catchClass;
if (m_type[m_currentCatch] != Filter)
{
- m_type[m_currentCatch]=type;
+ m_type[m_currentCatch] = type;
}
- m_catchAddr[m_currentCatch]=catchorfilterAddr;
+ m_catchAddr[m_currentCatch] = catchorfilterAddr;
if (m_currentCatch > 0)
{
- if (m_type[m_currentCatch] != Filter)
- {
- Debug.Assert(m_catchEndAddr[m_currentCatch-1] == -1,"m_catchEndAddr[m_currentCatch-1] == -1");
- m_catchEndAddr[m_currentCatch-1] = catchEndAddr;
- }
+ if (m_type[m_currentCatch] != Filter)
+ {
+ Debug.Assert(m_catchEndAddr[m_currentCatch - 1] == -1, "m_catchEndAddr[m_currentCatch-1] == -1");
+ m_catchEndAddr[m_currentCatch - 1] = catchEndAddr;
+ }
}
- m_catchEndAddr[m_currentCatch]=-1;
+ m_catchEndAddr[m_currentCatch] = -1;
m_currentCatch++;
}
- if (m_endAddr==-1)
+ if (m_endAddr == -1)
{
- m_endAddr=catchorfilterAddr;
+ m_endAddr = catchorfilterAddr;
}
}
@@ -1426,74 +1467,92 @@ namespace System.Reflection.Emit
MarkHelper(faultAddr, faultAddr, null, Fault);
}
- internal void MarkCatchAddr(int catchAddr, Type catchException) {
+ internal void MarkCatchAddr(int catchAddr, Type catchException)
+ {
m_currentState = State_Catch;
MarkHelper(catchAddr, catchAddr, catchException, None);
}
- internal void MarkFinallyAddr(int finallyAddr, int endCatchAddr) {
- if (m_endFinally!=-1) {
- throw new ArgumentException(Environment.GetResourceString("Argument_TooManyFinallyClause"));
- } else {
+ internal void MarkFinallyAddr(int finallyAddr, int endCatchAddr)
+ {
+ if (m_endFinally != -1)
+ {
+ throw new ArgumentException(SR.Argument_TooManyFinallyClause);
+ }
+ else
+ {
m_currentState = State_Finally;
- m_endFinally=finallyAddr;
+ m_endFinally = finallyAddr;
}
MarkHelper(finallyAddr, endCatchAddr, null, Finally);
}
- internal void Done(int endAddr) {
- Debug.Assert(m_currentCatch > 0,"m_currentCatch > 0");
- Debug.Assert(m_catchAddr[m_currentCatch-1] > 0,"m_catchAddr[m_currentCatch-1] > 0");
- Debug.Assert(m_catchEndAddr[m_currentCatch-1] == -1,"m_catchEndAddr[m_currentCatch-1] == -1");
- m_catchEndAddr[m_currentCatch-1] = endAddr;
+ internal void Done(int endAddr)
+ {
+ Debug.Assert(m_currentCatch > 0, "m_currentCatch > 0");
+ Debug.Assert(m_catchAddr[m_currentCatch - 1] > 0, "m_catchAddr[m_currentCatch-1] > 0");
+ Debug.Assert(m_catchEndAddr[m_currentCatch - 1] == -1, "m_catchEndAddr[m_currentCatch-1] == -1");
+ m_catchEndAddr[m_currentCatch - 1] = endAddr;
m_currentState = State_Done;
}
- internal int GetStartAddress() {
+ internal int GetStartAddress()
+ {
return m_startAddr;
}
- internal int GetEndAddress() {
+ internal int GetEndAddress()
+ {
return m_endAddr;
}
- internal int GetFinallyEndAddress() {
+ internal int GetFinallyEndAddress()
+ {
return m_endFinally;
}
- internal Label GetEndLabel() {
+ internal Label GetEndLabel()
+ {
return m_endLabel;
}
- internal int [] GetFilterAddresses() {
+ internal int[] GetFilterAddresses()
+ {
return m_filterAddr;
}
- internal int [] GetCatchAddresses() {
+ internal int[] GetCatchAddresses()
+ {
return m_catchAddr;
}
- internal int [] GetCatchEndAddresses() {
+ internal int[] GetCatchEndAddresses()
+ {
return m_catchEndAddr;
}
- internal Type [] GetCatchClass() {
+ internal Type[] GetCatchClass()
+ {
return m_catchClass;
}
- internal int GetNumberOfCatches() {
+ internal int GetNumberOfCatches()
+ {
return m_currentCatch;
}
- internal int[] GetExceptionTypes() {
+ internal int[] GetExceptionTypes()
+ {
return m_type;
}
- internal void SetFinallyEndLabel(Label lbl) {
- m_finallyEndLabel=lbl;
+ internal void SetFinallyEndLabel(Label lbl)
+ {
+ m_finallyEndLabel = lbl;
}
- internal Label GetFinallyEndLabel() {
+ internal Label GetFinallyEndLabel()
+ {
return m_finallyEndLabel;
}
@@ -1505,15 +1564,16 @@ namespace System.Reflection.Emit
// of an exception. This is somewhat of a mis-nomer. This gives a
// random result for cases where the two exceptions being compared do
// not having a nesting relation.
- internal bool IsInner(__ExceptionInfo exc) {
+ internal bool IsInner(__ExceptionInfo exc)
+ {
Contract.Requires(exc != null);
- Debug.Assert(m_currentCatch > 0,"m_currentCatch > 0");
- Debug.Assert(exc.m_currentCatch > 0,"exc.m_currentCatch > 0");
+ Debug.Assert(m_currentCatch > 0, "m_currentCatch > 0");
+ Debug.Assert(exc.m_currentCatch > 0, "exc.m_currentCatch > 0");
int exclast = exc.m_currentCatch - 1;
int last = m_currentCatch - 1;
- if (exc.m_catchEndAddr[exclast] < m_catchEndAddr[last])
+ if (exc.m_catchEndAddr[exclast] < m_catchEndAddr[last])
return true;
else if (exc.m_catchEndAddr[exclast] == m_catchEndAddr[last])
{
@@ -1530,7 +1590,8 @@ namespace System.Reflection.Emit
// 2 indicates in a catch block
// 3 indicates in a finally block
// 4 indicates Done
- internal int GetCurrentState() {
+ internal int GetCurrentState()
+ {
return m_currentState;
}
}
@@ -1545,10 +1606,10 @@ namespace System.Reflection.Emit
*
***************************/
[Serializable]
- enum ScopeAction
+ internal enum ScopeAction
{
- Open = 0x0,
- Close = 0x1,
+ Open = 0x0,
+ Close = 0x1,
}
internal sealed class ScopeTree
@@ -1569,8 +1630,8 @@ namespace System.Reflection.Emit
***************************/
internal int GetCurrentActiveScopeIndex()
{
- int cClose = 0;
- int i = m_iCount - 1;
+ int cClose = 0;
+ int i = m_iCount - 1;
if (m_iCount == 0)
{
@@ -1590,13 +1651,13 @@ namespace System.Reflection.Emit
}
internal void AddLocalSymInfoToCurrentScope(
- String strName,
- byte[] signature,
- int slot,
- int startOffset,
- int endOffset)
+ String strName,
+ byte[] signature,
+ int slot,
+ int startOffset,
+ int endOffset)
{
- int i = GetCurrentActiveScopeIndex();
+ int i = GetCurrentActiveScopeIndex();
if (m_localSymInfos[i] == null)
{
m_localSymInfos[i] = new LocalSymInfo();
@@ -1605,9 +1666,9 @@ namespace System.Reflection.Emit
}
internal void AddUsingNamespaceToCurrentScope(
- String strNamespace)
+ String strNamespace)
{
- int i = GetCurrentActiveScopeIndex();
+ int i = GetCurrentActiveScopeIndex();
if (m_localSymInfos[i] == null)
{
m_localSymInfos[i] = new LocalSymInfo();
@@ -1617,16 +1678,16 @@ namespace System.Reflection.Emit
internal void AddScopeInfo(ScopeAction sa, int iOffset)
{
- if (sa == ScopeAction.Close && m_iOpenScopeCount <=0)
+ if (sa == ScopeAction.Close && m_iOpenScopeCount <= 0)
{
- throw new ArgumentException(Environment.GetResourceString("Argument_UnmatchingSymScope"));
+ throw new ArgumentException(SR.Argument_UnmatchingSymScope);
}
Contract.EndContractBlock();
// make sure that arrays are large enough to hold addition info
- EnsureCapacity();
-
-
+ EnsureCapacity();
+
+
m_ScopeActions[m_iCount] = sa;
m_iOffsets[m_iCount] = iOffset;
m_localSymInfos[m_iCount] = null;
@@ -1637,7 +1698,6 @@ namespace System.Reflection.Emit
}
else
m_iOpenScopeCount--;
-
}
/**************************
@@ -1675,7 +1735,7 @@ namespace System.Reflection.Emit
internal void EmitScopeTree(ISymbolWriter symWriter)
{
- int i;
+ int i;
for (i = 0; i < m_iCount; i++)
{
if (m_ScopeActions[i] == ScopeAction.Open)
@@ -1693,11 +1753,11 @@ namespace System.Reflection.Emit
}
}
- internal int[] m_iOffsets; // array of offsets
- internal ScopeAction[] m_ScopeActions; // array of scope actions
- internal int m_iCount; // how many entries in the arrays are occupied
- internal int m_iOpenScopeCount; // keep track how many scopes are open
- internal const int InitialSize = 16;
+ internal int[] m_iOffsets; // array of offsets
+ internal ScopeAction[] m_ScopeActions; // array of scope actions
+ internal int m_iCount; // how many entries in the arrays are occupied
+ internal int m_iOpenScopeCount; // keep track how many scopes are open
+ internal const int InitialSize = 16;
internal LocalSymInfo[] m_localSymInfos; // keep track debugging local information
}
@@ -1718,32 +1778,32 @@ namespace System.Reflection.Emit
internal void AddLineNumberInfo(
ISymbolDocumentWriter document,
- int iOffset,
- int iStartLine,
- int iStartColumn,
- int iEndLine,
- int iEndColumn)
- {
- int i;
-
+ int iOffset,
+ int iStartLine,
+ int iStartColumn,
+ int iEndLine,
+ int iEndColumn)
+ {
+ int i;
+
// make sure that arrays are large enough to hold addition info
i = FindDocument(document);
-
+
Debug.Assert(i < m_DocumentCount, "Bad document look up!");
m_Documents[i].AddLineNumberInfo(document, iOffset, iStartLine, iStartColumn, iEndLine, iEndColumn);
}
-
+
// Find a REDocument representing document. If we cannot find one, we will add a new entry into
// the REDocument array.
private int FindDocument(ISymbolDocumentWriter document)
{
- int i;
-
+ int i;
+
// This is an optimization. The chance that the previous line is coming from the same
// document is very high.
if (m_iLastFound < m_DocumentCount && m_Documents[m_iLastFound].m_document == document)
return m_iLastFound;
-
+
for (i = 0; i < m_DocumentCount; i++)
{
if (m_Documents[i].m_document == document)
@@ -1752,7 +1812,7 @@ namespace System.Reflection.Emit
return m_iLastFound;
}
}
-
+
// cannot find an existing document so add one to the array
EnsureCapacity();
m_iLastFound = m_DocumentCount;
@@ -1776,7 +1836,7 @@ namespace System.Reflection.Emit
else if (m_DocumentCount == m_Documents.Length)
{
// the arrays are full. Enlarge the arrays
- REDocument[] temp = new REDocument [m_DocumentCount * 2];
+ REDocument[] temp = new REDocument[m_DocumentCount * 2];
Array.Copy(m_Documents, 0, temp, 0, m_DocumentCount);
m_Documents = temp;
}
@@ -1788,10 +1848,10 @@ namespace System.Reflection.Emit
m_Documents[i].EmitLineNumberInfo(symWriter);
}
- private int m_DocumentCount; // how many documents that we have right now
+ private int m_DocumentCount; // how many documents that we have right now
private REDocument[] m_Documents; // array of documents
- private const int InitialSize = 16;
- private int m_iLastFound;
+ private const int InitialSize = 16;
+ private int m_iLastFound;
}
@@ -1811,17 +1871,17 @@ namespace System.Reflection.Emit
internal void AddLineNumberInfo(
ISymbolDocumentWriter document,
- int iOffset,
- int iStartLine,
- int iStartColumn,
- int iEndLine,
- int iEndColumn)
+ int iOffset,
+ int iStartLine,
+ int iStartColumn,
+ int iEndLine,
+ int iEndColumn)
{
Debug.Assert(document == m_document, "Bad document look up!");
-
+
// make sure that arrays are large enough to hold addition info
EnsureCapacity();
-
+
m_iOffsets[m_iLineNumberCount] = iOffset;
m_iLines[m_iLineNumberCount] = iStartLine;
m_iColumns[m_iLineNumberCount] = iStartColumn;
@@ -1847,27 +1907,27 @@ namespace System.Reflection.Emit
m_iEndColumns = new int[InitialSize];
}
else if (m_iLineNumberCount == m_iOffsets.Length)
- {
+ {
// the arrays are full. Enlarge the arrays
// It would probably be simpler to just use Lists here
int newSize = checked(m_iLineNumberCount * 2);
- int[] temp = new int [newSize];
+ int[] temp = new int[newSize];
Array.Copy(m_iOffsets, 0, temp, 0, m_iLineNumberCount);
m_iOffsets = temp;
- temp = new int [newSize];
+ temp = new int[newSize];
Array.Copy(m_iLines, 0, temp, 0, m_iLineNumberCount);
m_iLines = temp;
- temp = new int [newSize];
+ temp = new int[newSize];
Array.Copy(m_iColumns, 0, temp, 0, m_iLineNumberCount);
m_iColumns = temp;
- temp = new int [newSize];
+ temp = new int[newSize];
Array.Copy(m_iEndLines, 0, temp, 0, m_iLineNumberCount);
m_iEndLines = temp;
- temp = new int [newSize];
+ temp = new int[newSize];
Array.Copy(m_iEndColumns, 0, temp, 0, m_iLineNumberCount);
m_iEndColumns = temp;
}
@@ -1875,40 +1935,40 @@ namespace System.Reflection.Emit
internal void EmitLineNumberInfo(ISymbolWriter symWriter)
{
- int[] iOffsetsTemp;
- int[] iLinesTemp;
- int[] iColumnsTemp;
- int[] iEndLinesTemp;
- int[] iEndColumnsTemp;
+ int[] iOffsetsTemp;
+ int[] iLinesTemp;
+ int[] iColumnsTemp;
+ int[] iEndLinesTemp;
+ int[] iEndColumnsTemp;
if (m_iLineNumberCount == 0)
return;
// reduce the array size to be exact
- iOffsetsTemp = new int [m_iLineNumberCount];
+ iOffsetsTemp = new int[m_iLineNumberCount];
Array.Copy(m_iOffsets, 0, iOffsetsTemp, 0, m_iLineNumberCount);
- iLinesTemp = new int [m_iLineNumberCount];
+ iLinesTemp = new int[m_iLineNumberCount];
Array.Copy(m_iLines, 0, iLinesTemp, 0, m_iLineNumberCount);
- iColumnsTemp = new int [m_iLineNumberCount];
+ iColumnsTemp = new int[m_iLineNumberCount];
Array.Copy(m_iColumns, 0, iColumnsTemp, 0, m_iLineNumberCount);
- iEndLinesTemp = new int [m_iLineNumberCount];
+ iEndLinesTemp = new int[m_iLineNumberCount];
Array.Copy(m_iEndLines, 0, iEndLinesTemp, 0, m_iLineNumberCount);
- iEndColumnsTemp = new int [m_iLineNumberCount];
+ iEndColumnsTemp = new int[m_iLineNumberCount];
Array.Copy(m_iEndColumns, 0, iEndColumnsTemp, 0, m_iLineNumberCount);
- symWriter.DefineSequencePoints(m_document, iOffsetsTemp, iLinesTemp, iColumnsTemp, iEndLinesTemp, iEndColumnsTemp);
+ symWriter.DefineSequencePoints(m_document, iOffsetsTemp, iLinesTemp, iColumnsTemp, iEndLinesTemp, iEndColumnsTemp);
}
- private int[] m_iOffsets; // array of offsets
- private int[] m_iLines; // array of offsets
- private int[] m_iColumns; // array of offsets
- private int[] m_iEndLines; // array of offsets
- private int[] m_iEndColumns; // array of offsets
+ private int[] m_iOffsets; // array of offsets
+ private int[] m_iLines; // array of offsets
+ private int[] m_iColumns; // array of offsets
+ private int[] m_iEndLines; // array of offsets
+ private int[] m_iEndColumns; // array of offsets
internal ISymbolDocumentWriter m_document; // The ISymbolDocumentWriter that this REDocument is tracking.
- private int m_iLineNumberCount; // how many entries in the arrays are occupied
- private const int InitialSize = 16;
+ private int m_iLineNumberCount; // how many entries in the arrays are occupied
+ private const int InitialSize = 16;
} // end of REDocument
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs b/src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs
index e6f4622f0e..cda651c9ce 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs
@@ -2,14 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System;
+using System.Security;
+using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
+using System.Diagnostics.SymbolStore;
+
namespace System.Reflection.Emit
{
- using System;
- using System.Security;
- using System.Runtime.InteropServices;
- using System.Runtime.CompilerServices;
- using System.Diagnostics.SymbolStore;
-
//-----------------------------------------------------------------------------------
// On Telesto, we don't ship the ISymWrapper.dll assembly. However, ReflectionEmit
// relies on that assembly to write out managed PDBs.
@@ -31,7 +31,7 @@ namespace System.Reflection.Emit
// SymWrapperCore is never instantiated and is used as an encapsulation class.
// It is our "ISymWrapper.dll" assembly within an assembly.
//------------------------------------------------------------------------------
- class SymWrapperCore
+ internal class SymWrapperCore
{
//------------------------------------------------------------------------------
// Block instantiation
@@ -49,7 +49,6 @@ namespace System.Reflection.Emit
//------------------------------------------------------------------------------
private unsafe class SymDocumentWriter : ISymbolDocumentWriter
{
-
//------------------------------------------------------------------------------
// Ctor
//------------------------------------------------------------------------------
@@ -57,10 +56,10 @@ namespace System.Reflection.Emit
{
m_pDocumentWriterSafeHandle = pDocumentWriterSafeHandle;
// The handle is actually a pointer to a native ISymUnmanagedDocumentWriter.
- m_pDocWriter = (ISymUnmanagedDocumentWriter *)m_pDocumentWriterSafeHandle.DangerousGetHandle();
+ m_pDocWriter = (ISymUnmanagedDocumentWriter*)m_pDocumentWriterSafeHandle.DangerousGetHandle();
m_vtable = (ISymUnmanagedDocumentWriterVTable)(Marshal.PtrToStructure(m_pDocWriter->m_unmanagedVTable, typeof(ISymUnmanagedDocumentWriterVTable)));
}
-
+
//------------------------------------------------------------------------------
// Returns the underlying ISymUnmanagedDocumentWriter* (as a safehandle.)
//------------------------------------------------------------------------------
@@ -68,7 +67,7 @@ namespace System.Reflection.Emit
{
return m_pDocumentWriterSafeHandle;
}
-
+
//=========================================================================================
// Public interface methods start here. (Well actually, they're all NotSupported
@@ -82,11 +81,11 @@ namespace System.Reflection.Emit
{
throw new NotSupportedException(); // Intentionally not supported to match desktop CLR
}
-
+
//------------------------------------------------------------------------------
// SetCheckSum() wrapper
//------------------------------------------------------------------------------
- void ISymbolDocumentWriter.SetCheckSum(Guid algorithmId, byte [] checkSum)
+ void ISymbolDocumentWriter.SetCheckSum(Guid algorithmId, byte[] checkSum)
{
int hr = m_vtable.SetCheckSum(m_pDocWriter, algorithmId, (uint)checkSum.Length, checkSum);
if (hr < 0)
@@ -94,8 +93,8 @@ namespace System.Reflection.Emit
throw Marshal.GetExceptionForHR(hr);
}
}
-
- private delegate int DSetCheckSum(ISymUnmanagedDocumentWriter * pThis, Guid algorithmId, uint checkSumSize, [In] byte[] checkSum);
+
+ private delegate int DSetCheckSum(ISymUnmanagedDocumentWriter* pThis, Guid algorithmId, uint checkSumSize, [In] byte[] checkSum);
//------------------------------------------------------------------------------
// This layout must match the unmanaged ISymUnmanagedDocumentWriter* COM vtable
@@ -105,14 +104,14 @@ namespace System.Reflection.Emit
[StructLayout(LayoutKind.Sequential)]
private struct ISymUnmanagedDocumentWriterVTable
{
- internal IntPtr QueryInterface;
- internal IntPtr AddRef;
- internal IntPtr Release;
+ internal IntPtr QueryInterface;
+ internal IntPtr AddRef;
+ internal IntPtr Release;
- internal IntPtr SetSource;
- internal DSetCheckSum SetCheckSum;
+ internal IntPtr SetSource;
+ internal DSetCheckSum SetCheckSum;
}
-
+
//------------------------------------------------------------------------------
// This layout must match the (start) of the unmanaged ISymUnmanagedDocumentWriter
// COM object.
@@ -128,15 +127,13 @@ namespace System.Reflection.Emit
//------------------------------------------------------------------------------
private PunkSafeHandle m_pDocumentWriterSafeHandle;
- private ISymUnmanagedDocumentWriter * m_pDocWriter;
+ private ISymUnmanagedDocumentWriter* m_pDocWriter;
//------------------------------------------------------------------------------
// Stores the "managed vtable" (actually a structure full of delegates that
// P/Invoke to the corresponding unmanaged COM methods.)
//------------------------------------------------------------------------------
private ISymUnmanagedDocumentWriterVTable m_vtable;
-
-
} // class SymDocumentWriter
@@ -146,8 +143,6 @@ namespace System.Reflection.Emit
//------------------------------------------------------------------------------
internal unsafe class SymWriter : ISymbolWriter
{
-
-
//------------------------------------------------------------------------------
// Creates a SymWriter. The SymWriter is a managed wrapper around the unmanaged
// symbol writer provided by the runtime (ildbsymlib or diasymreader.dll).
@@ -166,7 +161,7 @@ namespace System.Reflection.Emit
private SymWriter()
{
}
-
+
//------------------------------------------------------------------------------
// DefineDocument() wrapper
//------------------------------------------------------------------------------
@@ -188,7 +183,7 @@ namespace System.Reflection.Emit
}
return new SymDocumentWriter(psymUnmanagedDocumentWriter);
}
-
+
//------------------------------------------------------------------------------
// OpenMethod() wrapper
//------------------------------------------------------------------------------
@@ -200,7 +195,7 @@ namespace System.Reflection.Emit
throw Marshal.GetExceptionForHR(hr);
}
}
-
+
//------------------------------------------------------------------------------
// CloseMethod() wrapper
//------------------------------------------------------------------------------
@@ -212,7 +207,7 @@ namespace System.Reflection.Emit
throw Marshal.GetExceptionForHR(hr);
}
}
-
+
//------------------------------------------------------------------------------
// DefineSequencePoints() wrapper
//------------------------------------------------------------------------------
@@ -248,11 +243,11 @@ namespace System.Reflection.Emit
{
return;
}
- if ( (offsets != null && offsets.Length != spCount) ||
- (lines != null && lines.Length != spCount) ||
+ if ((offsets != null && offsets.Length != spCount) ||
+ (lines != null && lines.Length != spCount) ||
(columns != null && columns.Length != spCount) ||
(endLines != null && endLines.Length != spCount) ||
- (endColumns != null && endColumns.Length != spCount) )
+ (endColumns != null && endColumns.Length != spCount))
{
throw new ArgumentException();
}
@@ -269,9 +264,8 @@ namespace System.Reflection.Emit
{
throw Marshal.GetExceptionForHR(hr);
}
-
}
-
+
//------------------------------------------------------------------------------
// OpenScope() wrapper
//------------------------------------------------------------------------------
@@ -285,7 +279,7 @@ namespace System.Reflection.Emit
}
return ret;
}
-
+
//------------------------------------------------------------------------------
// CloseScope() wrapper
//------------------------------------------------------------------------------
@@ -297,7 +291,7 @@ namespace System.Reflection.Emit
throw Marshal.GetExceptionForHR(hr);
}
}
-
+
//------------------------------------------------------------------------------
// DefineLocalVariable() wrapper
//------------------------------------------------------------------------------
@@ -339,7 +333,7 @@ namespace System.Reflection.Emit
throw Marshal.GetExceptionForHR(hr);
}
}
-
+
//------------------------------------------------------------------------------
// UsingNamespace() wrapper
//------------------------------------------------------------------------------
@@ -364,65 +358,65 @@ namespace System.Reflection.Emit
internal void InternalSetUnderlyingWriter(IntPtr ppUnderlyingWriter)
{
m_pWriter = *((ISymUnmanagedWriter**)ppUnderlyingWriter);
- m_vtable = (ISymUnmanagedWriterVTable) (Marshal.PtrToStructure(m_pWriter->m_unmanagedVTable, typeof(ISymUnmanagedWriterVTable)));
+ m_vtable = (ISymUnmanagedWriterVTable)(Marshal.PtrToStructure(m_pWriter->m_unmanagedVTable, typeof(ISymUnmanagedWriterVTable)));
}
//------------------------------------------------------------------------------
// Define delegates for the unmanaged COM methods we invoke.
//------------------------------------------------------------------------------
- private delegate int DInitialize(ISymUnmanagedWriter* pthis,
- IntPtr emitter, //IUnknown*
+ private delegate int DInitialize(ISymUnmanagedWriter* pthis,
+ IntPtr emitter, //IUnknown*
[MarshalAs(UnmanagedType.LPWStr)] String filename, //WCHAR*
- IntPtr pIStream, //IStream*
- [MarshalAs(UnmanagedType.Bool)] bool fFullBuild
+ IntPtr pIStream, //IStream*
+ [MarshalAs(UnmanagedType.Bool)] bool fFullBuild
);
- private delegate int DDefineDocument(ISymUnmanagedWriter* pthis,
+ private delegate int DDefineDocument(ISymUnmanagedWriter* pthis,
[MarshalAs(UnmanagedType.LPWStr)] String url,
- [In] ref Guid language,
- [In] ref Guid languageVender,
- [In] ref Guid documentType,
- [Out] out PunkSafeHandle ppsymUnmanagedDocumentWriter
+ [In] ref Guid language,
+ [In] ref Guid languageVender,
+ [In] ref Guid documentType,
+ [Out] out PunkSafeHandle ppsymUnmanagedDocumentWriter
);
-
+
private delegate int DSetUserEntryPoint(ISymUnmanagedWriter* pthis, int entryMethod);
private delegate int DOpenMethod(ISymUnmanagedWriter* pthis, int entryMethod);
private delegate int DCloseMethod(ISymUnmanagedWriter* pthis);
private delegate int DDefineSequencePoints(ISymUnmanagedWriter* pthis,
- PunkSafeHandle document,
- int spCount,
- [In] int[] offsets,
- [In] int[] lines,
- [In] int[] columns,
- [In] int[] endLines,
- [In] int[] endColumns);
+ PunkSafeHandle document,
+ int spCount,
+ [In] int[] offsets,
+ [In] int[] lines,
+ [In] int[] columns,
+ [In] int[] endLines,
+ [In] int[] endColumns);
private delegate int DOpenScope(ISymUnmanagedWriter* pthis, int startOffset, [Out] out int pretval);
private delegate int DCloseScope(ISymUnmanagedWriter* pthis, int endOffset);
private delegate int DSetScopeRange(ISymUnmanagedWriter* pthis, int scopeID, int startOffset, int endOffset);
- private delegate int DDefineLocalVariable(ISymUnmanagedWriter* pthis,
+ private delegate int DDefineLocalVariable(ISymUnmanagedWriter* pthis,
[MarshalAs(UnmanagedType.LPWStr)] String name,
- int attributes,
- int cSig,
- [In] byte[] signature,
- int addrKind,
- int addr1,
- int addr2,
- int addr3,
- int startOffset,
- int endOffset
+ int attributes,
+ int cSig,
+ [In] byte[] signature,
+ int addrKind,
+ int addr1,
+ int addr2,
+ int addr3,
+ int startOffset,
+ int endOffset
);
private delegate int DClose(ISymUnmanagedWriter* pthis);
- private delegate int DSetSymAttribute(ISymUnmanagedWriter* pthis,
- int parent,
+ private delegate int DSetSymAttribute(ISymUnmanagedWriter* pthis,
+ int parent,
[MarshalAs(UnmanagedType.LPWStr)] String name,
- int cData,
- [In] byte[] data
+ int cData,
+ [In] byte[] data
);
@@ -440,38 +434,37 @@ namespace System.Reflection.Emit
[StructLayout(LayoutKind.Sequential)]
private struct ISymUnmanagedWriterVTable
{
- internal IntPtr QueryInterface;
- internal IntPtr AddRef;
- internal IntPtr Release;
+ internal IntPtr QueryInterface;
+ internal IntPtr AddRef;
+ internal IntPtr Release;
- internal DDefineDocument DefineDocument;
- internal DSetUserEntryPoint SetUserEntryPoint;
+ internal DDefineDocument DefineDocument;
+ internal DSetUserEntryPoint SetUserEntryPoint;
- internal DOpenMethod OpenMethod;
- internal DCloseMethod CloseMethod;
+ internal DOpenMethod OpenMethod;
+ internal DCloseMethod CloseMethod;
- internal DOpenScope OpenScope;
- internal DCloseScope CloseScope;
+ internal DOpenScope OpenScope;
+ internal DCloseScope CloseScope;
- internal DSetScopeRange SetScopeRange;
+ internal DSetScopeRange SetScopeRange;
- internal DDefineLocalVariable DefineLocalVariable;
- internal IntPtr DefineParameter;
- internal IntPtr DefineField;
- internal IntPtr DefineGlobalVariable;
+ internal DDefineLocalVariable DefineLocalVariable;
+ internal IntPtr DefineParameter;
+ internal IntPtr DefineField;
+ internal IntPtr DefineGlobalVariable;
- internal DClose Close;
- internal DSetSymAttribute SetSymAttribute;
+ internal DClose Close;
+ internal DSetSymAttribute SetSymAttribute;
- internal DOpenNamespace OpenNamespace;
- internal DCloseNamespace CloseNamespace;
- internal DUsingNamespace UsingNamespace;
+ internal DOpenNamespace OpenNamespace;
+ internal DCloseNamespace CloseNamespace;
+ internal DUsingNamespace UsingNamespace;
- internal IntPtr SetMethodSourceRange;
- internal DInitialize Initialize;
- internal IntPtr GetDebugInfo;
+ internal IntPtr SetMethodSourceRange;
+ internal DInitialize Initialize;
+ internal IntPtr GetDebugInfo;
internal DDefineSequencePoints DefineSequencePoints;
-
}
//------------------------------------------------------------------------------
@@ -490,19 +483,14 @@ namespace System.Reflection.Emit
// As with the real ISymWrapper.dll, ISymWrapper performs *no* Release (or AddRef) on this pointer.
// Managing lifetime is up to the caller (coreclr.dll).
//------------------------------------------------------------------------------
- private ISymUnmanagedWriter *m_pWriter;
+ private ISymUnmanagedWriter* m_pWriter;
//------------------------------------------------------------------------------
// Stores the "managed vtable" (actually a structure full of delegates that
// P/Invoke to the corresponding unmanaged COM methods.)
//------------------------------------------------------------------------------
private ISymUnmanagedWriterVTable m_vtable;
-
} // class SymWriter
-
-
-
-
} //class SymWrapperCore
@@ -518,7 +506,7 @@ namespace System.Reflection.Emit
//
// Had to make this a non-nested class since FCall's don't like to bind to nested classes.
//--------------------------------------------------------------------------------------
- sealed class PunkSafeHandle : SafeHandle
+ internal sealed class PunkSafeHandle : SafeHandle
{
internal PunkSafeHandle()
: base((IntPtr)0, true)
diff --git a/src/mscorlib/src/System/Reflection/Emit/Label.cs b/src/mscorlib/src/System/Reflection/Emit/Label.cs
index c7b987ff10..f6315a67d2 100644
--- a/src/mscorlib/src/System/Reflection/Emit/Label.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/Label.cs
@@ -13,11 +13,13 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
- using System;
- using System.Reflection;
- using System.Runtime.InteropServices;
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace System.Reflection.Emit
+{
// The Label class is an opaque representation of a label used by the
// ILGenerator class. The token is used to mark where labels occur in the IL
// stream and then the necessary offsets are put back in the code when the ILGenerator
@@ -25,27 +27,29 @@ namespace System.Reflection.Emit {
// Labels are created by using ILGenerator.CreateLabel and their position is set
// by using ILGenerator.MarkLabel.
[Serializable]
- public struct Label {
-
+ public struct Label
+ {
internal int m_label;
-
+
//public Label() {
// m_label=0;
//}
-
- internal Label (int label) {
- m_label=label;
+
+ internal Label(int label)
+ {
+ m_label = label;
}
-
- internal int GetLabelValue() {
+
+ internal int GetLabelValue()
+ {
return m_label;
}
-
+
public override int GetHashCode()
{
return m_label;
}
-
+
public override bool Equals(Object obj)
{
if (obj is Label)
@@ -53,17 +57,17 @@ namespace System.Reflection.Emit {
else
return false;
}
-
+
public bool Equals(Label obj)
{
return obj.m_label == m_label;
}
-
+
public static bool operator ==(Label a, Label b)
{
return a.Equals(b);
}
-
+
public static bool operator !=(Label a, Label b)
{
return !(a == b);
diff --git a/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs
index fe4c33160a..c04c3c8434 100644
--- a/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs
@@ -6,10 +6,10 @@ using System;
using System.Reflection;
using System.Runtime.InteropServices;
-namespace System.Reflection.Emit
+namespace System.Reflection.Emit
{
public sealed class LocalBuilder : LocalVariableInfo
- {
+ {
#region Private Data Members
private int m_localIndex;
private Type m_localType;
@@ -19,9 +19,9 @@ namespace System.Reflection.Emit
#region Constructor
private LocalBuilder() { }
- internal LocalBuilder(int localIndex, Type localType, MethodInfo methodBuilder)
+ internal LocalBuilder(int localIndex, Type localType, MethodInfo methodBuilder)
: this(localIndex, localType, methodBuilder, false) { }
- internal LocalBuilder(int localIndex, Type localType, MethodInfo methodBuilder, bool isPinned)
+ internal LocalBuilder(int localIndex, Type localType, MethodInfo methodBuilder, bool isPinned)
{
m_isPinned = isPinned;
m_localIndex = localIndex;
@@ -31,11 +31,11 @@ namespace System.Reflection.Emit
#endregion
#region Internal Members
- internal int GetLocalIndex()
+ internal int GetLocalIndex()
{
return m_localIndex;
}
- internal MethodInfo GetMethodBuilder()
+ internal MethodInfo GetMethodBuilder()
{
return m_methodBuilder;
}
@@ -43,13 +43,13 @@ namespace System.Reflection.Emit
#region LocalVariableInfo Override
public override bool IsPinned { get { return m_isPinned; } }
- public override Type LocalType
+ public override Type LocalType
{
- get
- {
- return m_localType;
+ get
+ {
+ return m_localType;
}
- }
+ }
public override int LocalIndex { get { return m_localIndex; } }
#endregion
@@ -57,7 +57,7 @@ namespace System.Reflection.Emit
public void SetLocalSymInfo(String name)
{
SetLocalSymInfo(name, 0, 0);
- }
+ }
public void SetLocalSymInfo(String name, int startOffset, int endOffset)
{
@@ -69,27 +69,27 @@ namespace System.Reflection.Emit
int index;
MethodBuilder methodBuilder = m_methodBuilder as MethodBuilder;
- if (methodBuilder == null)
+ if (methodBuilder == null)
// it's a light code gen entity
throw new NotSupportedException();
- dynMod = (ModuleBuilder) methodBuilder.Module;
+ dynMod = (ModuleBuilder)methodBuilder.Module;
if (methodBuilder.IsTypeCreated())
{
// cannot change method after its containing type has been created
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated"));
+ throw new InvalidOperationException(SR.InvalidOperation_TypeHasBeenCreated);
}
-
+
// set the name and range of offset for the local
if (dynMod.GetSymWriter() == null)
{
// cannot set local name if not debug module
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule"));
+ throw new InvalidOperationException(SR.InvalidOperation_NotADebugModule);
}
-
+
sigHelp = SignatureHelper.GetFieldSigHelper(dynMod);
sigHelp.AddArgument(m_localType);
signature = sigHelp.InternalGetSignature(out sigLength);
-
+
// The symbol store doesn't want the calling convention on the
// front of the signature, but InternalGetSignature returns
// the callinging convention. So we strip it off. This is a
@@ -97,7 +97,7 @@ namespace System.Reflection.Emit
// yet another array of bytes...
mungedSig = new byte[sigLength - 1];
Buffer.BlockCopy(signature, 1, mungedSig, 0, sigLength - 1);
-
+
index = methodBuilder.GetILGenerator().m_ScopeTree.GetCurrentActiveScopeIndex();
if (index == -1)
{
@@ -105,7 +105,7 @@ namespace System.Reflection.Emit
methodBuilder.m_localSymInfo.AddLocalSymInfo(
name,
mungedSig,
- m_localIndex,
+ m_localIndex,
startOffset,
endOffset);
}
@@ -114,7 +114,7 @@ namespace System.Reflection.Emit
methodBuilder.GetILGenerator().m_ScopeTree.AddLocalSymInfoToCurrentScope(
name,
mungedSig,
- m_localIndex,
+ m_localIndex,
startOffset,
endOffset);
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs
index 17c8ce074d..530a5ee092 100644
--- a/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs
@@ -4,7 +4,7 @@
//
-namespace System.Reflection.Emit
+namespace System.Reflection.Emit
{
using System.Text;
using System;
@@ -35,7 +35,7 @@ namespace System.Reflection.Emit
private byte[] m_ubBody; // The IL for the method
private ExceptionHandler[] m_exceptions; // Exception handlers or null if there are none.
private const int DefaultMaxStack = 16;
- private int m_maxStack = DefaultMaxStack;
+ private int m_maxStack = DefaultMaxStack;
// Flags
internal bool m_bIsBaked;
@@ -69,7 +69,7 @@ namespace System.Reflection.Emit
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers,
ModuleBuilder mod, TypeBuilder type, bool bIsGlobalMethod)
{
- Init(name, attributes, callingConvention,
+ Init(name, attributes, callingConvention,
returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers,
mod, type, bIsGlobalMethod);
@@ -77,17 +77,17 @@ namespace System.Reflection.Emit
private void Init(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
- Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers,
+ Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers,
ModuleBuilder mod, TypeBuilder type, bool bIsGlobalMethod)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
if (name[0] == '\0')
- throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(name));
+ throw new ArgumentException(SR.Argument_IllegalName, nameof(name));
if (mod == null)
throw new ArgumentNullException(nameof(mod));
@@ -95,7 +95,7 @@ namespace System.Reflection.Emit
if (parameterTypes != null)
{
- foreach(Type t in parameterTypes)
+ foreach (Type t in parameterTypes)
{
if (t == null)
throw new ArgumentNullException(nameof(parameterTypes));
@@ -124,7 +124,7 @@ namespace System.Reflection.Emit
else if ((attributes & MethodAttributes.Virtual) != 0)
{
// A method can't be both static and virtual
- throw new ArgumentException(Environment.GetResourceString("Arg_NoStaticVirtual"));
+ throw new ArgumentException(SR.Arg_NoStaticVirtual);
}
if ((attributes & MethodAttributes.SpecialName) != MethodAttributes.SpecialName)
@@ -132,10 +132,10 @@ namespace System.Reflection.Emit
if ((type.Attributes & TypeAttributes.Interface) == TypeAttributes.Interface)
{
// methods on interface have to be abstract + virtual except special name methods such as type initializer
- if ((attributes & (MethodAttributes.Abstract | MethodAttributes.Virtual)) !=
- (MethodAttributes.Abstract | MethodAttributes.Virtual) &&
+ if ((attributes & (MethodAttributes.Abstract | MethodAttributes.Virtual)) !=
+ (MethodAttributes.Abstract | MethodAttributes.Virtual) &&
(attributes & MethodAttributes.Static) == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadAttributeOnInterfaceMethod"));
+ throw new ArgumentException(SR.Argument_BadAttributeOnInterfaceMethod);
}
}
@@ -156,9 +156,9 @@ namespace System.Reflection.Emit
m_parameterTypeRequiredCustomModifiers = parameterTypeRequiredCustomModifiers;
m_parameterTypeOptionalCustomModifiers = parameterTypeOptionalCustomModifiers;
-// m_signature = SignatureHelper.GetMethodSigHelper(mod, callingConvention,
-// returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
-// parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers);
+ // m_signature = SignatureHelper.GetMethodSigHelper(mod, callingConvention,
+ // returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
+ // parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers);
m_iAttributes = attributes;
m_bIsGlobalMethod = bIsGlobalMethod;
@@ -179,9 +179,9 @@ namespace System.Reflection.Emit
internal void CheckContext(params Type[][] typess)
{
- m_module.CheckContext(typess);
+ m_module.CheckContext(typess);
}
-
+
internal void CheckContext(params Type[] types)
{
m_module.CheckContext(types);
@@ -197,22 +197,22 @@ namespace System.Reflection.Emit
}
Contract.EndContractBlock();
- __ExceptionInfo[] excp;
- int counter=0;
- int[] filterAddrs;
- int[] catchAddrs;
- int[] catchEndAddrs;
- Type[] catchClass;
- int[] type;
- int numCatch;
- int start, end;
- ModuleBuilder dynMod = (ModuleBuilder) m_module;
+ __ExceptionInfo[] excp;
+ int counter = 0;
+ int[] filterAddrs;
+ int[] catchAddrs;
+ int[] catchEndAddrs;
+ Type[] catchClass;
+ int[] type;
+ int numCatch;
+ int start, end;
+ ModuleBuilder dynMod = (ModuleBuilder)m_module;
m_containingType.ThrowIfCreated();
if (m_bIsBaked)
{
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MethodHasBody"));
+ throw new InvalidOperationException(SR.InvalidOperation_MethodHasBody);
}
if (il.m_methodBuilder != this && il.m_methodBuilder != null)
@@ -221,15 +221,15 @@ namespace System.Reflection.Emit
// through MethodBuilder::GetILGenerator.
//
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadILGeneratorUsage"));
+ throw new InvalidOperationException(SR.InvalidOperation_BadILGeneratorUsage);
}
-
+
ThrowIfShouldNotHaveBody();
if (il.m_ScopeTree.m_iOpenScopeCount != 0)
{
// There are still unclosed local scope
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_OpenLocalVariableScope"));
+ throw new InvalidOperationException(SR.InvalidOperation_OpenLocalVariableScope);
}
@@ -276,20 +276,18 @@ namespace System.Reflection.Emit
break;
}
}
-
}
}
- m_bIsBaked=true;
+ m_bIsBaked = true;
if (dynMod.GetSymWriter() != null)
{
-
// set the debugging information such as scope and line number
// if it is in a debug module
//
- SymbolToken tk = new SymbolToken(MetadataTokenInternal);
+ SymbolToken tk = new SymbolToken(MetadataTokenInternal);
ISymbolWriter symWriter = dynMod.GetSymWriter();
// call OpenMethod to make this method the current method
@@ -299,16 +297,16 @@ namespace System.Reflection.Emit
// the top-levelsmethod scope
//
symWriter.OpenScope(0);
-
+
if (m_symCustomAttrs != null)
{
- foreach(SymCustomAttr symCustomAttr in m_symCustomAttrs)
+ foreach (SymCustomAttr symCustomAttr in m_symCustomAttrs)
dynMod.GetSymWriter().SetSymAttribute(
- new SymbolToken (MetadataTokenInternal),
- symCustomAttr.m_name,
+ new SymbolToken(MetadataTokenInternal),
+ symCustomAttr.m_name,
symCustomAttr.m_data);
}
-
+
if (m_localSymInfo != null)
m_localSymInfo.EmitLocalSymInfo(symWriter);
il.m_ScopeTree.EmitScopeTree(symWriter);
@@ -330,14 +328,14 @@ namespace System.Reflection.Emit
m_ubBody = null;
m_localSymInfo = null;
m_mdMethodFixups = null;
- m_localSignature = null;
+ m_localSignature = null;
m_exceptions = null;
}
internal override Type[] GetParameterTypes()
{
if (m_parameterTypes == null)
- m_parameterTypes = EmptyArray<Type>.Value;
+ m_parameterTypes = Array.Empty<Type>();
return m_parameterTypes;
}
@@ -347,11 +345,11 @@ namespace System.Reflection.Emit
MethodInfo mi = null;
ConstructorInfo ci = null;
- if ( (mi = method as MethodInfo) != null )
+ if ((mi = method as MethodInfo) != null)
{
return mi.ReturnType;
}
- else if ( (ci = method as ConstructorInfo) != null)
+ else if ((ci = method as ConstructorInfo) != null)
{
return ci.GetReturnType();
}
@@ -377,9 +375,9 @@ namespace System.Reflection.Emit
internal SignatureHelper GetMethodSignature()
{
if (m_parameterTypes == null)
- m_parameterTypes = EmptyArray<Type>.Value;
+ m_parameterTypes = Array.Empty<Type>();
- m_signature = SignatureHelper.GetMethodSigHelper (m_module, m_callingConvention, m_inst != null ? m_inst.Length : 0,
+ m_signature = SignatureHelper.GetMethodSigHelper(m_module, m_callingConvention, m_inst != null ? m_inst.Length : 0,
m_returnType == null ? typeof(void) : m_returnType, m_returnTypeRequiredCustomModifiers, m_returnTypeOptionalCustomModifiers,
m_parameterTypes, m_parameterTypeRequiredCustomModifiers, m_parameterTypeOptionalCustomModifiers);
@@ -394,7 +392,7 @@ namespace System.Reflection.Emit
signatureLength = m_localSignature.Length;
return m_localSignature;
}
-
+
if (m_ilGenerator != null)
{
if (m_ilGenerator.m_localCount != 0)
@@ -432,28 +430,28 @@ namespace System.Reflection.Emit
internal int CalculateNumberOfExceptions(__ExceptionInfo[] excp)
{
- int num=0;
+ int num = 0;
- if (excp==null)
+ if (excp == null)
{
return 0;
}
- for (int i=0; i<excp.Length; i++)
+ for (int i = 0; i < excp.Length; i++)
{
- num+=excp[i].GetNumberOfCatches();
+ num += excp[i].GetNumberOfCatches();
}
return num;
}
internal bool IsTypeCreated()
- {
- return (m_containingType != null && m_containingType.IsCreated());
+ {
+ return (m_containingType != null && m_containingType.IsCreated());
}
internal TypeBuilder GetTypeBuilder()
- {
+ {
return m_containingType;
}
@@ -464,20 +462,25 @@ namespace System.Reflection.Emit
#endregion
#region Object Overrides
- public override bool Equals(Object obj) {
- if (!(obj is MethodBuilder)) {
+ public override bool Equals(Object obj)
+ {
+ if (!(obj is MethodBuilder))
+ {
return false;
}
- if (!(this.m_strName.Equals(((MethodBuilder)obj).m_strName))) {
+ if (!(this.m_strName.Equals(((MethodBuilder)obj).m_strName)))
+ {
return false;
}
- if (m_iAttributes!=(((MethodBuilder)obj).m_iAttributes)) {
+ if (m_iAttributes != (((MethodBuilder)obj).m_iAttributes))
+ {
return false;
}
SignatureHelper thatSig = ((MethodBuilder)obj).GetMethodSignature();
- if (thatSig.Equals(GetMethodSignature())) {
+ if (thatSig.Equals(GetMethodSignature()))
+ {
return true;
}
return false;
@@ -503,15 +506,15 @@ namespace System.Reflection.Emit
#region MemberInfo Overrides
public override String Name
{
- get
- {
- return m_strName;
+ get
+ {
+ return m_strName;
}
}
internal int MetadataTokenInternal
{
- get
+ get
{
return GetToken().Token;
}
@@ -519,7 +522,7 @@ namespace System.Reflection.Emit
public override Module Module
{
- get
+ get
{
return m_containingType.Module;
}
@@ -535,9 +538,9 @@ namespace System.Reflection.Emit
}
}
- public override ICustomAttributeProvider ReturnTypeCustomAttributes
+ public override ICustomAttributeProvider ReturnTypeCustomAttributes
{
- get
+ get
{
return null;
}
@@ -556,7 +559,7 @@ namespace System.Reflection.Emit
#region MethodBase Overrides
public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
public override MethodImplAttributes GetMethodImplementationFlags()
@@ -571,12 +574,12 @@ namespace System.Reflection.Emit
public override CallingConventions CallingConvention
{
- get {return m_callingConvention;}
+ get { return m_callingConvention; }
}
public override RuntimeMethodHandle MethodHandle
{
- get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); }
+ get { throw new NotSupportedException(SR.NotSupported_DynamicModule); }
}
public override bool IsSecurityCritical
@@ -613,7 +616,7 @@ namespace System.Reflection.Emit
public override ParameterInfo[] GetParameters()
{
if (!m_bIsBaked || m_containingType == null || m_containingType.BakedRuntimeType == null)
- throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_TypeNotCreated"));
+ throw new NotSupportedException(SR.InvalidOperation_TypeNotCreated);
MethodInfo rmi = m_containingType.GetMethod(m_strName, m_parameterTypes);
@@ -625,7 +628,7 @@ namespace System.Reflection.Emit
get
{
if (!m_bIsBaked || m_containingType == null || m_containingType.BakedRuntimeType == null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeNotCreated"));
+ throw new InvalidOperationException(SR.InvalidOperation_TypeNotCreated);
MethodInfo rmi = m_containingType.GetMethod(m_strName, m_parameterTypes);
@@ -637,20 +640,17 @@ namespace System.Reflection.Emit
#region ICustomAttributeProvider Implementation
public override Object[] GetCustomAttributes(bool inherit)
{
-
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
{
-
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
public override bool IsDefined(Type attributeType, bool inherit)
{
-
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
#endregion
@@ -663,43 +663,43 @@ namespace System.Reflection.Emit
public override MethodInfo GetGenericMethodDefinition() { if (!IsGenericMethod) throw new InvalidOperationException(); return this; }
public override bool IsGenericMethod { get { return m_inst != null; } }
-
+
public override Type[] GetGenericArguments() { return m_inst; }
- public override MethodInfo MakeGenericMethod(params Type[] typeArguments)
+ public override MethodInfo MakeGenericMethod(params Type[] typeArguments)
{
- return MethodBuilderInstantiation.MakeGenericMethod(this, typeArguments);
+ return MethodBuilderInstantiation.MakeGenericMethod(this, typeArguments);
}
-
-
- public GenericTypeParameterBuilder[] DefineGenericParameters (params string[] names)
+
+
+ public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names)
{
if (names == null)
throw new ArgumentNullException(nameof(names));
if (names.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Arg_EmptyArray"), nameof(names));
+ throw new ArgumentException(SR.Arg_EmptyArray, nameof(names));
Contract.EndContractBlock();
if (m_inst != null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GenericParametersAlreadySet"));
+ throw new InvalidOperationException(SR.InvalidOperation_GenericParametersAlreadySet);
- for (int i = 0; i < names.Length; i ++)
+ for (int i = 0; i < names.Length; i++)
if (names[i] == null)
throw new ArgumentNullException(nameof(names));
if (m_tkMethod.Token != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MethodBuilderBaked"));
+ throw new InvalidOperationException(SR.InvalidOperation_MethodBuilderBaked);
m_bIsGenMethDef = true;
m_inst = new GenericTypeParameterBuilder[names.Length];
- for (int i = 0; i < names.Length; i ++)
+ for (int i = 0; i < names.Length; i++)
m_inst[i] = new GenericTypeParameterBuilder(new TypeBuilder(names[i], i, this));
return m_inst;
}
-
- internal void ThrowIfGeneric () { if (IsGenericMethod && !IsGenericMethodDefinition) throw new InvalidOperationException (); }
+
+ internal void ThrowIfGeneric() { if (IsGenericMethod && !IsGenericMethodDefinition) throw new InvalidOperationException(); }
#endregion
#region Public Members
@@ -773,22 +773,22 @@ namespace System.Reflection.Emit
return m_tkMethod;
}
- public void SetParameters (params Type[] parameterTypes)
+ public void SetParameters(params Type[] parameterTypes)
{
CheckContext(parameterTypes);
-
- SetSignature (null, null, null, parameterTypes, null, null);
+
+ SetSignature(null, null, null, parameterTypes, null, null);
}
- public void SetReturnType (Type returnType)
+ public void SetReturnType(Type returnType)
{
CheckContext(returnType);
-
- SetSignature (returnType, null, null, null, null, null);
+
+ SetSignature(returnType, null, null, null, null, null);
}
public void SetSignature(
- Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
+ Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
{
// We should throw InvalidOperation_MethodBuilderBaked here if the method signature has been baked.
@@ -800,7 +800,7 @@ namespace System.Reflection.Emit
CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
CheckContext(parameterTypeRequiredCustomModifiers);
CheckContext(parameterTypeOptionalCustomModifiers);
-
+
ThrowIfGeneric();
if (returnType != null)
@@ -811,7 +811,7 @@ namespace System.Reflection.Emit
if (parameterTypes != null)
{
m_parameterTypes = new Type[parameterTypes.Length];
- Array.Copy (parameterTypes, 0, m_parameterTypes, 0, parameterTypes.Length);
+ Array.Copy(parameterTypes, 0, m_parameterTypes, 0, parameterTypes.Length);
}
m_returnTypeRequiredCustomModifiers = returnTypeRequiredCustomModifiers;
@@ -820,18 +820,18 @@ namespace System.Reflection.Emit
m_parameterTypeOptionalCustomModifiers = parameterTypeOptionalCustomModifiers;
}
-
+
public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, String strParamName)
{
if (position < 0)
- throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_ParamSequence"));
+ throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_ParamSequence);
Contract.EndContractBlock();
ThrowIfGeneric();
- m_containingType.ThrowIfCreated ();
+ m_containingType.ThrowIfCreated();
if (position > 0 && (m_parameterTypes == null || position > m_parameterTypes.Length))
- throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_ParamSequence"));
+ throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_ParamSequence);
attributes = attributes & ~ParameterAttributes.ReservedMask;
return new ParameterBuilder(this, position, attributes, strParamName);
@@ -844,11 +844,11 @@ namespace System.Reflection.Emit
public byte[] m_data;
}
- public void SetImplementationFlags(MethodImplAttributes attributes)
+ public void SetImplementationFlags(MethodImplAttributes attributes)
{
- ThrowIfGeneric ();
+ ThrowIfGeneric();
- m_containingType.ThrowIfCreated ();
+ m_containingType.ThrowIfCreated();
m_dwMethodImplFlags = attributes;
@@ -857,7 +857,8 @@ namespace System.Reflection.Emit
TypeBuilder.SetMethodImpl(m_module.GetNativeHandle(), MetadataTokenInternal, attributes);
}
- public ILGenerator GetILGenerator() {
+ public ILGenerator GetILGenerator()
+ {
Contract.Ensures(Contract.Result<ILGenerator>() != null);
ThrowIfGeneric();
@@ -868,18 +869,20 @@ namespace System.Reflection.Emit
return m_ilGenerator;
}
- public ILGenerator GetILGenerator(int size) {
+ public ILGenerator GetILGenerator(int size)
+ {
Contract.Ensures(Contract.Result<ILGenerator>() != null);
- ThrowIfGeneric ();
+ ThrowIfGeneric();
ThrowIfShouldNotHaveBody();
-
+
if (m_ilGenerator == null)
m_ilGenerator = new ILGenerator(this, size);
return m_ilGenerator;
}
- private void ThrowIfShouldNotHaveBody() {
+ private void ThrowIfShouldNotHaveBody()
+ {
if ((m_dwMethodImplFlags & MethodImplAttributes.CodeTypeMask) != MethodImplAttributes.IL ||
(m_dwMethodImplFlags & MethodImplAttributes.Unmanaged) != 0 ||
(m_iAttributes & MethodAttributes.PinvokeImpl) != 0 ||
@@ -887,16 +890,16 @@ namespace System.Reflection.Emit
{
// cannot attach method body if methodimpl is marked not marked as managed IL
//
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ShouldNotHaveMethodBody"));
+ throw new InvalidOperationException(SR.InvalidOperation_ShouldNotHaveMethodBody);
}
}
-
- public bool InitLocals
- {
+
+ public bool InitLocals
+ {
// Property is set to true if user wishes to have zero initialized stack frame for this method. Default to false.
- get { ThrowIfGeneric (); return m_fInitLocals; }
- set { ThrowIfGeneric (); m_fInitLocals = value; }
+ get { ThrowIfGeneric(); return m_fInitLocals; }
+ set { ThrowIfGeneric(); m_fInitLocals = value; }
}
public Module GetModule()
@@ -904,12 +907,12 @@ namespace System.Reflection.Emit
return GetModuleBuilder();
}
- public String Signature
- {
- get
- {
- return GetMethodSignature().ToString();
- }
+ public String Signature
+ {
+ get
+ {
+ return GetMethodSignature().ToString();
+ }
}
@@ -941,7 +944,7 @@ namespace System.Reflection.Emit
ThrowIfGeneric();
customBuilder.CreateCustomAttribute((ModuleBuilder)m_module, MetadataTokenInternal);
-
+
if (IsKnownCA(customBuilder.m_con))
ParseCA(customBuilder.m_con, customBuilder.m_blob);
}
@@ -959,7 +962,7 @@ namespace System.Reflection.Emit
private void ParseCA(ConstructorInfo con, byte[] blob)
{
Type caType = con.DeclaringType;
- if (caType == typeof(System.Runtime.CompilerServices.MethodImplAttribute))
+ if (caType == typeof(System.Runtime.CompilerServices.MethodImplAttribute))
{
// dig through the blob looking for the MethodImplAttributes flag
// that must be in the MethodCodeType field
@@ -968,11 +971,11 @@ namespace System.Reflection.Emit
// allows this method to have no body when any kind of MethodImplAttribute is present
m_canBeRuntimeImpl = true;
}
- else if (caType == typeof(DllImportAttribute)) {
+ else if (caType == typeof(DllImportAttribute))
+ {
m_canBeRuntimeImpl = true;
m_isDllImport = true;
}
-
}
internal bool m_canBeRuntimeImpl = false;
@@ -987,15 +990,15 @@ namespace System.Reflection.Emit
// and namespace information with a given active lexical scope.
#region Internal Data Members
- internal String[] m_strName;
- internal byte[][] m_ubSignature;
- internal int[] m_iLocalSlot;
- internal int[] m_iStartOffset;
- internal int[] m_iEndOffset;
- internal int m_iLocalSymCount; // how many entries in the arrays are occupied
- internal String[] m_namespace;
- internal int m_iNameSpaceCount;
- internal const int InitialSize = 16;
+ internal String[] m_strName;
+ internal byte[][] m_ubSignature;
+ internal int[] m_iLocalSlot;
+ internal int[] m_iStartOffset;
+ internal int[] m_iEndOffset;
+ internal int m_iLocalSymCount; // how many entries in the arrays are occupied
+ internal String[] m_namespace;
+ internal int m_iNameSpaceCount;
+ internal const int InitialSize = 16;
#endregion
#region Constructor
@@ -1016,7 +1019,7 @@ namespace System.Reflection.Emit
}
else if (m_iNameSpaceCount == m_namespace.Length)
{
- String [] strTemp = new String [checked(m_iNameSpaceCount * 2)];
+ String[] strTemp = new String[checked(m_iNameSpaceCount * 2)];
Array.Copy(m_namespace, 0, strTemp, 0, m_iNameSpaceCount);
m_namespace = strTemp;
}
@@ -1038,33 +1041,32 @@ namespace System.Reflection.Emit
// the arrays are full. Enlarge the arrays
// why aren't we just using lists here?
int newSize = checked(m_iLocalSymCount * 2);
- int[] temp = new int [newSize];
+ int[] temp = new int[newSize];
Array.Copy(m_iLocalSlot, 0, temp, 0, m_iLocalSymCount);
m_iLocalSlot = temp;
- temp = new int [newSize];
+ temp = new int[newSize];
Array.Copy(m_iStartOffset, 0, temp, 0, m_iLocalSymCount);
m_iStartOffset = temp;
- temp = new int [newSize];
+ temp = new int[newSize];
Array.Copy(m_iEndOffset, 0, temp, 0, m_iLocalSymCount);
m_iEndOffset = temp;
- String [] strTemp = new String [newSize];
+ String[] strTemp = new String[newSize];
Array.Copy(m_strName, 0, strTemp, 0, m_iLocalSymCount);
m_strName = strTemp;
byte[][] ubTemp = new byte[newSize][];
Array.Copy(m_ubSignature, 0, ubTemp, 0, m_iLocalSymCount);
m_ubSignature = ubTemp;
-
}
}
#endregion
#region Internal Members
- internal void AddLocalSymInfo(String strName,byte[] signature,int slot,int startOffset,int endOffset)
+ internal void AddLocalSymInfo(String strName, byte[] signature, int slot, int startOffset, int endOffset)
{
// make sure that arrays are large enough to hold addition info
EnsureCapacity();
@@ -1073,7 +1075,7 @@ namespace System.Reflection.Emit
m_iLocalSlot[m_iLocalSymCount] = slot;
m_strName[m_iLocalSymCount] = strName;
m_ubSignature[m_iLocalSymCount] = signature;
- checked {m_iLocalSymCount++; }
+ checked { m_iLocalSymCount++; }
}
internal void AddUsingNamespace(String strNamespace)
@@ -1085,13 +1087,13 @@ namespace System.Reflection.Emit
internal virtual void EmitLocalSymInfo(ISymbolWriter symWriter)
{
- int i;
+ int i;
- for (i = 0; i < m_iLocalSymCount; i ++)
+ for (i = 0; i < m_iLocalSymCount; i++)
{
symWriter.DefineLocalVariable(
m_strName[i],
- FieldAttributes.PrivateScope,
+ FieldAttributes.PrivateScope,
m_ubSignature[i],
SymAddressKind.ILOffset,
m_iLocalSlot[i],
@@ -1100,7 +1102,7 @@ namespace System.Reflection.Emit
m_iStartOffset[i],
m_iEndOffset[i]);
}
- for (i = 0; i < m_iNameSpaceCount; i ++)
+ for (i = 0; i < m_iNameSpaceCount; i++)
{
symWriter.UsingNamespace(m_namespace[i]);
}
@@ -1124,7 +1126,7 @@ namespace System.Reflection.Emit
internal readonly int m_handlerEndOffset;
internal readonly ExceptionHandlingClauseOptions m_kind;
-#region Constructors
+ #region Constructors
internal ExceptionHandler(int tryStartOffset, int tryEndOffset, int filterOffset, int handlerStartOffset, int handlerEndOffset,
int kind, int exceptionTypeToken)
@@ -1160,7 +1162,7 @@ namespace System.Reflection.Emit
return false;
}
}
-
+
#endregion
#region Equality
@@ -1187,7 +1189,7 @@ namespace System.Reflection.Emit
other.m_kind == m_kind;
}
- public static bool operator ==(ExceptionHandler left, ExceptionHandler right)
+ public static bool operator ==(ExceptionHandler left, ExceptionHandler right)
{
return left.Equals(right);
}
@@ -1196,7 +1198,7 @@ namespace System.Reflection.Emit
{
return !left.Equals(right);
}
-
+
#endregion
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs
index 57ad1665c0..2d0a9b41dd 100644
--- a/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs
@@ -4,14 +4,14 @@
//
+using System;
+using System.Reflection;
+using System.Collections;
+using System.Globalization;
+using System.Diagnostics.Contracts;
+
namespace System.Reflection.Emit
{
- using System;
- using System.Reflection;
- using System.Collections;
- using System.Globalization;
- using System.Diagnostics.Contracts;
-
internal sealed class MethodBuilderInstantiation : MethodInfo
{
#region Static Members
@@ -38,18 +38,18 @@ namespace System.Reflection.Emit
m_inst = inst;
}
#endregion
-
+
internal override Type[] GetParameterTypes()
{
return m_method.GetParameterTypes();
}
#region MemberBase
- public override MemberTypes MemberType { get { return m_method.MemberType; } }
+ public override MemberTypes MemberType { get { return m_method.MemberType; } }
public override String Name { get { return m_method.Name; } }
- public override Type DeclaringType { get { return m_method.DeclaringType; } }
+ public override Type DeclaringType { get { return m_method.DeclaringType; } }
public override Type ReflectedType { get { return m_method.ReflectedType; } }
- public override Object[] GetCustomAttributes(bool inherit) { return m_method.GetCustomAttributes(inherit); }
+ 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); }
public override Module Module { get { return m_method.Module; } }
@@ -57,9 +57,9 @@ namespace System.Reflection.Emit
#region MethodBase Members
[Pure]
- public override ParameterInfo[] GetParameters() { throw new NotSupportedException(); }
+ public override ParameterInfo[] GetParameters() { throw new NotSupportedException(); }
public override MethodImplAttributes GetMethodImplementationFlags() { return m_method.GetMethodImplementationFlags(); }
- public override RuntimeMethodHandle MethodHandle { get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); } }
+ public override RuntimeMethodHandle MethodHandle { get { throw new NotSupportedException(SR.NotSupported_DynamicModule); } }
public override MethodAttributes Attributes { get { return m_method.Attributes; } }
public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
@@ -88,11 +88,11 @@ namespace System.Reflection.Emit
public override MethodInfo MakeGenericMethod(params Type[] arguments)
{
- throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericMethodDefinition"));
+ throw new InvalidOperationException(SR.Arg_NotGenericMethodDefinition);
}
public override bool IsGenericMethod { get { return true; } }
-
+
#endregion
#region Public Abstract\Virtual Members
diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodToken.cs b/src/mscorlib/src/System/Reflection/Emit/MethodToken.cs
index 76b7279f30..0905ac922a 100644
--- a/src/mscorlib/src/System/Reflection/Emit/MethodToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/MethodToken.cs
@@ -12,25 +12,28 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
-
- using System;
- using System.Reflection;
+using System;
+using System.Reflection;
+
+namespace System.Reflection.Emit
+{
[Serializable]
public struct MethodToken
{
public static readonly MethodToken Empty = new MethodToken();
internal int m_method;
-
- internal MethodToken(int str) {
- m_method=str;
+
+ internal MethodToken(int str)
+ {
+ m_method = str;
}
-
- public int Token {
+
+ public int Token
+ {
get { return m_method; }
}
-
+
public override int GetHashCode()
{
return m_method;
@@ -43,21 +46,20 @@ namespace System.Reflection.Emit {
else
return false;
}
-
+
public bool Equals(MethodToken obj)
{
return obj.m_method == m_method;
}
-
+
public static bool operator ==(MethodToken a, MethodToken b)
{
return a.Equals(b);
}
-
+
public static bool operator !=(MethodToken a, MethodToken b)
{
return !(a == b);
}
-
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs
index 30e6382550..d92d8220b8 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs
@@ -4,7 +4,7 @@
//
-namespace System.Reflection.Emit
+namespace System.Reflection.Emit
{
using System.Runtime.InteropServices;
using System;
@@ -120,7 +120,7 @@ namespace System.Reflection.Emit
object.ReferenceEquals(foundType.DeclaringType, enclosingType))
{
// Cannot have two types with the same name
- throw new ArgumentException(Environment.GetResourceString("Argument_DuplicateTypeName"));
+ throw new ArgumentException(SR.Argument_DuplicateTypeName);
}
}
@@ -135,10 +135,9 @@ namespace System.Reflection.Emit
// convert the format string to byte array and then call FormCompoundType
return SymbolType.FormCompoundType(strFormat, baseType, 0);
-
}
-
-
+
+
internal void CheckContext(params Type[][] typess)
{
ContainingAssemblyBuilder.CheckContext(typess);
@@ -179,14 +178,6 @@ namespace System.Reflection.Emit
{
Debug.Assert(method != null);
-#if FEATURE_APPX
- if (ContainingAssemblyBuilder.ProfileAPICheck)
- {
- if ((method.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", method.FullName));
- }
-#endif
-
return GetMemberRefOfMethodInfo(GetNativeHandle(), tr, method);
}
@@ -194,14 +185,6 @@ namespace System.Reflection.Emit
{
Debug.Assert(method != null);
-#if FEATURE_APPX
- if (ContainingAssemblyBuilder.ProfileAPICheck)
- {
- if ((method.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", method.FullName));
- }
-#endif
-
return GetMemberRefOfMethodInfo(GetNativeHandle(), tr, method);
}
@@ -213,15 +196,6 @@ namespace System.Reflection.Emit
{
Debug.Assert(runtimeField != null);
-#if FEATURE_APPX
- if (ContainingAssemblyBuilder.ProfileAPICheck)
- {
- RtFieldInfo rtField = runtimeField as RtFieldInfo;
- if (rtField != null && (rtField.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtField.FullName));
- }
-#endif
-
return GetMemberRefOfFieldInfo(GetNativeHandle(), tkType, declaringType, runtimeField.MetadataToken);
}
@@ -286,17 +260,6 @@ namespace System.Reflection.Emit
Debug.Assert(!type.IsByRef, "Must not be ByRef.");
Debug.Assert(!type.IsGenericType || type.IsGenericTypeDefinition, "Must not have generic arguments.");
-#if FEATURE_APPX
- if (ContainingAssemblyBuilder.ProfileAPICheck)
- {
- RuntimeType rtType = type as RuntimeType;
- if (rtType != null && (rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName));
- }
- }
-#endif
-
return GetTypeRef(GetNativeHandle(), typeName, GetRuntimeModuleFromModule(refedModule).GetNativeHandle(), strRefedModuleFileName, tkResolution);
}
@@ -315,7 +278,7 @@ namespace System.Reflection.Emit
ConstructorOnTypeBuilderInstantiation conOnTypeBuilderInst = null;
RuntimeConstructorInfo rtCon = null;
- if ( (conBuilder = con as ConstructorBuilder) != null )
+ if ((conBuilder = con as ConstructorBuilder) != null)
{
if (usingRef == false && conBuilder.Module.Equals(this))
return conBuilder.GetToken();
@@ -324,14 +287,14 @@ namespace System.Reflection.Emit
tr = GetTypeTokenInternal(con.ReflectedType).Token;
mr = GetMemberRef(con.ReflectedType.Module, tr, conBuilder.GetToken().Token);
}
- else if ( (conOnTypeBuilderInst = con as ConstructorOnTypeBuilderInstantiation) != null )
+ else if ((conOnTypeBuilderInst = con as ConstructorOnTypeBuilderInstantiation) != null)
{
if (usingRef == true) throw new InvalidOperationException();
tr = GetTypeTokenInternal(con.DeclaringType).Token;
mr = GetMemberRef(con.DeclaringType.Module, tr, conOnTypeBuilderInst.MetadataTokenInternal);
}
- else if ( (rtCon = con as RuntimeConstructorInfo) != null && con.ReflectedType.IsArray == false)
+ else if ((rtCon = con as RuntimeConstructorInfo) != null && con.ReflectedType.IsArray == false)
{
// constructor is not a dynamic field
// We need to get the TypeRef tokens
@@ -345,7 +308,7 @@ namespace System.Reflection.Emit
// go through the slower code path, i.e. retrieve parameters and form signature helper.
ParameterInfo[] parameters = con.GetParameters();
if (parameters == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidConstructorInfo"));
+ throw new ArgumentException(SR.Argument_InvalidConstructorInfo);
Type[] parameterTypes = new Type[parameters.Length];
Type[][] requiredCustomModifiers = new Type[parameters.Length][];
@@ -354,7 +317,7 @@ namespace System.Reflection.Emit
for (int i = 0; i < parameters.Length; i++)
{
if (parameters[i] == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidConstructorInfo"));
+ throw new ArgumentException(SR.Argument_InvalidConstructorInfo);
parameterTypes[i] = parameters[i].ParameterType;
requiredCustomModifiers[i] = parameters[i].GetRequiredCustomModifiers();
@@ -369,8 +332,8 @@ namespace System.Reflection.Emit
mr = GetMemberRefFromSignature(tr, con.Name, sigBytes, length);
}
-
- return new MethodToken( mr );
+
+ return new MethodToken(mr);
}
internal void Init(String strModuleName, String strFileName, int tkFile)
@@ -395,7 +358,7 @@ namespace System.Reflection.Emit
#endregion
#region Module Overrides
-
+
// m_internalModuleBuilder is null iff this is a "internal" ModuleBuilder
internal InternalModuleBuilder InternalModule
{
@@ -405,7 +368,7 @@ namespace System.Reflection.Emit
}
}
- internal override ModuleHandle GetModuleHandle()
+ protected override ModuleHandle GetModuleHandleImpl()
{
return new ModuleHandle(GetNativeHandle());
}
@@ -446,7 +409,7 @@ namespace System.Reflection.Emit
if ((method.CallingConvention & CallingConventions.VarArgs) == 0)
{
// Client should not supply optional parameter in default calling convention
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention"));
+ throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention);
}
}
@@ -532,7 +495,7 @@ namespace System.Reflection.Emit
}
internal SignatureHelper GetMemberRefSignature(CallingConventions call, Type returnType,
- Type[] parameterTypes, IEnumerable<Type> optionalParameterTypes, int cGenericParameters)
+ Type[] parameterTypes, IEnumerable<Type> optionalParameterTypes, int cGenericParameters)
{
SignatureHelper sig = SignatureHelper.GetMethodSigHelper(this, call, returnType, cGenericParameters);
@@ -544,7 +507,8 @@ namespace System.Reflection.Emit
}
}
- if (optionalParameterTypes != null) {
+ if (optionalParameterTypes != null)
+ {
int i = 0;
foreach (Type type in optionalParameterTypes)
{
@@ -599,7 +563,7 @@ namespace System.Reflection.Emit
public override Type[] GetTypes()
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return GetTypesNoLock();
}
@@ -620,7 +584,7 @@ namespace System.Reflection.Emit
tmpTypeBldr = enumBldr.m_typeBuilder;
else
tmpTypeBldr = (TypeBuilder)builder;
-
+
// We should not return TypeBuilders.
// Otherwise anyone can emit code in it.
if (tmpTypeBldr.IsCreated())
@@ -636,15 +600,15 @@ namespace System.Reflection.Emit
{
return GetType(className, false, false);
}
-
+
public override Type GetType(String className, bool ignoreCase)
{
return GetType(className, false, ignoreCase);
}
-
+
public override Type GetType(String className, bool throwOnError, bool ignoreCase)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return GetTypeNoLock(className, throwOnError, ignoreCase);
}
@@ -658,7 +622,7 @@ namespace System.Reflection.Emit
// This API first delegate to the Module.GetType implementation. If succeeded, great!
// If not, we have to look up the current module to find the TypeBuilder to represent the base
// type and form the Type object for "foo[,]".
-
+
// Module.GetType() will verify className.
Type baseType = InternalModule.GetType(className, throwOnError, ignoreCase);
if (baseType != null)
@@ -674,7 +638,7 @@ namespace System.Reflection.Emit
while (startIndex <= className.Length)
{
// Are there any possible special characters left?
- int i = className.IndexOfAny(new char[]{'[', '*', '&'}, startIndex);
+ int i = className.IndexOfAny(new char[] { '[', '*', '&' }, startIndex);
if (i == -1)
{
// No, type name is simple.
@@ -709,7 +673,7 @@ namespace System.Reflection.Emit
parameters = null;
}
- baseName = baseName.Replace(@"\\",@"\").Replace(@"\[",@"[").Replace(@"\*",@"*").Replace(@"\&",@"&");
+ baseName = baseName.Replace(@"\\", @"\").Replace(@"\[", @"[").Replace(@"\*", @"*").Replace(@"\&", @"&");
if (parameters != null)
{
@@ -742,9 +706,9 @@ namespace System.Reflection.Emit
return null;
}
- if (parameters == null)
+ if (parameters == null)
return baseType;
-
+
return GetType(parameters, baseType);
}
@@ -885,7 +849,7 @@ namespace System.Reflection.Emit
{
Contract.Ensures(Contract.Result<TypeBuilder>() != null);
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineTypeNoLock(name, TypeAttributes.NotPublic, null, null, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize);
}
@@ -895,7 +859,7 @@ namespace System.Reflection.Emit
{
Contract.Ensures(Contract.Result<TypeBuilder>() != null);
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineTypeNoLock(name, attr, null, null, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize);
}
@@ -905,7 +869,7 @@ namespace System.Reflection.Emit
{
Contract.Ensures(Contract.Result<TypeBuilder>() != null);
- lock(SyncRoot)
+ lock (SyncRoot)
{
// Why do we only call CheckContext here? Why don't we call it in the other overloads?
CheckContext(parent);
@@ -918,7 +882,7 @@ namespace System.Reflection.Emit
{
Contract.Ensures(Contract.Result<TypeBuilder>() != null);
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineTypeNoLock(name, attr, parent, null, PackingSize.Unspecified, typesize);
}
@@ -938,7 +902,7 @@ namespace System.Reflection.Emit
{
Contract.Ensures(Contract.Result<TypeBuilder>() != null);
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineTypeNoLock(name, attr, parent, interfaces, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize);
}
@@ -955,7 +919,7 @@ namespace System.Reflection.Emit
{
Contract.Ensures(Contract.Result<TypeBuilder>() != null);
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineTypeNoLock(name, attr, parent, packsize);
}
@@ -979,7 +943,7 @@ namespace System.Reflection.Emit
Contract.Ensures(Contract.Result<EnumBuilder>() != null);
CheckContext(underlyingType);
- lock(SyncRoot)
+ lock (SyncRoot)
{
EnumBuilder enumBuilder = DefineEnumNoLock(name, visibility, underlyingType);
@@ -1006,7 +970,7 @@ namespace System.Reflection.Emit
return new EnumBuilder(name, underlyingType, visibility, this);
}
-
+
#endregion
#region Define Resource
@@ -1021,7 +985,7 @@ namespace System.Reflection.Emit
return DefineGlobalMethod(name, attributes, CallingConventions.Standard, returnType, parameterTypes);
}
- public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, CallingConventions callingConvention,
+ public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] parameterTypes)
{
Contract.Ensures(Contract.Result<MethodBuilder>() != null);
@@ -1029,33 +993,33 @@ namespace System.Reflection.Emit
return DefineGlobalMethod(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
}
- public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, CallingConventions callingConvention,
+ public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers,
Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
- return DefineGlobalMethodNoLock(name, attributes, callingConvention, returnType,
+ return DefineGlobalMethodNoLock(name, attributes, callingConvention, returnType,
requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers,
parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
}
}
- private MethodBuilder DefineGlobalMethodNoLock(String name, MethodAttributes attributes, CallingConventions callingConvention,
+ private MethodBuilder DefineGlobalMethodNoLock(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers,
Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
{
if (m_moduleData.m_fGlobalBeenCreated == true)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GlobalsHaveBeenCreated"));
-
+ throw new InvalidOperationException(SR.InvalidOperation_GlobalsHaveBeenCreated);
+
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
-
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
+
if ((attributes & MethodAttributes.Static) == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_GlobalFunctionHasToBeStatic"));
+ throw new ArgumentException(SR.Argument_GlobalFunctionHasToBeStatic);
Contract.Ensures(Contract.Result<MethodBuilder>() != null);
Contract.EndContractBlock();
@@ -1066,14 +1030,14 @@ namespace System.Reflection.Emit
m_moduleData.m_fHasGlobal = true;
- return m_moduleData.m_globalTypeBuilder.DefineMethod(name, attributes, callingConvention,
- returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers,
+ return m_moduleData.m_globalTypeBuilder.DefineMethod(name, attributes, callingConvention,
+ returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers,
parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
}
-
+
public void CreateGlobalFunctions()
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
CreateGlobalFunctionsNoLock();
}
@@ -1084,12 +1048,12 @@ namespace System.Reflection.Emit
if (m_moduleData.m_fGlobalBeenCreated)
{
// cannot create globals twice
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule"));
+ throw new InvalidOperationException(SR.InvalidOperation_NotADebugModule);
}
m_moduleData.m_globalTypeBuilder.CreateType();
m_moduleData.m_fGlobalBeenCreated = true;
}
-
+
#endregion
#region Define Data
@@ -1101,7 +1065,7 @@ namespace System.Reflection.Emit
// will be the signature for the Field.
Contract.Ensures(Contract.Result<FieldBuilder>() != null);
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineInitializedDataNoLock(name, data, attributes);
}
@@ -1114,20 +1078,20 @@ namespace System.Reflection.Emit
// will be the signature for the Field.
if (m_moduleData.m_fGlobalBeenCreated == true)
{
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GlobalsHaveBeenCreated"));
+ throw new InvalidOperationException(SR.InvalidOperation_GlobalsHaveBeenCreated);
}
Contract.Ensures(Contract.Result<FieldBuilder>() != null);
Contract.EndContractBlock();
-
+
m_moduleData.m_fHasGlobal = true;
return m_moduleData.m_globalTypeBuilder.DefineInitializedData(name, data, attributes);
}
-
+
public FieldBuilder DefineUninitializedData(String name, int size, FieldAttributes attributes)
{
Contract.Ensures(Contract.Result<FieldBuilder>() != null);
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineUninitializedDataNoLock(name, size, attributes);
}
@@ -1141,15 +1105,15 @@ namespace System.Reflection.Emit
if (m_moduleData.m_fGlobalBeenCreated == true)
{
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GlobalsHaveBeenCreated"));
+ throw new InvalidOperationException(SR.InvalidOperation_GlobalsHaveBeenCreated);
}
Contract.Ensures(Contract.Result<FieldBuilder>() != null);
Contract.EndContractBlock();
-
+
m_moduleData.m_fHasGlobal = true;
return m_moduleData.m_globalTypeBuilder.DefineUninitializedData(name, size, attributes);
}
-
+
#endregion
#region GetToken
@@ -1164,14 +1128,14 @@ namespace System.Reflection.Emit
private TypeToken GetTypeTokenInternal(Type type, bool getGenericDefinition)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return GetTypeTokenWorkerNoLock(type, getGenericDefinition);
}
}
public TypeToken GetTypeToken(Type type)
- {
+ {
return GetTypeTokenInternal(type, true);
}
@@ -1182,7 +1146,7 @@ namespace System.Reflection.Emit
Contract.EndContractBlock();
CheckContext(type);
-
+
// Return a token for the class relative to the Module. Tokens
// are used to indentify objects when the objects are used in IL
// instructions. Tokens are always relative to the Module. For example,
@@ -1194,7 +1158,7 @@ namespace System.Reflection.Emit
// We should also be aware of multiple dynamic modules and multiple implementation of Type!!!
if (type.IsByRef)
- throw new ArgumentException(Environment.GetResourceString("Argument_CannotGetTypeTokenForByRef"));
+ throw new ArgumentException(SR.Argument_CannotGetTypeTokenForByRef);
if ((type.IsGenericType && (!type.IsGenericTypeDefinition || !getGenericDefinition)) ||
type.IsGenericParameter ||
@@ -1231,10 +1195,10 @@ namespace System.Reflection.Emit
{
return new TypeToken(paramBuilder.MetadataTokenInternal);
}
-
+
return new TypeToken(GetTypeRefNested(type, this, String.Empty));
}
-
+
// After this point, the referenced module is not the same as the referencing
// module.
//
@@ -1258,21 +1222,21 @@ namespace System.Reflection.Emit
return new TypeToken(GetTypeRefNested(type, refedModule, strRefedModuleFileName));
}
-
+
public TypeToken GetTypeToken(String name)
{
// Return a token for the class relative to the Module.
// Module.GetType() verifies name
-
+
// Unfortunately, we will need to load the Type and then call GetTypeToken in
// order to correctly track the assembly reference information.
-
+
return GetTypeToken(InternalModule.GetType(name, false, true));
}
public MethodToken GetMethodToken(MethodInfo method)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return GetMethodTokenNoLock(method, true);
}
@@ -1280,7 +1244,7 @@ namespace System.Reflection.Emit
internal MethodToken GetMethodTokenInternal(MethodInfo method)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return GetMethodTokenNoLock(method, false);
}
@@ -1300,18 +1264,18 @@ namespace System.Reflection.Emit
int tr;
int mr = 0;
-
+
SymbolMethod symMethod = null;
MethodBuilder methBuilder = null;
- if ( (methBuilder = method as MethodBuilder) != null )
+ if ((methBuilder = method as MethodBuilder) != null)
{
int methodToken = methBuilder.MetadataTokenInternal;
if (method.Module.Equals(this))
return new MethodToken(methodToken);
if (method.DeclaringType == null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule"));
+ throw new InvalidOperationException(SR.InvalidOperation_CannotImportGlobalFromDifferentModule);
// method is defined in a different module
tr = getGenericTypeDefinition ? GetTypeToken(method.DeclaringType).Token : GetTypeTokenInternal(method.DeclaringType).Token;
@@ -1335,7 +1299,7 @@ namespace System.Reflection.Emit
// We need to get the TypeRef tokens
if (declaringType == null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule"));
+ throw new InvalidOperationException(SR.InvalidOperation_CannotImportGlobalFromDifferentModule);
RuntimeMethodInfo rtMeth = null;
@@ -1343,15 +1307,15 @@ namespace System.Reflection.Emit
{
// use reflection to build signature to work around the E_T_VAR problem in EEClass
ParameterInfo[] paramInfo = method.GetParameters();
-
+
Type[] tt = new Type[paramInfo.Length];
-
+
for (int i = 0; i < paramInfo.Length; i++)
tt[i] = paramInfo[i].ParameterType;
return GetArrayMethodToken(declaringType, method.Name, method.CallingConvention, method.ReturnType, tt);
}
- else if ( (rtMeth = method as RuntimeMethodInfo) != null )
+ else if ((rtMeth = method as RuntimeMethodInfo) != null)
{
tr = getGenericTypeDefinition ? GetTypeToken(method.DeclaringType).Token : GetTypeTokenInternal(method.DeclaringType).Token;
mr = GetMemberRefOfMethodInfo(tr, rtMeth);
@@ -1372,25 +1336,25 @@ namespace System.Reflection.Emit
requiredCustomModifiers[i] = parameters[i].GetRequiredCustomModifiers();
optionalCustomModifiers[i] = parameters[i].GetOptionalCustomModifiers();
}
-
+
tr = getGenericTypeDefinition ? GetTypeToken(method.DeclaringType).Token : GetTypeTokenInternal(method.DeclaringType).Token;
SignatureHelper sigHelp;
- try
+ try
{
sigHelp = SignatureHelper.GetMethodSigHelper(
- this, method.CallingConvention, method.ReturnType,
- method.ReturnParameter.GetRequiredCustomModifiers(), method.ReturnParameter.GetOptionalCustomModifiers(),
+ this, method.CallingConvention, method.ReturnType,
+ method.ReturnParameter.GetRequiredCustomModifiers(), method.ReturnParameter.GetOptionalCustomModifiers(),
parameterTypes, requiredCustomModifiers, optionalCustomModifiers);
- }
- catch(NotImplementedException)
+ }
+ catch (NotImplementedException)
{
// Legacy code deriving from MethodInfo may not have implemented ReturnParameter.
sigHelp = SignatureHelper.GetMethodSigHelper(this, method.ReturnType, parameterTypes);
}
- int length;
+ int length;
byte[] sigBytes = sigHelp.InternalGetSignature(out length);
mr = GetMemberRefFromSignature(tr, method.Name, sigBytes, length);
}
@@ -1464,17 +1428,17 @@ namespace System.Reflection.Emit
return tk;
}
-
- public MethodToken GetArrayMethodToken(Type arrayClass, String methodName, CallingConventions callingConvention,
+
+ public MethodToken GetArrayMethodToken(Type arrayClass, String methodName, CallingConventions callingConvention,
Type returnType, Type[] parameterTypes)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return GetArrayMethodTokenNoLock(arrayClass, methodName, callingConvention, returnType, parameterTypes);
}
}
- private MethodToken GetArrayMethodTokenNoLock(Type arrayClass, String methodName, CallingConventions callingConvention,
+ private MethodToken GetArrayMethodTokenNoLock(Type arrayClass, String methodName, CallingConventions callingConvention,
Type returnType, Type[] parameterTypes)
{
if (arrayClass == null)
@@ -1484,10 +1448,10 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(methodName));
if (methodName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(methodName));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(methodName));
if (arrayClass.IsArray == false)
- throw new ArgumentException(Environment.GetResourceString("Argument_HasToBeArrayClass"));
+ throw new ArgumentException(SR.Argument_HasToBeArrayClass);
Contract.EndContractBlock();
CheckContext(returnType, arrayClass);
@@ -1509,7 +1473,7 @@ namespace System.Reflection.Emit
typeSpec.Token, methodName, sigBytes, length));
}
- public MethodInfo GetArrayMethod(Type arrayClass, String methodName, CallingConventions callingConvention,
+ public MethodInfo GetArrayMethod(Type arrayClass, String methodName, CallingConventions callingConvention,
Type returnType, Type[] parameterTypes)
{
CheckContext(returnType, arrayClass);
@@ -1531,23 +1495,24 @@ namespace System.Reflection.Emit
return InternalGetConstructorToken(con, false);
}
- public FieldToken GetFieldToken(FieldInfo field)
+ public FieldToken GetFieldToken(FieldInfo field)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return GetFieldTokenNoLock(field);
}
}
- private FieldToken GetFieldTokenNoLock(FieldInfo field)
+ private FieldToken GetFieldTokenNoLock(FieldInfo field)
{
- if (field == null) {
+ if (field == null)
+ {
throw new ArgumentNullException(nameof(field));
}
Contract.EndContractBlock();
- int tr;
- int mr = 0;
+ int tr;
+ int mr = 0;
FieldBuilder fdBuilder = null;
RuntimeFieldInfo rtField = null;
@@ -1572,22 +1537,22 @@ namespace System.Reflection.Emit
// field is defined in a different module
if (field.DeclaringType == null)
{
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule"));
+ throw new InvalidOperationException(SR.InvalidOperation_CannotImportGlobalFromDifferentModule);
}
tr = GetTypeTokenInternal(field.DeclaringType).Token;
mr = GetMemberRef(field.ReflectedType.Module, tr, fdBuilder.GetToken().Token);
}
}
- else if ( (rtField = field as RuntimeFieldInfo) != null)
+ else if ((rtField = field as RuntimeFieldInfo) != null)
{
// FieldInfo is not an dynamic field
-
+
// We need to get the TypeRef tokens
if (field.DeclaringType == null)
{
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule"));
+ throw new InvalidOperationException(SR.InvalidOperation_CannotImportGlobalFromDifferentModule);
}
-
+
if (field.DeclaringType != null && field.DeclaringType.IsGenericType)
{
int length;
@@ -1597,11 +1562,11 @@ namespace System.Reflection.Emit
}
else
{
- tr = GetTypeTokenInternal(field.DeclaringType).Token;
+ tr = GetTypeTokenInternal(field.DeclaringType).Token;
mr = GetMemberRefOfFieldInfo(tr, field.DeclaringType.GetTypeHandleInternal(), rtField);
}
}
- else if ( (fOnTB = field as FieldOnTypeBuilderInstantiation) != null)
+ else if ((fOnTB = field as FieldOnTypeBuilderInstantiation) != null)
{
FieldInfo fb = fOnTB.FieldInfo;
int length;
@@ -1623,11 +1588,11 @@ namespace System.Reflection.Emit
mr = GetMemberRefFromSignature(tr, field.Name, sigBytes, length);
}
-
+
return new FieldToken(mr, field.GetType());
}
-
- public StringToken GetStringConstant(String str)
+
+ public StringToken GetStringConstant(String str)
{
if (str == null)
{
@@ -1639,7 +1604,7 @@ namespace System.Reflection.Emit
// value has already been defined, the existing token will be returned.
return new StringToken(GetStringConstant(GetNativeHandle(), str, str.Length));
}
-
+
public SignatureToken GetSignatureToken(SignatureHelper sigHelper)
{
// Define signature token given a signature helper. This will define a metadata
@@ -1653,11 +1618,11 @@ namespace System.Reflection.Emit
int sigLength;
byte[] sigBytes;
-
+
// get the signature in byte form
sigBytes = sigHelper.InternalGetSignature(out sigLength);
return new SignatureToken(TypeBuilder.GetTokenFromSig(GetNativeHandle(), sigBytes, sigLength), this);
- }
+ }
public SignatureToken GetSignatureToken(byte[] sigBytes, int sigLength)
{
if (sigBytes == null)
@@ -1669,7 +1634,7 @@ namespace System.Reflection.Emit
return new SignatureToken(TypeBuilder.GetTokenFromSig(GetNativeHandle(), localSigBytes, sigLength), this);
}
-
+
#endregion
#region Other
@@ -1681,7 +1646,7 @@ namespace System.Reflection.Emit
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
Contract.EndContractBlock();
-
+
TypeBuilder.DefineCustomAttribute(
this,
1, // This is hard coding the module token to 1
@@ -1742,7 +1707,7 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(url));
Contract.EndContractBlock();
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineDocumentNoLock(url, language, languageVendor, documentType);
}
@@ -1753,12 +1718,12 @@ namespace System.Reflection.Emit
if (m_iSymWriter == null)
{
// Cannot DefineDocument when it is not a debug module
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule"));
+ throw new InvalidOperationException(SR.InvalidOperation_NotADebugModule);
}
return m_iSymWriter.DefineDocument(url, language, languageVendor, documentType);
}
-
+
[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 4b6f8b4efe..4f1b8eb713 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs
@@ -6,16 +6,16 @@
////////////////////////////////////////////////////////////////////////////////
//
+using System;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+using System.Globalization;
+using System.IO;
+using System.Reflection;
+using System.Runtime.Versioning;
+
namespace System.Reflection.Emit
{
- using System;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
- using System.Globalization;
- using System.IO;
- using System.Reflection;
- using System.Runtime.Versioning;
-
// This is a package private class. This class hold all of the managed
// data member for ModuleBuilder. Note that what ever data members added to
// this class cannot be accessed from the EE.
@@ -46,25 +46,25 @@ namespace System.Reflection.Emit
if (strExtension == null || strExtension == String.Empty)
{
// This is required by our loader. It cannot load module file that does not have file extension.
- throw new ArgumentException(Environment.GetResourceString("Argument_NoModuleFileExtension", strFileName));
+ throw new ArgumentException(SR.Format(SR.Argument_NoModuleFileExtension, strFileName));
}
m_strFileName = strFileName;
}
}
- internal String m_strModuleName; // scope name (can be different from file name)
- internal String m_strFileName;
- internal bool m_fGlobalBeenCreated;
- internal bool m_fHasGlobal;
+ internal String m_strModuleName; // scope name (can be different from file name)
+ internal String m_strFileName;
+ internal bool m_fGlobalBeenCreated;
+ internal bool m_fHasGlobal;
[NonSerialized]
- internal TypeBuilder m_globalTypeBuilder;
+ internal TypeBuilder m_globalTypeBuilder;
[NonSerialized]
internal ModuleBuilder m_module;
- private int m_tkFile;
- internal bool m_isSaved;
+ private int m_tkFile;
+ internal bool m_isSaved;
internal const String MULTI_BYTE_VALUE_CLASS = "$ArrayType$";
- internal String m_strResourceFileName;
- internal byte[] m_resourceBytes;
+ internal String m_strResourceFileName;
+ internal byte[] m_resourceBytes;
} // class ModuleBuilderData
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs b/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs
index 324fad9ceb..99915492c1 100644
--- a/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs
@@ -10,2540 +10,2543 @@
**
**
============================================================*/
-namespace System.Reflection.Emit {
using System;
-//
-// Internal enums for opcode values. Note that the value names are used to construct
-// publicly visible ilasm-compatible opcode names, so their exact form is important!
-//
-internal enum OpCodeValues {
- Nop = 0x00,
- Break = 0x01,
- Ldarg_0 = 0x02,
- Ldarg_1 = 0x03,
- Ldarg_2 = 0x04,
- Ldarg_3 = 0x05,
- Ldloc_0 = 0x06,
- Ldloc_1 = 0x07,
- Ldloc_2 = 0x08,
- Ldloc_3 = 0x09,
- Stloc_0 = 0x0a,
- Stloc_1 = 0x0b,
- Stloc_2 = 0x0c,
- Stloc_3 = 0x0d,
- Ldarg_S = 0x0e,
- Ldarga_S = 0x0f,
- Starg_S = 0x10,
- Ldloc_S = 0x11,
- Ldloca_S = 0x12,
- Stloc_S = 0x13,
- Ldnull = 0x14,
- Ldc_I4_M1 = 0x15,
- Ldc_I4_0 = 0x16,
- Ldc_I4_1 = 0x17,
- Ldc_I4_2 = 0x18,
- Ldc_I4_3 = 0x19,
- Ldc_I4_4 = 0x1a,
- Ldc_I4_5 = 0x1b,
- Ldc_I4_6 = 0x1c,
- Ldc_I4_7 = 0x1d,
- Ldc_I4_8 = 0x1e,
- Ldc_I4_S = 0x1f,
- Ldc_I4 = 0x20,
- Ldc_I8 = 0x21,
- Ldc_R4 = 0x22,
- Ldc_R8 = 0x23,
- Dup = 0x25,
- Pop = 0x26,
- Jmp = 0x27,
- Call = 0x28,
- Calli = 0x29,
- Ret = 0x2a,
- Br_S = 0x2b,
- Brfalse_S = 0x2c,
- Brtrue_S = 0x2d,
- Beq_S = 0x2e,
- Bge_S = 0x2f,
- Bgt_S = 0x30,
- Ble_S = 0x31,
- Blt_S = 0x32,
- Bne_Un_S = 0x33,
- Bge_Un_S = 0x34,
- Bgt_Un_S = 0x35,
- Ble_Un_S = 0x36,
- Blt_Un_S = 0x37,
- Br = 0x38,
- Brfalse = 0x39,
- Brtrue = 0x3a,
- Beq = 0x3b,
- Bge = 0x3c,
- Bgt = 0x3d,
- Ble = 0x3e,
- Blt = 0x3f,
- Bne_Un = 0x40,
- Bge_Un = 0x41,
- Bgt_Un = 0x42,
- Ble_Un = 0x43,
- Blt_Un = 0x44,
- Switch = 0x45,
- Ldind_I1 = 0x46,
- Ldind_U1 = 0x47,
- Ldind_I2 = 0x48,
- Ldind_U2 = 0x49,
- Ldind_I4 = 0x4a,
- Ldind_U4 = 0x4b,
- Ldind_I8 = 0x4c,
- Ldind_I = 0x4d,
- Ldind_R4 = 0x4e,
- Ldind_R8 = 0x4f,
- Ldind_Ref = 0x50,
- Stind_Ref = 0x51,
- Stind_I1 = 0x52,
- Stind_I2 = 0x53,
- Stind_I4 = 0x54,
- Stind_I8 = 0x55,
- Stind_R4 = 0x56,
- Stind_R8 = 0x57,
- Add = 0x58,
- Sub = 0x59,
- Mul = 0x5a,
- Div = 0x5b,
- Div_Un = 0x5c,
- Rem = 0x5d,
- Rem_Un = 0x5e,
- And = 0x5f,
- Or = 0x60,
- Xor = 0x61,
- Shl = 0x62,
- Shr = 0x63,
- Shr_Un = 0x64,
- Neg = 0x65,
- Not = 0x66,
- Conv_I1 = 0x67,
- Conv_I2 = 0x68,
- Conv_I4 = 0x69,
- Conv_I8 = 0x6a,
- Conv_R4 = 0x6b,
- Conv_R8 = 0x6c,
- Conv_U4 = 0x6d,
- Conv_U8 = 0x6e,
- Callvirt = 0x6f,
- Cpobj = 0x70,
- Ldobj = 0x71,
- Ldstr = 0x72,
- Newobj = 0x73,
- Castclass = 0x74,
- Isinst = 0x75,
- Conv_R_Un = 0x76,
- Unbox = 0x79,
- Throw = 0x7a,
- Ldfld = 0x7b,
- Ldflda = 0x7c,
- Stfld = 0x7d,
- Ldsfld = 0x7e,
- Ldsflda = 0x7f,
- Stsfld = 0x80,
- Stobj = 0x81,
- Conv_Ovf_I1_Un = 0x82,
- Conv_Ovf_I2_Un = 0x83,
- Conv_Ovf_I4_Un = 0x84,
- Conv_Ovf_I8_Un = 0x85,
- Conv_Ovf_U1_Un = 0x86,
- Conv_Ovf_U2_Un = 0x87,
- Conv_Ovf_U4_Un = 0x88,
- Conv_Ovf_U8_Un = 0x89,
- Conv_Ovf_I_Un = 0x8a,
- Conv_Ovf_U_Un = 0x8b,
- Box = 0x8c,
- Newarr = 0x8d,
- Ldlen = 0x8e,
- Ldelema = 0x8f,
- Ldelem_I1 = 0x90,
- Ldelem_U1 = 0x91,
- Ldelem_I2 = 0x92,
- Ldelem_U2 = 0x93,
- Ldelem_I4 = 0x94,
- Ldelem_U4 = 0x95,
- Ldelem_I8 = 0x96,
- Ldelem_I = 0x97,
- Ldelem_R4 = 0x98,
- Ldelem_R8 = 0x99,
- Ldelem_Ref = 0x9a,
- Stelem_I = 0x9b,
- Stelem_I1 = 0x9c,
- Stelem_I2 = 0x9d,
- Stelem_I4 = 0x9e,
- Stelem_I8 = 0x9f,
- Stelem_R4 = 0xa0,
- Stelem_R8 = 0xa1,
- Stelem_Ref = 0xa2,
- Ldelem = 0xa3,
- Stelem = 0xa4,
- Unbox_Any = 0xa5,
- Conv_Ovf_I1 = 0xb3,
- Conv_Ovf_U1 = 0xb4,
- Conv_Ovf_I2 = 0xb5,
- Conv_Ovf_U2 = 0xb6,
- Conv_Ovf_I4 = 0xb7,
- Conv_Ovf_U4 = 0xb8,
- Conv_Ovf_I8 = 0xb9,
- Conv_Ovf_U8 = 0xba,
- Refanyval = 0xc2,
- Ckfinite = 0xc3,
- Mkrefany = 0xc6,
- Ldtoken = 0xd0,
- Conv_U2 = 0xd1,
- Conv_U1 = 0xd2,
- Conv_I = 0xd3,
- Conv_Ovf_I = 0xd4,
- Conv_Ovf_U = 0xd5,
- Add_Ovf = 0xd6,
- Add_Ovf_Un = 0xd7,
- Mul_Ovf = 0xd8,
- Mul_Ovf_Un = 0xd9,
- Sub_Ovf = 0xda,
- Sub_Ovf_Un = 0xdb,
- Endfinally = 0xdc,
- Leave = 0xdd,
- Leave_S = 0xde,
- Stind_I = 0xdf,
- Conv_U = 0xe0,
- Prefix7 = 0xf8,
- Prefix6 = 0xf9,
- Prefix5 = 0xfa,
- Prefix4 = 0xfb,
- Prefix3 = 0xfc,
- Prefix2 = 0xfd,
- Prefix1 = 0xfe,
- Prefixref = 0xff,
- Arglist = 0xfe00,
- Ceq = 0xfe01,
- Cgt = 0xfe02,
- Cgt_Un = 0xfe03,
- Clt = 0xfe04,
- Clt_Un = 0xfe05,
- Ldftn = 0xfe06,
- Ldvirtftn = 0xfe07,
- Ldarg = 0xfe09,
- Ldarga = 0xfe0a,
- Starg = 0xfe0b,
- Ldloc = 0xfe0c,
- Ldloca = 0xfe0d,
- Stloc = 0xfe0e,
- Localloc = 0xfe0f,
- Endfilter = 0xfe11,
- Unaligned_ = 0xfe12,
- Volatile_ = 0xfe13,
- Tail_ = 0xfe14,
- Initobj = 0xfe15,
- Constrained_ = 0xfe16,
- Cpblk = 0xfe17,
- Initblk = 0xfe18,
- Rethrow = 0xfe1a,
- Sizeof = 0xfe1c,
- Refanytype = 0xfe1d,
- Readonly_ = 0xfe1e,
-
- // If you add more opcodes here, modify OpCode.Name to handle them correctly
-};
-
-public class OpCodes {
-
-/// <summary>
-/// <para>
-/// The IL instruction opcodes supported by the
-/// runtime. The IL Instruction Specification describes each
-/// Opcode.
-/// </para>
-/// </summary>
-/// <seealso topic='IL Instruction Set Specification'/>
-
- private OpCodes() {
- }
-
- public static readonly OpCode Nop = new OpCode(OpCodeValues.Nop,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Break = new OpCode(OpCodeValues.Break,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Break << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldarg_0 = new OpCode(OpCodeValues.Ldarg_0,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldarg_1 = new OpCode(OpCodeValues.Ldarg_1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldarg_2 = new OpCode(OpCodeValues.Ldarg_2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldarg_3 = new OpCode(OpCodeValues.Ldarg_3,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldloc_0 = new OpCode(OpCodeValues.Ldloc_0,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldloc_1 = new OpCode(OpCodeValues.Ldloc_1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldloc_2 = new OpCode(OpCodeValues.Ldloc_2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldloc_3 = new OpCode(OpCodeValues.Ldloc_3,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stloc_0 = new OpCode(OpCodeValues.Stloc_0,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stloc_1 = new OpCode(OpCodeValues.Stloc_1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stloc_2 = new OpCode(OpCodeValues.Stloc_2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stloc_3 = new OpCode(OpCodeValues.Stloc_3,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldarg_S = new OpCode(OpCodeValues.Ldarg_S,
- ((int)OperandType.ShortInlineVar) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldarga_S = new OpCode(OpCodeValues.Ldarga_S,
- ((int)OperandType.ShortInlineVar) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Starg_S = new OpCode(OpCodeValues.Starg_S,
- ((int)OperandType.ShortInlineVar) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldloc_S = new OpCode(OpCodeValues.Ldloc_S,
- ((int)OperandType.ShortInlineVar) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldloca_S = new OpCode(OpCodeValues.Ldloca_S,
- ((int)OperandType.ShortInlineVar) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stloc_S = new OpCode(OpCodeValues.Stloc_S,
- ((int)OperandType.ShortInlineVar) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldnull = new OpCode(OpCodeValues.Ldnull,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I4_M1 = new OpCode(OpCodeValues.Ldc_I4_M1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I4_0 = new OpCode(OpCodeValues.Ldc_I4_0,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I4_1 = new OpCode(OpCodeValues.Ldc_I4_1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I4_2 = new OpCode(OpCodeValues.Ldc_I4_2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I4_3 = new OpCode(OpCodeValues.Ldc_I4_3,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I4_4 = new OpCode(OpCodeValues.Ldc_I4_4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I4_5 = new OpCode(OpCodeValues.Ldc_I4_5,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I4_6 = new OpCode(OpCodeValues.Ldc_I4_6,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I4_7 = new OpCode(OpCodeValues.Ldc_I4_7,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I4_8 = new OpCode(OpCodeValues.Ldc_I4_8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I4_S = new OpCode(OpCodeValues.Ldc_I4_S,
- ((int)OperandType.ShortInlineI) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I4 = new OpCode(OpCodeValues.Ldc_I4,
- ((int)OperandType.InlineI) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_I8 = new OpCode(OpCodeValues.Ldc_I8,
- ((int)OperandType.InlineI8) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_R4 = new OpCode(OpCodeValues.Ldc_R4,
- ((int)OperandType.ShortInlineR) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldc_R8 = new OpCode(OpCodeValues.Ldc_R8,
- ((int)OperandType.InlineR) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Dup = new OpCode(OpCodeValues.Dup,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1_push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Pop = new OpCode(OpCodeValues.Pop,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Jmp = new OpCode(OpCodeValues.Jmp,
- ((int)OperandType.InlineMethod) |
- ((int)FlowControl.Call << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- OpCode.EndsUncondJmpBlkFlag |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Call = new OpCode(OpCodeValues.Call,
- ((int)OperandType.InlineMethod) |
- ((int)FlowControl.Call << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Varpush << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Calli = new OpCode(OpCodeValues.Calli,
- ((int)OperandType.InlineSig) |
- ((int)FlowControl.Call << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Varpush << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ret = new OpCode(OpCodeValues.Ret,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Return << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- OpCode.EndsUncondJmpBlkFlag |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Br_S = new OpCode(OpCodeValues.Br_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- OpCode.EndsUncondJmpBlkFlag |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Brfalse_S = new OpCode(OpCodeValues.Brfalse_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Brtrue_S = new OpCode(OpCodeValues.Brtrue_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Beq_S = new OpCode(OpCodeValues.Beq_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Bge_S = new OpCode(OpCodeValues.Bge_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Bgt_S = new OpCode(OpCodeValues.Bgt_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ble_S = new OpCode(OpCodeValues.Ble_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Blt_S = new OpCode(OpCodeValues.Blt_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Bne_Un_S = new OpCode(OpCodeValues.Bne_Un_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Bge_Un_S = new OpCode(OpCodeValues.Bge_Un_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Bgt_Un_S = new OpCode(OpCodeValues.Bgt_Un_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ble_Un_S = new OpCode(OpCodeValues.Ble_Un_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Blt_Un_S = new OpCode(OpCodeValues.Blt_Un_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Br = new OpCode(OpCodeValues.Br,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- OpCode.EndsUncondJmpBlkFlag |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Brfalse = new OpCode(OpCodeValues.Brfalse,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Brtrue = new OpCode(OpCodeValues.Brtrue,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Beq = new OpCode(OpCodeValues.Beq,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Bge = new OpCode(OpCodeValues.Bge,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Bgt = new OpCode(OpCodeValues.Bgt,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ble = new OpCode(OpCodeValues.Ble,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Blt = new OpCode(OpCodeValues.Blt,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Bne_Un = new OpCode(OpCodeValues.Bne_Un,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Bge_Un = new OpCode(OpCodeValues.Bge_Un,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Bgt_Un = new OpCode(OpCodeValues.Bgt_Un,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ble_Un = new OpCode(OpCodeValues.Ble_Un,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Blt_Un = new OpCode(OpCodeValues.Blt_Un,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Switch = new OpCode(OpCodeValues.Switch,
- ((int)OperandType.InlineSwitch) |
- ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldind_I1 = new OpCode(OpCodeValues.Ldind_I1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldind_U1 = new OpCode(OpCodeValues.Ldind_U1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldind_I2 = new OpCode(OpCodeValues.Ldind_I2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldind_U2 = new OpCode(OpCodeValues.Ldind_U2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldind_I4 = new OpCode(OpCodeValues.Ldind_I4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldind_U4 = new OpCode(OpCodeValues.Ldind_U4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldind_I8 = new OpCode(OpCodeValues.Ldind_I8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldind_I = new OpCode(OpCodeValues.Ldind_I,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldind_R4 = new OpCode(OpCodeValues.Ldind_R4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldind_R8 = new OpCode(OpCodeValues.Ldind_R8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldind_Ref = new OpCode(OpCodeValues.Ldind_Ref,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stind_Ref = new OpCode(OpCodeValues.Stind_Ref,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stind_I1 = new OpCode(OpCodeValues.Stind_I1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stind_I2 = new OpCode(OpCodeValues.Stind_I2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stind_I4 = new OpCode(OpCodeValues.Stind_I4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stind_I8 = new OpCode(OpCodeValues.Stind_I8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi_popi8 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stind_R4 = new OpCode(OpCodeValues.Stind_R4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi_popr4 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stind_R8 = new OpCode(OpCodeValues.Stind_R8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi_popr8 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Add = new OpCode(OpCodeValues.Add,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Sub = new OpCode(OpCodeValues.Sub,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Mul = new OpCode(OpCodeValues.Mul,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Div = new OpCode(OpCodeValues.Div,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Div_Un = new OpCode(OpCodeValues.Div_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Rem = new OpCode(OpCodeValues.Rem,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Rem_Un = new OpCode(OpCodeValues.Rem_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode And = new OpCode(OpCodeValues.And,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Or = new OpCode(OpCodeValues.Or,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Xor = new OpCode(OpCodeValues.Xor,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Shl = new OpCode(OpCodeValues.Shl,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Shr = new OpCode(OpCodeValues.Shr,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Shr_Un = new OpCode(OpCodeValues.Shr_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Neg = new OpCode(OpCodeValues.Neg,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Not = new OpCode(OpCodeValues.Not,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_I1 = new OpCode(OpCodeValues.Conv_I1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_I2 = new OpCode(OpCodeValues.Conv_I2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_I4 = new OpCode(OpCodeValues.Conv_I4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_I8 = new OpCode(OpCodeValues.Conv_I8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_R4 = new OpCode(OpCodeValues.Conv_R4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_R8 = new OpCode(OpCodeValues.Conv_R8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_U4 = new OpCode(OpCodeValues.Conv_U4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_U8 = new OpCode(OpCodeValues.Conv_U8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Callvirt = new OpCode(OpCodeValues.Callvirt,
- ((int)OperandType.InlineMethod) |
- ((int)FlowControl.Call << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Varpush << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Cpobj = new OpCode(OpCodeValues.Cpobj,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldobj = new OpCode(OpCodeValues.Ldobj,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldstr = new OpCode(OpCodeValues.Ldstr,
- ((int)OperandType.InlineString) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Newobj = new OpCode(OpCodeValues.Newobj,
- ((int)OperandType.InlineMethod) |
- ((int)FlowControl.Call << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Castclass = new OpCode(OpCodeValues.Castclass,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Isinst = new OpCode(OpCodeValues.Isinst,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_R_Un = new OpCode(OpCodeValues.Conv_R_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Unbox = new OpCode(OpCodeValues.Unbox,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Throw = new OpCode(OpCodeValues.Throw,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Throw << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- OpCode.EndsUncondJmpBlkFlag |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldfld = new OpCode(OpCodeValues.Ldfld,
- ((int)OperandType.InlineField) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldflda = new OpCode(OpCodeValues.Ldflda,
- ((int)OperandType.InlineField) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stfld = new OpCode(OpCodeValues.Stfld,
- ((int)OperandType.InlineField) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldsfld = new OpCode(OpCodeValues.Ldsfld,
- ((int)OperandType.InlineField) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldsflda = new OpCode(OpCodeValues.Ldsflda,
- ((int)OperandType.InlineField) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stsfld = new OpCode(OpCodeValues.Stsfld,
- ((int)OperandType.InlineField) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stobj = new OpCode(OpCodeValues.Stobj,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_I1_Un = new OpCode(OpCodeValues.Conv_Ovf_I1_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_I2_Un = new OpCode(OpCodeValues.Conv_Ovf_I2_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_I4_Un = new OpCode(OpCodeValues.Conv_Ovf_I4_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_I8_Un = new OpCode(OpCodeValues.Conv_Ovf_I8_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_U1_Un = new OpCode(OpCodeValues.Conv_Ovf_U1_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_U2_Un = new OpCode(OpCodeValues.Conv_Ovf_U2_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_U4_Un = new OpCode(OpCodeValues.Conv_Ovf_U4_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_U8_Un = new OpCode(OpCodeValues.Conv_Ovf_U8_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_I_Un = new OpCode(OpCodeValues.Conv_Ovf_I_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_U_Un = new OpCode(OpCodeValues.Conv_Ovf_U_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Box = new OpCode(OpCodeValues.Box,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Newarr = new OpCode(OpCodeValues.Newarr,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldlen = new OpCode(OpCodeValues.Ldlen,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelema = new OpCode(OpCodeValues.Ldelema,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelem_I1 = new OpCode(OpCodeValues.Ldelem_I1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelem_U1 = new OpCode(OpCodeValues.Ldelem_U1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelem_I2 = new OpCode(OpCodeValues.Ldelem_I2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelem_U2 = new OpCode(OpCodeValues.Ldelem_U2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelem_I4 = new OpCode(OpCodeValues.Ldelem_I4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelem_U4 = new OpCode(OpCodeValues.Ldelem_U4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelem_I8 = new OpCode(OpCodeValues.Ldelem_I8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelem_I = new OpCode(OpCodeValues.Ldelem_I,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelem_R4 = new OpCode(OpCodeValues.Ldelem_R4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelem_R8 = new OpCode(OpCodeValues.Ldelem_R8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelem_Ref = new OpCode(OpCodeValues.Ldelem_Ref,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stelem_I = new OpCode(OpCodeValues.Stelem_I,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-3 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stelem_I1 = new OpCode(OpCodeValues.Stelem_I1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-3 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stelem_I2 = new OpCode(OpCodeValues.Stelem_I2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-3 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stelem_I4 = new OpCode(OpCodeValues.Stelem_I4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-3 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stelem_I8 = new OpCode(OpCodeValues.Stelem_I8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi_popi8 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-3 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stelem_R4 = new OpCode(OpCodeValues.Stelem_R4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi_popr4 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-3 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stelem_R8 = new OpCode(OpCodeValues.Stelem_R8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi_popr8 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-3 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stelem_Ref = new OpCode(OpCodeValues.Stelem_Ref,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi_popref << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-3 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldelem = new OpCode(OpCodeValues.Ldelem,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stelem = new OpCode(OpCodeValues.Stelem,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref_popi_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Unbox_Any = new OpCode(OpCodeValues.Unbox_Any,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_I1 = new OpCode(OpCodeValues.Conv_Ovf_I1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_U1 = new OpCode(OpCodeValues.Conv_Ovf_U1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_I2 = new OpCode(OpCodeValues.Conv_Ovf_I2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_U2 = new OpCode(OpCodeValues.Conv_Ovf_U2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_I4 = new OpCode(OpCodeValues.Conv_Ovf_I4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_U4 = new OpCode(OpCodeValues.Conv_Ovf_U4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_I8 = new OpCode(OpCodeValues.Conv_Ovf_I8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_U8 = new OpCode(OpCodeValues.Conv_Ovf_U8,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Refanyval = new OpCode(OpCodeValues.Refanyval,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ckfinite = new OpCode(OpCodeValues.Ckfinite,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Mkrefany = new OpCode(OpCodeValues.Mkrefany,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldtoken = new OpCode(OpCodeValues.Ldtoken,
- ((int)OperandType.InlineTok) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_U2 = new OpCode(OpCodeValues.Conv_U2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_U1 = new OpCode(OpCodeValues.Conv_U1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_I = new OpCode(OpCodeValues.Conv_I,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_I = new OpCode(OpCodeValues.Conv_Ovf_I,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_Ovf_U = new OpCode(OpCodeValues.Conv_Ovf_U,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Add_Ovf = new OpCode(OpCodeValues.Add_Ovf,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Add_Ovf_Un = new OpCode(OpCodeValues.Add_Ovf_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Mul_Ovf = new OpCode(OpCodeValues.Mul_Ovf,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Mul_Ovf_Un = new OpCode(OpCodeValues.Mul_Ovf_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Sub_Ovf = new OpCode(OpCodeValues.Sub_Ovf,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Sub_Ovf_Un = new OpCode(OpCodeValues.Sub_Ovf_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Endfinally = new OpCode(OpCodeValues.Endfinally,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Return << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- OpCode.EndsUncondJmpBlkFlag |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Leave = new OpCode(OpCodeValues.Leave,
- ((int)OperandType.InlineBrTarget) |
- ((int)FlowControl.Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- OpCode.EndsUncondJmpBlkFlag |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Leave_S = new OpCode(OpCodeValues.Leave_S,
- ((int)OperandType.ShortInlineBrTarget) |
- ((int)FlowControl.Branch << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- OpCode.EndsUncondJmpBlkFlag |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stind_I = new OpCode(OpCodeValues.Stind_I,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (-2 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Conv_U = new OpCode(OpCodeValues.Conv_U,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Prefix7 = new OpCode(OpCodeValues.Prefix7,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Prefix6 = new OpCode(OpCodeValues.Prefix6,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Prefix5 = new OpCode(OpCodeValues.Prefix5,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Prefix4 = new OpCode(OpCodeValues.Prefix4,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Prefix3 = new OpCode(OpCodeValues.Prefix3,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Prefix2 = new OpCode(OpCodeValues.Prefix2,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Prefix1 = new OpCode(OpCodeValues.Prefix1,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Prefixref = new OpCode(OpCodeValues.Prefixref,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (1 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Arglist = new OpCode(OpCodeValues.Arglist,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ceq = new OpCode(OpCodeValues.Ceq,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Cgt = new OpCode(OpCodeValues.Cgt,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Cgt_Un = new OpCode(OpCodeValues.Cgt_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Clt = new OpCode(OpCodeValues.Clt,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Clt_Un = new OpCode(OpCodeValues.Clt_Un,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldftn = new OpCode(OpCodeValues.Ldftn,
- ((int)OperandType.InlineMethod) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldvirtftn = new OpCode(OpCodeValues.Ldvirtftn,
- ((int)OperandType.InlineMethod) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldarg = new OpCode(OpCodeValues.Ldarg,
- ((int)OperandType.InlineVar) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldarga = new OpCode(OpCodeValues.Ldarga,
- ((int)OperandType.InlineVar) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Starg = new OpCode(OpCodeValues.Starg,
- ((int)OperandType.InlineVar) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldloc = new OpCode(OpCodeValues.Ldloc,
- ((int)OperandType.InlineVar) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Ldloca = new OpCode(OpCodeValues.Ldloca,
- ((int)OperandType.InlineVar) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Stloc = new OpCode(OpCodeValues.Stloc,
- ((int)OperandType.InlineVar) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Localloc = new OpCode(OpCodeValues.Localloc,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Endfilter = new OpCode(OpCodeValues.Endfilter,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Return << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- OpCode.EndsUncondJmpBlkFlag |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Unaligned = new OpCode(OpCodeValues.Unaligned_,
- ((int)OperandType.ShortInlineI) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Volatile = new OpCode(OpCodeValues.Volatile_,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Tailcall = new OpCode(OpCodeValues.Tail_,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Initobj = new OpCode(OpCodeValues.Initobj,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (-1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Constrained = new OpCode(OpCodeValues.Constrained_,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Cpblk = new OpCode(OpCodeValues.Cpblk,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi_popi_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (-3 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Initblk = new OpCode(OpCodeValues.Initblk,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Popi_popi_popi << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (-3 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Rethrow = new OpCode(OpCodeValues.Rethrow,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Throw << OpCode.FlowControlShift) |
- ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- OpCode.EndsUncondJmpBlkFlag |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Sizeof = new OpCode(OpCodeValues.Sizeof,
- ((int)OperandType.InlineType) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (1 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Refanytype = new OpCode(OpCodeValues.Refanytype,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Next << OpCode.FlowControlShift) |
- ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
- public static readonly OpCode Readonly = new OpCode(OpCodeValues.Readonly_,
- ((int)OperandType.InlineNone) |
- ((int)FlowControl.Meta << OpCode.FlowControlShift) |
- ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) |
- ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
- ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
- (2 << OpCode.SizeShift) |
- (0 << OpCode.StackChangeShift)
- );
-
-
- public static bool TakesSingleByteArgument(OpCode inst)
+namespace System.Reflection.Emit
+{
+ //
+ // Internal enums for opcode values. Note that the value names are used to construct
+ // publicly visible ilasm-compatible opcode names, so their exact form is important!
+ //
+ internal enum OpCodeValues
+ {
+ Nop = 0x00,
+ Break = 0x01,
+ Ldarg_0 = 0x02,
+ Ldarg_1 = 0x03,
+ Ldarg_2 = 0x04,
+ Ldarg_3 = 0x05,
+ Ldloc_0 = 0x06,
+ Ldloc_1 = 0x07,
+ Ldloc_2 = 0x08,
+ Ldloc_3 = 0x09,
+ Stloc_0 = 0x0a,
+ Stloc_1 = 0x0b,
+ Stloc_2 = 0x0c,
+ Stloc_3 = 0x0d,
+ Ldarg_S = 0x0e,
+ Ldarga_S = 0x0f,
+ Starg_S = 0x10,
+ Ldloc_S = 0x11,
+ Ldloca_S = 0x12,
+ Stloc_S = 0x13,
+ Ldnull = 0x14,
+ Ldc_I4_M1 = 0x15,
+ Ldc_I4_0 = 0x16,
+ Ldc_I4_1 = 0x17,
+ Ldc_I4_2 = 0x18,
+ Ldc_I4_3 = 0x19,
+ Ldc_I4_4 = 0x1a,
+ Ldc_I4_5 = 0x1b,
+ Ldc_I4_6 = 0x1c,
+ Ldc_I4_7 = 0x1d,
+ Ldc_I4_8 = 0x1e,
+ Ldc_I4_S = 0x1f,
+ Ldc_I4 = 0x20,
+ Ldc_I8 = 0x21,
+ Ldc_R4 = 0x22,
+ Ldc_R8 = 0x23,
+ Dup = 0x25,
+ Pop = 0x26,
+ Jmp = 0x27,
+ Call = 0x28,
+ Calli = 0x29,
+ Ret = 0x2a,
+ Br_S = 0x2b,
+ Brfalse_S = 0x2c,
+ Brtrue_S = 0x2d,
+ Beq_S = 0x2e,
+ Bge_S = 0x2f,
+ Bgt_S = 0x30,
+ Ble_S = 0x31,
+ Blt_S = 0x32,
+ Bne_Un_S = 0x33,
+ Bge_Un_S = 0x34,
+ Bgt_Un_S = 0x35,
+ Ble_Un_S = 0x36,
+ Blt_Un_S = 0x37,
+ Br = 0x38,
+ Brfalse = 0x39,
+ Brtrue = 0x3a,
+ Beq = 0x3b,
+ Bge = 0x3c,
+ Bgt = 0x3d,
+ Ble = 0x3e,
+ Blt = 0x3f,
+ Bne_Un = 0x40,
+ Bge_Un = 0x41,
+ Bgt_Un = 0x42,
+ Ble_Un = 0x43,
+ Blt_Un = 0x44,
+ Switch = 0x45,
+ Ldind_I1 = 0x46,
+ Ldind_U1 = 0x47,
+ Ldind_I2 = 0x48,
+ Ldind_U2 = 0x49,
+ Ldind_I4 = 0x4a,
+ Ldind_U4 = 0x4b,
+ Ldind_I8 = 0x4c,
+ Ldind_I = 0x4d,
+ Ldind_R4 = 0x4e,
+ Ldind_R8 = 0x4f,
+ Ldind_Ref = 0x50,
+ Stind_Ref = 0x51,
+ Stind_I1 = 0x52,
+ Stind_I2 = 0x53,
+ Stind_I4 = 0x54,
+ Stind_I8 = 0x55,
+ Stind_R4 = 0x56,
+ Stind_R8 = 0x57,
+ Add = 0x58,
+ Sub = 0x59,
+ Mul = 0x5a,
+ Div = 0x5b,
+ Div_Un = 0x5c,
+ Rem = 0x5d,
+ Rem_Un = 0x5e,
+ And = 0x5f,
+ Or = 0x60,
+ Xor = 0x61,
+ Shl = 0x62,
+ Shr = 0x63,
+ Shr_Un = 0x64,
+ Neg = 0x65,
+ Not = 0x66,
+ Conv_I1 = 0x67,
+ Conv_I2 = 0x68,
+ Conv_I4 = 0x69,
+ Conv_I8 = 0x6a,
+ Conv_R4 = 0x6b,
+ Conv_R8 = 0x6c,
+ Conv_U4 = 0x6d,
+ Conv_U8 = 0x6e,
+ Callvirt = 0x6f,
+ Cpobj = 0x70,
+ Ldobj = 0x71,
+ Ldstr = 0x72,
+ Newobj = 0x73,
+ Castclass = 0x74,
+ Isinst = 0x75,
+ Conv_R_Un = 0x76,
+ Unbox = 0x79,
+ Throw = 0x7a,
+ Ldfld = 0x7b,
+ Ldflda = 0x7c,
+ Stfld = 0x7d,
+ Ldsfld = 0x7e,
+ Ldsflda = 0x7f,
+ Stsfld = 0x80,
+ Stobj = 0x81,
+ Conv_Ovf_I1_Un = 0x82,
+ Conv_Ovf_I2_Un = 0x83,
+ Conv_Ovf_I4_Un = 0x84,
+ Conv_Ovf_I8_Un = 0x85,
+ Conv_Ovf_U1_Un = 0x86,
+ Conv_Ovf_U2_Un = 0x87,
+ Conv_Ovf_U4_Un = 0x88,
+ Conv_Ovf_U8_Un = 0x89,
+ Conv_Ovf_I_Un = 0x8a,
+ Conv_Ovf_U_Un = 0x8b,
+ Box = 0x8c,
+ Newarr = 0x8d,
+ Ldlen = 0x8e,
+ Ldelema = 0x8f,
+ Ldelem_I1 = 0x90,
+ Ldelem_U1 = 0x91,
+ Ldelem_I2 = 0x92,
+ Ldelem_U2 = 0x93,
+ Ldelem_I4 = 0x94,
+ Ldelem_U4 = 0x95,
+ Ldelem_I8 = 0x96,
+ Ldelem_I = 0x97,
+ Ldelem_R4 = 0x98,
+ Ldelem_R8 = 0x99,
+ Ldelem_Ref = 0x9a,
+ Stelem_I = 0x9b,
+ Stelem_I1 = 0x9c,
+ Stelem_I2 = 0x9d,
+ Stelem_I4 = 0x9e,
+ Stelem_I8 = 0x9f,
+ Stelem_R4 = 0xa0,
+ Stelem_R8 = 0xa1,
+ Stelem_Ref = 0xa2,
+ Ldelem = 0xa3,
+ Stelem = 0xa4,
+ Unbox_Any = 0xa5,
+ Conv_Ovf_I1 = 0xb3,
+ Conv_Ovf_U1 = 0xb4,
+ Conv_Ovf_I2 = 0xb5,
+ Conv_Ovf_U2 = 0xb6,
+ Conv_Ovf_I4 = 0xb7,
+ Conv_Ovf_U4 = 0xb8,
+ Conv_Ovf_I8 = 0xb9,
+ Conv_Ovf_U8 = 0xba,
+ Refanyval = 0xc2,
+ Ckfinite = 0xc3,
+ Mkrefany = 0xc6,
+ Ldtoken = 0xd0,
+ Conv_U2 = 0xd1,
+ Conv_U1 = 0xd2,
+ Conv_I = 0xd3,
+ Conv_Ovf_I = 0xd4,
+ Conv_Ovf_U = 0xd5,
+ Add_Ovf = 0xd6,
+ Add_Ovf_Un = 0xd7,
+ Mul_Ovf = 0xd8,
+ Mul_Ovf_Un = 0xd9,
+ Sub_Ovf = 0xda,
+ Sub_Ovf_Un = 0xdb,
+ Endfinally = 0xdc,
+ Leave = 0xdd,
+ Leave_S = 0xde,
+ Stind_I = 0xdf,
+ Conv_U = 0xe0,
+ Prefix7 = 0xf8,
+ Prefix6 = 0xf9,
+ Prefix5 = 0xfa,
+ Prefix4 = 0xfb,
+ Prefix3 = 0xfc,
+ Prefix2 = 0xfd,
+ Prefix1 = 0xfe,
+ Prefixref = 0xff,
+ Arglist = 0xfe00,
+ Ceq = 0xfe01,
+ Cgt = 0xfe02,
+ Cgt_Un = 0xfe03,
+ Clt = 0xfe04,
+ Clt_Un = 0xfe05,
+ Ldftn = 0xfe06,
+ Ldvirtftn = 0xfe07,
+ Ldarg = 0xfe09,
+ Ldarga = 0xfe0a,
+ Starg = 0xfe0b,
+ Ldloc = 0xfe0c,
+ Ldloca = 0xfe0d,
+ Stloc = 0xfe0e,
+ Localloc = 0xfe0f,
+ Endfilter = 0xfe11,
+ Unaligned_ = 0xfe12,
+ Volatile_ = 0xfe13,
+ Tail_ = 0xfe14,
+ Initobj = 0xfe15,
+ Constrained_ = 0xfe16,
+ Cpblk = 0xfe17,
+ Initblk = 0xfe18,
+ Rethrow = 0xfe1a,
+ Sizeof = 0xfe1c,
+ Refanytype = 0xfe1d,
+ Readonly_ = 0xfe1e,
+
+ // If you add more opcodes here, modify OpCode.Name to handle them correctly
+ };
+
+ public class OpCodes
{
- switch (inst.OperandType)
+ /// <summary>
+ /// <para>
+ /// The IL instruction opcodes supported by the
+ /// runtime. The IL Instruction Specification describes each
+ /// Opcode.
+ /// </para>
+ /// </summary>
+ /// <seealso topic='IL Instruction Set Specification'/>
+
+ private OpCodes()
{
- case OperandType.ShortInlineBrTarget :
- case OperandType.ShortInlineI :
- case OperandType.ShortInlineVar :
- return true;
- };
- return false;
+ }
+
+ public static readonly OpCode Nop = new OpCode(OpCodeValues.Nop,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Break = new OpCode(OpCodeValues.Break,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Break << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldarg_0 = new OpCode(OpCodeValues.Ldarg_0,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldarg_1 = new OpCode(OpCodeValues.Ldarg_1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldarg_2 = new OpCode(OpCodeValues.Ldarg_2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldarg_3 = new OpCode(OpCodeValues.Ldarg_3,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldloc_0 = new OpCode(OpCodeValues.Ldloc_0,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldloc_1 = new OpCode(OpCodeValues.Ldloc_1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldloc_2 = new OpCode(OpCodeValues.Ldloc_2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldloc_3 = new OpCode(OpCodeValues.Ldloc_3,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stloc_0 = new OpCode(OpCodeValues.Stloc_0,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stloc_1 = new OpCode(OpCodeValues.Stloc_1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stloc_2 = new OpCode(OpCodeValues.Stloc_2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stloc_3 = new OpCode(OpCodeValues.Stloc_3,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldarg_S = new OpCode(OpCodeValues.Ldarg_S,
+ ((int)OperandType.ShortInlineVar) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldarga_S = new OpCode(OpCodeValues.Ldarga_S,
+ ((int)OperandType.ShortInlineVar) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Starg_S = new OpCode(OpCodeValues.Starg_S,
+ ((int)OperandType.ShortInlineVar) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldloc_S = new OpCode(OpCodeValues.Ldloc_S,
+ ((int)OperandType.ShortInlineVar) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldloca_S = new OpCode(OpCodeValues.Ldloca_S,
+ ((int)OperandType.ShortInlineVar) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stloc_S = new OpCode(OpCodeValues.Stloc_S,
+ ((int)OperandType.ShortInlineVar) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldnull = new OpCode(OpCodeValues.Ldnull,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I4_M1 = new OpCode(OpCodeValues.Ldc_I4_M1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I4_0 = new OpCode(OpCodeValues.Ldc_I4_0,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I4_1 = new OpCode(OpCodeValues.Ldc_I4_1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I4_2 = new OpCode(OpCodeValues.Ldc_I4_2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I4_3 = new OpCode(OpCodeValues.Ldc_I4_3,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I4_4 = new OpCode(OpCodeValues.Ldc_I4_4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I4_5 = new OpCode(OpCodeValues.Ldc_I4_5,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I4_6 = new OpCode(OpCodeValues.Ldc_I4_6,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I4_7 = new OpCode(OpCodeValues.Ldc_I4_7,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I4_8 = new OpCode(OpCodeValues.Ldc_I4_8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I4_S = new OpCode(OpCodeValues.Ldc_I4_S,
+ ((int)OperandType.ShortInlineI) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I4 = new OpCode(OpCodeValues.Ldc_I4,
+ ((int)OperandType.InlineI) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_I8 = new OpCode(OpCodeValues.Ldc_I8,
+ ((int)OperandType.InlineI8) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_R4 = new OpCode(OpCodeValues.Ldc_R4,
+ ((int)OperandType.ShortInlineR) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldc_R8 = new OpCode(OpCodeValues.Ldc_R8,
+ ((int)OperandType.InlineR) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Dup = new OpCode(OpCodeValues.Dup,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1_push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Pop = new OpCode(OpCodeValues.Pop,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Jmp = new OpCode(OpCodeValues.Jmp,
+ ((int)OperandType.InlineMethod) |
+ ((int)FlowControl.Call << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ OpCode.EndsUncondJmpBlkFlag |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Call = new OpCode(OpCodeValues.Call,
+ ((int)OperandType.InlineMethod) |
+ ((int)FlowControl.Call << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Varpush << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Calli = new OpCode(OpCodeValues.Calli,
+ ((int)OperandType.InlineSig) |
+ ((int)FlowControl.Call << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Varpush << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ret = new OpCode(OpCodeValues.Ret,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Return << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ OpCode.EndsUncondJmpBlkFlag |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Br_S = new OpCode(OpCodeValues.Br_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ OpCode.EndsUncondJmpBlkFlag |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Brfalse_S = new OpCode(OpCodeValues.Brfalse_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Brtrue_S = new OpCode(OpCodeValues.Brtrue_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Beq_S = new OpCode(OpCodeValues.Beq_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Bge_S = new OpCode(OpCodeValues.Bge_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Bgt_S = new OpCode(OpCodeValues.Bgt_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ble_S = new OpCode(OpCodeValues.Ble_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Blt_S = new OpCode(OpCodeValues.Blt_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Bne_Un_S = new OpCode(OpCodeValues.Bne_Un_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Bge_Un_S = new OpCode(OpCodeValues.Bge_Un_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Bgt_Un_S = new OpCode(OpCodeValues.Bgt_Un_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ble_Un_S = new OpCode(OpCodeValues.Ble_Un_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Blt_Un_S = new OpCode(OpCodeValues.Blt_Un_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Br = new OpCode(OpCodeValues.Br,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ OpCode.EndsUncondJmpBlkFlag |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Brfalse = new OpCode(OpCodeValues.Brfalse,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Brtrue = new OpCode(OpCodeValues.Brtrue,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Beq = new OpCode(OpCodeValues.Beq,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Bge = new OpCode(OpCodeValues.Bge,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Bgt = new OpCode(OpCodeValues.Bgt,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ble = new OpCode(OpCodeValues.Ble,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Blt = new OpCode(OpCodeValues.Blt,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Bne_Un = new OpCode(OpCodeValues.Bne_Un,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Bge_Un = new OpCode(OpCodeValues.Bge_Un,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Bgt_Un = new OpCode(OpCodeValues.Bgt_Un,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ble_Un = new OpCode(OpCodeValues.Ble_Un,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Blt_Un = new OpCode(OpCodeValues.Blt_Un,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Switch = new OpCode(OpCodeValues.Switch,
+ ((int)OperandType.InlineSwitch) |
+ ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldind_I1 = new OpCode(OpCodeValues.Ldind_I1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldind_U1 = new OpCode(OpCodeValues.Ldind_U1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldind_I2 = new OpCode(OpCodeValues.Ldind_I2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldind_U2 = new OpCode(OpCodeValues.Ldind_U2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldind_I4 = new OpCode(OpCodeValues.Ldind_I4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldind_U4 = new OpCode(OpCodeValues.Ldind_U4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldind_I8 = new OpCode(OpCodeValues.Ldind_I8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldind_I = new OpCode(OpCodeValues.Ldind_I,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldind_R4 = new OpCode(OpCodeValues.Ldind_R4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldind_R8 = new OpCode(OpCodeValues.Ldind_R8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldind_Ref = new OpCode(OpCodeValues.Ldind_Ref,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stind_Ref = new OpCode(OpCodeValues.Stind_Ref,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stind_I1 = new OpCode(OpCodeValues.Stind_I1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stind_I2 = new OpCode(OpCodeValues.Stind_I2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stind_I4 = new OpCode(OpCodeValues.Stind_I4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stind_I8 = new OpCode(OpCodeValues.Stind_I8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi_popi8 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stind_R4 = new OpCode(OpCodeValues.Stind_R4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi_popr4 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stind_R8 = new OpCode(OpCodeValues.Stind_R8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi_popr8 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Add = new OpCode(OpCodeValues.Add,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Sub = new OpCode(OpCodeValues.Sub,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Mul = new OpCode(OpCodeValues.Mul,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Div = new OpCode(OpCodeValues.Div,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Div_Un = new OpCode(OpCodeValues.Div_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Rem = new OpCode(OpCodeValues.Rem,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Rem_Un = new OpCode(OpCodeValues.Rem_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode And = new OpCode(OpCodeValues.And,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Or = new OpCode(OpCodeValues.Or,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Xor = new OpCode(OpCodeValues.Xor,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Shl = new OpCode(OpCodeValues.Shl,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Shr = new OpCode(OpCodeValues.Shr,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Shr_Un = new OpCode(OpCodeValues.Shr_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Neg = new OpCode(OpCodeValues.Neg,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Not = new OpCode(OpCodeValues.Not,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_I1 = new OpCode(OpCodeValues.Conv_I1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_I2 = new OpCode(OpCodeValues.Conv_I2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_I4 = new OpCode(OpCodeValues.Conv_I4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_I8 = new OpCode(OpCodeValues.Conv_I8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_R4 = new OpCode(OpCodeValues.Conv_R4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_R8 = new OpCode(OpCodeValues.Conv_R8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_U4 = new OpCode(OpCodeValues.Conv_U4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_U8 = new OpCode(OpCodeValues.Conv_U8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Callvirt = new OpCode(OpCodeValues.Callvirt,
+ ((int)OperandType.InlineMethod) |
+ ((int)FlowControl.Call << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Varpush << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Cpobj = new OpCode(OpCodeValues.Cpobj,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldobj = new OpCode(OpCodeValues.Ldobj,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldstr = new OpCode(OpCodeValues.Ldstr,
+ ((int)OperandType.InlineString) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Newobj = new OpCode(OpCodeValues.Newobj,
+ ((int)OperandType.InlineMethod) |
+ ((int)FlowControl.Call << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Castclass = new OpCode(OpCodeValues.Castclass,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Isinst = new OpCode(OpCodeValues.Isinst,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_R_Un = new OpCode(OpCodeValues.Conv_R_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Unbox = new OpCode(OpCodeValues.Unbox,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Throw = new OpCode(OpCodeValues.Throw,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Throw << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ OpCode.EndsUncondJmpBlkFlag |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldfld = new OpCode(OpCodeValues.Ldfld,
+ ((int)OperandType.InlineField) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldflda = new OpCode(OpCodeValues.Ldflda,
+ ((int)OperandType.InlineField) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stfld = new OpCode(OpCodeValues.Stfld,
+ ((int)OperandType.InlineField) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldsfld = new OpCode(OpCodeValues.Ldsfld,
+ ((int)OperandType.InlineField) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldsflda = new OpCode(OpCodeValues.Ldsflda,
+ ((int)OperandType.InlineField) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stsfld = new OpCode(OpCodeValues.Stsfld,
+ ((int)OperandType.InlineField) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stobj = new OpCode(OpCodeValues.Stobj,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_I1_Un = new OpCode(OpCodeValues.Conv_Ovf_I1_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_I2_Un = new OpCode(OpCodeValues.Conv_Ovf_I2_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_I4_Un = new OpCode(OpCodeValues.Conv_Ovf_I4_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_I8_Un = new OpCode(OpCodeValues.Conv_Ovf_I8_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_U1_Un = new OpCode(OpCodeValues.Conv_Ovf_U1_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_U2_Un = new OpCode(OpCodeValues.Conv_Ovf_U2_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_U4_Un = new OpCode(OpCodeValues.Conv_Ovf_U4_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_U8_Un = new OpCode(OpCodeValues.Conv_Ovf_U8_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_I_Un = new OpCode(OpCodeValues.Conv_Ovf_I_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_U_Un = new OpCode(OpCodeValues.Conv_Ovf_U_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Box = new OpCode(OpCodeValues.Box,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Newarr = new OpCode(OpCodeValues.Newarr,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldlen = new OpCode(OpCodeValues.Ldlen,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelema = new OpCode(OpCodeValues.Ldelema,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelem_I1 = new OpCode(OpCodeValues.Ldelem_I1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelem_U1 = new OpCode(OpCodeValues.Ldelem_U1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelem_I2 = new OpCode(OpCodeValues.Ldelem_I2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelem_U2 = new OpCode(OpCodeValues.Ldelem_U2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelem_I4 = new OpCode(OpCodeValues.Ldelem_I4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelem_U4 = new OpCode(OpCodeValues.Ldelem_U4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelem_I8 = new OpCode(OpCodeValues.Ldelem_I8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelem_I = new OpCode(OpCodeValues.Ldelem_I,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelem_R4 = new OpCode(OpCodeValues.Ldelem_R4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelem_R8 = new OpCode(OpCodeValues.Ldelem_R8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelem_Ref = new OpCode(OpCodeValues.Ldelem_Ref,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stelem_I = new OpCode(OpCodeValues.Stelem_I,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-3 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stelem_I1 = new OpCode(OpCodeValues.Stelem_I1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-3 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stelem_I2 = new OpCode(OpCodeValues.Stelem_I2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-3 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stelem_I4 = new OpCode(OpCodeValues.Stelem_I4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-3 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stelem_I8 = new OpCode(OpCodeValues.Stelem_I8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi_popi8 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-3 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stelem_R4 = new OpCode(OpCodeValues.Stelem_R4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi_popr4 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-3 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stelem_R8 = new OpCode(OpCodeValues.Stelem_R8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi_popr8 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-3 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stelem_Ref = new OpCode(OpCodeValues.Stelem_Ref,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi_popref << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-3 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldelem = new OpCode(OpCodeValues.Ldelem,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stelem = new OpCode(OpCodeValues.Stelem,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref_popi_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Unbox_Any = new OpCode(OpCodeValues.Unbox_Any,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_I1 = new OpCode(OpCodeValues.Conv_Ovf_I1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_U1 = new OpCode(OpCodeValues.Conv_Ovf_U1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_I2 = new OpCode(OpCodeValues.Conv_Ovf_I2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_U2 = new OpCode(OpCodeValues.Conv_Ovf_U2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_I4 = new OpCode(OpCodeValues.Conv_Ovf_I4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_U4 = new OpCode(OpCodeValues.Conv_Ovf_U4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_I8 = new OpCode(OpCodeValues.Conv_Ovf_I8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_U8 = new OpCode(OpCodeValues.Conv_Ovf_U8,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Refanyval = new OpCode(OpCodeValues.Refanyval,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ckfinite = new OpCode(OpCodeValues.Ckfinite,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Mkrefany = new OpCode(OpCodeValues.Mkrefany,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldtoken = new OpCode(OpCodeValues.Ldtoken,
+ ((int)OperandType.InlineTok) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_U2 = new OpCode(OpCodeValues.Conv_U2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_U1 = new OpCode(OpCodeValues.Conv_U1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_I = new OpCode(OpCodeValues.Conv_I,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_I = new OpCode(OpCodeValues.Conv_Ovf_I,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_Ovf_U = new OpCode(OpCodeValues.Conv_Ovf_U,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Add_Ovf = new OpCode(OpCodeValues.Add_Ovf,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Add_Ovf_Un = new OpCode(OpCodeValues.Add_Ovf_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Mul_Ovf = new OpCode(OpCodeValues.Mul_Ovf,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Mul_Ovf_Un = new OpCode(OpCodeValues.Mul_Ovf_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Sub_Ovf = new OpCode(OpCodeValues.Sub_Ovf,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Sub_Ovf_Un = new OpCode(OpCodeValues.Sub_Ovf_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Endfinally = new OpCode(OpCodeValues.Endfinally,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Return << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ OpCode.EndsUncondJmpBlkFlag |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Leave = new OpCode(OpCodeValues.Leave,
+ ((int)OperandType.InlineBrTarget) |
+ ((int)FlowControl.Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ OpCode.EndsUncondJmpBlkFlag |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Leave_S = new OpCode(OpCodeValues.Leave_S,
+ ((int)OperandType.ShortInlineBrTarget) |
+ ((int)FlowControl.Branch << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ OpCode.EndsUncondJmpBlkFlag |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stind_I = new OpCode(OpCodeValues.Stind_I,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (-2 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Conv_U = new OpCode(OpCodeValues.Conv_U,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Prefix7 = new OpCode(OpCodeValues.Prefix7,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Prefix6 = new OpCode(OpCodeValues.Prefix6,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Prefix5 = new OpCode(OpCodeValues.Prefix5,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Prefix4 = new OpCode(OpCodeValues.Prefix4,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Prefix3 = new OpCode(OpCodeValues.Prefix3,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Prefix2 = new OpCode(OpCodeValues.Prefix2,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Prefix1 = new OpCode(OpCodeValues.Prefix1,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Prefixref = new OpCode(OpCodeValues.Prefixref,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (1 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Arglist = new OpCode(OpCodeValues.Arglist,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ceq = new OpCode(OpCodeValues.Ceq,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Cgt = new OpCode(OpCodeValues.Cgt,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Cgt_Un = new OpCode(OpCodeValues.Cgt_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Clt = new OpCode(OpCodeValues.Clt,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Clt_Un = new OpCode(OpCodeValues.Clt_Un,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldftn = new OpCode(OpCodeValues.Ldftn,
+ ((int)OperandType.InlineMethod) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldvirtftn = new OpCode(OpCodeValues.Ldvirtftn,
+ ((int)OperandType.InlineMethod) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldarg = new OpCode(OpCodeValues.Ldarg,
+ ((int)OperandType.InlineVar) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldarga = new OpCode(OpCodeValues.Ldarga,
+ ((int)OperandType.InlineVar) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Starg = new OpCode(OpCodeValues.Starg,
+ ((int)OperandType.InlineVar) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldloc = new OpCode(OpCodeValues.Ldloc,
+ ((int)OperandType.InlineVar) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Ldloca = new OpCode(OpCodeValues.Ldloca,
+ ((int)OperandType.InlineVar) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Stloc = new OpCode(OpCodeValues.Stloc,
+ ((int)OperandType.InlineVar) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Localloc = new OpCode(OpCodeValues.Localloc,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Endfilter = new OpCode(OpCodeValues.Endfilter,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Return << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ OpCode.EndsUncondJmpBlkFlag |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Unaligned = new OpCode(OpCodeValues.Unaligned_,
+ ((int)OperandType.ShortInlineI) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Volatile = new OpCode(OpCodeValues.Volatile_,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Tailcall = new OpCode(OpCodeValues.Tail_,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Initobj = new OpCode(OpCodeValues.Initobj,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (-1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Constrained = new OpCode(OpCodeValues.Constrained_,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Cpblk = new OpCode(OpCodeValues.Cpblk,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi_popi_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (-3 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Initblk = new OpCode(OpCodeValues.Initblk,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Popi_popi_popi << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (-3 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Rethrow = new OpCode(OpCodeValues.Rethrow,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Throw << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ OpCode.EndsUncondJmpBlkFlag |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Sizeof = new OpCode(OpCodeValues.Sizeof,
+ ((int)OperandType.InlineType) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (1 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Refanytype = new OpCode(OpCodeValues.Refanytype,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Next << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+ public static readonly OpCode Readonly = new OpCode(OpCodeValues.Readonly_,
+ ((int)OperandType.InlineNone) |
+ ((int)FlowControl.Meta << OpCode.FlowControlShift) |
+ ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) |
+ ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) |
+ ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) |
+ (2 << OpCode.SizeShift) |
+ (0 << OpCode.StackChangeShift)
+ );
+
+
+ public static bool TakesSingleByteArgument(OpCode inst)
+ {
+ switch (inst.OperandType)
+ {
+ case OperandType.ShortInlineBrTarget:
+ case OperandType.ShortInlineI:
+ case OperandType.ShortInlineVar:
+ return true;
+ };
+ return false;
+ }
}
}
-}
diff --git a/src/mscorlib/src/System/Reflection/Emit/Opcode.cs b/src/mscorlib/src/System/Reflection/Emit/Opcode.cs
index 74a9de16b6..37768be9d7 100644
--- a/src/mscorlib/src/System/Reflection/Emit/Opcode.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/Opcode.cs
@@ -2,191 +2,196 @@
// 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;
using System.Threading;
using System.Diagnostics.Contracts;
-public struct OpCode
+namespace System.Reflection.Emit
{
- //
- // Use packed bitfield for flags to avoid code bloat
- //
-
- internal const int OperandTypeMask = 0x1F; // 000000000000000000000000000XXXXX
-
- internal const int FlowControlShift = 5; // 00000000000000000000000XXXX00000
- internal const int FlowControlMask = 0x0F;
+ public struct OpCode
+ {
+ //
+ // Use packed bitfield for flags to avoid code bloat
+ //
- internal const int OpCodeTypeShift = 9; // 00000000000000000000XXX000000000
- internal const int OpCodeTypeMask = 0x07;
+ internal const int OperandTypeMask = 0x1F; // 000000000000000000000000000XXXXX
- internal const int StackBehaviourPopShift = 12; // 000000000000000XXXXX000000000000
- internal const int StackBehaviourPushShift = 17; // 0000000000XXXXX00000000000000000
- internal const int StackBehaviourMask = 0x1F;
+ internal const int FlowControlShift = 5; // 00000000000000000000000XXXX00000
+ internal const int FlowControlMask = 0x0F;
- internal const int SizeShift = 22; // 00000000XX0000000000000000000000
- internal const int SizeMask = 0x03;
+ internal const int OpCodeTypeShift = 9; // 00000000000000000000XXX000000000
+ internal const int OpCodeTypeMask = 0x07;
- internal const int EndsUncondJmpBlkFlag = 0x01000000; // 0000000X000000000000000000000000
+ internal const int StackBehaviourPopShift = 12; // 000000000000000XXXXX000000000000
+ internal const int StackBehaviourPushShift = 17; // 0000000000XXXXX00000000000000000
+ internal const int StackBehaviourMask = 0x1F;
- // unused // 0000XXX0000000000000000000000000
+ internal const int SizeShift = 22; // 00000000XX0000000000000000000000
+ internal const int SizeMask = 0x03;
- internal const int StackChangeShift = 28; // XXXX0000000000000000000000000000
+ internal const int EndsUncondJmpBlkFlag = 0x01000000; // 0000000X000000000000000000000000
- private OpCodeValues m_value;
- private int m_flags;
+ // unused // 0000XXX0000000000000000000000000
- internal OpCode(OpCodeValues value, int flags)
- {
- m_value = value;
- m_flags = flags;
- }
+ internal const int StackChangeShift = 28; // XXXX0000000000000000000000000000
- internal bool EndsUncondJmpBlk()
- {
- return (m_flags & EndsUncondJmpBlkFlag) != 0;
- }
-
- internal int StackChange()
- {
- return (m_flags >> StackChangeShift);
- }
+ private OpCodeValues m_value;
+ private int m_flags;
- public OperandType OperandType
- {
- get
+ internal OpCode(OpCodeValues value, int flags)
{
- return (OperandType)(m_flags & OperandTypeMask);
+ m_value = value;
+ m_flags = flags;
}
- }
- public FlowControl FlowControl
- {
- get
+ internal bool EndsUncondJmpBlk()
{
- return (FlowControl)((m_flags >> FlowControlShift) & FlowControlMask);
+ return (m_flags & EndsUncondJmpBlkFlag) != 0;
}
- }
- public OpCodeType OpCodeType
- {
- get
+ internal int StackChange()
{
- return (OpCodeType)((m_flags >> OpCodeTypeShift) & OpCodeTypeMask);
+ return (m_flags >> StackChangeShift);
}
- }
- public StackBehaviour StackBehaviourPop
- {
- get
+ public OperandType OperandType
{
- return (StackBehaviour)((m_flags >> StackBehaviourPopShift) & StackBehaviourMask);
+ get
+ {
+ return (OperandType)(m_flags & OperandTypeMask);
+ }
}
- }
- public StackBehaviour StackBehaviourPush
- {
- get
+ public FlowControl FlowControl
{
- return (StackBehaviour)((m_flags >> StackBehaviourPushShift) & StackBehaviourMask);
+ get
+ {
+ return (FlowControl)((m_flags >> FlowControlShift) & FlowControlMask);
+ }
}
- }
- public int Size
- {
- get
+ public OpCodeType OpCodeType
{
- return (m_flags >> SizeShift) & SizeMask;
+ get
+ {
+ return (OpCodeType)((m_flags >> OpCodeTypeShift) & OpCodeTypeMask);
+ }
}
- }
- public short Value
- {
- get
+ public StackBehaviour StackBehaviourPop
{
- return (short)m_value;
+ get
+ {
+ return (StackBehaviour)((m_flags >> StackBehaviourPopShift) & StackBehaviourMask);
+ }
}
- }
- private static volatile string[] g_nameCache;
+ public StackBehaviour StackBehaviourPush
+ {
+ get
+ {
+ return (StackBehaviour)((m_flags >> StackBehaviourPushShift) & StackBehaviourMask);
+ }
+ }
- public String Name
- {
- get
+ public int Size
{
- if (Size == 0)
- return null;
+ get
+ {
+ return (m_flags >> SizeShift) & SizeMask;
+ }
+ }
- // Create and cache the opcode names lazily. They should be rarely used (only for logging, etc.)
- // Note that we do not any locks here because of we always get the same names. The last one wins.
- string[] nameCache = g_nameCache;
- if (nameCache == null) {
- nameCache = new String[0x11f];
- g_nameCache = nameCache;
+ public short Value
+ {
+ get
+ {
+ return (short)m_value;
}
+ }
- OpCodeValues opCodeValue = (OpCodeValues)(ushort)Value;
+ private static volatile string[] g_nameCache;
- int idx = (int)opCodeValue;
- if (idx > 0xFF) {
- if (idx >= 0xfe00 && idx <= 0xfe1e) {
- // Transform two byte opcode value to lower range that's suitable
- // for array index
- idx = 0x100 + (idx - 0xfe00);
- }
- else {
- // Unknown opcode
+ public String Name
+ {
+ get
+ {
+ if (Size == 0)
return null;
+
+ // Create and cache the opcode names lazily. They should be rarely used (only for logging, etc.)
+ // Note that we do not any locks here because of we always get the same names. The last one wins.
+ string[] nameCache = g_nameCache;
+ if (nameCache == null)
+ {
+ nameCache = new String[0x11f];
+ g_nameCache = nameCache;
}
- }
- String name = Volatile.Read(ref nameCache[idx]);
- if (name != null)
- return name;
+ OpCodeValues opCodeValue = (OpCodeValues)(ushort)Value;
+
+ int idx = (int)opCodeValue;
+ if (idx > 0xFF)
+ {
+ if (idx >= 0xfe00 && idx <= 0xfe1e)
+ {
+ // Transform two byte opcode value to lower range that's suitable
+ // for array index
+ idx = 0x100 + (idx - 0xfe00);
+ }
+ else
+ {
+ // Unknown opcode
+ return null;
+ }
+ }
- // Create ilasm style name from the enum value name.
- name = Enum.GetName(typeof(OpCodeValues), opCodeValue).ToLowerInvariant().Replace("_", ".");
- Volatile.Write(ref nameCache[idx], name);
- return name;
+ String name = Volatile.Read(ref nameCache[idx]);
+ if (name != null)
+ return name;
+
+ // Create ilasm style name from the enum value name.
+ name = Enum.GetName(typeof(OpCodeValues), opCodeValue).ToLowerInvariant().Replace("_", ".");
+ Volatile.Write(ref nameCache[idx], name);
+ return name;
+ }
}
- }
- [Pure]
- public override bool Equals(Object obj)
- {
- if (obj is OpCode)
- return Equals((OpCode)obj);
- else
- return false;
- }
+ [Pure]
+ public override bool Equals(Object obj)
+ {
+ if (obj is OpCode)
+ return Equals((OpCode)obj);
+ else
+ return false;
+ }
- [Pure]
- public bool Equals(OpCode obj)
- {
- return obj.Value == Value;
- }
+ [Pure]
+ public bool Equals(OpCode obj)
+ {
+ return obj.Value == Value;
+ }
- [Pure]
- public static bool operator ==(OpCode a, OpCode b)
- {
- return a.Equals(b);
- }
+ [Pure]
+ public static bool operator ==(OpCode a, OpCode b)
+ {
+ return a.Equals(b);
+ }
- [Pure]
- public static bool operator !=(OpCode a, OpCode b)
- {
- return !(a == b);
- }
+ [Pure]
+ public static bool operator !=(OpCode a, OpCode b)
+ {
+ return !(a == b);
+ }
- public override int GetHashCode()
- {
- return Value;
- }
+ public override int GetHashCode()
+ {
+ return Value;
+ }
- public override String ToString()
- {
- return Name;
+ public override String ToString()
+ {
+ return Name;
+ }
}
}
-}
diff --git a/src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs b/src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs
index 87dea058e5..2363d607fc 100644
--- a/src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs
@@ -12,20 +12,20 @@
** THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND!
** See opcodegen.pl for more information.**
============================================================*/
-namespace System.Reflection.Emit {
using System;
-[Serializable]
-public enum OpCodeType
+namespace System.Reflection.Emit
{
-
- [Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")]
- Annotation = 0,
- Macro = 1,
- Nternal = 2,
- Objmodel = 3,
- Prefix = 4,
- Primitive = 5,
-}
+ [Serializable]
+ public enum OpCodeType
+ {
+ [Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")]
+ Annotation = 0,
+ Macro = 1,
+ Nternal = 2,
+ Objmodel = 3,
+ Prefix = 4,
+ Primitive = 5,
+ }
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/OperandType.cs b/src/mscorlib/src/System/Reflection/Emit/OperandType.cs
index e972e8603d..033539b999 100644
--- a/src/mscorlib/src/System/Reflection/Emit/OperandType.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/OperandType.cs
@@ -12,32 +12,32 @@
** THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND!
** See opcodegen.pl for more information.**
============================================================*/
-namespace System.Reflection.Emit {
using System;
-[Serializable]
-public enum OperandType
+namespace System.Reflection.Emit
{
-
- InlineBrTarget = 0,
- InlineField = 1,
- InlineI = 2,
- InlineI8 = 3,
- InlineMethod = 4,
- InlineNone = 5,
- [Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")]
- InlinePhi = 6,
- InlineR = 7,
- InlineSig = 9,
- InlineString = 10,
- InlineSwitch = 11,
- InlineTok = 12,
- InlineType = 13,
- InlineVar = 14,
- ShortInlineBrTarget = 15,
- ShortInlineI = 16,
- ShortInlineR = 17,
- ShortInlineVar = 18,
-}
+ [Serializable]
+ public enum OperandType
+ {
+ InlineBrTarget = 0,
+ InlineField = 1,
+ InlineI = 2,
+ InlineI8 = 3,
+ InlineMethod = 4,
+ InlineNone = 5,
+ [Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")]
+ InlinePhi = 6,
+ InlineR = 7,
+ InlineSig = 9,
+ InlineString = 10,
+ InlineSwitch = 11,
+ InlineTok = 12,
+ InlineType = 13,
+ InlineVar = 14,
+ ShortInlineBrTarget = 15,
+ ShortInlineI = 16,
+ ShortInlineR = 17,
+ ShortInlineVar = 18,
+ }
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs b/src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs
index 531ff41dd7..f9246fce6d 100644
--- a/src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs
@@ -2,14 +2,16 @@
// 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;
+
+using System;
+
+namespace System.Reflection.Emit
+{
// This Enum matchs the CorFieldAttr defined in CorHdr.h
[Serializable]
public enum PEFileKinds
{
- Dll = 0x0001,
+ Dll = 0x0001,
ConsoleApplication = 0x0002,
WindowApplication = 0x0003,
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
index 1b3babf595..636825956a 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
@@ -12,17 +12,18 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
- using System.Runtime.InteropServices;
- using System;
- using System.Reflection;
- using System.Diagnostics.Contracts;
+using System.Runtime.InteropServices;
+using System;
+using System.Reflection;
+using System.Diagnostics.Contracts;
+
+namespace System.Reflection.Emit
+{
public class ParameterBuilder
{
-
// Set the default value of the parameter
- public virtual void SetConstant(Object defaultValue)
+ public virtual void SetConstant(Object defaultValue)
{
TypeBuilder.SetConstantValue(
m_methodBuilder.GetModuleBuilder(),
@@ -30,7 +31,7 @@ namespace System.Reflection.Emit {
m_iPosition == 0 ? m_methodBuilder.ReturnType : m_methodBuilder.m_parameterTypes[m_iPosition - 1],
defaultValue);
}
-
+
// Use this function if client decides to form the custom attribute blob themselves
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
@@ -44,7 +45,7 @@ namespace System.Reflection.Emit {
TypeBuilder.DefineCustomAttribute(
m_methodBuilder.GetModuleBuilder(),
m_pdToken.Token,
- ((ModuleBuilder )m_methodBuilder.GetModule()).GetConstructorToken(con).Token,
+ ((ModuleBuilder)m_methodBuilder.GetModule()).GetConstructorToken(con).Token,
binaryAttribute,
false, false);
}
@@ -57,65 +58,71 @@ namespace System.Reflection.Emit {
throw new ArgumentNullException(nameof(customBuilder));
}
Contract.EndContractBlock();
- customBuilder.CreateCustomAttribute((ModuleBuilder) (m_methodBuilder .GetModule()), m_pdToken.Token);
+ customBuilder.CreateCustomAttribute((ModuleBuilder)(m_methodBuilder.GetModule()), m_pdToken.Token);
}
-
+
//*******************************
// Make a private constructor so these cannot be constructed externally.
//*******************************
- private ParameterBuilder() {}
+ private ParameterBuilder() { }
internal ParameterBuilder(
- MethodBuilder methodBuilder,
- int sequence,
- ParameterAttributes attributes,
- String strParamName) // can be NULL string
+ MethodBuilder methodBuilder,
+ int sequence,
+ ParameterAttributes attributes,
+ String strParamName) // can be NULL string
{
m_iPosition = sequence;
m_strParamName = strParamName;
m_methodBuilder = methodBuilder;
m_strParamName = strParamName;
m_attributes = attributes;
- m_pdToken = new ParameterToken( TypeBuilder.SetParamInfo(
+ m_pdToken = new ParameterToken(TypeBuilder.SetParamInfo(
m_methodBuilder.GetModuleBuilder().GetNativeHandle(),
- m_methodBuilder.GetToken().Token,
- sequence,
- attributes,
+ m_methodBuilder.GetToken().Token,
+ sequence,
+ attributes,
strParamName));
}
-
+
public virtual ParameterToken GetToken()
{
return m_pdToken;
- }
-
- public virtual String Name {
- get {return m_strParamName;}
}
-
- public virtual int Position {
- get {return m_iPosition;}
+
+ public virtual String Name
+ {
+ get { return m_strParamName; }
+ }
+
+ public virtual int Position
+ {
+ get { return m_iPosition; }
}
-
- public virtual int Attributes {
- get {return (int) m_attributes;}
+
+ public virtual int Attributes
+ {
+ get { return (int)m_attributes; }
}
-
- public bool IsIn {
- get {return ((m_attributes & ParameterAttributes.In) != 0);}
+
+ public bool IsIn
+ {
+ get { return ((m_attributes & ParameterAttributes.In) != 0); }
}
- public bool IsOut {
- get {return ((m_attributes & ParameterAttributes.Out) != 0);}
+ public bool IsOut
+ {
+ get { return ((m_attributes & ParameterAttributes.Out) != 0); }
}
- public bool IsOptional {
- get {return ((m_attributes & ParameterAttributes.Optional) != 0);}
+ public bool IsOptional
+ {
+ get { return ((m_attributes & ParameterAttributes.Optional) != 0); }
}
-
- private String m_strParamName;
- private int m_iPosition;
+
+ private String m_strParamName;
+ private int m_iPosition;
private ParameterAttributes m_attributes;
- private MethodBuilder m_methodBuilder;
- private ParameterToken m_pdToken;
+ private MethodBuilder m_methodBuilder;
+ private ParameterToken m_pdToken;
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs b/src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs
index a4a32a51fb..42f85af464 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs
@@ -12,33 +12,36 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
-
- using System;
- using System.Reflection;
+using System;
+using System.Reflection;
+
+namespace System.Reflection.Emit
+{
// The ParameterToken class is an opaque representation of the Token returned
// by the Metadata to represent the parameter.
[Serializable]
- public struct ParameterToken {
-
+ public struct ParameterToken
+ {
public static readonly ParameterToken Empty = new ParameterToken();
internal int m_tkParameter;
-
-
- internal ParameterToken(int tkParam) {
+
+
+ internal ParameterToken(int tkParam)
+ {
m_tkParameter = tkParam;
}
-
- public int Token {
+
+ public int Token
+ {
get { return m_tkParameter; }
}
-
+
public override int GetHashCode()
{
return m_tkParameter;
}
-
+
public override bool Equals(Object obj)
{
if (obj is ParameterToken)
@@ -46,21 +49,20 @@ namespace System.Reflection.Emit {
else
return false;
}
-
+
public bool Equals(ParameterToken obj)
{
return obj.m_tkParameter == m_tkParameter;
}
-
+
public static bool operator ==(ParameterToken a, ParameterToken b)
{
return a.Equals(b);
}
-
+
public static bool operator !=(ParameterToken a, ParameterToken b)
{
return !(a == b);
}
-
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs
index 7c4ed9dc0f..6dbcba251f 100644
--- a/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs
@@ -12,8 +12,9 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
-
+
+namespace System.Reflection.Emit
+{
using System;
using System.Reflection;
using CultureInfo = System.Globalization.CultureInfo;
@@ -25,30 +26,29 @@ namespace System.Reflection.Emit {
// method will return a new PropertyBuilder to a client.
//
public sealed class PropertyBuilder : PropertyInfo
- {
-
+ {
// Make a private constructor so these cannot be constructed externally.
- private PropertyBuilder() {}
-
+ private PropertyBuilder() { }
+
// Constructs a PropertyBuilder.
//
internal PropertyBuilder(
- ModuleBuilder mod, // the module containing this PropertyBuilder
- String name, // property name
- SignatureHelper sig, // property signature descriptor info
- PropertyAttributes attr, // property attribute such as DefaultProperty, Bindable, DisplayBind, etc
- Type returnType, // return type of the property.
- PropertyToken prToken, // the metadata token for this property
- TypeBuilder containingType) // the containing type
+ ModuleBuilder mod, // the module containing this PropertyBuilder
+ String name, // property name
+ SignatureHelper sig, // property signature descriptor info
+ PropertyAttributes attr, // property attribute such as DefaultProperty, Bindable, DisplayBind, etc
+ Type returnType, // return type of the property.
+ PropertyToken prToken, // the metadata token for this property
+ TypeBuilder containingType) // the containing type
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
if (name[0] == '\0')
- throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(name));
+ throw new ArgumentException(SR.Argument_IllegalName, nameof(name));
Contract.EndContractBlock();
-
+
m_name = name;
m_moduleBuilder = mod;
m_signature = sig;
@@ -58,32 +58,32 @@ namespace System.Reflection.Emit {
m_tkProperty = prToken.Token;
m_containingType = containingType;
}
-
+
//************************************************
// Set the default value of the Property
//************************************************
- public void SetConstant(Object defaultValue)
+ public void SetConstant(Object defaultValue)
{
m_containingType.ThrowIfCreated();
-
+
TypeBuilder.SetConstantValue(
m_moduleBuilder,
m_prToken.Token,
m_returnType,
defaultValue);
}
-
+
// Return the Token for this property within the TypeBuilder that the
// property is defined within.
public PropertyToken PropertyToken
{
- get {return m_prToken;}
+ get { return m_prToken; }
}
-
+
public override Module Module
{
- get
+ get
{
return m_containingType.Module;
}
@@ -102,25 +102,25 @@ namespace System.Reflection.Emit {
m_prToken.Token,
semantics,
mdBuilder.GetToken().Token);
- }
+ }
public void SetGetMethod(MethodBuilder mdBuilder)
{
SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.Getter);
m_getMethod = mdBuilder;
}
-
+
public void SetSetMethod(MethodBuilder mdBuilder)
{
SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.Setter);
- m_setMethod = mdBuilder;
+ m_setMethod = mdBuilder;
}
public void AddOtherMethod(MethodBuilder mdBuilder)
{
SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.Other);
}
-
+
// Use this function if client decides to form the custom attribute blob themselves
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
@@ -129,7 +129,7 @@ namespace System.Reflection.Emit {
throw new ArgumentNullException(nameof(con));
if (binaryAttribute == null)
throw new ArgumentNullException(nameof(binaryAttribute));
-
+
m_containingType.ThrowIfCreated();
TypeBuilder.DefineCustomAttribute(
m_moduleBuilder,
@@ -151,29 +151,29 @@ namespace System.Reflection.Emit {
}
// Not supported functions in dynamic module.
- public override Object GetValue(Object obj,Object[] index)
+ public override Object GetValue(Object obj, Object[] index)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
- public override Object GetValue(Object obj,BindingFlags invokeAttr,Binder binder,Object[] index,CultureInfo culture)
+ public override Object GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
- public override void SetValue(Object obj,Object value,Object[] index)
+ public override void SetValue(Object obj, Object value, Object[] index)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
- public override void SetValue(Object obj,Object value,BindingFlags invokeAttr,Binder binder,Object[] index,CultureInfo culture)
+ public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
public override MethodInfo[] GetAccessors(bool nonPublic)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
public override MethodInfo GetGetMethod(bool nonPublic)
@@ -198,61 +198,69 @@ namespace System.Reflection.Emit {
public override ParameterInfo[] GetIndexParameters()
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
- public override Type PropertyType {
+ public override Type PropertyType
+ {
get { return m_returnType; }
}
- public override PropertyAttributes Attributes {
- get { return m_attributes;}
+ public override PropertyAttributes Attributes
+ {
+ get { return m_attributes; }
}
- public override bool CanRead {
- get { if (m_getMethod != null) return true; else return false; } }
+ public override bool CanRead
+ {
+ get { if (m_getMethod != null) return true; else return false; }
+ }
- public override bool CanWrite {
+ public override bool CanWrite
+ {
get { if (m_setMethod != null) return true; else return false; }
}
public override Object[] GetCustomAttributes(bool inherit)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
- public override bool IsDefined (Type attributeType, bool inherit)
+ public override bool IsDefined(Type attributeType, bool inherit)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
- public override String Name {
+ public override String Name
+ {
get { return m_name; }
}
- public override Type DeclaringType {
+ public override Type DeclaringType
+ {
get { return m_containingType; }
}
- public override Type ReflectedType {
+ public override Type ReflectedType
+ {
get { return m_containingType; }
}
// These are package private so that TypeBuilder can access them.
- private String m_name; // The name of the property
- private PropertyToken m_prToken; // The token of this property
- private int m_tkProperty;
- private ModuleBuilder m_moduleBuilder;
- private SignatureHelper m_signature;
- private PropertyAttributes m_attributes; // property's attribute flags
- private Type m_returnType; // property's return type
- private MethodInfo m_getMethod;
- private MethodInfo m_setMethod;
- private TypeBuilder m_containingType;
+ private String m_name; // The name of the property
+ private PropertyToken m_prToken; // The token of this property
+ private int m_tkProperty;
+ private ModuleBuilder m_moduleBuilder;
+ private SignatureHelper m_signature;
+ private PropertyAttributes m_attributes; // property's attribute flags
+ private Type m_returnType; // property's return type
+ private MethodInfo m_getMethod;
+ private MethodInfo m_setMethod;
+ private TypeBuilder m_containingType;
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs b/src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs
index 72ab983bb9..b450b198d2 100644
--- a/src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs
@@ -12,26 +12,29 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
-
- using System;
- using System.Reflection;
+using System;
+using System.Reflection;
+
+namespace System.Reflection.Emit
+{
[Serializable]
- public struct PropertyToken {
-
+ public struct PropertyToken
+ {
public static readonly PropertyToken Empty = new PropertyToken();
internal int m_property;
- internal PropertyToken(int str) {
- m_property=str;
+ internal PropertyToken(int str)
+ {
+ m_property = str;
}
-
- public int Token {
+
+ public int Token
+ {
get { return m_property; }
}
-
+
// Satisfy value class requirements
public override int GetHashCode()
{
@@ -46,23 +49,20 @@ namespace System.Reflection.Emit {
else
return false;
}
-
+
public bool Equals(PropertyToken obj)
{
return obj.m_property == m_property;
}
-
+
public static bool operator ==(PropertyToken a, PropertyToken b)
{
return a.Equals(b);
}
-
+
public static bool operator !=(PropertyToken a, PropertyToken b)
{
return !(a == b);
}
-
}
-
-
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs b/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs
index b43abcb51c..fd1a8e70fe 100644
--- a/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs
@@ -4,23 +4,23 @@
//
-namespace System.Reflection.Emit
+using System.Text;
+using System;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
+
+namespace System.Reflection.Emit
{
- using System.Text;
- using System;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
- using System.Reflection;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- using System.Runtime.Versioning;
-
public sealed class SignatureHelper
{
#region Consts Fields
private const int NO_SIZE_IN_SIG = -1;
#endregion
-
+
#region Static Members
public static SignatureHelper GetMethodSigHelper(Module mod, Type returnType, Type[] parameterTypes)
{
@@ -31,7 +31,7 @@ namespace System.Reflection.Emit
{
return GetMethodSigHelper(mod, callingConvention, cGenericParam, returnType, null, null, null, null, null);
}
-
+
public static SignatureHelper GetMethodSigHelper(Module mod, CallingConventions callingConvention, Type returnType)
{
return GetMethodSigHelper(mod, callingConvention, returnType, null, null, null, null, null);
@@ -41,17 +41,17 @@ namespace System.Reflection.Emit
{
SignatureHelper sigHelp = new SignatureHelper(scope, MdSigCallingConvention.GenericInst);
sigHelp.AddData(inst.Length);
- foreach(Type t in inst)
+ foreach (Type t in inst)
sigHelp.AddArgument(t);
return sigHelp;
}
-
+
internal static SignatureHelper GetMethodSigHelper(
Module scope, CallingConventions callingConvention,
Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers,
Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
{
- return GetMethodSigHelper(scope, callingConvention, 0, returnType, requiredReturnTypeCustomModifiers,
+ return GetMethodSigHelper(scope, callingConvention, 0, returnType, requiredReturnTypeCustomModifiers,
optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
}
@@ -62,11 +62,11 @@ namespace System.Reflection.Emit
{
SignatureHelper sigHelp;
MdSigCallingConvention intCall;
-
+
if (returnType == null)
{
returnType = typeof(void);
- }
+ }
intCall = MdSigCallingConvention.Default;
@@ -81,8 +81,8 @@ namespace System.Reflection.Emit
if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis)
intCall |= MdSigCallingConvention.HasThis;
- sigHelp = new SignatureHelper(scope, intCall, cGenericParam, returnType,
- requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers);
+ sigHelp = new SignatureHelper(scope, intCall, cGenericParam, returnType,
+ requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers);
sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
return sigHelp;
@@ -92,7 +92,7 @@ namespace System.Reflection.Emit
{
SignatureHelper sigHelp;
MdSigCallingConvention intCall;
-
+
if (returnType == null)
returnType = typeof(void);
@@ -114,19 +114,19 @@ namespace System.Reflection.Emit
}
else
{
- throw new ArgumentException(Environment.GetResourceString("Argument_UnknownUnmanagedCallConv"), nameof(unmanagedCallConv));
+ throw new ArgumentException(SR.Argument_UnknownUnmanagedCallConv, nameof(unmanagedCallConv));
}
-
+
sigHelp = new SignatureHelper(mod, intCall, returnType, null, null);
-
+
return sigHelp;
}
public static SignatureHelper GetLocalVarSigHelper()
- {
+ {
return GetLocalVarSigHelper(null);
}
-
+
public static SignatureHelper GetMethodSigHelper(CallingConventions callingConvention, Type returnType)
{
return GetMethodSigHelper(null, callingConvention, returnType);
@@ -141,47 +141,47 @@ namespace System.Reflection.Emit
{
return new SignatureHelper(mod, MdSigCallingConvention.LocalSig);
}
-
+
public static SignatureHelper GetFieldSigHelper(Module mod)
{
return new SignatureHelper(mod, MdSigCallingConvention.Field);
}
-
+
public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] parameterTypes)
{
return GetPropertySigHelper(mod, returnType, null, null, parameterTypes, null, null);
}
- public static SignatureHelper GetPropertySigHelper(Module mod,
- Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers,
+ public static SignatureHelper GetPropertySigHelper(Module mod,
+ Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers,
Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
{
- return GetPropertySigHelper(mod, (CallingConventions)0, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers,
+ return GetPropertySigHelper(mod, (CallingConventions)0, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers,
parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
}
public static SignatureHelper GetPropertySigHelper(Module mod, CallingConventions callingConvention,
- Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers,
+ Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers,
Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
{
SignatureHelper sigHelp;
-
+
if (returnType == null)
{
returnType = typeof(void);
- }
+ }
MdSigCallingConvention intCall = MdSigCallingConvention.Property;
if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis)
intCall |= MdSigCallingConvention.HasThis;
- sigHelp = new SignatureHelper(mod, intCall,
+ sigHelp = new SignatureHelper(mod, intCall,
returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers);
sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers);
return sigHelp;
}
-
+
internal static SignatureHelper GetTypeSigToken(Module module, Type type)
{
if (module == null)
@@ -216,13 +216,13 @@ namespace System.Reflection.Emit
// Use this constructor to instantiate a any signatures that will require a return type.
Init(mod, callingConvention, cGenericParameters);
- if (callingConvention == MdSigCallingConvention.Field)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadFieldSig"));
+ if (callingConvention == MdSigCallingConvention.Field)
+ throw new ArgumentException(SR.Argument_BadFieldSig);
- AddOneArgTypeHelper(returnType, requiredCustomModifiers, optionalCustomModifiers);
+ AddOneArgTypeHelper(returnType, requiredCustomModifiers, optionalCustomModifiers);
}
- private SignatureHelper(Module mod, MdSigCallingConvention callingConvention,
+ private SignatureHelper(Module mod, MdSigCallingConvention callingConvention,
Type returnType, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers)
: this(mod, callingConvention, 0, returnType, requiredCustomModifiers, optionalCustomModifiers)
{
@@ -244,31 +244,31 @@ namespace System.Reflection.Emit
m_sigDone = false;
m_sizeLoc = NO_SIZE_IN_SIG;
- if (m_module == null && mod != null)
- throw new ArgumentException(Environment.GetResourceString("NotSupported_MustBeModuleBuilder"));
+ if (m_module == null && mod != null)
+ throw new ArgumentException(SR.NotSupported_MustBeModuleBuilder);
}
private void Init(Module mod, MdSigCallingConvention callingConvention)
{
Init(mod, callingConvention, 0);
}
-
+
private void Init(Module mod, MdSigCallingConvention callingConvention, int cGenericParam)
- {
+ {
Init(mod);
AddData((byte)callingConvention);
if (callingConvention == MdSigCallingConvention.Field ||
- callingConvention == MdSigCallingConvention.GenericInst)
+ callingConvention == MdSigCallingConvention.GenericInst)
{
m_sizeLoc = NO_SIZE_IN_SIG;
- }
- else
+ }
+ else
{
if (cGenericParam > 0)
AddData(cGenericParam);
-
+
m_sizeLoc = m_currSig++;
}
}
@@ -302,10 +302,10 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(optionalCustomModifiers));
if (t.HasElementType)
- throw new ArgumentException(Environment.GetResourceString("Argument_ArraysInvalid"), nameof(optionalCustomModifiers));
+ throw new ArgumentException(SR.Argument_ArraysInvalid, nameof(optionalCustomModifiers));
if (t.ContainsGenericParameters)
- throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(optionalCustomModifiers));
+ throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(optionalCustomModifiers));
AddElementType(CorElementType.CModOpt);
@@ -325,10 +325,10 @@ namespace System.Reflection.Emit
throw new ArgumentNullException(nameof(requiredCustomModifiers));
if (t.HasElementType)
- throw new ArgumentException(Environment.GetResourceString("Argument_ArraysInvalid"), nameof(requiredCustomModifiers));
+ throw new ArgumentException(SR.Argument_ArraysInvalid, nameof(requiredCustomModifiers));
if (t.ContainsGenericParameters)
- throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(requiredCustomModifiers));
+ throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(requiredCustomModifiers));
AddElementType(CorElementType.CModReqd);
@@ -425,7 +425,7 @@ namespace System.Reflection.Emit
}
else if (clsArgument.IsArray)
{
- if (clsArgument.IsSzArray)
+ if (clsArgument.IsSZArray)
{
AddElementType(CorElementType.SzArray);
@@ -482,7 +482,7 @@ namespace System.Reflection.Emit
}
}
}
-
+
private void AddData(int data)
{
// A managed representation of CorSigCompressData;
@@ -491,80 +491,79 @@ namespace System.Reflection.Emit
{
m_signature = ExpandArray(m_signature);
}
-
+
if (data <= 0x7F)
{
m_signature[m_currSig++] = (byte)(data & 0xFF);
- }
+ }
else if (data <= 0x3FFF)
{
- m_signature[m_currSig++] = (byte)((data >>8) | 0x80);
+ m_signature[m_currSig++] = (byte)((data >> 8) | 0x80);
m_signature[m_currSig++] = (byte)(data & 0xFF);
- }
+ }
else if (data <= 0x1FFFFFFF)
{
- m_signature[m_currSig++] = (byte)((data >>24) | 0xC0);
- m_signature[m_currSig++] = (byte)((data >>16) & 0xFF);
- m_signature[m_currSig++] = (byte)((data >>8) & 0xFF);
+ m_signature[m_currSig++] = (byte)((data >> 24) | 0xC0);
+ m_signature[m_currSig++] = (byte)((data >> 16) & 0xFF);
+ m_signature[m_currSig++] = (byte)((data >> 8) & 0xFF);
m_signature[m_currSig++] = (byte)((data) & 0xFF);
- }
+ }
else
{
- throw new ArgumentException(Environment.GetResourceString("Argument_LargeInteger"));
- }
-
+ throw new ArgumentException(SR.Argument_LargeInteger);
+ }
}
-
+
private void AddElementType(CorElementType cvt)
{
// Adds an element to the signature. A managed represenation of CorSigCompressElement
- if (m_currSig + 1 > m_signature.Length)
+ if (m_currSig + 1 > m_signature.Length)
m_signature = ExpandArray(m_signature);
m_signature[m_currSig++] = (byte)cvt;
}
-
- private void AddToken(int token)
+
+ private void AddToken(int token)
{
// A managed represenation of CompressToken
// Pulls the token appart to get a rid, adds some appropriate bits
// to the token and then adds this to the signature.
- int rid = (token & 0x00FFFFFF); //This is RidFromToken;
+ int rid = (token & 0x00FFFFFF); //This is RidFromToken;
MetadataTokenType type = (MetadataTokenType)(token & unchecked((int)0xFF000000)); //This is TypeFromToken;
-
- if (rid > 0x3FFFFFF)
+
+ if (rid > 0x3FFFFFF)
{
// token is too big to be compressed
- throw new ArgumentException(Environment.GetResourceString("Argument_LargeInteger"));
+ throw new ArgumentException(SR.Argument_LargeInteger);
}
-
- rid = (rid << 2);
-
+
+ rid = (rid << 2);
+
// TypeDef is encoded with low bits 00
// TypeRef is encoded with low bits 01
// TypeSpec is encoded with low bits 10
- if (type == MetadataTokenType.TypeRef)
- {
+ if (type == MetadataTokenType.TypeRef)
+ {
//if type is mdtTypeRef
- rid|=0x1;
- }
- else if (type == MetadataTokenType.TypeSpec)
- {
+ rid |= 0x1;
+ }
+ else if (type == MetadataTokenType.TypeSpec)
+ {
//if type is mdtTypeSpec
- rid|=0x2;
+ rid |= 0x2;
}
-
+
AddData(rid);
}
-
+
private void InternalAddTypeToken(TypeToken clsToken, CorElementType CorType)
{
// Add a type token into signature. CorType will be either CorElementType.Class or CorElementType.ValueType
AddElementType(CorType);
AddToken(clsToken.Token);
}
-
+
private unsafe void InternalAddRuntimeType(Type type)
{
// Add a runtime type into the signature.
@@ -580,11 +579,11 @@ namespace System.Reflection.Emit
if (m_currSig + sizeof(void*) > m_signature.Length)
m_signature = ExpandArray(m_signature);
- byte *phandle = (byte*)&handle;
+ byte* phandle = (byte*)&handle;
for (int i = 0; i < sizeof(void*); i++)
m_signature[m_currSig++] = phandle[i];
}
-
+
private byte[] ExpandArray(byte[] inArray)
{
// Expand the signature buffer size
@@ -595,25 +594,25 @@ namespace System.Reflection.Emit
{
// Expand the signature buffer size
- if (requiredLength < inArray.Length)
- requiredLength = inArray.Length*2;
+ if (requiredLength < inArray.Length)
+ requiredLength = inArray.Length * 2;
byte[] outArray = new byte[requiredLength];
Buffer.BlockCopy(inArray, 0, outArray, 0, inArray.Length);
return outArray;
}
-
+
private void IncrementArgCounts()
{
- if (m_sizeLoc == NO_SIZE_IN_SIG)
- {
+ if (m_sizeLoc == NO_SIZE_IN_SIG)
+ {
//We don't have a size if this is a field.
return;
}
m_argCount++;
}
-
+
private void SetNumberOfSignatureElements(bool forceCopy)
{
// For most signatures, this will set the number of elements in a byte which we have reserved for it.
@@ -628,18 +627,18 @@ namespace System.Reflection.Emit
byte[] temp;
int newSigSize;
int currSigHolder = m_currSig;
-
- if (m_sizeLoc == NO_SIZE_IN_SIG)
+
+ if (m_sizeLoc == NO_SIZE_IN_SIG)
return;
-
+
//If we have fewer than 128 arguments and we haven't been told to copy the
//array, we can just set the appropriate bit and return.
- if (m_argCount < 0x80 && !forceCopy)
+ if (m_argCount < 0x80 && !forceCopy)
{
m_signature[m_sizeLoc] = (byte)m_argCount;
return;
- }
-
+ }
+
//We need to have more bytes for the size. Figure out how many bytes here.
//Since we need to copy anyway, we're just going to take the cost of doing a
//new allocation.
@@ -655,45 +654,45 @@ namespace System.Reflection.Emit
{
newSigSize = 4;
}
-
+
//Allocate the new array.
temp = new byte[m_currSig + newSigSize - 1];
-
+
//Copy the calling convention. The calling convention is always just one byte
//so we just copy that byte. Then copy the rest of the array, shifting everything
//to make room for the new number of elements.
temp[0] = m_signature[0];
Buffer.BlockCopy(m_signature, m_sizeLoc + 1, temp, m_sizeLoc + newSigSize, currSigHolder - (m_sizeLoc + 1));
m_signature = temp;
-
+
//Use the AddData method to add the number of elements appropriately compressed.
m_currSig = m_sizeLoc;
AddData(m_argCount);
m_currSig = currSigHolder + (newSigSize - 1);
}
-
+
#endregion
#region Internal Members
internal int ArgumentCount
- {
- get
- {
- return m_argCount;
- }
+ {
+ get
+ {
+ return m_argCount;
+ }
}
internal static bool IsSimpleType(CorElementType type)
{
- if (type <= CorElementType.String)
+ if (type <= CorElementType.String)
return true;
- if (type == CorElementType.TypedByRef || type == CorElementType.I || type == CorElementType.U || type == CorElementType.Object)
+ if (type == CorElementType.TypedByRef || type == CorElementType.I || type == CorElementType.U || type == CorElementType.Object)
return true;
return false;
}
-
+
internal byte[] InternalGetSignature(out int length)
{
// An internal method to return the signature. Does not trim the
@@ -703,7 +702,7 @@ namespace System.Reflection.Emit
//
// param length : an out param indicating the length of the array.
// return : A reference to the internal ubyte array.
-
+
if (!m_sigDone)
{
m_sigDone = true;
@@ -713,20 +712,20 @@ namespace System.Reflection.Emit
// array. Bummer, eh?
SetNumberOfSignatureElements(false);
}
-
+
length = m_currSig;
return m_signature;
}
-
-
-
-
+
+
+
+
internal byte[] InternalGetSignatureArray()
{
- int argCount = m_argCount;
+ int argCount = m_argCount;
int currSigLength = m_currSig;
int newSigSize = currSigLength;
-
+
//Allocate the new array.
if (argCount < 0x7F)
newSigSize += 1;
@@ -745,26 +744,26 @@ namespace System.Reflection.Emit
temp[sigCopyIndex++] = (byte)(argCount & 0xFF);
else if (argCount <= 0x3FFF)
{
- temp[sigCopyIndex++] = (byte)((argCount >>8) | 0x80);
+ temp[sigCopyIndex++] = (byte)((argCount >> 8) | 0x80);
temp[sigCopyIndex++] = (byte)(argCount & 0xFF);
- }
+ }
else if (argCount <= 0x1FFFFFFF)
{
- temp[sigCopyIndex++] = (byte)((argCount >>24) | 0xC0);
- temp[sigCopyIndex++] = (byte)((argCount >>16) & 0xFF);
- temp[sigCopyIndex++] = (byte)((argCount >>8) & 0xFF);
+ temp[sigCopyIndex++] = (byte)((argCount >> 24) | 0xC0);
+ temp[sigCopyIndex++] = (byte)((argCount >> 16) & 0xFF);
+ temp[sigCopyIndex++] = (byte)((argCount >> 8) & 0xFF);
temp[sigCopyIndex++] = (byte)((argCount) & 0xFF);
- }
+ }
else
- throw new ArgumentException(Environment.GetResourceString("Argument_LargeInteger"));
+ throw new ArgumentException(SR.Argument_LargeInteger);
// copy the sig part of the sig
Buffer.BlockCopy(m_signature, 2, temp, sigCopyIndex, currSigLength - 2);
// mark the end of sig
temp[newSigSize - 1] = (byte)CorElementType.End;
-
+
return temp;
}
-
+
#endregion
#region Public Methods
@@ -781,21 +780,21 @@ namespace System.Reflection.Emit
IncrementArgCounts();
AddOneArgTypeHelper(argument, pinned);
}
-
+
public void AddArguments(Type[] arguments, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers)
{
if (requiredCustomModifiers != null && (arguments == null || requiredCustomModifiers.Length != arguments.Length))
- throw new ArgumentException(Environment.GetResourceString("Argument_MismatchedArrays", nameof(requiredCustomModifiers), nameof(arguments)));
+ throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, nameof(requiredCustomModifiers), nameof(arguments)));
if (optionalCustomModifiers != null && (arguments == null || optionalCustomModifiers.Length != arguments.Length))
- throw new ArgumentException(Environment.GetResourceString("Argument_MismatchedArrays", nameof(optionalCustomModifiers), nameof(arguments)));
+ throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, nameof(optionalCustomModifiers), nameof(arguments)));
if (arguments != null)
{
- for (int i =0; i < arguments.Length; i++)
+ for (int i = 0; i < arguments.Length; i++)
{
- AddArgument(arguments[i],
- requiredCustomModifiers == null ? null : requiredCustomModifiers[i],
+ AddArgument(arguments[i],
+ requiredCustomModifiers == null ? null : requiredCustomModifiers[i],
optionalCustomModifiers == null ? null : optionalCustomModifiers[i]);
}
}
@@ -804,13 +803,13 @@ namespace System.Reflection.Emit
public void AddArgument(Type argument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers)
{
if (m_sigDone)
- throw new ArgumentException(Environment.GetResourceString("Argument_SigIsFinalized"));
-
+ throw new ArgumentException(SR.Argument_SigIsFinalized);
+
if (argument == null)
throw new ArgumentNullException(nameof(argument));
IncrementArgCounts();
-
+
// Add an argument to the signature. Takes a Type and determines whether it
// is one of the primitive types of which we have special knowledge or a more
// general class. In the former case, we only add the appropriate short cut encoding,
@@ -825,26 +824,26 @@ namespace System.Reflection.Emit
public override bool Equals(Object obj)
{
- if (!(obj is SignatureHelper))
+ if (!(obj is SignatureHelper))
{
return false;
}
-
+
SignatureHelper temp = (SignatureHelper)obj;
-
- if ( !temp.m_module.Equals(m_module) || temp.m_currSig!=m_currSig || temp.m_sizeLoc!=m_sizeLoc || temp.m_sigDone !=m_sigDone )
+
+ if (!temp.m_module.Equals(m_module) || temp.m_currSig != m_currSig || temp.m_sizeLoc != m_sizeLoc || temp.m_sigDone != m_sigDone)
{
return false;
}
-
- for (int i=0; i<m_currSig; i++)
+
+ for (int i = 0; i < m_currSig; i++)
{
- if (m_signature[i]!=temp.m_signature[i])
+ if (m_signature[i] != temp.m_signature[i])
return false;
}
return true;
}
-
+
public override int GetHashCode()
{
// Start the hash code with the hash code of the module and the values of the member variables.
@@ -855,7 +854,7 @@ namespace System.Reflection.Emit
HashCode += 1;
// Then add the hash code of all the arguments.
- for (int i=0; i < m_currSig; i++)
+ for (int i = 0; i < m_currSig; i++)
HashCode += m_signature[i].GetHashCode();
return HashCode;
@@ -865,23 +864,23 @@ namespace System.Reflection.Emit
{
return GetSignature(false);
}
-
+
internal byte[] GetSignature(bool appendEndOfSig)
{
// Chops the internal signature to the appropriate length. Adds the
// end token to the signature and marks the signature as finished so that
// no further tokens can be added. Return the full signature in a trimmed array.
- if (!m_sigDone)
+ if (!m_sigDone)
{
- if (appendEndOfSig)
+ if (appendEndOfSig)
AddElementType(CorElementType.End);
SetNumberOfSignatureElements(true);
m_sigDone = true;
}
-
+
// This case will only happen if the user got the signature through
// InternalGetSignature first and then called GetSignature.
- if (m_signature.Length > m_currSig)
+ if (m_signature.Length > m_currSig)
{
byte[] temp = new byte[m_currSig];
Array.Copy(m_signature, 0, temp, 0, m_currSig);
@@ -890,7 +889,7 @@ namespace System.Reflection.Emit
return m_signature;
}
-
+
public override String ToString()
{
StringBuilder sb = new StringBuilder();
@@ -906,7 +905,7 @@ namespace System.Reflection.Emit
}
sb.Append("Signature: " + Environment.NewLine);
- for (int i=0; i<=m_currSig; i++)
+ for (int i = 0; i <= m_currSig; i++)
{
sb.Append(m_signature[i] + " ");
}
@@ -914,9 +913,8 @@ namespace System.Reflection.Emit
sb.Append(Environment.NewLine);
return sb.ToString();
}
-
- #endregion
+ #endregion
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs b/src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs
index 5c908b89c7..e17e0c955e 100644
--- a/src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs
@@ -13,32 +13,35 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
-
- using System;
- using System.Reflection;
- public struct SignatureToken {
-
+using System;
+using System.Reflection;
+
+namespace System.Reflection.Emit
+{
+ public struct SignatureToken
+ {
public static readonly SignatureToken Empty = new SignatureToken();
internal int m_signature;
internal ModuleBuilder m_moduleBuilder;
-
- internal SignatureToken(int str, ModuleBuilder mod) {
- m_signature=str;
+
+ internal SignatureToken(int str, ModuleBuilder mod)
+ {
+ m_signature = str;
m_moduleBuilder = mod;
}
-
- public int Token {
+
+ public int Token
+ {
get { return m_signature; }
}
-
+
public override int GetHashCode()
{
return m_signature;
}
-
+
public override bool Equals(Object obj)
{
if (obj is SignatureToken)
@@ -46,21 +49,20 @@ namespace System.Reflection.Emit {
else
return false;
}
-
+
public bool Equals(SignatureToken obj)
{
return obj.m_signature == m_signature;
}
-
+
public static bool operator ==(SignatureToken a, SignatureToken b)
{
return a.Equals(b);
}
-
+
public static bool operator !=(SignatureToken a, SignatureToken b)
{
return !(a == b);
}
-
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs b/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs
index 8a447d03fc..afcf2ddf0a 100644
--- a/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs
@@ -12,42 +12,42 @@
** THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND!
** See clr\src\inc\opcodegen.pl for more information.**
============================================================*/
-namespace System.Reflection.Emit {
using System;
-[Serializable]
-public enum StackBehaviour
+namespace System.Reflection.Emit
{
-
- Pop0 = 0,
- Pop1 = 1,
- Pop1_pop1 = 2,
- Popi = 3,
- Popi_pop1 = 4,
- Popi_popi = 5,
- Popi_popi8 = 6,
- Popi_popi_popi = 7,
- Popi_popr4 = 8,
- Popi_popr8 = 9,
- Popref = 10,
- Popref_pop1 = 11,
- Popref_popi = 12,
- Popref_popi_popi = 13,
- Popref_popi_popi8 = 14,
- Popref_popi_popr4 = 15,
- Popref_popi_popr8 = 16,
- Popref_popi_popref = 17,
- Push0 = 18,
- Push1 = 19,
- Push1_push1 = 20,
- Pushi = 21,
- Pushi8 = 22,
- Pushr4 = 23,
- Pushr8 = 24,
- Pushref = 25,
- Varpop = 26,
- Varpush = 27,
- Popref_popi_pop1 = 28,
-}
+ [Serializable]
+ public enum StackBehaviour
+ {
+ Pop0 = 0,
+ Pop1 = 1,
+ Pop1_pop1 = 2,
+ Popi = 3,
+ Popi_pop1 = 4,
+ Popi_popi = 5,
+ Popi_popi8 = 6,
+ Popi_popi_popi = 7,
+ Popi_popr4 = 8,
+ Popi_popr8 = 9,
+ Popref = 10,
+ Popref_pop1 = 11,
+ Popref_popi = 12,
+ Popref_popi_popi = 13,
+ Popref_popi_popi8 = 14,
+ Popref_popi_popr4 = 15,
+ Popref_popi_popr8 = 16,
+ Popref_popi_popref = 17,
+ Push0 = 18,
+ Push1 = 19,
+ Push1_push1 = 20,
+ Pushi = 21,
+ Pushi8 = 22,
+ Pushr4 = 23,
+ Pushr8 = 24,
+ Pushref = 25,
+ Varpop = 26,
+ Varpush = 27,
+ Popref_popi_pop1 = 28,
+ }
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/StringToken.cs b/src/mscorlib/src/System/Reflection/Emit/StringToken.cs
index 852225697c..1d90816fc6 100644
--- a/src/mscorlib/src/System/Reflection/Emit/StringToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/StringToken.cs
@@ -12,36 +12,39 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
-
- using System;
- using System.Reflection;
+using System;
+using System.Reflection;
+
+namespace System.Reflection.Emit
+{
[Serializable]
- public struct StringToken {
-
+ public struct StringToken
+ {
internal int m_string;
-
+
//public StringToken() {
// m_string=0;
//}
-
- internal StringToken(int str) {
- m_string=str;
+
+ internal StringToken(int str)
+ {
+ m_string = str;
}
-
+
// Returns the metadata token for this particular string.
// Generated by a call to Module.GetStringConstant().
//
- public int Token {
+ public int Token
+ {
get { return m_string; }
}
-
+
public override int GetHashCode()
{
return m_string;
}
-
+
public override bool Equals(Object obj)
{
if (obj is StringToken)
@@ -49,29 +52,20 @@ namespace System.Reflection.Emit {
else
return false;
}
-
+
public bool Equals(StringToken obj)
{
return obj.m_string == m_string;
}
-
+
public static bool operator ==(StringToken a, StringToken b)
{
return a.Equals(b);
}
-
+
public static bool operator !=(StringToken a, StringToken b)
{
return !(a == b);
}
-
}
-
-
-
-
-
-
-
-
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs b/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs
index 6b47770608..42713b86db 100644
--- a/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs
@@ -4,14 +4,14 @@
//
-namespace System.Reflection.Emit
+namespace System.Reflection.Emit
{
using System.Runtime.InteropServices;
using System;
using System.Reflection;
using System.Diagnostics.Contracts;
using CultureInfo = System.Globalization.CultureInfo;
-
+
internal sealed class SymbolMethod : MethodInfo
{
#region Private Data Members
@@ -26,7 +26,7 @@ namespace System.Reflection.Emit
#endregion
#region Constructor
- internal SymbolMethod(ModuleBuilder mod, MethodToken token, Type arrayClass, String methodName,
+ internal SymbolMethod(ModuleBuilder mod, MethodToken token, Type arrayClass, String methodName,
CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
{
// This is a kind of MethodInfo to represent methods for array type of unbaked type
@@ -47,9 +47,9 @@ namespace System.Reflection.Emit
}
else
{
- m_parameterTypes = EmptyArray<Type>.Value;
+ m_parameterTypes = Array.Empty<Type>();
}
-
+
m_module = mod;
m_containingType = arrayClass;
m_name = methodName;
@@ -70,28 +70,28 @@ namespace System.Reflection.Emit
{
return mod.GetArrayMethodToken(m_containingType, m_name, m_callingConvention, m_returnType, m_parameterTypes);
}
-
+
#endregion
#region MemberInfo Overrides
- public override Module Module
- {
- get { return m_module; }
- }
+ public override Module Module
+ {
+ get { return m_module; }
+ }
public override Type ReflectedType
{
get { return m_containingType as Type; }
}
- public override String Name
+ public override String Name
{
get { return m_name; }
}
- public override Type DeclaringType
+ public override Type DeclaringType
{
- get {return m_containingType;}
+ get { return m_containingType; }
}
#endregion
@@ -99,27 +99,27 @@ namespace System.Reflection.Emit
[Pure]
public override ParameterInfo[] GetParameters()
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod"));
+ throw new NotSupportedException(SR.NotSupported_SymbolMethod);
}
-
+
public override MethodImplAttributes GetMethodImplementationFlags()
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod"));
+ throw new NotSupportedException(SR.NotSupported_SymbolMethod);
}
-
- public override MethodAttributes Attributes
+
+ public override MethodAttributes Attributes
{
- get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); }
+ get { throw new NotSupportedException(SR.NotSupported_SymbolMethod); }
}
-
- public override CallingConventions CallingConvention
+
+ public override CallingConventions CallingConvention
{
get { return m_callingConvention; }
}
- public override RuntimeMethodHandle MethodHandle
+ public override RuntimeMethodHandle MethodHandle
{
- get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); }
+ get { throw new NotSupportedException(SR.NotSupported_SymbolMethod); }
}
#endregion
@@ -133,16 +133,16 @@ namespace System.Reflection.Emit
}
}
- public override ICustomAttributeProvider ReturnTypeCustomAttributes
+ public override ICustomAttributeProvider ReturnTypeCustomAttributes
{
- get { return null; }
+ get { return null; }
}
-
+
public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod"));
+ throw new NotSupportedException(SR.NotSupported_SymbolMethod);
}
-
+
public override MethodInfo GetBaseDefinition()
{
return this;
@@ -152,19 +152,19 @@ namespace System.Reflection.Emit
#region ICustomAttributeProvider Implementation
public override Object[] GetCustomAttributes(bool inherit)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod"));
+ throw new NotSupportedException(SR.NotSupported_SymbolMethod);
}
-
+
public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod"));
+ throw new NotSupportedException(SR.NotSupported_SymbolMethod);
}
public override bool IsDefined(Type attributeType, bool inherit)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod"));
+ throw new NotSupportedException(SR.NotSupported_SymbolMethod);
}
-
+
#endregion
#region Public Members
diff --git a/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs b/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs
index 205299125b..16848b43dd 100644
--- a/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs
@@ -4,7 +4,7 @@
//
-namespace System.Reflection.Emit
+namespace System.Reflection.Emit
{
using System.Runtime.InteropServices;
using System;
@@ -15,16 +15,17 @@ namespace System.Reflection.Emit
[Serializable]
internal enum TypeKind
{
- IsArray = 1,
+ IsArray = 1,
IsPointer = 2,
- IsByRef = 3,
+ IsByRef = 3,
}
// This is a kind of Type object that will represent the compound expression of a parameter type or field type.
internal sealed class SymbolType : TypeInfo
{
- public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
- if(typeInfo==null) return false;
+ public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo)
+ {
+ if (typeInfo == null) return false;
return IsAssignableFrom(typeInfo.AsType());
}
@@ -52,8 +53,8 @@ namespace System.Reflection.Emit
return baseType;
}
-
-
+
+
if (format[curIndex] == '&')
{
@@ -62,10 +63,10 @@ namespace System.Reflection.Emit
symbolType = new SymbolType(TypeKind.IsByRef);
symbolType.SetFormat(format, curIndex, 1);
curIndex++;
-
+
if (curIndex != format.Length)
// ByRef has to be the last char!!
- throw new ArgumentException(Environment.GetResourceString("Argument_BadSigFormat"));
+ throw new ArgumentException(SR.Argument_BadSigFormat);
symbolType.SetElementType(baseType);
return symbolType;
@@ -84,13 +85,13 @@ namespace System.Reflection.Emit
// Example: [2..4] - one dimension array with lower bound 2 and size of 3
// Example: [3, 5, 6] - three dimension array with lower bound 3, 5, 6
// Example: [-3, ] [] - one dimensional array of two dimensional array (with lower bound -3 sepcified)
-
+
while (format[curIndex] != ']')
{
if (format[curIndex] == '*')
{
symbolType.m_isSzArray = false;
- curIndex++;
+ curIndex++;
}
// consume, one dimension at a time
if ((format[curIndex] >= '0' && format[curIndex] <= '9') || format[curIndex] == '-')
@@ -117,10 +118,9 @@ namespace System.Reflection.Emit
// set the upper bound to be less than LowerBound to indicate that upper bound it not specified yet!
iUpperBound = iLowerBound - 1;
-
}
if (format[curIndex] == '.')
- {
+ {
// upper bound is specified
// skip over ".."
@@ -128,7 +128,7 @@ namespace System.Reflection.Emit
if (format[curIndex] != '.')
{
// bad format!! Throw exception
- throw new ArgumentException(Environment.GetResourceString("Argument_BadSigFormat"));
+ throw new ArgumentException(SR.Argument_BadSigFormat);
}
curIndex++;
@@ -158,7 +158,7 @@ namespace System.Reflection.Emit
{
// User specified upper bound less than lower bound, this is an error.
// Throw error exception.
- throw new ArgumentException(Environment.GetResourceString("Argument_BadSigFormat"));
+ throw new ArgumentException(SR.Argument_BadSigFormat);
}
}
}
@@ -176,10 +176,10 @@ namespace System.Reflection.Emit
}
else if (format[curIndex] != ']')
{
- throw new ArgumentException(Environment.GetResourceString("Argument_BadSigFormat"));
+ throw new ArgumentException(SR.Argument_BadSigFormat);
}
}
-
+
// The last dimension information
symbolType.SetBounds(iLowerBound, iUpperBound);
@@ -209,21 +209,21 @@ namespace System.Reflection.Emit
#endregion
#region Data Members
- internal TypeKind m_typeKind;
- internal Type m_baseType;
- internal int m_cRank; // count of dimension
+ internal TypeKind m_typeKind;
+ internal Type m_baseType;
+ internal int m_cRank; // count of dimension
// If LowerBound and UpperBound is equal, that means one element.
// If UpperBound is less than LowerBound, then the size is not specified.
- internal int[] m_iaLowerBound;
- internal int[] m_iaUpperBound; // count of dimension
- private string m_format; // format string to form the full name.
- private bool m_isSzArray = true;
+ internal int[] m_iaLowerBound;
+ internal int[] m_iaUpperBound; // count of dimension
+ private string m_format; // format string to form the full name.
+ private bool m_isSzArray = true;
#endregion
#region Constructor
internal SymbolType(TypeKind typeKind)
{
- m_typeKind = typeKind;
+ m_typeKind = typeKind;
m_iaLowerBound = new int[4];
m_iaUpperBound = new int[4];
}
@@ -246,15 +246,15 @@ namespace System.Reflection.Emit
if (lower != 0 || upper != -1)
m_isSzArray = false;
-
+
if (m_iaLowerBound.Length <= m_cRank)
{
// resize the bound array
- int[] iaTemp = new int[m_cRank * 2];
+ int[] iaTemp = new int[m_cRank * 2];
Array.Copy(m_iaLowerBound, 0, iaTemp, 0, m_cRank);
- m_iaLowerBound = iaTemp;
+ m_iaLowerBound = iaTemp;
Array.Copy(m_iaUpperBound, 0, iaTemp, 0, m_cRank);
- m_iaUpperBound = iaTemp;
+ m_iaUpperBound = iaTemp;
}
m_iaLowerBound[m_cRank] = lower;
@@ -269,36 +269,27 @@ namespace System.Reflection.Emit
m_format = format.Substring(curIndex, length);
}
#endregion
-
+
#region Type Overrides
- internal override bool IsSzArray
- {
- get
- {
- if (m_cRank > 1)
- return false;
-
- return m_isSzArray;
- }
- }
+ public override bool IsSZArray => m_cRank <= 1 && m_isSzArray;
- public override Type MakePointerType()
- {
+ public override Type MakePointerType()
+ {
return SymbolType.FormCompoundType(m_format + "*", m_baseType, 0);
}
- public override Type MakeByRefType()
- {
+ public override Type MakeByRefType()
+ {
return SymbolType.FormCompoundType(m_format + "&", m_baseType, 0);
}
-
- public override Type MakeArrayType()
- {
+
+ public override Type MakeArrayType()
+ {
return SymbolType.FormCompoundType(m_format + "[]", m_baseType, 0);
}
-
- public override Type MakeArrayType(int rank)
- {
+
+ public override Type MakeArrayType(int rank)
+ {
if (rank <= 0)
throw new IndexOutOfRangeException();
Contract.EndContractBlock();
@@ -308,9 +299,9 @@ namespace System.Reflection.Emit
{
szrank = "*";
}
- else
+ else
{
- for(int i = 1; i < rank; i++)
+ for (int i = 1; i < rank; i++)
szrank += ",";
}
@@ -322,55 +313,55 @@ namespace System.Reflection.Emit
public override int GetArrayRank()
{
if (!IsArray)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride"));
+ throw new NotSupportedException(SR.NotSupported_SubclassOverride);
Contract.EndContractBlock();
return m_cRank;
}
-
- public override Guid GUID
+
+ public override Guid GUID
{
- get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); }
+ get { throw new NotSupportedException(SR.NotSupported_NonReflectedType); }
}
- public override Object InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target,
+ public override Object InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target,
Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
- public override Module Module
+ public override Module Module
{
- get
+ get
{
Type baseType;
- for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType) baseType).m_baseType);
+ for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType)baseType).m_baseType) ;
return baseType.Module;
}
}
- public override Assembly Assembly
+ public override Assembly Assembly
{
- get
+ get
{
Type baseType;
- for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType) baseType).m_baseType);
+ for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType)baseType).m_baseType) ;
return baseType.Assembly;
}
}
-
- public override RuntimeTypeHandle TypeHandle
+
+ public override RuntimeTypeHandle TypeHandle
{
- get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); }
+ get { throw new NotSupportedException(SR.NotSupported_NonReflectedType); }
}
-
- public override String Name
+
+ public override String Name
{
- get
- {
+ get
+ {
Type baseType;
String sFormat = m_format;
@@ -380,140 +371,139 @@ namespace System.Reflection.Emit
return baseType.Name + sFormat;
}
}
-
- public override String FullName
+
+ public override String FullName
{
- get
- {
+ get
+ {
return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.FullName);
}
}
- public override String AssemblyQualifiedName
+ public override String AssemblyQualifiedName
{
- get
- {
+ get
+ {
return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.AssemblyQualifiedName);
}
}
public override String ToString()
- {
- return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString);
+ {
+ return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString);
}
-
- public override String Namespace
+
+ public override String Namespace
{
get { return m_baseType.Namespace; }
}
-
- public override Type BaseType
+
+ public override Type BaseType
{
-
get { return typeof(System.Array); }
}
-
- protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr,Binder binder,
- CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers)
+
+ protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
+ CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
+
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
- protected override MethodInfo GetMethodImpl(String name,BindingFlags bindingAttr,Binder binder,
- CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers)
+
+ protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder,
+ CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
+
public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
+
public override FieldInfo GetField(String name, BindingFlags bindingAttr)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
+
public override FieldInfo[] GetFields(BindingFlags bindingAttr)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
- public override Type GetInterface(String name,bool ignoreCase)
+
+ public override Type GetInterface(String name, bool ignoreCase)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
+
public override Type[] GetInterfaces()
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
- public override EventInfo GetEvent(String name,BindingFlags bindingAttr)
+
+ public override EventInfo GetEvent(String name, BindingFlags bindingAttr)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
+
public override EventInfo[] GetEvents()
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
- protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder,
+
+ protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder,
Type returnType, Type[] types, ParameterModifier[] modifiers)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
+
public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
public override Type[] GetNestedTypes(BindingFlags bindingAttr)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
+
public override Type GetNestedType(String name, BindingFlags bindingAttr)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
- public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr)
+ public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
+
public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
public override InterfaceMapping GetInterfaceMap(Type interfaceType)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
public override EventInfo[] GetEvents(BindingFlags bindingAttr)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
-
+
protected override TypeAttributes GetAttributeFlagsImpl()
{
// Return the attribute flags of the base type?
Type baseType;
- for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType)baseType).m_baseType);
+ for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType)baseType).m_baseType) ;
return baseType.Attributes;
}
-
+
protected override bool IsArrayImpl()
{
return m_typeKind == TypeKind.IsArray;
@@ -533,12 +523,12 @@ namespace System.Reflection.Emit
{
return false;
}
-
- protected override bool IsValueTypeImpl()
+
+ protected override bool IsValueTypeImpl()
{
return false;
}
-
+
protected override bool IsCOMObjectImpl()
{
return false;
@@ -556,31 +546,30 @@ namespace System.Reflection.Emit
{
return m_baseType;
}
-
+
protected override bool HasElementTypeImpl()
{
return m_baseType != null;
}
-
- public override Type UnderlyingSystemType
+
+ public override Type UnderlyingSystemType
{
-
get { return this; }
}
-
+
public override Object[] GetCustomAttributes(bool inherit)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
- public override bool IsDefined (Type attributeType, bool inherit)
+ public override bool IsDefined(Type attributeType, bool inherit)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType"));
+ throw new NotSupportedException(SR.NotSupported_NonReflectedType);
}
#endregion
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
index 88502cb096..a98af2bdcf 100644
--- a/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
@@ -5,7 +5,8 @@
//
-namespace System.Reflection.Emit {
+namespace System.Reflection.Emit
+{
using System;
using System.Reflection;
using System.Security;
@@ -22,21 +23,22 @@ namespace System.Reflection.Emit {
[Serializable]
public enum PackingSize
{
- Unspecified = 0,
- Size1 = 1,
- Size2 = 2,
- Size4 = 4,
- Size8 = 8,
- Size16 = 16,
- Size32 = 32,
- Size64 = 64,
- Size128 = 128,
+ Unspecified = 0,
+ Size1 = 1,
+ Size2 = 2,
+ Size4 = 4,
+ Size8 = 8,
+ Size16 = 16,
+ Size32 = 32,
+ Size64 = 64,
+ Size128 = 128,
}
public sealed class TypeBuilder : TypeInfo
{
- public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
- if(typeInfo==null) return false;
+ public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo)
+ {
+ if (typeInfo == null) return false;
return IsAssignableFrom(typeInfo.AsType());
}
@@ -46,7 +48,7 @@ namespace System.Reflection.Emit {
private ConstructorInfo m_con;
private byte[] m_binaryAttribute;
private CustomAttributeBuilder m_customBuilder;
-
+
public CustAttr(ConstructorInfo con, byte[] binaryAttribute)
{
if (con == null)
@@ -83,12 +85,12 @@ namespace System.Reflection.Emit {
}
}
#endregion
-
+
#region Public Static Methods
public static MethodInfo GetMethod(Type type, MethodInfo method)
{
if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeTypeBuilder"));
+ throw new ArgumentException(SR.Argument_MustBeTypeBuilder);
// The following checks establishes invariants that more simply put require type to be generic and
// method to be a generic method definition declared on the generic type definition of type.
@@ -96,15 +98,15 @@ namespace System.Reflection.Emit {
// this function followed by MakeGenericMethod on the resulting MethodInfo to finally get G<Foo>.M<Bar>.
// We could also allow G<T>.M<Bar> to be created before G<Foo>.M<Bar> (BindGenParm followed by this method)
// if we wanted to but that just complicates things so these checks are designed to prevent that scenario.
-
+
if (method.IsGenericMethod && !method.IsGenericMethodDefinition)
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedGenericMethodDefinition"), nameof(method));
-
+ throw new ArgumentException(SR.Argument_NeedGenericMethodDefinition, nameof(method));
+
if (method.DeclaringType == null || !method.DeclaringType.IsGenericTypeDefinition)
- throw new ArgumentException(Environment.GetResourceString("Argument_MethodNeedGenericDeclaringType"), nameof(method));
-
+ throw new ArgumentException(SR.Argument_MethodNeedGenericDeclaringType, nameof(method));
+
if (type.GetGenericTypeDefinition() != method.DeclaringType)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidMethodDeclaringType"), nameof(type));
+ throw new ArgumentException(SR.Argument_InvalidMethodDeclaringType, nameof(type));
Contract.EndContractBlock();
// The following converts from Type or TypeBuilder of G<T> to TypeBuilderInstantiation G<T>. These types
@@ -112,51 +114,51 @@ namespace System.Reflection.Emit {
// G<M>.M() be encoded by a typeSpec whose parent is the typeDef for G<M> and whose instantiation is also G<M>.
if (type.IsGenericTypeDefinition)
type = type.MakeGenericType(type.GetGenericArguments());
-
+
if (!(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(type));
+ throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type));
return MethodOnTypeBuilderInstantiation.GetMethod(method, type as TypeBuilderInstantiation);
}
public static ConstructorInfo GetConstructor(Type type, ConstructorInfo constructor)
- {
+ {
if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeTypeBuilder"));
+ throw new ArgumentException(SR.Argument_MustBeTypeBuilder);
if (!constructor.DeclaringType.IsGenericTypeDefinition)
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstructorNeedGenericDeclaringType"), nameof(constructor));
+ throw new ArgumentException(SR.Argument_ConstructorNeedGenericDeclaringType, nameof(constructor));
Contract.EndContractBlock();
-
+
if (!(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(type));
+ throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type));
// TypeBuilder G<T> ==> TypeBuilderInstantiation G<T>
if (type is TypeBuilder && type.IsGenericTypeDefinition)
type = type.MakeGenericType(type.GetGenericArguments());
if (type.GetGenericTypeDefinition() != constructor.DeclaringType)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidConstructorDeclaringType"), nameof(type));
+ throw new ArgumentException(SR.Argument_InvalidConstructorDeclaringType, nameof(type));
return ConstructorOnTypeBuilderInstantiation.GetConstructor(constructor, type as TypeBuilderInstantiation);
}
public static FieldInfo GetField(Type type, FieldInfo field)
{
if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeTypeBuilder"));
+ throw new ArgumentException(SR.Argument_MustBeTypeBuilder);
if (!field.DeclaringType.IsGenericTypeDefinition)
- throw new ArgumentException(Environment.GetResourceString("Argument_FieldNeedGenericDeclaringType"), nameof(field));
+ throw new ArgumentException(SR.Argument_FieldNeedGenericDeclaringType, nameof(field));
Contract.EndContractBlock();
-
+
if (!(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(type));
+ throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type));
// TypeBuilder G<T> ==> TypeBuilderInstantiation G<T>
if (type is TypeBuilder && type.IsGenericTypeDefinition)
type = type.MakeGenericType(type.GetGenericArguments());
if (type.GetGenericTypeDefinition() != field.DeclaringType)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFieldDeclaringType"), nameof(type));
+ throw new ArgumentException(SR.Argument_InvalidFieldDeclaringType, nameof(type));
return FieldOnTypeBuilderInstantiation.GetField(field, type as TypeBuilderInstantiation);
}
@@ -168,41 +170,41 @@ namespace System.Reflection.Emit {
#region Private Static FCalls
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
private static extern void SetParentType(RuntimeModule module, int tdTypeDef, int tkParent);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
private static extern void AddInterfaceImpl(RuntimeModule module, int tdTypeDef, int tkInterface);
#endregion
#region Internal Static FCalls
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- internal static extern int DefineMethod(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength,
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern int DefineMethod(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength,
MethodAttributes attributes);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern int DefineMethodSpec(RuntimeModule module, int tkParent, byte[] signature, int sigLength);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- internal static extern int DefineField(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength,
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern int DefineField(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength,
FieldAttributes attributes);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private static extern void SetMethodIL(RuntimeModule module, int tk, bool isInitLocals,
+ [SuppressUnmanagedCodeSecurity]
+ private static extern void SetMethodIL(RuntimeModule module, int tk, bool isInitLocals,
byte[] body, int bodyLength,
- byte[] LocalSig, int sigLength,
+ byte[] LocalSig, int sigLength,
int maxStackSize,
- ExceptionHandler[] exceptions, int numExceptions,
- int [] tokenFixups, int numTokenFixups);
+ ExceptionHandler[] exceptions, int numExceptions,
+ int[] tokenFixups, int numTokenFixups);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private static extern void DefineCustomAttribute(RuntimeModule module, int tkAssociate, int tkConstructor,
+ [SuppressUnmanagedCodeSecurity]
+ private static extern void DefineCustomAttribute(RuntimeModule module, int tkAssociate, int tkConstructor,
byte[] attr, int attrLength, bool toDisk, bool updateCompilerFlags);
internal static void DefineCustomAttribute(ModuleBuilder module, int tkAssociate, int tkConstructor,
@@ -216,55 +218,55 @@ namespace System.Reflection.Emit {
Buffer.BlockCopy(attr, 0, localAttr, 0, attr.Length);
}
- DefineCustomAttribute(module.GetNativeHandle(), tkAssociate, tkConstructor,
+ DefineCustomAttribute(module.GetNativeHandle(), tkAssociate, tkConstructor,
localAttr, (localAttr != null) ? localAttr.Length : 0, toDisk, updateCompilerFlags);
}
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern int DefineProperty(RuntimeModule module, int tkParent, String name, PropertyAttributes attributes,
byte[] signature, int sigLength);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern int DefineEvent(RuntimeModule module, int tkParent, String name, EventAttributes attributes, int tkEventType);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- internal static extern void DefineMethodSemantics(RuntimeModule module, int tkAssociation,
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern void DefineMethodSemantics(RuntimeModule module, int tkAssociation,
MethodSemanticsAttributes semantics, int tkMethod);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern void DefineMethodImpl(RuntimeModule module, int tkType, int tkBody, int tkDecl);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern void SetMethodImpl(RuntimeModule module, int tkMethod, MethodImplAttributes MethodImplAttributes);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- internal static extern int SetParamInfo(RuntimeModule module, int tkMethod, int iSequence,
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern int SetParamInfo(RuntimeModule module, int tkMethod, int iSequence,
ParameterAttributes iParamAttributes, String strParamName);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern int GetTokenFromSig(RuntimeModule module, byte[] signature, int sigLength);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern void SetFieldLayoutOffset(RuntimeModule module, int fdToken, int iOffset);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern void SetClassLayout(RuntimeModule module, int tk, PackingSize iPackingSize, int iTypeSize);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
private static extern unsafe void SetConstantValue(RuntimeModule module, int tk, int corType, void* pValue);
-#endregion
-#region Internal\Private Static Members
+ #endregion
+ #region Internal\Private Static Members
[Pure]
internal static bool IsTypeEqual(Type t1, Type t2)
@@ -273,14 +275,14 @@ namespace System.Reflection.Emit {
if (t1 == t2)
return true;
TypeBuilder tb1 = null;
- TypeBuilder tb2 = null;
- Type runtimeType1 = null;
- Type runtimeType2 = null;
-
+ TypeBuilder tb2 = null;
+ Type runtimeType1 = null;
+ Type runtimeType2 = null;
+
// set up the runtimeType and TypeBuilder type corresponding to t1 and t2
if (t1 is TypeBuilder)
{
- tb1 =(TypeBuilder)t1;
+ tb1 = (TypeBuilder)t1;
// This will be null if it is not baked.
runtimeType1 = tb1.m_bakedRuntimeType;
}
@@ -291,7 +293,7 @@ namespace System.Reflection.Emit {
if (t2 is TypeBuilder)
{
- tb2 =(TypeBuilder)t2;
+ tb2 = (TypeBuilder)t2;
// This will be null if it is not baked.
runtimeType2 = tb2.m_bakedRuntimeType;
}
@@ -299,16 +301,16 @@ namespace System.Reflection.Emit {
{
runtimeType2 = t2;
}
-
+
// If the type builder view is eqaul then it is equal
if (tb1 != null && tb2 != null && Object.ReferenceEquals(tb1, tb2))
return true;
// if the runtimetype view is eqaul than it is equal
- if (runtimeType1 != null && runtimeType2 != null && runtimeType1 == runtimeType2)
+ if (runtimeType1 != null && runtimeType2 != null && runtimeType1 == runtimeType2)
return true;
- return false;
+ return false;
}
internal static unsafe void SetConstantValue(ModuleBuilder module, int tk, Type destType, Object value)
@@ -349,7 +351,7 @@ namespace System.Reflection.Emit {
// The constant value supplied should match either the baked enum type or its underlying type
// we don't need to compare it with the EnumBuilder itself because you can never have an object of that type
if (type != enumBldr.m_typeBuilder.m_bakedRuntimeType && type != underlyingType)
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch"));
+ throw new ArgumentException(SR.Argument_ConstantDoesntMatch);
}
else if ((typeBldr = destType as TypeBuilder) != null)
{
@@ -358,7 +360,7 @@ namespace System.Reflection.Emit {
// The constant value supplied should match either the baked enum type or its underlying type
// typeBldr.m_enumUnderlyingType is null if the user hasn't created a "value__" field on the enum
if (underlyingType == null || (type != typeBldr.UnderlyingSystemType && type != underlyingType))
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch"));
+ throw new ArgumentException(SR.Argument_ConstantDoesntMatch);
}
else // must be a runtime Enum Type
{
@@ -368,7 +370,7 @@ namespace System.Reflection.Emit {
// The constant value supplied should match either the enum itself or its underlying type
if (type != destType && type != underlyingType)
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch"));
+ throw new ArgumentException(SR.Argument_ConstantDoesntMatch);
}
type = underlyingType;
@@ -377,9 +379,9 @@ namespace System.Reflection.Emit {
{
// Note that it is non CLS compliant if destType != type. But RefEmit never guarantees CLS-Compliance.
if (!destType.IsAssignableFrom(type))
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch"));
+ throw new ArgumentException(SR.Argument_ConstantDoesntMatch);
}
-
+
CorElementType corType = RuntimeTypeHandle.GetCorElementType((RuntimeType)type);
switch (corType)
@@ -414,7 +416,7 @@ namespace System.Reflection.Emit {
}
else
{
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantNotSupported", type.ToString()));
+ throw new ArgumentException(SR.Format(SR.Argument_ConstantNotSupported, type.ToString()));
}
break;
}
@@ -425,7 +427,7 @@ namespace System.Reflection.Emit {
{
// nullable types can hold null value.
if (!(destType.IsGenericType && destType.GetGenericTypeDefinition() == typeof(Nullable<>)))
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantNull"));
+ throw new ArgumentException(SR.Argument_ConstantNull);
}
SetConstantValue(module.GetNativeHandle(), tk, (int)CorElementType.Class, null);
@@ -436,7 +438,7 @@ namespace System.Reflection.Emit {
#region Private Data Members
private List<CustAttr> m_ca;
- private TypeToken m_tdType;
+ private TypeToken m_tdType;
private ModuleBuilder m_module;
private String m_strName;
private String m_strNameSpace;
@@ -483,8 +485,8 @@ namespace System.Reflection.Emit {
{
Contract.Requires(declMeth != null);
m_declMeth = declMeth;
- m_DeclaringType =m_declMeth.GetTypeBuilder();
- m_module =declMeth.GetModuleBuilder();
+ m_DeclaringType = m_declMeth.GetTypeBuilder();
+ m_module = declMeth.GetModuleBuilder();
InitAsGenericParam(szName, genParamPos);
}
@@ -493,7 +495,7 @@ namespace System.Reflection.Emit {
{
Contract.Requires(declType != null);
m_DeclaringType = declType;
- m_module =declType.GetModuleBuilder();
+ m_module = declType.GetModuleBuilder();
InitAsGenericParam(szName, genParamPos);
}
@@ -512,7 +514,7 @@ namespace System.Reflection.Emit {
Type[] interfaces,
ModuleBuilder module,
PackingSize iPackingSize,
- int iTypeSize,
+ int iTypeSize,
TypeBuilder enclosingType)
{
Init(name, attr, parent, interfaces, module, iPackingSize, iTypeSize, enclosingType);
@@ -525,14 +527,14 @@ namespace System.Reflection.Emit {
throw new ArgumentNullException(nameof(fullname));
if (fullname.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(fullname));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(fullname));
if (fullname[0] == '\0')
- throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(fullname));
+ throw new ArgumentException(SR.Argument_IllegalName, nameof(fullname));
if (fullname.Length > 1023)
- throw new ArgumentException(Environment.GetResourceString("Argument_TypeNameTooLong"), nameof(fullname));
+ throw new ArgumentException(SR.Argument_TypeNameTooLong, nameof(fullname));
Contract.EndContractBlock();
int i;
@@ -547,14 +549,14 @@ namespace System.Reflection.Emit {
{
// Nested Type should have nested attribute set.
// If we are renumbering TypeAttributes' bit, we need to change the logic here.
- if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public) ||((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic))
- throw new ArgumentException(Environment.GetResourceString("Argument_BadNestedTypeFlags"), nameof(attr));
+ if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public) || ((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic))
+ throw new ArgumentException(SR.Argument_BadNestedTypeFlags, nameof(attr));
}
int[] interfaceTokens = null;
if (interfaces != null)
{
- for(i = 0; i < interfaces.Length; i++)
+ for (i = 0; i < interfaces.Length; i++)
{
if (interfaces[i] == null)
{
@@ -563,7 +565,7 @@ namespace System.Reflection.Emit {
}
}
interfaceTokens = new int[interfaces.Length + 1];
- for(i = 0; i < interfaces.Length; i++)
+ for (i = 0; i < interfaces.Length; i++)
{
interfaceTokens[i] = m_module.GetTypeTokenInternal(interfaces[i]).Token;
}
@@ -609,14 +611,14 @@ namespace System.Reflection.Emit {
m_iPackingSize = iPackingSize;
m_iTypeSize = iTypeSize;
- if ((m_iPackingSize != 0) ||(m_iTypeSize != 0))
+ if ((m_iPackingSize != 0) || (m_iTypeSize != 0))
SetClassLayout(GetModuleBuilder().GetNativeHandle(), m_tdType.Token, m_iPackingSize, m_iTypeSize);
m_module.AddType(FullName, this);
}
-#endregion
-#region Private Members
+ #endregion
+ #region Private Members
private FieldBuilder DefineDataHelper(String name, byte[] data, int size, FieldAttributes attributes)
{
@@ -629,10 +631,10 @@ namespace System.Reflection.Emit {
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
if (size <= 0 || size >= 0x003f0000)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadSizeForData"));
+ throw new ArgumentException(SR.Argument_BadSizeForData);
Contract.EndContractBlock();
ThrowIfCreated();
@@ -653,7 +655,7 @@ namespace System.Reflection.Emit {
valueClassType.CreateType();
}
- fdBuilder = DefineField(name, valueClassType,(attributes | FieldAttributes.Static));
+ fdBuilder = DefineField(name, valueClassType, (attributes | FieldAttributes.Static));
// now we need to set the RVA
fdBuilder.SetData(data, size);
@@ -666,54 +668,54 @@ namespace System.Reflection.Emit {
if (DeclaringType == null)
{
// Not a nested class.
- if (((attr & TypeAttributes.VisibilityMask) != TypeAttributes.NotPublic) &&((attr & TypeAttributes.VisibilityMask) != TypeAttributes.Public))
+ if (((attr & TypeAttributes.VisibilityMask) != TypeAttributes.NotPublic) && ((attr & TypeAttributes.VisibilityMask) != TypeAttributes.Public))
{
- throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeAttrNestedVisibilityOnNonNestedType"));
+ throw new ArgumentException(SR.Argument_BadTypeAttrNestedVisibilityOnNonNestedType);
}
}
else
{
// Nested class.
- if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic) ||((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public))
+ if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic) || ((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public))
{
- throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeAttrNonNestedVisibilityNestedType"));
+ throw new ArgumentException(SR.Argument_BadTypeAttrNonNestedVisibilityNestedType);
}
}
// Verify that the layout mask is valid.
- if (((attr & TypeAttributes.LayoutMask) != TypeAttributes.AutoLayout) &&((attr & TypeAttributes.LayoutMask) != TypeAttributes.SequentialLayout) &&((attr & TypeAttributes.LayoutMask) != TypeAttributes.ExplicitLayout))
+ if (((attr & TypeAttributes.LayoutMask) != TypeAttributes.AutoLayout) && ((attr & TypeAttributes.LayoutMask) != TypeAttributes.SequentialLayout) && ((attr & TypeAttributes.LayoutMask) != TypeAttributes.ExplicitLayout))
{
- throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeAttrInvalidLayout"));
+ throw new ArgumentException(SR.Argument_BadTypeAttrInvalidLayout);
}
// Check if the user attempted to set any reserved bits.
if ((attr & TypeAttributes.ReservedMask) != 0)
{
- throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeAttrReservedBitsSet"));
+ throw new ArgumentException(SR.Argument_BadTypeAttrReservedBitsSet);
}
}
[Pure]
public bool IsCreated()
- {
+ {
return m_hasBeenCreated;
}
-
+
#endregion
#region FCalls
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
private extern static int DefineType(RuntimeModule module,
String fullname, int tkParent, TypeAttributes attributes, int tkEnclosingType, int[] interfaceTokens);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
private extern static int DefineGenericParam(RuntimeModule module,
String name, int tkParent, GenericParameterAttributes attributes, int position, int[] constraints);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
private static extern void TermCreateClass(RuntimeModule module, int tk, ObjectHandleOnStack type);
#endregion
@@ -721,7 +723,7 @@ namespace System.Reflection.Emit {
internal void ThrowIfCreated()
{
if (IsCreated())
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated"));
+ throw new InvalidOperationException(SR.InvalidOperation_TypeHasBeenCreated);
}
internal object SyncRoot
@@ -749,12 +751,12 @@ namespace System.Reflection.Emit {
{
m_genParamAttributes = genericParameterAttributes;
}
-
+
internal void SetGenParamCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
CustAttr ca = new CustAttr(con, binaryAttribute);
- lock(SyncRoot)
+ lock (SyncRoot)
{
SetGenParamCustomAttributeNoLock(ca);
}
@@ -764,7 +766,7 @@ namespace System.Reflection.Emit {
{
CustAttr ca = new CustAttr(customBuilder);
- lock(SyncRoot)
+ lock (SyncRoot)
{
SetGenParamCustomAttributeNoLock(ca);
}
@@ -774,7 +776,7 @@ namespace System.Reflection.Emit {
{
if (m_ca == null)
m_ca = new List<TypeBuilder.CustAttr>();
-
+
m_ca.Add(ca);
}
#endregion
@@ -782,30 +784,30 @@ namespace System.Reflection.Emit {
#region Object Overrides
public override String ToString()
{
- return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString);
+ return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString);
}
#endregion
#region MemberInfo Overrides
- public override Type DeclaringType
+ public override Type DeclaringType
{
get { return m_DeclaringType; }
}
- public override Type ReflectedType
+ public override Type ReflectedType
{
// Return the class that was used to obtain this field.
-
+
get { return m_DeclaringType; }
}
- public override String Name
+ public override String Name
{
get { return m_strName; }
}
- public override Module Module
+ public override Module Module
{
get { return GetModuleBuilder(); }
}
@@ -818,12 +820,12 @@ namespace System.Reflection.Emit {
#endregion
#region Type Overrides
- public override Guid GUID
+ public override Guid GUID
{
- get
+ get
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GUID;
@@ -834,27 +836,26 @@ namespace System.Reflection.Emit {
Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.InvokeMember(name, invokeAttr, binder, target, args, modifiers, culture, namedParameters);
}
- public override Assembly Assembly
+ public override Assembly Assembly
{
get { return m_module.Assembly; }
}
- public override RuntimeTypeHandle TypeHandle
+ public override RuntimeTypeHandle TypeHandle
{
-
- get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); }
+ get { throw new NotSupportedException(SR.NotSupported_DynamicModule); }
}
- public override String FullName
+ public override String FullName
{
- get
- {
+ get
+ {
if (m_strFullQualName == null)
m_strFullQualName = TypeNameBuilder.ToString(this, TypeNameBuilder.Format.FullName);
@@ -862,29 +863,29 @@ namespace System.Reflection.Emit {
}
}
- public override String Namespace
+ public override String Namespace
{
get { return m_strNameSpace; }
}
- public override String AssemblyQualifiedName
+ public override String AssemblyQualifiedName
{
- get
- {
+ get
+ {
return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.AssemblyQualifiedName);
}
}
- public override Type BaseType
+ public override Type BaseType
{
- get{ return m_typeParent; }
+ get { return m_typeParent; }
}
- protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr,Binder binder,
- CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers)
+ protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
+ CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetConstructor(bindingAttr, binder, callConvention, types, modifiers);
@@ -893,17 +894,17 @@ namespace System.Reflection.Emit {
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetConstructors(bindingAttr);
}
- protected override MethodInfo GetMethodImpl(String name,BindingFlags bindingAttr,Binder binder,
- CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers)
+ protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder,
+ CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
if (types == null)
@@ -919,7 +920,7 @@ namespace System.Reflection.Emit {
public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetMethods(bindingAttr);
@@ -928,7 +929,7 @@ namespace System.Reflection.Emit {
public override FieldInfo GetField(String name, BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetField(name, bindingAttr);
@@ -937,18 +938,18 @@ namespace System.Reflection.Emit {
public override FieldInfo[] GetFields(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetFields(bindingAttr);
}
- public override Type GetInterface(String name,bool ignoreCase)
+ public override Type GetInterface(String name, bool ignoreCase)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
-
+
return m_bakedRuntimeType.GetInterface(name, ignoreCase);
}
@@ -961,16 +962,16 @@ namespace System.Reflection.Emit {
if (m_typeInterfaces == null)
{
- return EmptyArray<Type>.Value;
+ return Array.Empty<Type>();
}
return m_typeInterfaces.ToArray();
}
- public override EventInfo GetEvent(String name,BindingFlags bindingAttr)
+ public override EventInfo GetEvent(String name, BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetEvent(name, bindingAttr);
@@ -979,7 +980,7 @@ namespace System.Reflection.Emit {
public override EventInfo[] GetEvents()
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetEvents();
@@ -988,13 +989,13 @@ namespace System.Reflection.Emit {
protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder,
Type returnType, Type[] types, ParameterModifier[] modifiers)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetProperties(bindingAttr);
@@ -1003,7 +1004,7 @@ namespace System.Reflection.Emit {
public override Type[] GetNestedTypes(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetNestedTypes(bindingAttr);
@@ -1012,16 +1013,16 @@ namespace System.Reflection.Emit {
public override Type GetNestedType(String name, BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
- return m_bakedRuntimeType.GetNestedType(name,bindingAttr);
+ return m_bakedRuntimeType.GetNestedType(name, bindingAttr);
}
public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetMember(name, type, bindingAttr);
@@ -1030,7 +1031,7 @@ namespace System.Reflection.Emit {
public override InterfaceMapping GetInterfaceMap(Type interfaceType)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetInterfaceMap(interfaceType);
@@ -1039,7 +1040,7 @@ namespace System.Reflection.Emit {
public override EventInfo[] GetEvents(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetEvents(bindingAttr);
@@ -1048,66 +1049,68 @@ namespace System.Reflection.Emit {
public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetMembers(bindingAttr);
}
-
+
public override bool IsAssignableFrom(Type c)
{
if (TypeBuilder.IsTypeEqual(c, this))
return true;
-
+
Type fromRuntimeType = null;
TypeBuilder fromTypeBuilder = c as TypeBuilder;
-
+
if (fromTypeBuilder != null)
fromRuntimeType = fromTypeBuilder.m_bakedRuntimeType;
else
fromRuntimeType = c;
-
+
if (fromRuntimeType != null && fromRuntimeType is RuntimeType)
{
// fromType is baked. So if this type is not baked, it cannot be assignable to!
if (m_bakedRuntimeType == null)
return false;
-
+
// since toType is also baked, delegate to the base
return m_bakedRuntimeType.IsAssignableFrom(fromRuntimeType);
}
-
+
// So if c is not a runtimeType nor TypeBuilder. We don't know how to deal with it.
// return false then.
if (fromTypeBuilder == null)
return false;
-
+
// If fromTypeBuilder is a subclass of this class, then c can be cast to this type.
if (fromTypeBuilder.IsSubclassOf(this))
return true;
-
+
if (this.IsInterface == false)
return false;
-
+
// now is This type a base type on one of the interface impl?
Type[] interfaces = fromTypeBuilder.GetInterfaces();
- for(int i = 0; i < interfaces.Length; i++)
+ for (int i = 0; i < interfaces.Length; i++)
{
// unfortunately, IsSubclassOf does not cover the case when they are the same type.
if (TypeBuilder.IsTypeEqual(interfaces[i], this))
return true;
-
+
if (interfaces[i].IsSubclassOf(this))
return true;
}
- return false;
- }
+ return false;
+ }
protected override TypeAttributes GetAttributeFlagsImpl()
{
return m_iAttr;
}
+ public override bool IsSZArray => false;
+
protected override bool IsArrayImpl()
{
return false;
@@ -1127,14 +1130,13 @@ namespace System.Reflection.Emit {
protected override bool IsCOMObjectImpl()
{
- return((GetAttributeFlagsImpl() & TypeAttributes.Import) != 0) ? true : false;
+ return ((GetAttributeFlagsImpl() & TypeAttributes.Import) != 0) ? true : false;
}
public override Type GetElementType()
{
-
// You will never have to deal with a TypeBuilder if you are just referring to arrays.
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
protected override bool HasElementTypeImpl()
@@ -1165,9 +1167,9 @@ namespace System.Reflection.Emit {
if (TypeBuilder.IsTypeEqual(p, c))
return false;
- p = p.BaseType;
-
- while(p != null)
+ p = p.BaseType;
+
+ while (p != null)
{
if (TypeBuilder.IsTypeEqual(p, c))
return true;
@@ -1177,10 +1179,10 @@ namespace System.Reflection.Emit {
return false;
}
-
- public override Type UnderlyingSystemType
+
+ public override Type UnderlyingSystemType
{
- get
+ get
{
if (m_bakedRuntimeType != null)
return m_bakedRuntimeType;
@@ -1188,9 +1190,9 @@ namespace System.Reflection.Emit {
if (IsEnum)
{
if (m_enumUnderlyingType == null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoUnderlyingTypeOnEnum"));
-
- return m_enumUnderlyingType;
+ throw new InvalidOperationException(SR.InvalidOperation_NoUnderlyingTypeOnEnum);
+
+ return m_enumUnderlyingType;
}
else
{
@@ -1199,22 +1201,22 @@ namespace System.Reflection.Emit {
}
}
- public override Type MakePointerType()
- {
- return SymbolType.FormCompoundType("*", this, 0);
+ public override Type MakePointerType()
+ {
+ return SymbolType.FormCompoundType("*", this, 0);
}
- public override Type MakeByRefType()
+ public override Type MakeByRefType()
{
return SymbolType.FormCompoundType("&", this, 0);
}
- public override Type MakeArrayType()
+ public override Type MakeArrayType()
{
return SymbolType.FormCompoundType("[]", this, 0);
}
- public override Type MakeArrayType(int rank)
+ public override Type MakeArrayType(int rank)
{
if (rank <= 0)
throw new IndexOutOfRangeException();
@@ -1225,9 +1227,9 @@ namespace System.Reflection.Emit {
{
szrank = "*";
}
- else
+ else
{
- for(int i = 1; i < rank; i++)
+ for (int i = 1; i < rank; i++)
szrank += ",";
}
@@ -1241,7 +1243,7 @@ namespace System.Reflection.Emit {
public override Object[] GetCustomAttributes(bool inherit)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return CustomAttribute.GetCustomAttributes(m_bakedRuntimeType, typeof(object) as RuntimeType, inherit);
@@ -1250,7 +1252,7 @@ namespace System.Reflection.Emit {
public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
@@ -1259,7 +1261,7 @@ namespace System.Reflection.Emit {
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(m_bakedRuntimeType, attributeRuntimeType, inherit);
}
@@ -1267,7 +1269,7 @@ namespace System.Reflection.Emit {
public override bool IsDefined(Type attributeType, bool inherit)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
@@ -1276,7 +1278,7 @@ namespace System.Reflection.Emit {
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.IsDefined(m_bakedRuntimeType, attributeRuntimeType, inherit);
}
@@ -1284,12 +1286,12 @@ namespace System.Reflection.Emit {
#endregion
#region Public Member
-
+
#region DefineType
public override GenericParameterAttributes GenericParameterAttributes { get { return m_genParamAttributes; } }
- internal void SetInterfaces(params Type[] interfaces)
- {
+ internal void SetInterfaces(params Type[] interfaces)
+ {
ThrowIfCreated();
m_typeInterfaces = new List<Type>();
@@ -1308,8 +1310,8 @@ namespace System.Reflection.Emit {
if (names.Length == 0)
throw new ArgumentException();
Contract.EndContractBlock();
-
- for (int i = 0; i < names.Length; i ++)
+
+ for (int i = 0; i < names.Length; i++)
if (names[i] == null)
throw new ArgumentNullException(nameof(names));
@@ -1317,25 +1319,25 @@ namespace System.Reflection.Emit {
throw new InvalidOperationException();
m_inst = new GenericTypeParameterBuilder[names.Length];
- for(int i = 0; i < names.Length; i ++)
+ for (int i = 0; i < names.Length; i++)
m_inst[i] = new GenericTypeParameterBuilder(new TypeBuilder(names[i], i, this));
return m_inst;
}
-
- public override Type MakeGenericType(params Type[] typeArguments)
- {
+
+ public override Type MakeGenericType(params Type[] typeArguments)
+ {
CheckContext(typeArguments);
-
- return TypeBuilderInstantiation.MakeGenericType(this, typeArguments);
+
+ return TypeBuilderInstantiation.MakeGenericType(this, typeArguments);
}
-
+
public override Type[] GetGenericArguments() { return m_inst; }
// If a TypeBuilder is generic, it must be a generic type definition
// All instantiated generic types are TypeBuilderInstantiation.
public override bool IsGenericTypeDefinition { get { return IsGenericType; } }
- public override bool IsGenericType { get { return m_inst != null; } }
+ public override bool IsGenericType { get { return m_inst != null; } }
public override bool IsGenericParameter { get { return m_bIsGenParam; } }
public override bool IsConstructedGenericType { get { return false; } }
@@ -1347,7 +1349,7 @@ namespace System.Reflection.Emit {
#region Define Method
public void DefineMethodOverride(MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
DefineMethodOverrideNoLock(methodInfoBody, methodInfoDeclaration);
}
@@ -1363,13 +1365,13 @@ namespace System.Reflection.Emit {
Contract.EndContractBlock();
ThrowIfCreated();
-
+
if (!object.ReferenceEquals(methodInfoBody.DeclaringType, this))
// Loader restriction: body method has to be from this class
- throw new ArgumentException(Environment.GetResourceString("ArgumentException_BadMethodImplBody"));
-
- MethodToken tkBody;
- MethodToken tkDecl;
+ throw new ArgumentException(SR.ArgumentException_BadMethodImplBody);
+
+ MethodToken tkBody;
+ MethodToken tkDecl;
tkBody = m_module.GetMethodTokenInternal(methodInfoBody);
tkDecl = m_module.GetMethodTokenInternal(methodInfoDeclaration);
@@ -1405,21 +1407,21 @@ namespace System.Reflection.Emit {
return DefineMethod(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
}
-
+
public MethodBuilder DefineMethod(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
{
Contract.Ensures(Contract.Result<MethodBuilder>() != null);
- lock(SyncRoot)
+ lock (SyncRoot)
{
- return DefineMethodNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers,
- returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers,
+ return DefineMethodNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers,
+ returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers,
parameterTypeOptionalCustomModifiers);
}
}
-
+
private MethodBuilder DefineMethodNoLock(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
@@ -1428,7 +1430,7 @@ namespace System.Reflection.Emit {
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
Contract.Ensures(Contract.Result<MethodBuilder>() != null);
Contract.EndContractBlock();
@@ -1440,10 +1442,10 @@ namespace System.Reflection.Emit {
if (parameterTypes != null)
{
if (parameterTypeOptionalCustomModifiers != null && parameterTypeOptionalCustomModifiers.Length != parameterTypes.Length)
- throw new ArgumentException(Environment.GetResourceString("Argument_MismatchedArrays", nameof(parameterTypeOptionalCustomModifiers), nameof(parameterTypes)));
+ throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, nameof(parameterTypeOptionalCustomModifiers), nameof(parameterTypes)));
if (parameterTypeRequiredCustomModifiers != null && parameterTypeRequiredCustomModifiers.Length != parameterTypes.Length)
- throw new ArgumentException(Environment.GetResourceString("Argument_MismatchedArrays", nameof(parameterTypeRequiredCustomModifiers), nameof(parameterTypes)));
+ throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, nameof(parameterTypeRequiredCustomModifiers), nameof(parameterTypes)));
}
ThrowIfCreated();
@@ -1451,21 +1453,21 @@ namespace System.Reflection.Emit {
if (!m_isHiddenGlobalType)
{
if (((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface) &&
- (attributes & MethodAttributes.Abstract) == 0 &&(attributes & MethodAttributes.Static) == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadAttributeOnInterfaceMethod"));
+ (attributes & MethodAttributes.Abstract) == 0 && (attributes & MethodAttributes.Static) == 0)
+ throw new ArgumentException(SR.Argument_BadAttributeOnInterfaceMethod);
}
// pass in Method attributes
MethodBuilder method = new MethodBuilder(
- name, attributes, callingConvention,
+ name, attributes, callingConvention,
returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
- parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers,
+ parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers,
m_module, this, false);
if (!m_isHiddenGlobalType)
{
//If this method is declared to be a constructor, increment our constructor count.
- if ((method.Attributes & MethodAttributes.SpecialName) != 0 && method.Name.Equals(ConstructorInfo.ConstructorName))
+ if ((method.Attributes & MethodAttributes.SpecialName) != 0 && method.Name.Equals(ConstructorInfo.ConstructorName))
{
m_constructorCount++;
}
@@ -1481,7 +1483,7 @@ namespace System.Reflection.Emit {
#region Define Constructor
public ConstructorBuilder DefineTypeInitializer()
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineTypeInitializerNoLock();
}
@@ -1504,10 +1506,10 @@ namespace System.Reflection.Emit {
{
if ((m_iAttr & TypeAttributes.Interface) == TypeAttributes.Interface)
{
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ConstructorNotAllowedOnInterface"));
+ throw new InvalidOperationException(SR.InvalidOperation_ConstructorNotAllowedOnInterface);
}
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineDefaultConstructorNoLock(attributes);
}
@@ -1533,14 +1535,14 @@ namespace System.Reflection.Emit {
genericTypeDefinition = ((TypeBuilder)genericTypeDefinition).m_bakedRuntimeType;
if (genericTypeDefinition == null)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
Type inst = genericTypeDefinition.MakeGenericType(m_typeParent.GetGenericArguments());
if (inst is TypeBuilderInstantiation)
con = TypeBuilder.GetConstructor(inst, genericTypeDefinition.GetConstructor(
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null));
- else
+ else
con = inst.GetConstructor(
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
}
@@ -1551,7 +1553,7 @@ namespace System.Reflection.Emit {
}
if (con == null)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NoParentDefaultConstructor"));
+ throw new NotSupportedException(SR.NotSupported_NoParentDefaultConstructor);
// Define the constructor Builder
constBuilder = DefineConstructor(attributes, CallingConventions.Standard, null);
@@ -1560,7 +1562,7 @@ namespace System.Reflection.Emit {
// generate the code to call the parent's default constructor
ILGenerator il = constBuilder.GetILGenerator();
il.Emit(OpCodes.Ldarg_0);
- il.Emit(OpCodes.Call,con);
+ il.Emit(OpCodes.Call, con);
il.Emit(OpCodes.Ret);
constBuilder.m_isDefaultConstructor = true;
@@ -1572,21 +1574,21 @@ namespace System.Reflection.Emit {
return DefineConstructor(attributes, callingConvention, parameterTypes, null, null);
}
- public ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention,
+ public ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention,
Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers)
{
if ((m_iAttr & TypeAttributes.Interface) == TypeAttributes.Interface && (attributes & MethodAttributes.Static) != MethodAttributes.Static)
{
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ConstructorNotAllowedOnInterface"));
+ throw new InvalidOperationException(SR.InvalidOperation_ConstructorNotAllowedOnInterface);
}
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineConstructorNoLock(attributes, callingConvention, parameterTypes, requiredCustomModifiers, optionalCustomModifiers);
}
}
- private ConstructorBuilder DefineConstructorNoLock(MethodAttributes attributes, CallingConventions callingConvention,
+ private ConstructorBuilder DefineConstructorNoLock(MethodAttributes attributes, CallingConventions callingConvention,
Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers)
{
CheckContext(parameterTypes);
@@ -1608,8 +1610,8 @@ namespace System.Reflection.Emit {
attributes = attributes | MethodAttributes.SpecialName;
- ConstructorBuilder constBuilder =
- new ConstructorBuilder(name, attributes, callingConvention,
+ ConstructorBuilder constBuilder =
+ new ConstructorBuilder(name, attributes, callingConvention,
parameterTypes, requiredCustomModifiers, optionalCustomModifiers, m_module, this);
m_constructorCount++;
@@ -1622,7 +1624,7 @@ namespace System.Reflection.Emit {
#region Define Nested Type
public TypeBuilder DefineNestedType(String name)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineNestedTypeNoLock(name, TypeAttributes.NestedPrivate, null, null, PackingSize.Unspecified, UnspecifiedTypeSize);
}
@@ -1630,7 +1632,7 @@ namespace System.Reflection.Emit {
public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, Type[] interfaces)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
// Why do we only call CheckContext here? Why don't we call it in the other overloads?
CheckContext(parent);
@@ -1642,7 +1644,7 @@ namespace System.Reflection.Emit {
public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineNestedTypeNoLock(name, attr, parent, null, PackingSize.Unspecified, UnspecifiedTypeSize);
}
@@ -1650,7 +1652,7 @@ namespace System.Reflection.Emit {
public TypeBuilder DefineNestedType(String name, TypeAttributes attr)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineNestedTypeNoLock(name, attr, null, null, PackingSize.Unspecified, UnspecifiedTypeSize);
}
@@ -1658,7 +1660,7 @@ namespace System.Reflection.Emit {
public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, int typeSize)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineNestedTypeNoLock(name, attr, parent, null, PackingSize.Unspecified, typeSize);
}
@@ -1666,7 +1668,7 @@ namespace System.Reflection.Emit {
public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, PackingSize packSize)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineNestedTypeNoLock(name, attr, parent, null, packSize, UnspecifiedTypeSize);
}
@@ -1688,22 +1690,22 @@ namespace System.Reflection.Emit {
#endregion
#region Define Field
- public FieldBuilder DefineField(String fieldName, Type type, FieldAttributes attributes)
+ public FieldBuilder DefineField(String fieldName, Type type, FieldAttributes attributes)
{
return DefineField(fieldName, type, null, null, attributes);
}
- public FieldBuilder DefineField(String fieldName, Type type, Type[] requiredCustomModifiers,
- Type[] optionalCustomModifiers, FieldAttributes attributes)
+ public FieldBuilder DefineField(String fieldName, Type type, Type[] requiredCustomModifiers,
+ Type[] optionalCustomModifiers, FieldAttributes attributes)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineFieldNoLock(fieldName, type, requiredCustomModifiers, optionalCustomModifiers, attributes);
}
}
- private FieldBuilder DefineFieldNoLock(String fieldName, Type type, Type[] requiredCustomModifiers,
- Type[] optionalCustomModifiers, FieldAttributes attributes)
+ private FieldBuilder DefineFieldNoLock(String fieldName, Type type, Type[] requiredCustomModifiers,
+ Type[] optionalCustomModifiers, FieldAttributes attributes)
{
ThrowIfCreated();
CheckContext(type);
@@ -1715,7 +1717,7 @@ namespace System.Reflection.Emit {
{
// remember the underlying type for enum type
m_enumUnderlyingType = type;
- }
+ }
}
return new FieldBuilder(this, fieldName, type, requiredCustomModifiers, optionalCustomModifiers, attributes);
@@ -1723,7 +1725,7 @@ namespace System.Reflection.Emit {
public FieldBuilder DefineInitializedData(String name, byte[] data, FieldAttributes attributes)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineInitializedDataNoLock(name, data, attributes);
}
@@ -1744,7 +1746,7 @@ namespace System.Reflection.Emit {
public FieldBuilder DefineUninitializedData(String name, int size, FieldAttributes attributes)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineUninitializedDataNoLock(name, size, attributes);
}
@@ -1763,44 +1765,44 @@ namespace System.Reflection.Emit {
#region Define Properties and Events
public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes)
{
- return DefineProperty(name, attributes, returnType, null, null, parameterTypes, null, null);
+ return DefineProperty(name, attributes, returnType, null, null, parameterTypes, null, null);
}
- public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes,
+ public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes,
CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
{
- return DefineProperty(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
+ return DefineProperty(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
}
- public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes,
- Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
+ public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes,
+ Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
{
- return DefineProperty(name, attributes, (CallingConventions)0, returnType,
- returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
- parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers);
+ return DefineProperty(name, attributes, (CallingConventions)0, returnType,
+ returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
+ parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers);
}
- public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, CallingConventions callingConvention,
- Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
+ public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, CallingConventions callingConvention,
+ Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
- return DefinePropertyNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
+ return DefinePropertyNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers);
}
}
private PropertyBuilder DefinePropertyNoLock(String name, PropertyAttributes attributes, CallingConventions callingConvention,
- Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
+ Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
Contract.EndContractBlock();
CheckContext(returnType);
@@ -1809,8 +1811,8 @@ namespace System.Reflection.Emit {
CheckContext(parameterTypeOptionalCustomModifiers);
SignatureHelper sigHelper;
- int sigLength;
- byte[] sigBytes;
+ int sigLength;
+ byte[] sigBytes;
ThrowIfCreated();
@@ -1844,7 +1846,7 @@ namespace System.Reflection.Emit {
public EventBuilder DefineEvent(String name, EventAttributes attributes, Type eventtype)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineEventNoLock(name, attributes, eventtype);
}
@@ -1855,19 +1857,19 @@ namespace System.Reflection.Emit {
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
if (name[0] == '\0')
- throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(name));
+ throw new ArgumentException(SR.Argument_IllegalName, nameof(name));
Contract.EndContractBlock();
int tkType;
- EventToken evToken;
-
+ EventToken evToken;
+
CheckContext(eventtype);
ThrowIfCreated();
- tkType = m_module.GetTypeTokenInternal( eventtype ).Token;
+ tkType = m_module.GetTypeTokenInternal(eventtype).Token;
// Internal helpers to define property records
evToken = new EventToken(DefineEvent(
@@ -1909,7 +1911,7 @@ namespace System.Reflection.Emit {
internal void CheckContext(params Type[][] typess)
{
- m_module.CheckContext(typess);
+ m_module.CheckContext(typess);
}
internal void CheckContext(params Type[] types)
{
@@ -1927,7 +1929,7 @@ namespace System.Reflection.Emit {
m_typeInterfaces = new List<Type>();
int[] interfaceTokens = new int[m_typeInterfaces.Count];
- for(int i = 0; i < m_typeInterfaces.Count; i++)
+ for (int i = 0; i < m_typeInterfaces.Count; i++)
{
interfaceTokens[i] = m_module.GetTypeTokenInternal(m_typeInterfaces[i]).Token;
}
@@ -1976,16 +1978,16 @@ namespace System.Reflection.Emit {
// Check for global typebuilder
if (((m_tdType.Token & 0x00FFFFFF) != 0) && ((tkParent & 0x00FFFFFF) != 0))
SetParentType(m_module.GetNativeHandle(), m_tdType.Token, tkParent);
-
+
if (m_inst != null)
foreach (Type tb in m_inst)
if (tb is GenericTypeParameterBuilder)
((GenericTypeParameterBuilder)tb).m_type.CreateType();
}
- byte [] body;
+ byte[] body;
MethodAttributes methodAttrs;
-
+
if (!m_isHiddenGlobalType)
{
// create a public default constructor if this class has no constructor.
@@ -1998,7 +2000,7 @@ namespace System.Reflection.Emit {
int size = m_listMethods.Count;
- for(int i = 0; i < size; i++)
+ for (int i = 0; i < size; i++)
{
MethodBuilder meth = m_listMethods[i];
@@ -2009,19 +2011,19 @@ namespace System.Reflection.Emit {
methodAttrs = meth.Attributes;
// Any of these flags in the implemenation flags is set, we will not attach the IL method body
- if (((meth.GetMethodImplementationFlags() &(MethodImplAttributes.CodeTypeMask|MethodImplAttributes.PreserveSig|MethodImplAttributes.Unmanaged)) != MethodImplAttributes.IL) ||
- ((methodAttrs & MethodAttributes.PinvokeImpl) !=(MethodAttributes) 0))
+ if (((meth.GetMethodImplementationFlags() & (MethodImplAttributes.CodeTypeMask | MethodImplAttributes.PreserveSig | MethodImplAttributes.Unmanaged)) != MethodImplAttributes.IL) ||
+ ((methodAttrs & MethodAttributes.PinvokeImpl) != (MethodAttributes)0))
{
continue;
}
int sigLength;
byte[] localSig = meth.GetLocalSignature(out sigLength);
-
+
// Check that they haven't declared an abstract method on a non-abstract class
- if (((methodAttrs & MethodAttributes.Abstract) != 0) &&((m_iAttr & TypeAttributes.Abstract) == 0))
+ if (((methodAttrs & MethodAttributes.Abstract) != 0) && ((m_iAttr & TypeAttributes.Abstract) == 0))
{
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadTypeAttributesNotAbstract"));
+ throw new InvalidOperationException(SR.InvalidOperation_BadTypeAttributesNotAbstract);
}
body = meth.GetBody();
@@ -2036,7 +2038,7 @@ namespace System.Reflection.Emit {
//((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface))
if (body != null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadMethodBody"));
+ throw new InvalidOperationException(SR.InvalidOperation_BadMethodBody);
}
else if (body == null || body.Length == 0)
{
@@ -2051,7 +2053,7 @@ namespace System.Reflection.Emit {
if ((body == null || body.Length == 0) && !meth.m_canBeRuntimeImpl)
throw new InvalidOperationException(
- Environment.GetResourceString("InvalidOperation_BadEmptyMethodBody", meth.Name) );
+ SR.Format(SR.InvalidOperation_BadEmptyMethodBody, meth.Name));
}
int maxStack = meth.GetMaxStack();
@@ -2059,7 +2061,7 @@ namespace System.Reflection.Emit {
ExceptionHandler[] exceptions = meth.GetExceptionHandlers();
int[] tokenFixups = meth.GetTokenFixups();
- SetMethodIL(m_module.GetNativeHandle(), meth.GetToken().Token, meth.InitLocals,
+ SetMethodIL(m_module.GetNativeHandle(), meth.GetToken().Token, meth.InitLocals,
body, (body != null) ? body.Length : 0,
localSig, sigLength, maxStack,
exceptions, (exceptions != null) ? exceptions.Length : 0,
@@ -2086,7 +2088,7 @@ namespace System.Reflection.Emit {
// if this type is a nested type, we need to invalidate the cached nested runtime type on the nesting type
if (m_DeclaringType != null && m_DeclaringType.m_bakedRuntimeType != null)
{
- m_DeclaringType.m_bakedRuntimeType.InvalidateCachedNestedType();
+ m_DeclaringType.m_bakedRuntimeType.InvalidateCachedNestedType();
}
return cls;
@@ -2104,8 +2106,8 @@ namespace System.Reflection.Emit {
{
get { return m_iTypeSize; }
}
-
- public PackingSize PackingSize
+
+ public PackingSize PackingSize
{
get { return m_iPackingSize; }
}
@@ -2119,7 +2121,7 @@ namespace System.Reflection.Emit {
CheckContext(parent);
if (parent.IsInterface)
- throw new ArgumentException(Environment.GetResourceString("Argument_CannotSetParentToInterface"));
+ throw new ArgumentException(SR.Argument_CannotSetParentToInterface);
m_typeParent = parent;
}
@@ -2132,7 +2134,7 @@ namespace System.Reflection.Emit {
else
{
if ((m_iAttr & TypeAttributes.Abstract) == 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadInterfaceNotAbstract"));
+ throw new InvalidOperationException(SR.InvalidOperation_BadInterfaceNotAbstract);
// there is no extends for interface class
m_typeParent = null;
@@ -2149,7 +2151,7 @@ namespace System.Reflection.Emit {
Contract.EndContractBlock();
CheckContext(interfaceType);
-
+
ThrowIfCreated();
TypeToken tkInterface = m_module.GetTypeTokenInternal(interfaceType);
@@ -2158,14 +2160,14 @@ namespace System.Reflection.Emit {
m_typeInterfaces.Add(interfaceType);
}
-public TypeToken TypeToken
+ public TypeToken TypeToken
{
- get
+ get
{
if (IsGenericParameter)
ThrowIfCreated();
- return m_tdType;
+ return m_tdType;
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs
index da5a56ba28..6d46362f91 100644
--- a/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs
@@ -4,18 +4,19 @@
//
+using System;
+using System.Reflection;
+using System.Collections;
+using System.Globalization;
+using System.Diagnostics.Contracts;
+
namespace System.Reflection.Emit
{
- using System;
- using System.Reflection;
- using System.Collections;
- using System.Globalization;
- using System.Diagnostics.Contracts;
-
internal sealed class TypeBuilderInstantiation : TypeInfo
{
- public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
- if(typeInfo==null) return false;
+ public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo)
+ {
+ if (typeInfo == null) return false;
return IsAssignableFrom(typeInfo.AsType());
}
@@ -34,9 +35,9 @@ namespace System.Reflection.Emit
foreach (Type t in typeArguments)
{
if (t == null)
- throw new ArgumentNullException(nameof(typeArguments));
+ throw new ArgumentNullException(nameof(typeArguments));
}
-
+
return new TypeBuilderInstantiation(type, typeArguments);
}
@@ -77,26 +78,26 @@ namespace System.Reflection.Emit
#endregion
#region Type Overrides
- public override Type MakePointerType()
- {
- return SymbolType.FormCompoundType("*", this, 0);
+ public override Type MakePointerType()
+ {
+ return SymbolType.FormCompoundType("*", this, 0);
}
- public override Type MakeByRefType()
+ public override Type MakeByRefType()
{
return SymbolType.FormCompoundType("&", this, 0);
}
- public override Type MakeArrayType()
+ public override Type MakeArrayType()
{
return SymbolType.FormCompoundType("[]", this, 0);
}
- public override Type MakeArrayType(int rank)
+ public override Type MakeArrayType(int rank)
{
if (rank <= 0)
throw new IndexOutOfRangeException();
Contract.EndContractBlock();
string comma = "";
- for(int i = 1; i < rank; i++)
+ for (int i = 1; i < rank; i++)
comma += ",";
string s = String.Format(CultureInfo.InvariantCulture, "[{0}]", comma);
@@ -106,14 +107,14 @@ namespace System.Reflection.Emit
public override Object InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) { throw new NotSupportedException(); }
public override Assembly Assembly { get { return m_type.Assembly; } }
public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } }
- public override String FullName
- {
- get
- {
+ public override String FullName
+ {
+ get
+ {
if (m_strFullQualName == null)
- m_strFullQualName = TypeNameBuilder.ToString(this, TypeNameBuilder.Format.FullName);
+ m_strFullQualName = TypeNameBuilder.ToString(this, TypeNameBuilder.Format.FullName);
return m_strFullQualName;
- }
+ }
}
public override String Namespace { get { return m_type.Namespace; } }
public override String AssemblyQualifiedName { get { return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.AssemblyQualifiedName); } }
@@ -125,7 +126,7 @@ namespace System.Reflection.Emit
for (int i = 0; i < instSubstituted.Length; i++)
{
Type t = inst[i];
-
+
if (t is TypeBuilderInstantiation)
{
instSubstituted[i] = (t as TypeBuilderInstantiation).Substitute(substitutes);
@@ -147,7 +148,7 @@ namespace System.Reflection.Emit
{
// B<A,B,C>
// D<T,S> : B<S,List<T>,char>
-
+
// D<string,int> : B<int,List<string>,char>
// D<S,T> : B<T,List<S>,char>
// D<S,string> : B<string,List<S>,char>
@@ -159,7 +160,7 @@ namespace System.Reflection.Emit
return null;
TypeBuilderInstantiation typeBldrBaseAs = typeBldrBase as TypeBuilderInstantiation;
-
+
if (typeBldrBaseAs == null)
return typeBldrBase;
@@ -167,7 +168,7 @@ namespace System.Reflection.Emit
}
}
protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); }
-
+
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(); }
@@ -187,6 +188,9 @@ namespace System.Reflection.Emit
public override EventInfo[] GetEvents(BindingFlags bindingAttr) { throw new NotSupportedException(); }
public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { throw new NotSupportedException(); }
protected override TypeAttributes GetAttributeFlagsImpl() { return m_type.Attributes; }
+
+ public override bool IsSZArray => false;
+
protected override bool IsArrayImpl() { return false; }
protected override bool IsByRefImpl() { return false; }
protected override bool IsPointerImpl() { return false; }
@@ -217,7 +221,7 @@ namespace System.Reflection.Emit
}
public override MethodBase DeclaringMethod { get { return null; } }
public override Type GetGenericTypeDefinition() { return m_type; }
- public override Type MakeGenericType(params Type[] inst) { throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericTypeDefinition")); }
+ public override Type MakeGenericType(params Type[] inst) { throw new InvalidOperationException(SR.Arg_NotGenericTypeDefinition); }
public override bool IsAssignableFrom(Type c) { throw new NotSupportedException(); }
[Pure]
diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeToken.cs b/src/mscorlib/src/System/Reflection/Emit/TypeToken.cs
index 4fa851c529..4f0c1b3dac 100644
--- a/src/mscorlib/src/System/Reflection/Emit/TypeToken.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/TypeToken.cs
@@ -12,33 +12,36 @@
**
**
===========================================================*/
-namespace System.Reflection.Emit {
-
- using System;
- using System.Reflection;
- using System.Threading;
+using System;
+using System.Reflection;
+using System.Threading;
+
+namespace System.Reflection.Emit
+{
[Serializable]
- public struct TypeToken {
-
+ public struct TypeToken
+ {
public static readonly TypeToken Empty = new TypeToken();
internal int m_class;
-
-
- internal TypeToken(int str) {
- m_class=str;
+
+
+ internal TypeToken(int str)
+ {
+ m_class = str;
}
-
- public int Token {
+
+ public int Token
+ {
get { return m_class; }
}
-
+
public override int GetHashCode()
{
return m_class;
}
-
+
public override bool Equals(Object obj)
{
if (obj is TypeToken)
@@ -46,22 +49,21 @@ namespace System.Reflection.Emit {
else
return false;
}
-
+
public bool Equals(TypeToken obj)
{
return obj.m_class == m_class;
}
-
+
public static bool operator ==(TypeToken a, TypeToken b)
{
return a.Equals(b);
}
-
+
public static bool operator !=(TypeToken a, TypeToken b)
{
return !(a == b);
}
-
}
}
diff --git a/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs
index ca0faf31ca..78238c02b7 100644
--- a/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs
@@ -4,16 +4,16 @@
//
+using System;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+
namespace System.Reflection.Emit
{
- using System;
- using System.Reflection;
- using System.Collections;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
-
internal sealed class MethodOnTypeBuilderInstantiation : MethodInfo
{
#region Private Static Members
@@ -37,21 +37,21 @@ namespace System.Reflection.Emit
m_type = type;
}
#endregion
-
+
internal override Type[] GetParameterTypes()
{
return m_method.GetParameterTypes();
}
#region MemberInfo Overrides
- public override MemberTypes MemberType { get { return m_method.MemberType; } }
+ public override MemberTypes MemberType { get { return m_method.MemberType; } }
public override String Name { get { return m_method.Name; } }
public override Type DeclaringType { get { return m_type; } }
public override Type ReflectedType { get { return m_type; } }
- public override Object[] GetCustomAttributes(bool inherit) { return m_method.GetCustomAttributes(inherit); }
+ 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); }
- public override Module Module { get { return m_method.Module; } }
+ public override Module Module { get { return m_method.Module; } }
#endregion
#region MethodBase Members
@@ -65,21 +65,21 @@ namespace System.Reflection.Emit
throw new NotSupportedException();
}
public override CallingConventions CallingConvention { get { return m_method.CallingConvention; } }
- public override Type [] GetGenericArguments() { return m_method.GetGenericArguments(); }
+ public override Type[] GetGenericArguments() { return m_method.GetGenericArguments(); }
public override MethodInfo GetGenericMethodDefinition() { return m_method; }
public override bool IsGenericMethodDefinition { get { return m_method.IsGenericMethodDefinition; } }
public override bool ContainsGenericParameters { get { return m_method.ContainsGenericParameters; } }
public override MethodInfo MakeGenericMethod(params Type[] typeArgs)
{
if (!IsGenericMethodDefinition)
- throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericMethodDefinition"));
+ throw new InvalidOperationException(SR.Arg_NotGenericMethodDefinition);
Contract.EndContractBlock();
return MethodBuilderInstantiation.MakeGenericMethod(this, typeArgs);
}
public override bool IsGenericMethod { get { return m_method.IsGenericMethod; } }
-
+
#endregion
#region Public Abstract\Virtual Members
@@ -113,7 +113,7 @@ namespace System.Reflection.Emit
m_type = type;
}
#endregion
-
+
internal override Type[] GetParameterTypes()
{
return m_ctor.GetParameterTypes();
@@ -129,7 +129,7 @@ namespace System.Reflection.Emit
public override String Name { get { return m_ctor.Name; } }
public override Type DeclaringType { get { return m_type; } }
public override Type ReflectedType { get { return m_type; } }
- public override Object[] GetCustomAttributes(bool inherit) { return m_ctor.GetCustomAttributes(inherit); }
+ public override Object[] GetCustomAttributes(bool inherit) { return m_ctor.GetCustomAttributes(inherit); }
public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_ctor.GetCustomAttributes(attributeType, inherit); }
public override bool IsDefined(Type attributeType, bool inherit) { return m_ctor.IsDefined(attributeType, inherit); }
internal int MetadataTokenInternal
@@ -147,7 +147,7 @@ namespace System.Reflection.Emit
}
}
}
- public override Module Module { get { return m_ctor.Module; } }
+ public override Module Module { get { return m_ctor.Module; } }
#endregion
#region MethodBase Members
@@ -195,10 +195,12 @@ namespace System.Reflection.Emit
// We're not entirely sure if this cache helps any specific scenarios, so
// long-term, one could investigate whether it's needed. In any case, this
// method isn't expected to be on any critical paths for performance.
- if (type.m_hashtable.Contains(Field)) {
+ if (type.m_hashtable.Contains(Field))
+ {
m = type.m_hashtable[Field] as FieldInfo;
}
- else {
+ else
+ {
m = new FieldOnTypeBuilderInstantiation(Field, type);
type.m_hashtable[Field] = m;
}
@@ -225,11 +227,11 @@ namespace System.Reflection.Emit
internal FieldInfo FieldInfo { get { return m_field; } }
#region MemberInfo Overrides
- public override MemberTypes MemberType { get { return System.Reflection.MemberTypes.Field; } }
+ public override MemberTypes MemberType { get { return System.Reflection.MemberTypes.Field; } }
public override String Name { get { return m_field.Name; } }
public override Type DeclaringType { get { return m_type; } }
public override Type ReflectedType { get { return m_type; } }
- public override Object[] GetCustomAttributes(bool inherit) { return m_field.GetCustomAttributes(inherit); }
+ public override Object[] GetCustomAttributes(bool inherit) { return m_field.GetCustomAttributes(inherit); }
public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_field.GetCustomAttributes(attributeType, inherit); }
public override bool IsDefined(Type attributeType, bool inherit) { return m_field.IsDefined(attributeType, inherit); }
internal int MetadataTokenInternal
@@ -247,7 +249,7 @@ namespace System.Reflection.Emit
}
}
}
- public override Module Module { get { return m_field.Module; } }
+ public override Module Module { get { return m_field.Module; } }
#endregion
#region Public Abstract\Virtual Members
@@ -260,15 +262,15 @@ namespace System.Reflection.Emit
public override Object GetValueDirect(TypedReference obj)
{
throw new NotImplementedException();
- }
- public override RuntimeFieldHandle FieldHandle
+ }
+ public override RuntimeFieldHandle FieldHandle
{
get { throw new NotImplementedException(); }
- }
+ }
public override Type FieldType { get { throw new NotImplementedException(); } }
public override Object GetValue(Object obj) { throw new InvalidOperationException(); }
public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) { throw new InvalidOperationException(); }
- public override FieldAttributes Attributes { get { return m_field.Attributes; } }
+ public override FieldAttributes Attributes { get { return m_field.Attributes; } }
#endregion
}
}
diff --git a/src/mscorlib/src/System/Reflection/EventAttributes.cs b/src/mscorlib/src/System/Reflection/EventAttributes.cs
deleted file mode 100644
index 4cc08f62d3..0000000000
--- a/src/mscorlib/src/System/Reflection/EventAttributes.cs
+++ /dev/null
@@ -1,29 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// EventAttributes are an enum defining the attributes associated with
-//
-// and Event. These are defined in CorHdr.h and are a combination of
-// bits and enums.
-//
-//
-namespace System.Reflection {
-
- using System;
- [Serializable]
- [Flags]
- public enum EventAttributes {
- None = 0x0000,
-
- // This Enum matchs the CorEventAttr defined in CorHdr.h
- SpecialName = 0x0200, // event is special. Name describes how.
-
- // Reserved flags for Runtime use only.
- ReservedMask = 0x0400,
- RTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding.
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/EventInfo.cs b/src/mscorlib/src/System/Reflection/EventInfo.cs
deleted file mode 100644
index 9b529c2960..0000000000
--- a/src/mscorlib/src/System/Reflection/EventInfo.cs
+++ /dev/null
@@ -1,401 +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
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
- using System.Runtime.InteropServices;
- using System.Runtime.Serialization;
- using System.Runtime.ConstrainedExecution;
- using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
-
- [Serializable]
- public abstract class EventInfo : MemberInfo
- {
- #region Constructor
- protected EventInfo() { }
- #endregion
-
- public static bool operator ==(EventInfo left, EventInfo right)
- {
- if (ReferenceEquals(left, right))
- return true;
-
- if ((object)left == null || (object)right == null ||
- left is RuntimeEventInfo || right is RuntimeEventInfo)
- {
- return false;
- }
- return left.Equals(right);
- }
-
- public static bool operator !=(EventInfo left, EventInfo right)
- {
- return !(left == right);
- }
-
- public override bool Equals(object obj)
- {
- return base.Equals(obj);
- }
-
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
-
- #region MemberInfo Overrides
- public override MemberTypes MemberType { get { return MemberTypes.Event; } }
- #endregion
-
- #region Public Abstract\Virtual Members
- public virtual MethodInfo[] GetOtherMethods(bool nonPublic)
- {
- throw new NotImplementedException();
- }
-
- public abstract MethodInfo GetAddMethod(bool nonPublic);
-
- public abstract MethodInfo GetRemoveMethod(bool nonPublic);
-
- public abstract MethodInfo GetRaiseMethod(bool nonPublic);
-
- public abstract EventAttributes Attributes { get; }
- #endregion
-
- #region Public Members
- public virtual MethodInfo AddMethod
- {
- get
- {
- return GetAddMethod(true);
- }
- }
-
- public virtual MethodInfo RemoveMethod
- {
- get
- {
- return GetRemoveMethod(true);
- }
- }
-
- public virtual MethodInfo RaiseMethod
- {
- get
- {
- return GetRaiseMethod(true);
- }
- }
-
- public MethodInfo[] GetOtherMethods() { return GetOtherMethods(false); }
-
- public MethodInfo GetAddMethod() { return GetAddMethod(false); }
-
- public MethodInfo GetRemoveMethod() { return GetRemoveMethod(false); }
-
- public MethodInfo GetRaiseMethod() { return GetRaiseMethod(false); }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public virtual void AddEventHandler(Object target, Delegate handler)
- {
- MethodInfo addMethod = GetAddMethod();
-
- if (addMethod == null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoPublicAddMethod"));
-
-#if FEATURE_COMINTEROP
- if (addMethod.ReturnType == typeof(System.Runtime.InteropServices.WindowsRuntime.EventRegistrationToken))
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotSupportedOnWinRTEvent"));
-
- // Must be a normal non-WinRT event
- Debug.Assert(addMethod.ReturnType == typeof(void));
-#endif // FEATURE_COMINTEROP
-
- addMethod.Invoke(target, new object[] { handler });
- }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public virtual void RemoveEventHandler(Object target, Delegate handler)
- {
- MethodInfo removeMethod = GetRemoveMethod();
-
- if (removeMethod == null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoPublicRemoveMethod"));
-
-#if FEATURE_COMINTEROP
- ParameterInfo[] parameters = removeMethod.GetParametersNoCopy();
- Debug.Assert(parameters != null && parameters.Length == 1);
-
- if (parameters[0].ParameterType == typeof(System.Runtime.InteropServices.WindowsRuntime.EventRegistrationToken))
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotSupportedOnWinRTEvent"));
-
- // Must be a normal non-WinRT event
- Debug.Assert(parameters[0].ParameterType.BaseType == typeof(MulticastDelegate));
-#endif // FEATURE_COMINTEROP
-
- removeMethod.Invoke(target, new object[] { handler });
- }
-
- public virtual Type EventHandlerType
- {
- get
- {
- MethodInfo m = GetAddMethod(true);
-
- ParameterInfo[] p = m.GetParametersNoCopy();
-
- Type del = typeof(Delegate);
-
- for (int i = 0; i < p.Length; i++)
- {
- Type c = p[i].ParameterType;
-
- if (c.IsSubclassOf(del))
- return c;
- }
- return null;
- }
- }
- public bool IsSpecialName
- {
- get
- {
- return(Attributes & EventAttributes.SpecialName) != 0;
- }
- }
-
- public virtual bool IsMulticast
- {
- get
- {
- Type cl = EventHandlerType;
- Type mc = typeof(MulticastDelegate);
- return mc.IsAssignableFrom(cl);
- }
- }
- #endregion
- }
-
- [Serializable]
- internal unsafe sealed class RuntimeEventInfo : EventInfo, ISerializable
- {
- #region Private Data Members
- private int m_token;
- private EventAttributes m_flags;
- private string m_name;
- private void* m_utf8name;
- private RuntimeTypeCache m_reflectedTypeCache;
- private RuntimeMethodInfo m_addMethod;
- private RuntimeMethodInfo m_removeMethod;
- private RuntimeMethodInfo m_raiseMethod;
- private MethodInfo[] m_otherMethod;
- private RuntimeType m_declaringType;
- private BindingFlags m_bindingFlags;
- #endregion
-
- #region Constructor
- internal RuntimeEventInfo()
- {
- // Used for dummy head node during population
- }
- internal RuntimeEventInfo(int tkEvent, RuntimeType declaredType, RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
- {
- Contract.Requires(declaredType != null);
- Contract.Requires(reflectedTypeCache != null);
- Debug.Assert(!reflectedTypeCache.IsGlobal);
-
- MetadataImport scope = declaredType.GetRuntimeModule().MetadataImport;
-
- m_token = tkEvent;
- m_reflectedTypeCache = reflectedTypeCache;
- m_declaringType = declaredType;
-
-
- RuntimeType reflectedType = reflectedTypeCache.GetRuntimeType();
-
- scope.GetEventProps(tkEvent, out m_utf8name, out m_flags);
-
- RuntimeMethodInfo dummy;
- Associates.AssignAssociates(scope, tkEvent, declaredType, reflectedType,
- out m_addMethod, out m_removeMethod, out m_raiseMethod,
- out dummy, out dummy, out m_otherMethod, out isPrivate, out m_bindingFlags);
- }
- #endregion
-
- #region Internal Members
- internal override bool CacheEquals(object o)
- {
- RuntimeEventInfo m = o as RuntimeEventInfo;
-
- if ((object)m == null)
- return false;
-
- return m.m_token == m_token &&
- RuntimeTypeHandle.GetModule(m_declaringType).Equals(
- RuntimeTypeHandle.GetModule(m.m_declaringType));
- }
-
- internal BindingFlags BindingFlags { get { return m_bindingFlags; } }
- #endregion
-
- #region Object Overrides
- public override String ToString()
- {
- if (m_addMethod == null || m_addMethod.GetParametersNoCopy().Length == 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoPublicAddMethod"));
-
- return m_addMethod.GetParametersNoCopy()[0].ParameterType.FormatTypeName() + " " + Name;
- }
- #endregion
-
- #region ICustomAttributeProvider
- public override Object[] GetCustomAttributes(bool inherit)
- {
- return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType);
- }
-
- public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
- {
- if (attributeType == null)
- throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
-
- RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
-
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
-
- return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
- }
-
- public override bool IsDefined(Type attributeType, bool inherit)
- {
- if (attributeType == null)
- throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
-
- RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
-
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
-
- return CustomAttribute.IsDefined(this, attributeRuntimeType);
- }
-
- public override IList<CustomAttributeData> GetCustomAttributesData()
- {
- return CustomAttributeData.GetCustomAttributesInternal(this);
- }
- #endregion
-
- #region MemberInfo Overrides
- public override MemberTypes MemberType { get { return MemberTypes.Event; } }
- public override String Name
- {
- get
- {
- if (m_name == null)
- m_name = new Utf8String(m_utf8name).ToString();
-
- return m_name;
- }
- }
- public override Type DeclaringType { get { return m_declaringType; } }
- public override Type ReflectedType
- {
- get
- {
- return ReflectedTypeInternal;
- }
- }
-
- private RuntimeType ReflectedTypeInternal
- {
- get
- {
- return m_reflectedTypeCache.GetRuntimeType();
- }
- }
-
- public override int MetadataToken { get { return m_token; } }
- public override Module Module { get { return GetRuntimeModule(); } }
- internal RuntimeModule GetRuntimeModule() { return m_declaringType.GetRuntimeModule(); }
- #endregion
-
- #region ISerializable
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- MemberInfoSerializationHolder.GetSerializationInfo(
- info,
- Name,
- ReflectedTypeInternal,
- null,
- MemberTypes.Event);
- }
- #endregion
-
- #region EventInfo Overrides
- public override MethodInfo[] GetOtherMethods(bool nonPublic)
- {
- List<MethodInfo> ret = new List<MethodInfo>();
-
- if ((object)m_otherMethod == null)
- return new MethodInfo[0];
-
- for(int i = 0; i < m_otherMethod.Length; i ++)
- {
- if (Associates.IncludeAccessor((MethodInfo)m_otherMethod[i], nonPublic))
- ret.Add(m_otherMethod[i]);
- }
-
- return ret.ToArray();
- }
-
- public override MethodInfo GetAddMethod(bool nonPublic)
- {
- if (!Associates.IncludeAccessor(m_addMethod, nonPublic))
- return null;
-
- return m_addMethod;
- }
-
- public override MethodInfo GetRemoveMethod(bool nonPublic)
- {
- if (!Associates.IncludeAccessor(m_removeMethod, nonPublic))
- return null;
-
- return m_removeMethod;
- }
-
- public override MethodInfo GetRaiseMethod(bool nonPublic)
- {
- if (!Associates.IncludeAccessor(m_raiseMethod, nonPublic))
- return null;
-
- return m_raiseMethod;
- }
-
- public override EventAttributes Attributes
- {
- get
- {
- return m_flags;
- }
- }
- #endregion
- }
-
-}
diff --git a/src/mscorlib/src/System/Reflection/ExceptionHandlingClause.cs b/src/mscorlib/src/System/Reflection/ExceptionHandlingClause.cs
new file mode 100644
index 0000000000..9bb45aebb2
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/ExceptionHandlingClause.cs
@@ -0,0 +1,93 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Globalization;
+using System.Diagnostics.Contracts;
+
+namespace System.Reflection
+{
+ public class ExceptionHandlingClause
+ {
+ #region costructor
+ // This class can only be created from inside the EE.
+ protected ExceptionHandlingClause() { }
+ #endregion
+
+ #region Private Data Members
+ private MethodBody m_methodBody;
+ [ContractPublicPropertyName("Flags")]
+ private ExceptionHandlingClauseOptions m_flags;
+ private int m_tryOffset;
+ private int m_tryLength;
+ private int m_handlerOffset;
+ private int m_handlerLength;
+ private int m_catchMetadataToken;
+ private int m_filterOffset;
+ #endregion
+
+ #region Public Members
+ public virtual ExceptionHandlingClauseOptions Flags { get { return m_flags; } }
+ public virtual int TryOffset { get { return m_tryOffset; } }
+ public virtual int TryLength { get { return m_tryLength; } }
+ public virtual int HandlerOffset { get { return m_handlerOffset; } }
+ public virtual int HandlerLength { get { return m_handlerLength; } }
+
+ public virtual int FilterOffset
+ {
+ get
+ {
+ if (m_flags != ExceptionHandlingClauseOptions.Filter)
+ throw new InvalidOperationException(SR.Arg_EHClauseNotFilter);
+
+ return m_filterOffset;
+ }
+ }
+
+ public virtual Type CatchType
+ {
+ get
+ {
+ if (m_flags != ExceptionHandlingClauseOptions.Clause)
+ throw new InvalidOperationException(SR.Arg_EHClauseNotClause);
+
+ Type type = null;
+
+ if (!MetadataToken.IsNullToken(m_catchMetadataToken))
+ {
+ Type declaringType = m_methodBody.m_methodBase.DeclaringType;
+ Module module = (declaringType == null) ? m_methodBody.m_methodBase.Module : declaringType.Module;
+ type = module.ResolveType(m_catchMetadataToken, (declaringType == null) ? null : declaringType.GetGenericArguments(),
+ m_methodBody.m_methodBase is MethodInfo ? m_methodBody.m_methodBase.GetGenericArguments() : null);
+ }
+
+ return type;
+ }
+ }
+ #endregion
+
+ #region Object Overrides
+ public override string ToString()
+ {
+ if (Flags == ExceptionHandlingClauseOptions.Clause)
+ {
+ return String.Format(CultureInfo.CurrentUICulture,
+ "Flags={0}, TryOffset={1}, TryLength={2}, HandlerOffset={3}, HandlerLength={4}, CatchType={5}",
+ Flags, TryOffset, TryLength, HandlerOffset, HandlerLength, CatchType);
+ }
+
+ if (Flags == ExceptionHandlingClauseOptions.Filter)
+ {
+ return String.Format(CultureInfo.CurrentUICulture,
+ "Flags={0}, TryOffset={1}, TryLength={2}, HandlerOffset={3}, HandlerLength={4}, FilterOffset={5}",
+ Flags, TryOffset, TryLength, HandlerOffset, HandlerLength, FilterOffset);
+ }
+
+ return String.Format(CultureInfo.CurrentUICulture,
+ "Flags={0}, TryOffset={1}, TryLength={2}, HandlerOffset={3}, HandlerLength={4}",
+ Flags, TryOffset, TryLength, HandlerOffset, HandlerLength);
+ }
+ #endregion
+ }
+}
+
diff --git a/src/mscorlib/src/System/Reflection/FieldAttributes.cs b/src/mscorlib/src/System/Reflection/FieldAttributes.cs
deleted file mode 100644
index e49a0a45b1..0000000000
--- a/src/mscorlib/src/System/Reflection/FieldAttributes.cs
+++ /dev/null
@@ -1,42 +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
-{
- using System;
- // This Enum matchs the CorFieldAttr defined in CorHdr.h
- [Serializable]
- [Flags()]
- public enum FieldAttributes
- {
- // member access mask - Use this mask to retrieve accessibility information.
- FieldAccessMask = 0x0007,
- PrivateScope = 0x0000, // Member not referenceable.
- Private = 0x0001, // Accessible only by the parent type.
- FamANDAssem = 0x0002, // Accessible by sub-types only in this Assembly.
- Assembly = 0x0003, // Accessibly by anyone in the Assembly.
- Family = 0x0004, // Accessible only by type and sub-types.
- FamORAssem = 0x0005, // Accessibly by sub-types anywhere, plus anyone in assembly.
- Public = 0x0006, // Accessibly by anyone who has visibility to this scope.
- // end member access mask
-
- // field contract attributes.
- Static = 0x0010, // Defined on type, else per instance.
- InitOnly = 0x0020, // Field may only be initialized, not written to after init.
- Literal = 0x0040, // Value is compile time constant.
- NotSerialized = 0x0080, // Field does not have to be serialized when type is remoted.
-
- SpecialName = 0x0200, // field is special. Name describes how.
-
- // interop attributes
- PinvokeImpl = 0x2000, // Implementation is forwarded through pinvoke.
-
- // Reserved flags for runtime use only.
- ReservedMask = 0x9500,
- RTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding.
- HasFieldMarshal = 0x1000, // Field has marshalling information.
- HasDefault = 0x8000, // Field has default.
- HasFieldRVA = 0x0100, // Field has RVA.
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/FieldInfo.CoreCLR.cs b/src/mscorlib/src/System/Reflection/FieldInfo.CoreCLR.cs
new file mode 100644
index 0000000000..bcda3418fa
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/FieldInfo.CoreCLR.cs
@@ -0,0 +1,35 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Globalization;
+
+namespace System.Reflection
+{
+ public abstract partial class FieldInfo : MemberInfo
+ {
+ public static FieldInfo GetFieldFromHandle(RuntimeFieldHandle handle)
+ {
+ if (handle.IsNullHandle())
+ throw new ArgumentException(SR.Argument_InvalidHandle, nameof(handle));
+
+ FieldInfo f = RuntimeType.GetFieldInfo(handle.GetRuntimeFieldInfo());
+
+ Type declaringType = f.DeclaringType;
+ if (declaringType != null && declaringType.IsGenericType)
+ throw new ArgumentException(String.Format(
+ CultureInfo.CurrentCulture, SR.Argument_FieldDeclaringTypeGeneric,
+ f.Name, declaringType.GetGenericTypeDefinition()));
+
+ return f;
+ }
+
+ public static FieldInfo GetFieldFromHandle(RuntimeFieldHandle handle, RuntimeTypeHandle declaringType)
+ {
+ if (handle.IsNullHandle())
+ throw new ArgumentException(SR.Argument_InvalidHandle);
+
+ return RuntimeType.GetFieldInfo(declaringType.GetRuntimeType(), handle.GetRuntimeFieldInfo());
+ }
+ }
+}
diff --git a/src/mscorlib/src/System/Reflection/FieldInfo.cs b/src/mscorlib/src/System/Reflection/FieldInfo.cs
deleted file mode 100644
index 7b6517c2bb..0000000000
--- a/src/mscorlib/src/System/Reflection/FieldInfo.cs
+++ /dev/null
@@ -1,862 +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
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
- using System.Globalization;
- using System.Runtime;
- using System.Runtime.CompilerServices;
- using System.Runtime.ConstrainedExecution;
- using System.Runtime.InteropServices;
- using System.Runtime.Serialization;
- using System.Threading;
- using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
-
- [Serializable]
- public abstract class FieldInfo : MemberInfo
- {
- #region Static Members
- public static FieldInfo GetFieldFromHandle(RuntimeFieldHandle handle)
- {
- if (handle.IsNullHandle())
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"), nameof(handle));
-
- FieldInfo f = RuntimeType.GetFieldInfo(handle.GetRuntimeFieldInfo());
-
- Type declaringType = f.DeclaringType;
- if (declaringType != null && declaringType.IsGenericType)
- throw new ArgumentException(String.Format(
- CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_FieldDeclaringTypeGeneric"),
- f.Name, declaringType.GetGenericTypeDefinition()));
-
- return f;
- }
-
- public static FieldInfo GetFieldFromHandle(RuntimeFieldHandle handle, RuntimeTypeHandle declaringType)
- {
- if (handle.IsNullHandle())
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));
-
- return RuntimeType.GetFieldInfo(declaringType.GetRuntimeType(), handle.GetRuntimeFieldInfo());
- }
- #endregion
-
- #region Constructor
- protected FieldInfo() { }
- #endregion
-
- public static bool operator ==(FieldInfo left, FieldInfo right)
- {
- if (ReferenceEquals(left, right))
- return true;
-
- if ((object)left == null || (object)right == null ||
- left is RuntimeFieldInfo || right is RuntimeFieldInfo)
- {
- return false;
- }
- return left.Equals(right);
- }
-
- public static bool operator !=(FieldInfo left, FieldInfo right)
- {
- return !(left == right);
- }
-
- public override bool Equals(object obj)
- {
- return base.Equals(obj);
- }
-
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
-
- #region MemberInfo Overrides
- public override MemberTypes MemberType { get { return System.Reflection.MemberTypes.Field; } }
- #endregion
-
- #region Public Abstract\Virtual Members
-
- public virtual Type[] GetRequiredCustomModifiers()
- {
- throw new NotImplementedException();
- }
-
- public virtual Type[] GetOptionalCustomModifiers()
- {
- throw new NotImplementedException();
- }
-
- [CLSCompliant(false)]
- public virtual void SetValueDirect(TypedReference obj, Object value)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_AbstractNonCLS"));
- }
-
- [CLSCompliant(false)]
- public virtual Object GetValueDirect(TypedReference obj)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_AbstractNonCLS"));
- }
-
- public abstract RuntimeFieldHandle FieldHandle { get; }
-
- public abstract Type FieldType { get; }
-
- public abstract Object GetValue(Object obj);
-
- public virtual Object GetRawConstantValue() { throw new NotSupportedException(Environment.GetResourceString("NotSupported_AbstractNonCLS")); }
-
- public abstract void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture);
-
- public abstract FieldAttributes Attributes { get; }
- #endregion
-
- #region Public Members
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public void SetValue(Object obj, Object value)
- {
- // Theoretically we should set up a LookForMyCaller stack mark here and pass that along.
- // But to maintain backward compatibility we can't switch to calling an
- // internal overload that takes a stack mark.
- // Fortunately the stack walker skips all the reflection invocation frames including this one.
- // So this method will never be returned by the stack walker as the caller.
- // See SystemDomain::CallersMethodCallbackWithStackMark in AppDomain.cpp.
- SetValue(obj, value, BindingFlags.Default, Type.DefaultBinder, null);
- }
-
- public bool IsPublic { get { return(Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public; } }
-
- public bool IsPrivate { get { return(Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Private; } }
-
- public bool IsFamily { get { return(Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family; } }
-
- public bool IsAssembly { get { return(Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Assembly; } }
-
- public bool IsFamilyAndAssembly { get { return(Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamANDAssem; } }
-
- public bool IsFamilyOrAssembly { get { return(Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamORAssem; } }
-
- public bool IsStatic { get { return(Attributes & FieldAttributes.Static) != 0; } }
-
- public bool IsInitOnly { get { return(Attributes & FieldAttributes.InitOnly) != 0; } }
-
- public bool IsLiteral { get { return(Attributes & FieldAttributes.Literal) != 0; } }
-
- public bool IsNotSerialized { get { return(Attributes & FieldAttributes.NotSerialized) != 0; } }
-
- public bool IsSpecialName { get { return(Attributes & FieldAttributes.SpecialName) != 0; } }
-
- public bool IsPinvokeImpl { get { return(Attributes & FieldAttributes.PinvokeImpl) != 0; } }
-
- public virtual bool IsSecurityCritical
- {
- get { return FieldHandle.IsSecurityCritical(); }
- }
-
- public virtual bool IsSecuritySafeCritical
- {
- get { return FieldHandle.IsSecuritySafeCritical(); }
- }
-
- public virtual bool IsSecurityTransparent
- {
- get { return FieldHandle.IsSecurityTransparent(); }
- }
-
- #endregion
- }
-
- [Serializable]
- internal abstract class RuntimeFieldInfo : FieldInfo, ISerializable
- {
- #region Private Data Members
- private BindingFlags m_bindingFlags;
- protected RuntimeTypeCache m_reflectedTypeCache;
- protected RuntimeType m_declaringType;
- #endregion
-
- #region Constructor
- protected RuntimeFieldInfo()
- {
- // Used for dummy head node during population
- }
- protected RuntimeFieldInfo(RuntimeTypeCache reflectedTypeCache, RuntimeType declaringType, BindingFlags bindingFlags)
- {
- m_bindingFlags = bindingFlags;
- m_declaringType = declaringType;
- m_reflectedTypeCache = reflectedTypeCache;
- }
- #endregion
-
- #region NonPublic Members
- internal BindingFlags BindingFlags { get { return m_bindingFlags; } }
- private RuntimeType ReflectedTypeInternal
- {
- get
- {
- return m_reflectedTypeCache.GetRuntimeType();
- }
- }
-
- internal RuntimeType GetDeclaringTypeInternal()
- {
- return m_declaringType;
- }
-
- internal RuntimeType GetRuntimeType() { return m_declaringType; }
- internal abstract RuntimeModule GetRuntimeModule();
- #endregion
-
- #region MemberInfo Overrides
- public override MemberTypes MemberType { get { return MemberTypes.Field; } }
- public override Type ReflectedType
- {
- get
- {
- return m_reflectedTypeCache.IsGlobal ? null : ReflectedTypeInternal;
- }
- }
-
- public override Type DeclaringType
- {
- get
- {
- return m_reflectedTypeCache.IsGlobal ? null : m_declaringType;
- }
- }
-
- public override Module Module { get { return GetRuntimeModule(); } }
- #endregion
-
- #region Object Overrides
- public unsafe override String ToString()
- {
- return FieldType.FormatTypeName() + " " + Name;
- }
- #endregion
-
- #region ICustomAttributeProvider
- public override Object[] GetCustomAttributes(bool inherit)
- {
- return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType);
- }
-
- public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
- {
- if (attributeType == null)
- throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
-
- RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
-
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
-
- return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
- }
-
- public override bool IsDefined(Type attributeType, bool inherit)
- {
- if (attributeType == null)
- throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
-
- RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
-
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
-
- return CustomAttribute.IsDefined(this, attributeRuntimeType);
- }
-
- public override IList<CustomAttributeData> GetCustomAttributesData()
- {
- return CustomAttributeData.GetCustomAttributesInternal(this);
- }
- #endregion
-
- #region FieldInfo Overrides
- // All implemented on derived classes
- #endregion
-
- #region ISerializable Implementation
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
- MemberInfoSerializationHolder.GetSerializationInfo(
- info,
- Name,
- ReflectedTypeInternal,
- ToString(),
- MemberTypes.Field);
- }
- #endregion
- }
-
- [Serializable]
- internal unsafe sealed class RtFieldInfo : RuntimeFieldInfo, IRuntimeFieldInfo
- {
- #region FCalls
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static private extern void PerformVisibilityCheckOnField(IntPtr field, Object target, RuntimeType declaringType, FieldAttributes attr, uint invocationFlags);
- #endregion
-
- #region Private Data Members
- // agressive caching
- private IntPtr m_fieldHandle;
- private FieldAttributes m_fieldAttributes;
- // lazy caching
- private string m_name;
- private RuntimeType m_fieldType;
- private INVOCATION_FLAGS m_invocationFlags;
-
-#if FEATURE_APPX
- private bool IsNonW8PFrameworkAPI()
- {
- if (GetRuntimeType().IsNonW8PFrameworkAPI())
- return true;
-
- // Allow "value__"
- if (m_declaringType.IsEnum)
- return false;
-
- RuntimeAssembly rtAssembly = GetRuntimeAssembly();
- if (rtAssembly.IsFrameworkAssembly())
- {
- int ctorToken = rtAssembly.InvocableAttributeCtorToken;
- if (System.Reflection.MetadataToken.IsNullToken(ctorToken) ||
- !CustomAttribute.IsAttributeDefined(GetRuntimeModule(), MetadataToken, ctorToken))
- return true;
- }
-
- return false;
- }
-#endif
-
- internal INVOCATION_FLAGS InvocationFlags
- {
- get
- {
- if ((m_invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_INITIALIZED) == 0)
- {
- Type declaringType = DeclaringType;
- bool fIsReflectionOnlyType = (declaringType is ReflectionOnlyType);
-
- INVOCATION_FLAGS invocationFlags = 0;
-
- // first take care of all the NO_INVOKE cases
- if (
- (declaringType != null && declaringType.ContainsGenericParameters) ||
- (declaringType == null && Module.Assembly.ReflectionOnly) ||
- (fIsReflectionOnlyType)
- )
- {
- invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE;
- }
-
- // If the invocationFlags are still 0, then
- // this should be an usable field, determine the other flags
- if (invocationFlags == 0)
- {
- if ((m_fieldAttributes & FieldAttributes.InitOnly) != (FieldAttributes)0)
- invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_SPECIAL_FIELD;
-
- if ((m_fieldAttributes & FieldAttributes.HasFieldRVA) != (FieldAttributes)0)
- invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_SPECIAL_FIELD;
-
- // A public field is inaccesible to Transparent code if the field is Critical.
- bool needsTransparencySecurityCheck = IsSecurityCritical && !IsSecuritySafeCritical;
- bool needsVisibilitySecurityCheck = ((m_fieldAttributes & FieldAttributes.FieldAccessMask) != FieldAttributes.Public) ||
- (declaringType != null && declaringType.NeedsReflectionSecurityCheck);
- if (needsTransparencySecurityCheck || needsVisibilitySecurityCheck)
- invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY;
-
- // find out if the field type is one of the following: Primitive, Enum or Pointer
- Type fieldType = FieldType;
- if (fieldType.IsPointer || fieldType.IsEnum || fieldType.IsPrimitive)
- invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_FIELD_SPECIAL_CAST;
- }
-
-#if FEATURE_APPX
- if (AppDomain.ProfileAPICheck && IsNonW8PFrameworkAPI())
- invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API;
-#endif // FEATURE_APPX
-
- // must be last to avoid threading problems
- m_invocationFlags = invocationFlags | INVOCATION_FLAGS.INVOCATION_FLAGS_INITIALIZED;
- }
-
- return m_invocationFlags;
- }
- }
- #endregion
-
- private RuntimeAssembly GetRuntimeAssembly() { return m_declaringType.GetRuntimeAssembly(); }
-
- #region Constructor
- internal RtFieldInfo(
- RuntimeFieldHandleInternal handle, RuntimeType declaringType, RuntimeTypeCache reflectedTypeCache, BindingFlags bindingFlags)
- : base(reflectedTypeCache, declaringType, bindingFlags)
- {
- m_fieldHandle = handle.Value;
- m_fieldAttributes = RuntimeFieldHandle.GetAttributes(handle);
- }
- #endregion
-
- #region Private Members
- RuntimeFieldHandleInternal IRuntimeFieldInfo.Value
- {
- get
- {
- return new RuntimeFieldHandleInternal(m_fieldHandle);
- }
- }
-
- #endregion
-
- #region Internal Members
- internal void CheckConsistency(Object target)
- {
- // only test instance fields
- if ((m_fieldAttributes & FieldAttributes.Static) != FieldAttributes.Static)
- {
- if (!m_declaringType.IsInstanceOfType(target))
- {
- if (target == null)
- {
- throw new TargetException(Environment.GetResourceString("RFLCT.Targ_StatFldReqTarg"));
- }
- else
- {
- throw new ArgumentException(
- String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Arg_FieldDeclTarget"),
- Name, m_declaringType, target.GetType()));
- }
- }
- }
- }
-
- internal override bool CacheEquals(object o)
- {
- RtFieldInfo m = o as RtFieldInfo;
-
- if ((object)m == null)
- return false;
-
- return m.m_fieldHandle == m_fieldHandle;
- }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- internal void InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, ref StackCrawlMark stackMark)
- {
- INVOCATION_FLAGS invocationFlags = InvocationFlags;
- RuntimeType declaringType = DeclaringType as RuntimeType;
-
- if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != 0)
- {
- if (declaringType != null && declaringType.ContainsGenericParameters)
- throw new InvalidOperationException(Environment.GetResourceString("Arg_UnboundGenField"));
-
- if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType)
- throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyField"));
-
- throw new FieldAccessException();
- }
-
- CheckConsistency(obj);
-
- RuntimeType fieldType = (RuntimeType)FieldType;
- value = fieldType.CheckValue(value, binder, culture, invokeAttr);
-
- #region Security Check
-#if FEATURE_APPX
- if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- {
- RuntimeAssembly caller = RuntimeAssembly.GetExecutingAssembly(ref stackMark);
- if (caller != null && !caller.IsSafeForReflection())
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", FullName));
- }
-#endif
-
- if ((invocationFlags & (INVOCATION_FLAGS.INVOCATION_FLAGS_SPECIAL_FIELD | INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY)) != 0)
- PerformVisibilityCheckOnField(m_fieldHandle, obj, m_declaringType, m_fieldAttributes, (uint)m_invocationFlags);
- #endregion
-
- bool domainInitialized = false;
- if (declaringType == null)
- {
- RuntimeFieldHandle.SetValue(this, obj, value, fieldType, m_fieldAttributes, null, ref domainInitialized);
- }
- else
- {
- domainInitialized = declaringType.DomainInitialized;
- RuntimeFieldHandle.SetValue(this, obj, value, fieldType, m_fieldAttributes, declaringType, ref domainInitialized);
- declaringType.DomainInitialized = domainInitialized;
- }
- }
-
- // UnsafeSetValue doesn't perform any consistency or visibility check.
- // It is the caller's responsibility to ensure the operation is safe.
- // When the caller needs to perform visibility checks they should call
- // InternalSetValue() instead. When the caller needs to perform
- // consistency checks they should call CheckConsistency() before
- // calling this method.
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- internal void UnsafeSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
- {
- RuntimeType declaringType = DeclaringType as RuntimeType;
- RuntimeType fieldType = (RuntimeType)FieldType;
- value = fieldType.CheckValue(value, binder, culture, invokeAttr);
-
- bool domainInitialized = false;
- if (declaringType == null)
- {
- RuntimeFieldHandle.SetValue(this, obj, value, fieldType, m_fieldAttributes, null, ref domainInitialized);
- }
- else
- {
- domainInitialized = declaringType.DomainInitialized;
- RuntimeFieldHandle.SetValue(this, obj, value, fieldType, m_fieldAttributes, declaringType, ref domainInitialized);
- declaringType.DomainInitialized = domainInitialized;
- }
- }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- internal Object InternalGetValue(Object obj, ref StackCrawlMark stackMark)
- {
- INVOCATION_FLAGS invocationFlags = InvocationFlags;
- RuntimeType declaringType = DeclaringType as RuntimeType;
-
- if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != 0)
- {
- if (declaringType != null && DeclaringType.ContainsGenericParameters)
- throw new InvalidOperationException(Environment.GetResourceString("Arg_UnboundGenField"));
-
- if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType)
- throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyField"));
-
- throw new FieldAccessException();
- }
-
- CheckConsistency(obj);
-
-#if FEATURE_APPX
- if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- {
- RuntimeAssembly caller = RuntimeAssembly.GetExecutingAssembly(ref stackMark);
- if (caller != null && !caller.IsSafeForReflection())
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", FullName));
- }
-#endif
-
- RuntimeType fieldType = (RuntimeType)FieldType;
- if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY) != 0)
- PerformVisibilityCheckOnField(m_fieldHandle, obj, m_declaringType, m_fieldAttributes, (uint)(m_invocationFlags & ~INVOCATION_FLAGS.INVOCATION_FLAGS_SPECIAL_FIELD));
-
- return UnsafeGetValue(obj);
- }
-
- // UnsafeGetValue doesn't perform any consistency or visibility check.
- // It is the caller's responsibility to ensure the operation is safe.
- // When the caller needs to perform visibility checks they should call
- // InternalGetValue() instead. When the caller needs to perform
- // consistency checks they should call CheckConsistency() before
- // calling this method.
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- internal Object UnsafeGetValue(Object obj)
- {
- RuntimeType declaringType = DeclaringType as RuntimeType;
-
- RuntimeType fieldType = (RuntimeType)FieldType;
-
- bool domainInitialized = false;
- if (declaringType == null)
- {
- return RuntimeFieldHandle.GetValue(this, obj, fieldType, null, ref domainInitialized);
- }
- else
- {
- domainInitialized = declaringType.DomainInitialized;
- object retVal = RuntimeFieldHandle.GetValue(this, obj, fieldType, declaringType, ref domainInitialized);
- declaringType.DomainInitialized = domainInitialized;
- return retVal;
- }
- }
-
- #endregion
-
- #region MemberInfo Overrides
- public override String Name
- {
- get
- {
- if (m_name == null)
- m_name = RuntimeFieldHandle.GetName(this);
-
- return m_name;
- }
- }
-
- internal String FullName
- {
- get
- {
- return String.Format("{0}.{1}", DeclaringType.FullName, Name);
- }
- }
-
- public override int MetadataToken
- {
- get { return RuntimeFieldHandle.GetToken(this); }
- }
-
- internal override RuntimeModule GetRuntimeModule()
- {
- return RuntimeTypeHandle.GetModule(RuntimeFieldHandle.GetApproxDeclaringType(this));
- }
-
- #endregion
-
- #region FieldInfo Overrides
- public override Object GetValue(Object obj)
- {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return InternalGetValue(obj, ref stackMark);
- }
-
- public override object GetRawConstantValue() { throw new InvalidOperationException(); }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public override Object GetValueDirect(TypedReference obj)
- {
- if (obj.IsNull)
- throw new ArgumentException(Environment.GetResourceString("Arg_TypedReference_Null"));
- Contract.EndContractBlock();
-
- unsafe
- {
- // Passing TypedReference by reference is easier to make correct in native code
- return RuntimeFieldHandle.GetValueDirect(this, (RuntimeType)FieldType, &obj, (RuntimeType)DeclaringType);
- }
- }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
- {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- InternalSetValue(obj, value, invokeAttr, binder, culture, ref stackMark);
- }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public override void SetValueDirect(TypedReference obj, Object value)
- {
- if (obj.IsNull)
- throw new ArgumentException(Environment.GetResourceString("Arg_TypedReference_Null"));
- Contract.EndContractBlock();
-
- unsafe
- {
- // Passing TypedReference by reference is easier to make correct in native code
- RuntimeFieldHandle.SetValueDirect(this, (RuntimeType)FieldType, &obj, value, (RuntimeType)DeclaringType);
- }
- }
-
- public override RuntimeFieldHandle FieldHandle
- {
- get
- {
- Type declaringType = DeclaringType;
- if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInReflectionOnly"));
- return new RuntimeFieldHandle(this);
- }
- }
-
- internal IntPtr GetFieldHandle()
- {
- return m_fieldHandle;
- }
-
- public override FieldAttributes Attributes
- {
- get
- {
- return m_fieldAttributes;
- }
- }
-
- public override Type FieldType
- {
- get
- {
- if (m_fieldType == null)
- m_fieldType = new Signature(this, m_declaringType).FieldType;
-
- return m_fieldType;
- }
- }
-
- public override Type[] GetRequiredCustomModifiers()
- {
- return new Signature(this, m_declaringType).GetCustomModifiers(1, true);
- }
-
- public override Type[] GetOptionalCustomModifiers()
- {
- return new Signature(this, m_declaringType).GetCustomModifiers(1, false);
- }
-
- #endregion
- }
-
- [Serializable]
- internal sealed unsafe class MdFieldInfo : RuntimeFieldInfo, ISerializable
- {
- #region Private Data Members
- private int m_tkField;
- private string m_name;
- private RuntimeType m_fieldType;
- private FieldAttributes m_fieldAttributes;
- #endregion
-
- #region Constructor
- internal MdFieldInfo(
- int tkField, FieldAttributes fieldAttributes, RuntimeTypeHandle declaringTypeHandle, RuntimeTypeCache reflectedTypeCache, BindingFlags bindingFlags)
- : base(reflectedTypeCache, declaringTypeHandle.GetRuntimeType(), bindingFlags)
- {
- m_tkField = tkField;
- m_name = null;
- m_fieldAttributes = fieldAttributes;
- }
- #endregion
-
- #region Internal Members
- internal override bool CacheEquals(object o)
- {
- MdFieldInfo m = o as MdFieldInfo;
-
- if ((object)m == null)
- return false;
-
- return m.m_tkField == m_tkField &&
- m_declaringType.GetTypeHandleInternal().GetModuleHandle().Equals(
- m.m_declaringType.GetTypeHandleInternal().GetModuleHandle());
- }
- #endregion
-
- #region MemberInfo Overrides
- public override String Name
- {
- get
- {
- if (m_name == null)
- m_name = GetRuntimeModule().MetadataImport.GetName(m_tkField).ToString();
-
- return m_name;
- }
- }
-
- public override int MetadataToken { get { return m_tkField; } }
- internal override RuntimeModule GetRuntimeModule() { return m_declaringType.GetRuntimeModule(); }
- #endregion
-
- #region FieldInfo Overrides
- public override RuntimeFieldHandle FieldHandle { get { throw new NotSupportedException(); } }
- public override FieldAttributes Attributes { get { return m_fieldAttributes; } }
-
- public override bool IsSecurityCritical { get { return DeclaringType.IsSecurityCritical; } }
- public override bool IsSecuritySafeCritical { get { return DeclaringType.IsSecuritySafeCritical; } }
- public override bool IsSecurityTransparent { get { return DeclaringType.IsSecurityTransparent; } }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public override Object GetValueDirect(TypedReference obj)
- {
- return GetValue(null);
- }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public override void SetValueDirect(TypedReference obj,Object value)
- {
- throw new FieldAccessException(Environment.GetResourceString("Acc_ReadOnly"));
- }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public unsafe override Object GetValue(Object obj)
- {
- return GetValue(false);
- }
-
- public unsafe override Object GetRawConstantValue() { return GetValue(true); }
-
- private unsafe Object GetValue(bool raw)
- {
- // Cannot cache these because they could be user defined non-agile enumerations
-
- Object value = MdConstant.GetValue(GetRuntimeModule().MetadataImport, m_tkField, FieldType.GetTypeHandleInternal(), raw);
-
- if (value == DBNull.Value)
- throw new NotSupportedException(Environment.GetResourceString("Arg_EnumLitValueNotFound"));
-
- return value;
- }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
- {
- throw new FieldAccessException(Environment.GetResourceString("Acc_ReadOnly"));
- }
-
- public override Type FieldType
- {
- get
- {
- if (m_fieldType == null)
- {
- ConstArray fieldMarshal = GetRuntimeModule().MetadataImport.GetSigOfFieldDef(m_tkField);
-
- m_fieldType = new Signature(fieldMarshal.Signature.ToPointer(),
- (int)fieldMarshal.Length, m_declaringType).FieldType;
- }
-
- return m_fieldType;
- }
- }
-
- public override Type[] GetRequiredCustomModifiers()
- {
- return EmptyArray<Type>.Value;
- }
-
- public override Type[] GetOptionalCustomModifiers()
- {
- return EmptyArray<Type>.Value;
- }
-
- #endregion
- }
-
-}
diff --git a/src/mscorlib/src/System/Reflection/GenericParameterAttributes.cs b/src/mscorlib/src/System/Reflection/GenericParameterAttributes.cs
deleted file mode 100644
index d954b2e0f2..0000000000
--- a/src/mscorlib/src/System/Reflection/GenericParameterAttributes.cs
+++ /dev/null
@@ -1,22 +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
-{
- [Flags()]
- public enum GenericParameterAttributes
- {
- None = 0x0000,
- VarianceMask = 0x0003,
- Covariant = 0x0001,
- Contravariant = 0x0002,
- SpecialConstraintMask = 0x001C,
- ReferenceTypeConstraint = 0x0004,
- NotNullableValueTypeConstraint = 0x0008,
- DefaultConstructorConstraint = 0x0010,
- }
-}
-
diff --git a/src/mscorlib/src/System/Reflection/ICustomAttributeProvider.cs b/src/mscorlib/src/System/Reflection/ICustomAttributeProvider.cs
deleted file mode 100644
index faea91a81e..0000000000
--- a/src/mscorlib/src/System/Reflection/ICustomAttributeProvider.cs
+++ /dev/null
@@ -1,33 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// ICustomAttributeProvider is an interface that is implemented by reflection
-//
-// objects which support custom attributes.
-//
-//
-namespace System.Reflection {
-
- using System;
-
- // Interface does not need to be marked with the serializable attribute
- public interface ICustomAttributeProvider
- {
-
- // Return an array of custom attributes identified by Type
- Object[] GetCustomAttributes(Type attributeType, bool inherit);
-
-
- // Return an array of all of the custom attributes (named attributes are not included)
- Object[] GetCustomAttributes(bool inherit);
-
-
- // Returns true if one or more instance of attributeType is defined on this member.
- bool IsDefined (Type attributeType, bool inherit);
-
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/INVOCATION_FLAGS.cs b/src/mscorlib/src/System/Reflection/INVOCATION_FLAGS.cs
new file mode 100644
index 0000000000..6ffc3e968b
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/INVOCATION_FLAGS.cs
@@ -0,0 +1,38 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Reflection
+{
+ //
+ // Invocation cached flags. Those are used in unmanaged code as well
+ // so be careful if you change them
+ //
+ [Flags]
+ internal enum INVOCATION_FLAGS : uint
+ {
+ INVOCATION_FLAGS_UNKNOWN = 0x00000000,
+ INVOCATION_FLAGS_INITIALIZED = 0x00000001,
+ // it's used for both method and field to signify that no access is allowed
+ INVOCATION_FLAGS_NO_INVOKE = 0x00000002,
+ INVOCATION_FLAGS_NEED_SECURITY = 0x00000004,
+ // Set for static ctors and ctors on abstract types, which
+ // can be invoked only if the "this" object is provided (even if it's null).
+ INVOCATION_FLAGS_NO_CTOR_INVOKE = 0x00000008,
+ // because field and method are different we can reuse the same bits
+ // method
+ INVOCATION_FLAGS_IS_CTOR = 0x00000010,
+ INVOCATION_FLAGS_RISKY_METHOD = 0x00000020,
+ /* unused 0x00000040 */
+ INVOCATION_FLAGS_IS_DELEGATE_CTOR = 0x00000080,
+ INVOCATION_FLAGS_CONTAINS_STACK_POINTERS = 0x00000100,
+ // field
+ INVOCATION_FLAGS_SPECIAL_FIELD = 0x00000010,
+ INVOCATION_FLAGS_FIELD_SPECIAL_CAST = 0x00000020,
+
+ // temporary flag used for flagging invocation of method vs ctor
+ // this flag never appears on the instance m_invocationFlag and is simply
+ // passed down from within ConstructorInfo.Invoke()
+ INVOCATION_FLAGS_CONSTRUCTOR_INVOKE = 0x10000000,
+ }
+}
diff --git a/src/mscorlib/src/System/Reflection/IReflect.cs b/src/mscorlib/src/System/Reflection/IReflect.cs
deleted file mode 100644
index 1c3c57613b..0000000000
--- a/src/mscorlib/src/System/Reflection/IReflect.cs
+++ /dev/null
@@ -1,116 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// IReflect is an interface that defines a subset of the Type reflection methods.
-//
-// This interface is used to access and invoke members of a Type. It can be either
-// type based (like Type) or instance based (like Expando). This interface is used in
-// combination with IExpando to model the IDispatchEx expando capibilities in
-// the interop layer.
-//
-//
-namespace System.Reflection {
- using System;
- using System.Runtime.InteropServices;
- using CultureInfo = System.Globalization.CultureInfo;
-
- // Interface does not need to be marked with the serializable attribute
- [Guid("AFBF15E5-C37C-11d2-B88E-00A0C9B471B8")]
- public interface IReflect
- {
- // Return the requested method if it is implemented by the Reflection object. The
- // match is based upon the name and DescriptorInfo which describes the signature
- // of the method.
- MethodInfo GetMethod(String name,BindingFlags bindingAttr,Binder binder,
- Type[] types,ParameterModifier[] modifiers);
-
- // Return the requested method if it is implemented by the Reflection object. The
- // match is based upon the name of the method. If the object implementes multiple methods
- // with the same name an AmbiguousMatchException is thrown.
- MethodInfo GetMethod(String name,BindingFlags bindingAttr);
-
- MethodInfo[] GetMethods(BindingFlags bindingAttr);
-
- // Return the requestion field if it is implemented by the Reflection object. The
- // match is based upon a name. There cannot be more than a single field with
- // a name.
- FieldInfo GetField(
- String name,
- BindingFlags bindingAttr);
-
- FieldInfo[] GetFields(
- BindingFlags bindingAttr);
-
- // Return the property based upon name. If more than one property has the given
- // name an AmbiguousMatchException will be thrown. Returns null if no property
- // is found.
- PropertyInfo GetProperty(
- String name,
- BindingFlags bindingAttr);
-
- // Return the property based upon the name and Descriptor info describing the property
- // indexing. Return null if no property is found.
- PropertyInfo GetProperty(
- String name,
- BindingFlags bindingAttr,
- Binder binder,
- Type returnType,
- Type[] types,
- ParameterModifier[] modifiers);
-
- // Returns an array of PropertyInfos for all the properties defined on
- // the Reflection object.
- PropertyInfo[] GetProperties(
- BindingFlags bindingAttr);
-
- // Return an array of members which match the passed in name.
- MemberInfo[] GetMember(
- String name,
- BindingFlags bindingAttr);
-
- // Return an array of all of the members defined for this object.
- MemberInfo[] GetMembers(
- BindingFlags bindingAttr);
-
- // Description of the Binding Process.
- // We must invoke a method that is accessable and for which the provided
- // parameters have the most specific match. A method may be called if
- // 1. The number of parameters in the method declaration equals the number of
- // arguments provided to the invocation
- // 2. The type of each argument can be converted by the binder to the
- // type of the type of the parameter.
- //
- // The binder will find all of the matching methods. These method are found based
- // upon the type of binding requested (MethodInvoke, Get/Set Properties). The set
- // of methods is filtered by the name, number of arguments and a set of search modifiers
- // defined in the Binder.
- //
- // After the method is selected, it will be invoked. Accessability is checked
- // at that point. The search may be control which set of methods are searched based
- // upon the accessibility attribute associated with the method.
- //
- // The BindToMethod method is responsible for selecting the method to be invoked.
- // For the default binder, the most specific method will be selected.
- //
- // This will invoke a specific member...
- Object InvokeMember(
- String name,
- BindingFlags invokeAttr,
- Binder binder,
- Object target,
- Object[] args,
- ParameterModifier[] modifiers,
- CultureInfo culture,
- String[] namedParameters);
-
- // Return the underlying Type that represents the IReflect Object. For expando object,
- // this is the (Object) IReflectInstance.GetType(). For Type object it is this.
- Type UnderlyingSystemType {
- get;
- }
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/IReflectableType.cs b/src/mscorlib/src/System/Reflection/IReflectableType.cs
deleted file mode 100644
index 7d4936868b..0000000000
--- a/src/mscorlib/src/System/Reflection/IReflectableType.cs
+++ /dev/null
@@ -1,20 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// IReflectableType is an interface that is implemented by a Type produced
-// by a ReflectionContext
-//
-
-//
-namespace System.Reflection {
-
- using System;
-
- public interface IReflectableType {
- TypeInfo GetTypeInfo();
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/InterfaceMapping.cs b/src/mscorlib/src/System/Reflection/InterfaceMapping.cs
deleted file mode 100644
index bf994f7b47..0000000000
--- a/src/mscorlib/src/System/Reflection/InterfaceMapping.cs
+++ /dev/null
@@ -1,22 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-//
-// Interface Map. This struct returns the mapping of an interface into the actual methods on a class
-// that implement that interface.
-//
-//
-namespace System.Reflection {
- using System;
-
- public struct InterfaceMapping {
- public Type TargetType; // The type implementing the interface
- public Type InterfaceType; // The type representing the interface
- public MethodInfo[] TargetMethods; // The methods implementing the interface
- public MethodInfo[] InterfaceMethods; // The methods defined on the interface
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/IntrospectionExtensions.cs b/src/mscorlib/src/System/Reflection/IntrospectionExtensions.cs
deleted file mode 100644
index 49819a942f..0000000000
--- a/src/mscorlib/src/System/Reflection/IntrospectionExtensions.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: Get the underlying TypeInfo from a Type
-**
-**
-=============================================================================*/
-namespace System.Reflection
-{
- public static class IntrospectionExtensions
- {
- public static TypeInfo GetTypeInfo(this Type type)
- {
- if (type == null)
- throw new ArgumentNullException(nameof(type));
-
- var rcType=(IReflectableType)type;
- return rcType.GetTypeInfo();
- }
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs b/src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs
deleted file mode 100644
index 8b8c06d9cf..0000000000
--- a/src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs
+++ /dev/null
@@ -1,39 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// InvalidFilterCriteriaException is thrown in FindMembers when the
-//
-// filter criteria is not valid for the type of filter being used.
-//
-//
-//
-//
-namespace System.Reflection {
-
- using System;
- using System.Runtime.Serialization;
- using ApplicationException = System.ApplicationException;
- [Serializable]
- public class InvalidFilterCriteriaException : ApplicationException {
- public InvalidFilterCriteriaException()
- : base(Environment.GetResourceString("Arg_InvalidFilterCriteriaException")) {
- SetErrorCode(__HResults.COR_E_INVALIDFILTERCRITERIA);
- }
-
- public InvalidFilterCriteriaException(String message) : base(message) {
- SetErrorCode(__HResults.COR_E_INVALIDFILTERCRITERIA);
- }
-
- public InvalidFilterCriteriaException(String message, Exception inner) : base(message, inner) {
- SetErrorCode(__HResults.COR_E_INVALIDFILTERCRITERIA);
- }
-
- protected InvalidFilterCriteriaException(SerializationInfo info, StreamingContext context) : base(info, context) {
- }
-
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/LoaderAllocator.cs b/src/mscorlib/src/System/Reflection/LoaderAllocator.cs
index 7c6c6bd0e8..035f158251 100644
--- a/src/mscorlib/src/System/Reflection/LoaderAllocator.cs
+++ b/src/mscorlib/src/System/Reflection/LoaderAllocator.cs
@@ -49,7 +49,6 @@ namespace System.Reflection
if (!Environment.HasShutdownStarted &&
!AppDomain.CurrentDomain.IsFinalizingForUnload())
{
-
// Destroy returns false if the managed LoaderAllocator is still alive.
if (!Destroy(m_nativeLoaderAllocator))
{
@@ -63,9 +62,9 @@ namespace System.Reflection
internal sealed class LoaderAllocator
{
- LoaderAllocator()
+ private LoaderAllocator()
{
- m_slots = new object [5];
+ m_slots = new object[5];
// m_slotsUsed = 0;
m_scout = new LoaderAllocatorScout();
@@ -73,10 +72,10 @@ namespace System.Reflection
#pragma warning disable 169
#pragma warning disable 414
- LoaderAllocatorScout m_scout;
- object [] m_slots;
+ private LoaderAllocatorScout m_scout;
+ private object[] m_slots;
internal CerHashtable<RuntimeMethodInfo, RuntimeMethodInfo> m_methodInstantiations;
- int m_slotsUsed;
+ private int m_slotsUsed;
#pragma warning restore 414
#pragma warning restore 169
}
diff --git a/src/mscorlib/src/System/Reflection/LocalVariableInfo.cs b/src/mscorlib/src/System/Reflection/LocalVariableInfo.cs
new file mode 100644
index 0000000000..241a3c4de6
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/LocalVariableInfo.cs
@@ -0,0 +1,40 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Diagnostics;
+
+namespace System.Reflection
+{
+ public class LocalVariableInfo
+ {
+ #region Private Data Members
+ private RuntimeType m_type;
+ private int m_isPinned;
+ private int m_localIndex;
+ #endregion
+
+ #region Constructor
+ protected LocalVariableInfo() { }
+ #endregion
+
+ #region Object Overrides
+ public override string ToString()
+ {
+ string toString = LocalType.ToString() + " (" + LocalIndex + ")";
+
+ if (IsPinned)
+ toString += " (pinned)";
+
+ return toString;
+ }
+ #endregion
+
+ #region Public Members
+ public virtual Type LocalType { get { Debug.Assert(m_type != null, "type must be set!"); return m_type; } }
+ public virtual bool IsPinned { get { return m_isPinned != 0; } }
+ public virtual int LocalIndex { get { return m_localIndex; } }
+ #endregion
+ }
+}
+
diff --git a/src/mscorlib/src/System/Reflection/ManifestResourceInfo.cs b/src/mscorlib/src/System/Reflection/ManifestResourceInfo.cs
deleted file mode 100644
index 91c7ceb2ea..0000000000
--- a/src/mscorlib/src/System/Reflection/ManifestResourceInfo.cs
+++ /dev/null
@@ -1,65 +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: For info regarding a manifest resource's topology.
-**
-**
-=============================================================================*/
-
-namespace System.Reflection {
- using System;
-
- public class ManifestResourceInfo {
- private Assembly _containingAssembly;
- private String _containingFileName;
- private ResourceLocation _resourceLocation;
-
- public ManifestResourceInfo(Assembly containingAssembly,
- String containingFileName,
- ResourceLocation resourceLocation)
- {
- _containingAssembly = containingAssembly;
- _containingFileName = containingFileName;
- _resourceLocation = resourceLocation;
- }
-
- public virtual Assembly ReferencedAssembly
- {
- get {
- return _containingAssembly;
- }
- }
-
- public virtual String FileName
- {
- get {
- return _containingFileName;
- }
- }
-
- public virtual ResourceLocation ResourceLocation
- {
- get {
- return _resourceLocation;
- }
- }
- }
-
- // The ResourceLocation is a combination of these flags, set or not.
- // Linked means not Embedded.
-[Serializable]
- [Flags]
- public enum ResourceLocation
- {
- Embedded = 0x1,
- ContainedInAnotherAssembly = 0x2,
- ContainedInManifestFile = 0x4
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/MdConstant.cs b/src/mscorlib/src/System/Reflection/MdConstant.cs
index e59244f109..8e5b65724d 100644
--- a/src/mscorlib/src/System/Reflection/MdConstant.cs
+++ b/src/mscorlib/src/System/Reflection/MdConstant.cs
@@ -4,10 +4,10 @@
//
+using System;
+
namespace System.Reflection
{
- using System;
-
internal static class MdConstant
{
public static unsafe Object GetValue(MetadataImport scope, int token, RuntimeTypeHandle fieldTypeHandle, bool raw)
@@ -67,13 +67,13 @@ namespace System.Reflection
case CorElementType.U8:
defaultValue = buffer;
break;
-
+
default:
- throw new FormatException(Environment.GetResourceString("Arg_BadLiteralFormat"));
- #endregion
+ throw new FormatException(SR.Arg_BadLiteralFormat);
+ #endregion
}
- return RuntimeType.CreateEnum(fieldType, defaultValue);
+ return RuntimeType.CreateEnum(fieldType, defaultValue);
}
else if (fieldType == typeof(DateTime))
{
@@ -85,7 +85,7 @@ namespace System.Reflection
case CorElementType.Void:
return DBNull.Value;
-
+
case CorElementType.I8:
defaultValue = buffer;
break;
@@ -93,10 +93,10 @@ namespace System.Reflection
case CorElementType.U8:
defaultValue = buffer;
break;
-
+
default:
- throw new FormatException(Environment.GetResourceString("Arg_BadLiteralFormat"));
- #endregion
+ throw new FormatException(SR.Arg_BadLiteralFormat);
+ #endregion
}
return new DateTime(defaultValue);
@@ -136,14 +136,14 @@ namespace System.Reflection
case CorElementType.U8:
return (ulong)buffer;
-
- case CorElementType.Boolean :
+
+ case CorElementType.Boolean:
// The boolean value returned from the metadata engine is stored as a
// BOOL, which actually maps to an int. We need to read it out as an int
// to avoid problems on big-endian machines.
return (*(int*)&buffer != 0);
- case CorElementType.R4 :
+ case CorElementType.R4:
return *(float*)&buffer;
case CorElementType.R8:
@@ -156,13 +156,12 @@ namespace System.Reflection
case CorElementType.Class:
return null;
-
+
default:
- throw new FormatException(Environment.GetResourceString("Arg_BadLiteralFormat"));
- #endregion
+ throw new FormatException(SR.Arg_BadLiteralFormat);
+ #endregion
}
}
- }
+ }
}
-
}
diff --git a/src/mscorlib/src/System/Reflection/MdFieldInfo.cs b/src/mscorlib/src/System/Reflection/MdFieldInfo.cs
new file mode 100644
index 0000000000..41ee4d9297
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/MdFieldInfo.cs
@@ -0,0 +1,141 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Diagnostics;
+using System.Globalization;
+using System.Runtime.Serialization;
+using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
+
+namespace System.Reflection
+{
+ [Serializable]
+ internal sealed unsafe class MdFieldInfo : RuntimeFieldInfo, ISerializable
+ {
+ #region Private Data Members
+ private int m_tkField;
+ private string m_name;
+ private RuntimeType m_fieldType;
+ private FieldAttributes m_fieldAttributes;
+ #endregion
+
+ #region Constructor
+ internal MdFieldInfo(
+ int tkField, FieldAttributes fieldAttributes, RuntimeTypeHandle declaringTypeHandle, RuntimeTypeCache reflectedTypeCache, BindingFlags bindingFlags)
+ : base(reflectedTypeCache, declaringTypeHandle.GetRuntimeType(), bindingFlags)
+ {
+ m_tkField = tkField;
+ m_name = null;
+ m_fieldAttributes = fieldAttributes;
+ }
+ #endregion
+
+ #region Internal Members
+ internal override bool CacheEquals(object o)
+ {
+ MdFieldInfo m = o as MdFieldInfo;
+
+ if ((object)m == null)
+ return false;
+
+ return m.m_tkField == m_tkField &&
+ m_declaringType.GetTypeHandleInternal().GetModuleHandle().Equals(
+ m.m_declaringType.GetTypeHandleInternal().GetModuleHandle());
+ }
+ #endregion
+
+ #region MemberInfo Overrides
+ public override String Name
+ {
+ get
+ {
+ if (m_name == null)
+ m_name = GetRuntimeModule().MetadataImport.GetName(m_tkField).ToString();
+
+ return m_name;
+ }
+ }
+
+ public override int MetadataToken { get { return m_tkField; } }
+ internal override RuntimeModule GetRuntimeModule() { return m_declaringType.GetRuntimeModule(); }
+ #endregion
+
+ #region FieldInfo Overrides
+ public override RuntimeFieldHandle FieldHandle { get { throw new NotSupportedException(); } }
+ public override FieldAttributes Attributes { get { return m_fieldAttributes; } }
+
+ public override bool IsSecurityCritical { get { return DeclaringType.IsSecurityCritical; } }
+ public override bool IsSecuritySafeCritical { get { return DeclaringType.IsSecuritySafeCritical; } }
+ public override bool IsSecurityTransparent { get { return DeclaringType.IsSecurityTransparent; } }
+
+ [DebuggerStepThroughAttribute]
+ [Diagnostics.DebuggerHidden]
+ public override Object GetValueDirect(TypedReference obj)
+ {
+ return GetValue(null);
+ }
+
+ [DebuggerStepThroughAttribute]
+ [Diagnostics.DebuggerHidden]
+ public override void SetValueDirect(TypedReference obj, Object value)
+ {
+ throw new FieldAccessException(SR.Acc_ReadOnly);
+ }
+
+ [DebuggerStepThroughAttribute]
+ [Diagnostics.DebuggerHidden]
+ public unsafe override Object GetValue(Object obj)
+ {
+ return GetValue(false);
+ }
+
+ public unsafe override Object GetRawConstantValue() { return GetValue(true); }
+
+ private unsafe Object GetValue(bool raw)
+ {
+ // Cannot cache these because they could be user defined non-agile enumerations
+
+ Object value = MdConstant.GetValue(GetRuntimeModule().MetadataImport, m_tkField, FieldType.GetTypeHandleInternal(), raw);
+
+ if (value == DBNull.Value)
+ throw new NotSupportedException(SR.Arg_EnumLitValueNotFound);
+
+ return value;
+ }
+
+ [DebuggerStepThroughAttribute]
+ [Diagnostics.DebuggerHidden]
+ public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
+ {
+ throw new FieldAccessException(SR.Acc_ReadOnly);
+ }
+
+ public override Type FieldType
+ {
+ get
+ {
+ if (m_fieldType == null)
+ {
+ ConstArray fieldMarshal = GetRuntimeModule().MetadataImport.GetSigOfFieldDef(m_tkField);
+
+ m_fieldType = new Signature(fieldMarshal.Signature.ToPointer(),
+ (int)fieldMarshal.Length, m_declaringType).FieldType;
+ }
+
+ return m_fieldType;
+ }
+ }
+
+ public override Type[] GetRequiredCustomModifiers()
+ {
+ return Array.Empty<Type>();
+ }
+
+ public override Type[] GetOptionalCustomModifiers()
+ {
+ return Array.Empty<Type>();
+ }
+
+ #endregion
+ }
+}
diff --git a/src/mscorlib/src/System/Reflection/MdImport.cs b/src/mscorlib/src/System/Reflection/MdImport.cs
index b1d9c5eae8..a224a50513 100644
--- a/src/mscorlib/src/System/Reflection/MdImport.cs
+++ b/src/mscorlib/src/System/Reflection/MdImport.cs
@@ -21,149 +21,149 @@ using System.Diagnostics.Contracts;
namespace System.Reflection
{
[Serializable]
- internal enum CorElementType : byte
+ internal enum CorElementType : byte
{
- End = 0x00,
- Void = 0x01,
- Boolean = 0x02,
- Char = 0x03,
- I1 = 0x04,
- U1 = 0x05,
- I2 = 0x06,
- U2 = 0x07,
- I4 = 0x08,
- U4 = 0x09,
- I8 = 0x0A,
- U8 = 0x0B,
- R4 = 0x0C,
- R8 = 0x0D,
- String = 0x0E,
- Ptr = 0x0F,
- ByRef = 0x10,
- ValueType = 0x11,
- Class = 0x12,
- Var = 0x13,
- Array = 0x14,
- GenericInst = 0x15,
- TypedByRef = 0x16,
- I = 0x18,
- U = 0x19,
- FnPtr = 0x1B,
- Object = 0x1C,
- SzArray = 0x1D,
- MVar = 0x1E,
- CModReqd = 0x1F,
- CModOpt = 0x20,
- Internal = 0x21,
- Max = 0x22,
- Modifier = 0x40,
- Sentinel = 0x41,
- Pinned = 0x45,
+ End = 0x00,
+ Void = 0x01,
+ Boolean = 0x02,
+ Char = 0x03,
+ I1 = 0x04,
+ U1 = 0x05,
+ I2 = 0x06,
+ U2 = 0x07,
+ I4 = 0x08,
+ U4 = 0x09,
+ I8 = 0x0A,
+ U8 = 0x0B,
+ R4 = 0x0C,
+ R8 = 0x0D,
+ String = 0x0E,
+ Ptr = 0x0F,
+ ByRef = 0x10,
+ ValueType = 0x11,
+ Class = 0x12,
+ Var = 0x13,
+ Array = 0x14,
+ GenericInst = 0x15,
+ TypedByRef = 0x16,
+ I = 0x18,
+ U = 0x19,
+ FnPtr = 0x1B,
+ Object = 0x1C,
+ SzArray = 0x1D,
+ MVar = 0x1E,
+ CModReqd = 0x1F,
+ CModOpt = 0x20,
+ Internal = 0x21,
+ Max = 0x22,
+ Modifier = 0x40,
+ Sentinel = 0x41,
+ Pinned = 0x45,
}
-[Serializable]
-[Flags()]
- internal enum MdSigCallingConvention: byte
+ [Serializable]
+ [Flags()]
+ internal enum MdSigCallingConvention : byte
{
- CallConvMask = 0x0f, // Calling convention is bottom 4 bits
-
- Default = 0x00,
- C = 0x01,
- StdCall = 0x02,
- ThisCall = 0x03,
- FastCall = 0x04,
- Vararg = 0x05,
- Field = 0x06,
- LocalSig = 0x07,
- Property = 0x08,
- Unmgd = 0x09,
- GenericInst = 0x0a, // generic method instantiation
-
- Generic = 0x10, // Generic method sig with explicit number of type arguments (precedes ordinary parameter count)
- HasThis = 0x20, // Top bit indicates a 'this' parameter
- ExplicitThis = 0x40, // This parameter is explicitly in the signature
+ CallConvMask = 0x0f, // Calling convention is bottom 4 bits
+
+ Default = 0x00,
+ C = 0x01,
+ StdCall = 0x02,
+ ThisCall = 0x03,
+ FastCall = 0x04,
+ Vararg = 0x05,
+ Field = 0x06,
+ LocalSig = 0x07,
+ Property = 0x08,
+ Unmgd = 0x09,
+ GenericInst = 0x0a, // generic method instantiation
+
+ Generic = 0x10, // Generic method sig with explicit number of type arguments (precedes ordinary parameter count)
+ HasThis = 0x20, // Top bit indicates a 'this' parameter
+ ExplicitThis = 0x40, // This parameter is explicitly in the signature
}
-[Serializable]
-[Flags()]
+ [Serializable]
+ [Flags()]
internal enum PInvokeAttributes
- {
- NoMangle = 0x0001,
-
-
- CharSetMask = 0x0006,
- CharSetNotSpec = 0x0000,
- CharSetAnsi = 0x0002,
- CharSetUnicode = 0x0004,
- CharSetAuto = 0x0006,
-
-
- BestFitUseAssem = 0x0000,
- BestFitEnabled = 0x0010,
- BestFitDisabled = 0x0020,
- BestFitMask = 0x0030,
-
- ThrowOnUnmappableCharUseAssem = 0x0000,
- ThrowOnUnmappableCharEnabled = 0x1000,
- ThrowOnUnmappableCharDisabled = 0x2000,
- ThrowOnUnmappableCharMask = 0x3000,
-
- SupportsLastError = 0x0040,
-
- CallConvMask = 0x0700,
- CallConvWinapi = 0x0100,
- CallConvCdecl = 0x0200,
- CallConvStdcall = 0x0300,
- CallConvThiscall = 0x0400,
- CallConvFastcall = 0x0500,
-
- MaxValue = 0xFFFF,
+ {
+ NoMangle = 0x0001,
+
+
+ CharSetMask = 0x0006,
+ CharSetNotSpec = 0x0000,
+ CharSetAnsi = 0x0002,
+ CharSetUnicode = 0x0004,
+ CharSetAuto = 0x0006,
+
+
+ BestFitUseAssem = 0x0000,
+ BestFitEnabled = 0x0010,
+ BestFitDisabled = 0x0020,
+ BestFitMask = 0x0030,
+
+ ThrowOnUnmappableCharUseAssem = 0x0000,
+ ThrowOnUnmappableCharEnabled = 0x1000,
+ ThrowOnUnmappableCharDisabled = 0x2000,
+ ThrowOnUnmappableCharMask = 0x3000,
+
+ SupportsLastError = 0x0040,
+
+ CallConvMask = 0x0700,
+ CallConvWinapi = 0x0100,
+ CallConvCdecl = 0x0200,
+ CallConvStdcall = 0x0300,
+ CallConvThiscall = 0x0400,
+ CallConvFastcall = 0x0500,
+
+ MaxValue = 0xFFFF,
}
-[Serializable]
-[Flags()]
+ [Serializable]
+ [Flags()]
internal enum MethodSemanticsAttributes
{
- Setter = 0x0001,
- Getter = 0x0002,
- Other = 0x0004,
- AddOn = 0x0008,
- RemoveOn = 0x0010,
- Fire = 0x0020,
+ Setter = 0x0001,
+ Getter = 0x0002,
+ Other = 0x0004,
+ AddOn = 0x0008,
+ RemoveOn = 0x0010,
+ Fire = 0x0020,
}
[Serializable]
internal enum MetadataTokenType
{
- Module = 0x00000000,
- TypeRef = 0x01000000,
- TypeDef = 0x02000000,
- FieldDef = 0x04000000,
- MethodDef = 0x06000000,
- ParamDef = 0x08000000,
- InterfaceImpl = 0x09000000,
- MemberRef = 0x0a000000,
- CustomAttribute = 0x0c000000,
- Permission = 0x0e000000,
- Signature = 0x11000000,
- Event = 0x14000000,
- Property = 0x17000000,
- ModuleRef = 0x1a000000,
- TypeSpec = 0x1b000000,
- Assembly = 0x20000000,
- AssemblyRef = 0x23000000,
- File = 0x26000000,
- ExportedType = 0x27000000,
- ManifestResource = 0x28000000,
- GenericPar = 0x2a000000,
- MethodSpec = 0x2b000000,
- String = 0x70000000,
- Name = 0x71000000,
- BaseType = 0x72000000,
- Invalid = 0x7FFFFFFF,
+ Module = 0x00000000,
+ TypeRef = 0x01000000,
+ TypeDef = 0x02000000,
+ FieldDef = 0x04000000,
+ MethodDef = 0x06000000,
+ ParamDef = 0x08000000,
+ InterfaceImpl = 0x09000000,
+ MemberRef = 0x0a000000,
+ CustomAttribute = 0x0c000000,
+ Permission = 0x0e000000,
+ Signature = 0x11000000,
+ Event = 0x14000000,
+ Property = 0x17000000,
+ ModuleRef = 0x1a000000,
+ TypeSpec = 0x1b000000,
+ Assembly = 0x20000000,
+ AssemblyRef = 0x23000000,
+ File = 0x26000000,
+ ExportedType = 0x27000000,
+ ManifestResource = 0x28000000,
+ GenericPar = 0x2a000000,
+ MethodSpec = 0x2b000000,
+ String = 0x70000000,
+ Name = 0x71000000,
+ BaseType = 0x72000000,
+ Invalid = 0x7FFFFFFF,
}
[Serializable]
@@ -179,7 +179,7 @@ namespace System.Reflection
throw new IndexOutOfRangeException();
Contract.EndContractBlock();
- unsafe
+ unsafe
{
return ((byte*)m_constArray.ToPointer())[index];
}
@@ -190,7 +190,7 @@ namespace System.Reflection
internal int m_length;
internal IntPtr m_constArray;
}
-
+
[Serializable]
internal struct MetadataToken
{
@@ -211,9 +211,9 @@ namespace System.Reflection
return false;
}
- public static bool IsNullToken(int token)
- {
- return (token & 0x00FFFFFF) == 0;
+ public static bool IsNullToken(int token)
+ {
+ return (token & 0x00FFFFFF) == 0;
}
#endregion
@@ -222,11 +222,11 @@ namespace System.Reflection
#endregion
#region Constructor
- public MetadataToken(int token) { Value = token; }
+ public MetadataToken(int token) { Value = token; }
#endregion
-
+
#region Public Members
- public bool IsGlobalTypeDefToken { get { return (Value == 0x02000001); } }
+ public bool IsGlobalTypeDefToken { get { return (Value == 0x02000001); } }
public MetadataTokenType TokenType { get { return (MetadataTokenType)(Value & 0xFF000000); } }
public bool IsTypeRef { get { return TokenType == MetadataTokenType.TypeRef; } }
public bool IsTypeDef { get { return TokenType == MetadataTokenType.TypeDef; } }
@@ -288,7 +288,7 @@ namespace System.Reflection
#region Override methods from Object
internal static readonly MetadataImport EmptyImport = new MetadataImport((IntPtr)0, null);
-
+
public override int GetHashCode()
{
return ValueType.GetHashCodeOfPtr(m_metadataImport2);
@@ -296,11 +296,11 @@ namespace System.Reflection
public override bool Equals(object obj)
{
- if(!(obj is MetadataImport))
+ if (!(obj is MetadataImport))
return false;
return Equals((MetadataImport)obj);
}
-
+
private bool Equals(MetadataImport import)
{
return import.m_metadataImport2 == m_metadataImport2;
@@ -310,18 +310,18 @@ namespace System.Reflection
#region Static Members
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void _GetMarshalAs(IntPtr pNativeType, int cNativeType, out int unmanagedType, out int safeArraySubType, out string safeArrayUserDefinedSubType,
+ private static extern void _GetMarshalAs(IntPtr pNativeType, int cNativeType, out int unmanagedType, out int safeArraySubType, out string safeArrayUserDefinedSubType,
out int arraySubType, out int sizeParamIndex, out int sizeConst, out string marshalType, out string marshalCookie,
out int iidParamIndex);
- internal static void GetMarshalAs(ConstArray nativeType,
- out UnmanagedType unmanagedType, out VarEnum safeArraySubType, out string safeArrayUserDefinedSubType,
+ internal static void GetMarshalAs(ConstArray nativeType,
+ out UnmanagedType unmanagedType, out VarEnum safeArraySubType, out string safeArrayUserDefinedSubType,
out UnmanagedType arraySubType, out int sizeParamIndex, out int sizeConst, out string marshalType, out string marshalCookie,
out int iidParamIndex)
{
int _unmanagedType, _safeArraySubType, _arraySubType;
_GetMarshalAs(nativeType.Signature, (int)nativeType.Length,
- out _unmanagedType, out _safeArraySubType, out safeArrayUserDefinedSubType,
+ out _unmanagedType, out _safeArraySubType, out safeArrayUserDefinedSubType,
out _arraySubType, out sizeParamIndex, out sizeConst, out marshalType, out marshalCookie,
out iidParamIndex);
unmanagedType = (UnmanagedType)_unmanagedType;
@@ -339,32 +339,32 @@ namespace System.Reflection
#region Constructor
internal MetadataImport(IntPtr metadataImport2, object keepalive)
- {
+ {
m_metadataImport2 = metadataImport2;
m_keepalive = keepalive;
}
#endregion
#region FCalls
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
private unsafe static extern void _Enum(IntPtr scope, int type, int parent, out MetadataEnumResult result);
- public unsafe void Enum(MetadataTokenType type, int parent, out MetadataEnumResult result)
- {
+ public unsafe void Enum(MetadataTokenType type, int parent, out MetadataEnumResult result)
+ {
_Enum(m_metadataImport2, (int)type, parent, out result);
}
- public unsafe void EnumNestedTypes(int mdTypeDef, out MetadataEnumResult result)
+ public unsafe void EnumNestedTypes(int mdTypeDef, out MetadataEnumResult result)
{
Enum(MetadataTokenType.TypeDef, mdTypeDef, out result);
}
- public unsafe void EnumCustomAttributes(int mdToken, out MetadataEnumResult result)
+ public unsafe void EnumCustomAttributes(int mdToken, out MetadataEnumResult result)
{
Enum(MetadataTokenType.CustomAttribute, mdToken, out result);
}
- public unsafe void EnumParams(int mdMethodDef, out MetadataEnumResult result)
+ public unsafe void EnumParams(int mdMethodDef, out MetadataEnumResult result)
{
Enum(MetadataTokenType.ParamDef, mdMethodDef, out result);
}
@@ -384,30 +384,30 @@ namespace System.Reflection
Enum(MetadataTokenType.Event, mdTypeDef, out result);
}
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern String _GetDefaultValue(IntPtr scope, int mdToken, out long value, out int length, out int corElementType);
- public String GetDefaultValue(int mdToken, out long value, out int length, out CorElementType corElementType)
- {
- int _corElementType;
+ public String GetDefaultValue(int mdToken, out long value, out int length, out CorElementType corElementType)
+ {
+ int _corElementType;
String stringVal;
- stringVal = _GetDefaultValue(m_metadataImport2, mdToken, out value, out length, out _corElementType);
+ stringVal = _GetDefaultValue(m_metadataImport2, mdToken, out value, out length, out _corElementType);
corElementType = (CorElementType)_corElementType;
return stringVal;
}
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
private static unsafe extern void _GetUserString(IntPtr scope, int mdToken, void** name, out int length);
- public unsafe String GetUserString(int mdToken)
- {
+ public unsafe String GetUserString(int mdToken)
+ {
void* name;
int length;
- _GetUserString(m_metadataImport2, mdToken, &name, out length);
+ _GetUserString(m_metadataImport2, mdToken, &name, out length);
if (name == null)
return null;
char[] c = new char[length];
- for (int i = 0; i < c.Length; i ++)
+ for (int i = 0; i < c.Length; i++)
{
#if ALIGN_ACCESS
c[i] = (char)Marshal.ReadInt16( (IntPtr) (((char*)name) + i) );
@@ -419,87 +419,87 @@ namespace System.Reflection
return new String(c);
}
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
private static unsafe extern void _GetName(IntPtr scope, int mdToken, void** name);
- public unsafe Utf8String GetName(int mdToken)
- {
+ public unsafe Utf8String GetName(int mdToken)
+ {
void* name;
- _GetName(m_metadataImport2, mdToken, &name);
-
+ _GetName(m_metadataImport2, mdToken, &name);
+
return new Utf8String(name);
}
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
private static unsafe extern void _GetNamespace(IntPtr scope, int mdToken, void** namesp);
- public unsafe Utf8String GetNamespace(int mdToken)
- {
+ public unsafe Utf8String GetNamespace(int mdToken)
+ {
void* namesp;
_GetNamespace(m_metadataImport2, mdToken, &namesp);
-
+
return new Utf8String(namesp);
}
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
private unsafe static extern void _GetEventProps(IntPtr scope, int mdToken, void** name, out int eventAttributes);
- public unsafe void GetEventProps(int mdToken, out void* name, out EventAttributes eventAttributes)
- {
- int _eventAttributes;
+ public unsafe void GetEventProps(int mdToken, out void* name, out EventAttributes eventAttributes)
+ {
+ int _eventAttributes;
void* _name;
_GetEventProps(m_metadataImport2, mdToken, &_name, out _eventAttributes);
name = _name;
eventAttributes = (EventAttributes)_eventAttributes;
}
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void _GetFieldDefProps(IntPtr scope, int mdToken, out int fieldAttributes);
- public void GetFieldDefProps(int mdToken, out FieldAttributes fieldAttributes)
- {
- int _fieldAttributes;
+ public void GetFieldDefProps(int mdToken, out FieldAttributes fieldAttributes)
+ {
+ int _fieldAttributes;
_GetFieldDefProps(m_metadataImport2, mdToken, out _fieldAttributes);
fieldAttributes = (FieldAttributes)_fieldAttributes;
}
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- private unsafe static extern void _GetPropertyProps(IntPtr scope,
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private unsafe static extern void _GetPropertyProps(IntPtr scope,
int mdToken, void** name, out int propertyAttributes, out ConstArray signature);
- public unsafe void GetPropertyProps(int mdToken, out void* name, out PropertyAttributes propertyAttributes, out ConstArray signature)
- {
- int _propertyAttributes;
+ public unsafe void GetPropertyProps(int mdToken, out void* name, out PropertyAttributes propertyAttributes, out ConstArray signature)
+ {
+ int _propertyAttributes;
void* _name;
- _GetPropertyProps(m_metadataImport2, mdToken, &_name, out _propertyAttributes, out signature);
+ _GetPropertyProps(m_metadataImport2, mdToken, &_name, out _propertyAttributes, out signature);
name = _name;
propertyAttributes = (PropertyAttributes)_propertyAttributes;
}
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- private static extern void _GetParentToken(IntPtr scope,
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern void _GetParentToken(IntPtr scope,
int mdToken, out int tkParent);
- public int GetParentToken(int tkToken)
- {
+ public int GetParentToken(int tkToken)
+ {
int tkParent;
- _GetParentToken(m_metadataImport2, tkToken, out tkParent);
+ _GetParentToken(m_metadataImport2, tkToken, out tkParent);
return tkParent;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void _GetParamDefProps(IntPtr scope,
+ private static extern void _GetParamDefProps(IntPtr scope,
int parameterToken, out int sequence, out int attributes);
public void GetParamDefProps(int parameterToken, out int sequence, out ParameterAttributes attributes)
{
int _attributes;
_GetParamDefProps(m_metadataImport2, parameterToken, out sequence, out _attributes);
-
+
attributes = (ParameterAttributes)_attributes;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void _GetGenericParamProps(IntPtr scope,
- int genericParameter,
+ private static extern void _GetGenericParamProps(IntPtr scope,
+ int genericParameter,
out int flags);
-
+
public void GetGenericParamProps(
- int genericParameter,
+ int genericParameter,
out GenericParameterAttributes attributes)
{
int _attributes;
@@ -508,9 +508,9 @@ namespace System.Reflection
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void _GetScopeProps(IntPtr scope,
+ private static extern void _GetScopeProps(IntPtr scope,
out Guid mvid);
-
+
public void GetScopeProps(
out Guid mvid)
{
@@ -522,15 +522,15 @@ namespace System.Reflection
{
if (token.IsMemberRef)
return GetMemberRefProps(token);
-
+
return GetSigOfMethodDef(token);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void _GetSigOfMethodDef(IntPtr scope,
- int methodToken,
+ private static extern void _GetSigOfMethodDef(IntPtr scope,
+ int methodToken,
ref ConstArray signature);
-
+
public ConstArray GetSigOfMethodDef(int methodToken)
{
ConstArray signature = new ConstArray();
@@ -541,10 +541,10 @@ namespace System.Reflection
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void _GetSignatureFromToken(IntPtr scope,
- int methodToken,
+ private static extern void _GetSignatureFromToken(IntPtr scope,
+ int methodToken,
ref ConstArray signature);
-
+
public ConstArray GetSignatureFromToken(int token)
{
ConstArray signature = new ConstArray();
@@ -555,61 +555,61 @@ namespace System.Reflection
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void _GetMemberRefProps(IntPtr scope,
- int memberTokenRef,
+ private static extern void _GetMemberRefProps(IntPtr scope,
+ int memberTokenRef,
out ConstArray signature);
-
+
public ConstArray GetMemberRefProps(int memberTokenRef)
{
ConstArray signature = new ConstArray();
-
+
_GetMemberRefProps(m_metadataImport2, memberTokenRef, out signature);
return signature;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void _GetCustomAttributeProps(IntPtr scope,
- int customAttributeToken,
- out int constructorToken,
+ private static extern void _GetCustomAttributeProps(IntPtr scope,
+ int customAttributeToken,
+ out int constructorToken,
out ConstArray signature);
-
- public void GetCustomAttributeProps(
- int customAttributeToken,
- out int constructorToken,
+
+ public void GetCustomAttributeProps(
+ int customAttributeToken,
+ out int constructorToken,
out ConstArray signature)
{
- _GetCustomAttributeProps(m_metadataImport2, customAttributeToken,
+ _GetCustomAttributeProps(m_metadataImport2, customAttributeToken,
out constructorToken, out signature);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void _GetClassLayout(IntPtr scope,
+ private static extern void _GetClassLayout(IntPtr scope,
int typeTokenDef, out int packSize, out int classSize);
public void GetClassLayout(
- int typeTokenDef,
- out int packSize,
+ int typeTokenDef,
+ out int packSize,
out int classSize)
{
_GetClassLayout(m_metadataImport2, typeTokenDef, out packSize, out classSize);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern bool _GetFieldOffset(IntPtr scope,
+ private static extern bool _GetFieldOffset(IntPtr scope,
int typeTokenDef, int fieldTokenDef, out int offset);
public bool GetFieldOffset(
- int typeTokenDef,
- int fieldTokenDef,
+ int typeTokenDef,
+ int fieldTokenDef,
out int offset)
{
return _GetFieldOffset(m_metadataImport2, typeTokenDef, fieldTokenDef, out offset);
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void _GetSigOfFieldDef(IntPtr scope,
- int fieldToken,
+ private static extern void _GetSigOfFieldDef(IntPtr scope,
+ int fieldToken,
ref ConstArray fieldMarshal);
-
+
public ConstArray GetSigOfFieldDef(int fieldToken)
{
ConstArray fieldMarshal = new ConstArray();
@@ -620,10 +620,10 @@ namespace System.Reflection
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern void _GetFieldMarshal(IntPtr scope,
- int fieldToken,
+ private static extern void _GetFieldMarshal(IntPtr scope,
+ int fieldToken,
ref ConstArray fieldMarshal);
-
+
public ConstArray GetFieldMarshal(int fieldToken)
{
ConstArray fieldMarshal = new ConstArray();
@@ -634,16 +634,16 @@ namespace System.Reflection
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private unsafe static extern void _GetPInvokeMap(IntPtr scope,
- int token,
- out int attributes,
- void** importName,
- void** importDll);
-
+ private unsafe static extern void _GetPInvokeMap(IntPtr scope,
+ int token,
+ out int attributes,
+ void** importName,
+ void** importDll);
+
public unsafe void GetPInvokeMap(
- int token,
- out PInvokeAttributes attributes,
- out String importName,
+ int token,
+ out PInvokeAttributes attributes,
+ out String importName,
out String importDll)
{
int _attributes;
@@ -656,10 +656,10 @@ namespace System.Reflection
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern bool _IsValidToken(IntPtr scope, int token);
- public bool IsValidToken(int token)
- {
- return _IsValidToken(m_metadataImport2, token);
+ private static extern bool _IsValidToken(IntPtr scope, int token);
+ public bool IsValidToken(int token)
+ {
+ return _IsValidToken(m_metadataImport2, token);
}
#endregion
}
diff --git a/src/mscorlib/src/System/Reflection/MemberFilter.cs b/src/mscorlib/src/System/Reflection/MemberFilter.cs
deleted file mode 100644
index 56fc9c0804..0000000000
--- a/src/mscorlib/src/System/Reflection/MemberFilter.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// MemberFilter is a delegate used to filter Members. This delegate is used
-//
-// as a callback from Type.FindMembers.
-//
-//
-namespace System.Reflection {
-
- // Define the delegate
- [Serializable]
- public delegate bool MemberFilter(MemberInfo m, Object filterCriteria);
-}
diff --git a/src/mscorlib/src/System/Reflection/MemberInfo.Internal.cs b/src/mscorlib/src/System/Reflection/MemberInfo.Internal.cs
new file mode 100644
index 0000000000..8e7be56511
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/MemberInfo.Internal.cs
@@ -0,0 +1,11 @@
+// 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
+{
+ public abstract partial class MemberInfo
+ {
+ internal virtual bool CacheEquals(object o) { throw new NotImplementedException(); }
+ }
+}
diff --git a/src/mscorlib/src/System/Reflection/MemberInfo.cs b/src/mscorlib/src/System/Reflection/MemberInfo.cs
deleted file mode 100644
index 5ecbfe06a1..0000000000
--- a/src/mscorlib/src/System/Reflection/MemberInfo.cs
+++ /dev/null
@@ -1,113 +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
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.Contracts;
- using System.Runtime;
- using System.Runtime.InteropServices;
-
- [Serializable]
- public abstract class MemberInfo : ICustomAttributeProvider
- {
- #region Constructor
- protected MemberInfo() { }
- #endregion
-
- #region Internal Methods
- internal virtual bool CacheEquals(object o) { throw new NotImplementedException(); }
- #endregion
-
- #region Public Abstract\Virtual Members
- public abstract MemberTypes MemberType { get; }
-
- public abstract String Name { get; }
-
- public abstract Type DeclaringType { get; }
-
- public abstract Type ReflectedType { get; }
-
- public virtual IEnumerable<CustomAttributeData> CustomAttributes
- {
- get
- {
- return GetCustomAttributesData();
- }
- }
- public abstract Object[] GetCustomAttributes(bool inherit);
-
- public abstract Object[] GetCustomAttributes(Type attributeType, bool inherit);
-
- public abstract bool IsDefined(Type attributeType, bool inherit);
-
- public virtual IList<CustomAttributeData> GetCustomAttributesData()
- {
- throw new NotImplementedException();
- }
-
- public virtual int MetadataToken { get { throw new InvalidOperationException(); } }
-
- public virtual Module Module
- {
- get
- {
- if (this is Type)
- return ((Type)this).Module;
-
- throw new NotImplementedException();
- }
- }
-
-
-
- #endregion
-
- public static bool operator ==(MemberInfo left, MemberInfo right)
- {
- if (ReferenceEquals(left, right))
- return true;
-
- if ((object)left == null || (object)right == null)
- return false;
-
- Type type1, type2;
- MethodBase method1, method2;
- FieldInfo field1, field2;
- EventInfo event1, event2;
- PropertyInfo property1, property2;
-
- if ((type1 = left as Type) != null && (type2 = right as Type) != null)
- return type1 == type2;
- else if ((method1 = left as MethodBase) != null && (method2 = right as MethodBase) != null)
- return method1 == method2;
- else if ((field1 = left as FieldInfo) != null && (field2 = right as FieldInfo) != null)
- return field1 == field2;
- else if ((event1 = left as EventInfo) != null && (event2 = right as EventInfo) != null)
- return event1 == event2;
- else if ((property1 = left as PropertyInfo) != null && (property2 = right as PropertyInfo) != null)
- return property1 == property2;
-
- return false;
- }
-
- public static bool operator !=(MemberInfo left, MemberInfo right)
- {
- return !(left == right);
- }
-
- public override bool Equals(object obj)
- {
- return base.Equals(obj);
- }
-
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/MemberInfoSerializationHolder.cs b/src/mscorlib/src/System/Reflection/MemberInfoSerializationHolder.cs
deleted file mode 100644
index 20ff37650c..0000000000
--- a/src/mscorlib/src/System/Reflection/MemberInfoSerializationHolder.cs
+++ /dev/null
@@ -1,285 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-//
-
-using System;
-using System.Runtime.Remoting;
-using System.Runtime.Serialization;
-using System.Globalization;
-using System.Diagnostics.Contracts;
-
-namespace System.Reflection
-{
- [Serializable]
- internal class MemberInfoSerializationHolder : ISerializable, IObjectReference
- {
- #region Staitc Public Members
- public static void GetSerializationInfo(SerializationInfo info, String name, RuntimeType reflectedClass, String signature, MemberTypes type)
- {
- GetSerializationInfo(info, name, reflectedClass, signature, null, type, null);
- }
-
- public static void GetSerializationInfo(
- SerializationInfo info,
- String name,
- RuntimeType reflectedClass,
- String signature,
- String signature2,
- MemberTypes type,
- Type[] genericArguments)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- String assemblyName = reflectedClass.Module.Assembly.FullName;
- String typeName = reflectedClass.FullName;
-
- info.SetType(typeof(MemberInfoSerializationHolder));
- info.AddValue("Name", name, typeof(String));
- info.AddValue("AssemblyName", assemblyName, typeof(String));
- info.AddValue("ClassName", typeName, typeof(String));
- info.AddValue("Signature", signature, typeof(String));
- info.AddValue("Signature2", signature2, typeof(String));
- info.AddValue("MemberType", (int)type);
- info.AddValue("GenericArguments", genericArguments, typeof(Type[]));
- }
- #endregion
-
- #region Private Data Members
- private String m_memberName;
- private RuntimeType m_reflectedType;
- // m_signature stores the ToString() representation of the member which is sometimes ambiguous.
- // Mulitple overloads of the same methods or properties can identical ToString().
- // m_signature2 stores the SerializationToString() representation which should be unique for each member.
- // It is only written and used by post 4.0 CLR versions.
- private String m_signature;
- private String m_signature2;
- private MemberTypes m_memberType;
- private SerializationInfo m_info;
- #endregion
-
- #region Constructor
- internal MemberInfoSerializationHolder(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- String assemblyName = info.GetString("AssemblyName");
- String typeName = info.GetString("ClassName");
-
- if (assemblyName == null || typeName == null)
- throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
-
- Assembly assem = FormatterServices.LoadAssemblyFromString(assemblyName);
- m_reflectedType = assem.GetType(typeName, true, false) as RuntimeType;
- m_memberName = info.GetString("Name");
- m_signature = info.GetString("Signature");
- // Only v4.0 and later generates and consumes Signature2
- m_signature2 = (string)info.GetValueNoThrow("Signature2", typeof(string));
- m_memberType = (MemberTypes)info.GetInt32("MemberType");
- m_info = info;
- }
- #endregion
-
- #region ISerializable
- public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- throw new NotSupportedException(Environment.GetResourceString(ResId.NotSupported_Method));
- }
- #endregion
-
- #region IObjectReference
- public virtual Object GetRealObject(StreamingContext context)
- {
- if (m_memberName == null || m_reflectedType == null || m_memberType == 0)
- throw new SerializationException(Environment.GetResourceString(ResId.Serialization_InsufficientState));
-
- BindingFlags bindingFlags =
- BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic |
- BindingFlags.Static | BindingFlags.OptionalParamBinding;
-
- switch (m_memberType)
- {
- #region case MemberTypes.Field:
- case MemberTypes.Field:
- {
- FieldInfo[] fields = m_reflectedType.GetMember(m_memberName, MemberTypes.Field, bindingFlags) as FieldInfo[];
-
- if (fields.Length == 0)
- throw new SerializationException(Environment.GetResourceString("Serialization_UnknownMember", m_memberName));
-
- return fields[0];
- }
- #endregion
-
- #region case MemberTypes.Event:
- case MemberTypes.Event:
- {
- EventInfo[] events = m_reflectedType.GetMember(m_memberName, MemberTypes.Event, bindingFlags) as EventInfo[];
-
- if (events.Length == 0)
- throw new SerializationException(Environment.GetResourceString("Serialization_UnknownMember", m_memberName));
-
- return events[0];
- }
- #endregion
-
- #region case MemberTypes.Property:
- case MemberTypes.Property:
- {
- PropertyInfo[] properties = m_reflectedType.GetMember(m_memberName, MemberTypes.Property, bindingFlags) as PropertyInfo[];
-
- if (properties.Length == 0)
- throw new SerializationException(Environment.GetResourceString("Serialization_UnknownMember", m_memberName));
-
- if (properties.Length == 1)
- return properties[0];
-
- if (properties.Length > 1)
- {
- for (int i = 0; i < properties.Length; i++)
- {
- if (m_signature2 != null)
- {
- if (((RuntimePropertyInfo)properties[i]).SerializationToString().Equals(m_signature2))
- return properties[i];
- }
- else
- {
- if ((properties[i]).ToString().Equals(m_signature))
- return properties[i];
- }
- }
- }
-
- throw new SerializationException(Environment.GetResourceString(ResId.Serialization_UnknownMember, m_memberName));
- }
- #endregion
-
- #region case MemberTypes.Constructor:
- case MemberTypes.Constructor:
- {
- if (m_signature == null)
- throw new SerializationException(Environment.GetResourceString(ResId.Serialization_NullSignature));
-
- ConstructorInfo[] constructors = m_reflectedType.GetMember(m_memberName, MemberTypes.Constructor, bindingFlags) as ConstructorInfo[];
-
- if (constructors.Length == 1)
- return constructors[0];
-
- if (constructors.Length > 1)
- {
- for (int i = 0; i < constructors.Length; i++)
- {
- if (m_signature2 != null)
- {
- if (((RuntimeConstructorInfo)constructors[i]).SerializationToString().Equals(m_signature2))
- return constructors[i];
- }
- else
- {
- if (constructors[i].ToString().Equals(m_signature))
- return constructors[i];
- }
- }
- }
-
- throw new SerializationException(Environment.GetResourceString(ResId.Serialization_UnknownMember, m_memberName));
- }
- #endregion
-
- #region case MemberTypes.Method:
- case MemberTypes.Method:
- {
- MethodInfo methodInfo = null;
-
- if (m_signature == null)
- throw new SerializationException(Environment.GetResourceString(ResId.Serialization_NullSignature));
-
- Type[] genericArguments = m_info.GetValueNoThrow("GenericArguments", typeof(Type[])) as Type[];
-
- MethodInfo[] methods = m_reflectedType.GetMember(m_memberName, MemberTypes.Method, bindingFlags) as MethodInfo[];
-
- if (methods.Length == 1)
- methodInfo = methods[0];
-
- else if (methods.Length > 1)
- {
- for (int i = 0; i < methods.Length; i++)
- {
- if (m_signature2 != null)
- {
- if (((RuntimeMethodInfo)methods[i]).SerializationToString().Equals(m_signature2))
- {
- methodInfo = methods[i];
- break;
- }
- }
- else
- {
-
- if (methods[i].ToString().Equals(m_signature))
- {
- methodInfo = methods[i];
- break;
- }
- }
-
- // Handle generic methods specially since the signature match above probably won't work (the candidate
- // method info hasn't been instantiated). If our target method is generic as well we can skip this.
- if (genericArguments != null && methods[i].IsGenericMethod)
- {
- if (methods[i].GetGenericArguments().Length == genericArguments.Length)
- {
- MethodInfo candidateMethod = methods[i].MakeGenericMethod(genericArguments);
-
- if (m_signature2 != null)
- {
- if (((RuntimeMethodInfo)candidateMethod).SerializationToString().Equals(m_signature2))
- {
- methodInfo = candidateMethod;
- break;
- }
- }
- else
- {
- if (candidateMethod.ToString().Equals(m_signature))
- {
- methodInfo = candidateMethod;
- break;
- }
- }
- }
- }
- }
- }
-
- if (methodInfo == null)
- throw new SerializationException(Environment.GetResourceString(ResId.Serialization_UnknownMember, m_memberName));
-
- if (!methodInfo.IsGenericMethodDefinition)
- return methodInfo;
-
- if (genericArguments == null)
- return methodInfo;
-
- if (genericArguments[0] == null)
- return null;
-
- return methodInfo.MakeGenericMethod(genericArguments);
- }
- #endregion
-
- default:
- throw new ArgumentException(Environment.GetResourceString("Serialization_MemberTypeNotRecognized"));
- }
- }
- #endregion
- }
-
-
-}
diff --git a/src/mscorlib/src/System/Reflection/MemberSerializationStringGenerator.cs b/src/mscorlib/src/System/Reflection/MemberSerializationStringGenerator.cs
new file mode 100644
index 0000000000..d25c746a85
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/MemberSerializationStringGenerator.cs
@@ -0,0 +1,39 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Text;
+using System.Reflection;
+using System.Diagnostics;
+using System.Collections.Generic;
+
+namespace System
+{
+ internal static class MemberSerializationStringGenerator
+ {
+ //
+ // Generate the "Signature2" binary serialization string for PropertyInfos
+ //
+ // Because the string is effectively a file format for serialized Reflection objects, it must be exactly correct. If missing
+ // metadata prevents generating the string, this method throws a MissingMetadata exception.
+ //
+ public static string SerializationToString(this PropertyInfo property) => ((RuntimePropertyInfo)property).SerializationToString();
+
+ //
+ // Generate the "Signature2" binary serialization string for ConstructorInfos
+ //
+ // Because the string is effectively a file format for serialized Reflection objects, it must be exactly correct. If missing
+ // metadata prevents generating the string, this method throws a MissingMetadata exception.
+ //
+ public static string SerializationToString(this ConstructorInfo constructor) => ((RuntimeConstructorInfo)constructor).SerializationToString();
+
+ //
+ // Generate the "Signature2" binary serialization string for MethodInfos
+ //
+ // Because the string is effectively a file format for serialized Reflection objects, it must be exactly correct. If missing
+ // metadata prevents generating the string, this method throws a MissingMetadata exception.
+ //
+ public static string SerializationToString(this MethodInfo method) => ((RuntimeMethodInfo)method).SerializationToString();
+ }
+}
diff --git a/src/mscorlib/src/System/Reflection/MemberTypes.cs b/src/mscorlib/src/System/Reflection/MemberTypes.cs
deleted file mode 100644
index 95c41022f1..0000000000
--- a/src/mscorlib/src/System/Reflection/MemberTypes.cs
+++ /dev/null
@@ -1,33 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// MemberTypes is an bit mask marking each type of Member that is defined as
-//
-// a subclass of MemberInfo. These are returned by MemberInfo.MemberType and
-// are useful in switch statements.
-//
-//
-namespace System.Reflection {
-
- using System;
- // This Enum matchs the CorTypeAttr defined in CorHdr.h
- [Serializable]
- [Flags()]
- public enum MemberTypes
- {
- // The following are the known classes which extend MemberInfo
- Constructor = 0x01,
- Event = 0x02,
- Field = 0x04,
- Method = 0x08,
- Property = 0x10,
- TypeInfo = 0x20,
- Custom = 0x40,
- NestedType = 0x80,
- All = Constructor | Event | Field | Method | Property | TypeInfo | NestedType,
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/MethodAttributes.cs b/src/mscorlib/src/System/Reflection/MethodAttributes.cs
deleted file mode 100644
index 7e4391cccd..0000000000
--- a/src/mscorlib/src/System/Reflection/MethodAttributes.cs
+++ /dev/null
@@ -1,55 +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
-{
- using System;
- [Serializable]
- [Flags]
- public enum MethodAttributes
- {
- // NOTE: This Enum matchs the CorMethodAttr defined in CorHdr.h
-
- // member access mask - Use this mask to retrieve accessibility information.
- MemberAccessMask = 0x0007,
- PrivateScope = 0x0000, // Member not referenceable.
- Private = 0x0001, // Accessible only by the parent type.
- FamANDAssem = 0x0002, // Accessible by sub-types only in this Assembly.
- Assembly = 0x0003, // Accessibly by anyone in the Assembly.
- Family = 0x0004, // Accessible only by type and sub-types.
- FamORAssem = 0x0005, // Accessibly by sub-types anywhere, plus anyone in assembly.
- Public = 0x0006, // Accessibly by anyone who has visibility to this scope.
- // end member access mask
-
- // method contract attributes.
- Static = 0x0010, // Defined on type, else per instance.
- Final = 0x0020, // Method may not be overridden.
- Virtual = 0x0040, // Method virtual.
- HideBySig = 0x0080, // Method hides by name+sig, else just by name.
- CheckAccessOnOverride= 0x0200,
-
- // vtable layout mask - Use this mask to retrieve vtable attributes.
- VtableLayoutMask = 0x0100,
- ReuseSlot = 0x0000, // The default.
- NewSlot = 0x0100, // Method always gets a new slot in the vtable.
- // end vtable layout mask
-
- // method implementation attributes.
- Abstract = 0x0400, // Method does not provide an implementation.
- SpecialName = 0x0800, // Method is special. Name describes how.
-
- // interop attributes
- PinvokeImpl = 0x2000, // Implementation is forwarded through pinvoke.
- UnmanagedExport = 0x0008, // Managed method exported via thunk to unmanaged code.
- RTSpecialName = 0x1000, // Runtime should check name encoding.
-
- // Reserved flags for runtime use only.
- ReservedMask = 0xd000,
- HasSecurity = 0x4000, // Method has security associate with it.
- RequireSecObject = 0x8000, // Method calls another method containing security code.
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/MethodBase.CoreCLR.cs b/src/mscorlib/src/System/Reflection/MethodBase.CoreCLR.cs
new file mode 100644
index 0000000000..3afd396471
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/MethodBase.CoreCLR.cs
@@ -0,0 +1,157 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Diagnostics;
+using System.Globalization;
+using System.Text;
+using System.Threading;
+
+namespace System.Reflection
+{
+ public abstract partial class MethodBase : MemberInfo
+ {
+ #region Static Members
+ public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
+ {
+ if (handle.IsNullHandle())
+ throw new ArgumentException(SR.Argument_InvalidHandle);
+
+ MethodBase m = RuntimeType.GetMethodBase(handle.GetMethodInfo());
+
+ Type declaringType = m.DeclaringType;
+ if (declaringType != null && declaringType.IsGenericType)
+ throw new ArgumentException(String.Format(
+ CultureInfo.CurrentCulture, SR.Argument_MethodDeclaringTypeGeneric,
+ m, declaringType.GetGenericTypeDefinition()));
+
+ return m;
+ }
+
+ public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType)
+ {
+ if (handle.IsNullHandle())
+ throw new ArgumentException(SR.Argument_InvalidHandle);
+
+ return RuntimeType.GetMethodBase(declaringType.GetRuntimeType(), handle.GetMethodInfo());
+ }
+
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
+ public static MethodBase GetCurrentMethod()
+ {
+ StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
+ return RuntimeMethodInfo.InternalGetCurrentMethod(ref stackMark);
+ }
+ #endregion
+
+ #region Internal Members
+ // used by EE
+ private IntPtr GetMethodDesc() { return MethodHandle.Value; }
+
+ internal virtual ParameterInfo[] GetParametersNoCopy() { return GetParameters(); }
+ #endregion
+
+ #region Internal Methods
+ // helper method to construct the string representation of the parameter list
+
+ internal static string ConstructParameters(Type[] parameterTypes, CallingConventions callingConvention, bool serialization)
+ {
+ StringBuilder sbParamList = new StringBuilder();
+ string comma = "";
+
+ for (int i = 0; i < parameterTypes.Length; i++)
+ {
+ Type t = parameterTypes[i];
+
+ sbParamList.Append(comma);
+
+ string typeName = t.FormatTypeName(serialization);
+
+ // Legacy: Why use "ByRef" for by ref parameters? What language is this?
+ // VB uses "ByRef" but it should precede (not follow) the parameter name.
+ // Why don't we just use "&"?
+ if (t.IsByRef && !serialization)
+ {
+ sbParamList.Append(typeName.TrimEnd('&'));
+ sbParamList.Append(" ByRef");
+ }
+ else
+ {
+ sbParamList.Append(typeName);
+ }
+
+ comma = ", ";
+ }
+
+ if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs)
+ {
+ sbParamList.Append(comma);
+ sbParamList.Append("...");
+ }
+
+ return sbParamList.ToString();
+ }
+
+ internal string FullName
+ {
+ get
+ {
+ return String.Format("{0}.{1}", DeclaringType.FullName, FormatNameAndSig());
+ }
+ }
+ internal string FormatNameAndSig()
+ {
+ return FormatNameAndSig(false);
+ }
+
+ internal virtual string FormatNameAndSig(bool serialization)
+ {
+ // Serialization uses ToString to resolve MethodInfo overloads.
+ StringBuilder sbName = new StringBuilder(Name);
+
+ sbName.Append("(");
+ sbName.Append(ConstructParameters(GetParameterTypes(), CallingConvention, serialization));
+ sbName.Append(")");
+
+ return sbName.ToString();
+ }
+
+ internal virtual Type[] GetParameterTypes()
+ {
+ ParameterInfo[] paramInfo = GetParametersNoCopy();
+
+ Type[] parameterTypes = new Type[paramInfo.Length];
+ for (int i = 0; i < paramInfo.Length; i++)
+ parameterTypes[i] = paramInfo[i].ParameterType;
+
+ return parameterTypes;
+ }
+
+ internal Object[] CheckArguments(Object[] parameters, Binder binder,
+ BindingFlags invokeAttr, CultureInfo culture, Signature sig)
+ {
+ // copy the arguments in a different array so we detach from any user changes
+ Object[] copyOfParameters = new Object[parameters.Length];
+
+ ParameterInfo[] p = null;
+ for (int i = 0; i < parameters.Length; i++)
+ {
+ Object arg = parameters[i];
+ RuntimeType argRT = sig.Arguments[i];
+
+ if (arg == Type.Missing)
+ {
+ if (p == null)
+ p = GetParametersNoCopy();
+ if (p[i].DefaultValue == System.DBNull.Value)
+ throw new ArgumentException(SR.Arg_VarMissNull, nameof(parameters));
+ arg = p[i].DefaultValue;
+ }
+ copyOfParameters[i] = argRT.CheckValue(arg, binder, culture, invokeAttr);
+ }
+
+ return copyOfParameters;
+ }
+ #endregion
+ }
+}
diff --git a/src/mscorlib/src/System/Reflection/MethodBase.cs b/src/mscorlib/src/System/Reflection/MethodBase.cs
deleted file mode 100644
index 3109821ac9..0000000000
--- a/src/mscorlib/src/System/Reflection/MethodBase.cs
+++ /dev/null
@@ -1,330 +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
-{
- using System;
- using System.Diagnostics;
- using System.Globalization;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading;
-
- //
- // Invocation cached flags. Those are used in unmanaged code as well
- // so be careful if you change them
- //
- [Flags]
- internal enum INVOCATION_FLAGS : uint
- {
- INVOCATION_FLAGS_UNKNOWN = 0x00000000,
- INVOCATION_FLAGS_INITIALIZED = 0x00000001,
- // it's used for both method and field to signify that no access is allowed
- INVOCATION_FLAGS_NO_INVOKE = 0x00000002,
- INVOCATION_FLAGS_NEED_SECURITY = 0x00000004,
- // Set for static ctors and ctors on abstract types, which
- // can be invoked only if the "this" object is provided (even if it's null).
- INVOCATION_FLAGS_NO_CTOR_INVOKE = 0x00000008,
- // because field and method are different we can reuse the same bits
- // method
- INVOCATION_FLAGS_IS_CTOR = 0x00000010,
- INVOCATION_FLAGS_RISKY_METHOD = 0x00000020,
- INVOCATION_FLAGS_NON_W8P_FX_API = 0x00000040,
- INVOCATION_FLAGS_IS_DELEGATE_CTOR = 0x00000080,
- INVOCATION_FLAGS_CONTAINS_STACK_POINTERS = 0x00000100,
- // field
- INVOCATION_FLAGS_SPECIAL_FIELD = 0x00000010,
- INVOCATION_FLAGS_FIELD_SPECIAL_CAST = 0x00000020,
-
- // temporary flag used for flagging invocation of method vs ctor
- // this flag never appears on the instance m_invocationFlag and is simply
- // passed down from within ConstructorInfo.Invoke()
- INVOCATION_FLAGS_CONSTRUCTOR_INVOKE = 0x10000000,
- }
-
- [Serializable]
- public abstract class MethodBase : MemberInfo
- {
- #region Static Members
- public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
- {
- if (handle.IsNullHandle())
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));
-
- MethodBase m = RuntimeType.GetMethodBase(handle.GetMethodInfo());
-
- Type declaringType = m.DeclaringType;
- if (declaringType != null && declaringType.IsGenericType)
- throw new ArgumentException(String.Format(
- CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGeneric"),
- m, declaringType.GetGenericTypeDefinition()));
-
- return m;
- }
-
- public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType)
- {
- if (handle.IsNullHandle())
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));
-
- return RuntimeType.GetMethodBase(declaringType.GetRuntimeType(), handle.GetMethodInfo());
- }
-
- [System.Security.DynamicSecurityMethod] // Specify DynamicSecurityMethod attribute to prevent inlining of the caller.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static MethodBase GetCurrentMethod()
- {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeMethodInfo.InternalGetCurrentMethod(ref stackMark);
- }
- #endregion
-
- #region Constructor
- protected MethodBase() { }
- #endregion
-
- public static bool operator ==(MethodBase left, MethodBase right)
- {
- if (ReferenceEquals(left, right))
- return true;
-
- if ((object)left == null || (object)right == null)
- return false;
-
- MethodInfo method1, method2;
- ConstructorInfo constructor1, constructor2;
-
- if ((method1 = left as MethodInfo) != null && (method2 = right as MethodInfo) != null)
- return method1 == method2;
- else if ((constructor1 = left as ConstructorInfo) != null && (constructor2 = right as ConstructorInfo) != null)
- return constructor1 == constructor2;
-
- return false;
- }
-
- public static bool operator !=(MethodBase left, MethodBase right)
- {
- return !(left == right);
- }
-
- public override bool Equals(object obj)
- {
- return base.Equals(obj);
- }
-
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
-
- #region Internal Members
- // used by EE
- private IntPtr GetMethodDesc() { return MethodHandle.Value; }
-
-#if FEATURE_APPX
-#endif
- #endregion
-
- #region Public Abstract\Virtual Members
- internal virtual ParameterInfo[] GetParametersNoCopy() { return GetParameters (); }
-
- [System.Diagnostics.Contracts.Pure]
- public abstract ParameterInfo[] GetParameters();
-
- public virtual MethodImplAttributes MethodImplementationFlags
- {
- get
- {
- return GetMethodImplementationFlags();
- }
- }
-
- public abstract MethodImplAttributes GetMethodImplementationFlags();
-
- public abstract RuntimeMethodHandle MethodHandle { get; }
-
- public abstract MethodAttributes Attributes { get; }
-
- public abstract Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture);
-
- public virtual CallingConventions CallingConvention { get { return CallingConventions.Standard; } }
-
- public virtual Type[] GetGenericArguments() { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride")); }
-
- public virtual bool IsGenericMethodDefinition { get { return false; } }
-
- public virtual bool ContainsGenericParameters { get { return false; } }
-
- public virtual bool IsGenericMethod { get { return false; } }
-
- public virtual bool IsSecurityCritical { get { throw new NotImplementedException(); } }
-
- public virtual bool IsSecuritySafeCritical { get { throw new NotImplementedException(); } }
-
- public virtual bool IsSecurityTransparent { get { throw new NotImplementedException(); } }
-
- #endregion
-
- #region Public Members
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public Object Invoke(Object obj, Object[] parameters)
- {
- // Theoretically we should set up a LookForMyCaller stack mark here and pass that along.
- // But to maintain backward compatibility we can't switch to calling an
- // internal overload that takes a stack mark.
- // Fortunately the stack walker skips all the reflection invocation frames including this one.
- // So this method will never be returned by the stack walker as the caller.
- // See SystemDomain::CallersMethodCallbackWithStackMark in AppDomain.cpp.
- return Invoke(obj, BindingFlags.Default, null, parameters, null);
- }
-
- public bool IsPublic { get { return(Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public; } }
-
- public bool IsPrivate { get { return(Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; } }
-
- public bool IsFamily { get { return(Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Family; } }
-
- public bool IsAssembly { get { return(Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Assembly; } }
-
- public bool IsFamilyAndAssembly { get { return(Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamANDAssem; } }
-
- public bool IsFamilyOrAssembly { get {return(Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamORAssem; } }
-
- public bool IsStatic { get { return(Attributes & MethodAttributes.Static) != 0; } }
-
- public bool IsFinal { get { return(Attributes & MethodAttributes.Final) != 0; }
- }
- public bool IsVirtual { get { return(Attributes & MethodAttributes.Virtual) != 0; }
- }
- public bool IsHideBySig { get { return(Attributes & MethodAttributes.HideBySig) != 0; } }
-
- public bool IsAbstract { get { return(Attributes & MethodAttributes.Abstract) != 0; } }
-
- public bool IsSpecialName { get { return(Attributes & MethodAttributes.SpecialName) != 0; } }
-
- public bool IsConstructor
- {
- get
- {
- // To be backward compatible we only return true for instance RTSpecialName ctors.
- return (this is ConstructorInfo &&
- !IsStatic &&
- ((Attributes & MethodAttributes.RTSpecialName) == MethodAttributes.RTSpecialName));
- }
- }
-
- public virtual MethodBody GetMethodBody()
- {
- throw new InvalidOperationException();
- }
- #endregion
-
- #region Internal Methods
- // helper method to construct the string representation of the parameter list
-
- internal static string ConstructParameters(Type[] parameterTypes, CallingConventions callingConvention, bool serialization)
- {
- StringBuilder sbParamList = new StringBuilder();
- string comma = "";
-
- for (int i = 0; i < parameterTypes.Length; i++)
- {
- Type t = parameterTypes[i];
-
- sbParamList.Append(comma);
-
- string typeName = t.FormatTypeName(serialization);
-
- // Legacy: Why use "ByRef" for by ref parameters? What language is this?
- // VB uses "ByRef" but it should precede (not follow) the parameter name.
- // Why don't we just use "&"?
- if (t.IsByRef && !serialization)
- {
- sbParamList.Append(typeName.TrimEnd('&'));
- sbParamList.Append(" ByRef");
- }
- else
- {
- sbParamList.Append(typeName);
- }
-
- comma = ", ";
- }
-
- if ((callingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs)
- {
- sbParamList.Append(comma);
- sbParamList.Append("...");
- }
-
- return sbParamList.ToString();
- }
-
- internal string FullName
- {
- get
- {
- return String.Format("{0}.{1}", DeclaringType.FullName, FormatNameAndSig());
- }
- }
- internal string FormatNameAndSig()
- {
- return FormatNameAndSig(false);
- }
-
- internal virtual string FormatNameAndSig(bool serialization)
- {
- // Serialization uses ToString to resolve MethodInfo overloads.
- StringBuilder sbName = new StringBuilder(Name);
-
- sbName.Append("(");
- sbName.Append(ConstructParameters(GetParameterTypes(), CallingConvention, serialization));
- sbName.Append(")");
-
- return sbName.ToString();
- }
-
- internal virtual Type[] GetParameterTypes()
- {
- ParameterInfo[] paramInfo = GetParametersNoCopy();
-
- Type[] parameterTypes = new Type[paramInfo.Length];
- for (int i = 0; i < paramInfo.Length; i++)
- parameterTypes[i] = paramInfo[i].ParameterType;
-
- return parameterTypes;
- }
-
- internal Object[] CheckArguments(Object[] parameters, Binder binder,
- BindingFlags invokeAttr, CultureInfo culture, Signature sig)
- {
- // copy the arguments in a different array so we detach from any user changes
- Object[] copyOfParameters = new Object[parameters.Length];
-
- ParameterInfo[] p = null;
- for (int i = 0; i < parameters.Length; i++)
- {
- Object arg = parameters[i];
- RuntimeType argRT = sig.Arguments[i];
-
- if (arg == Type.Missing)
- {
- if (p == null)
- p = GetParametersNoCopy();
- if (p[i].DefaultValue == System.DBNull.Value)
- throw new ArgumentException(Environment.GetResourceString("Arg_VarMissNull"),nameof(parameters));
- arg = p[i].DefaultValue;
- }
- copyOfParameters[i] = argRT.CheckValue(arg, binder, culture, invokeAttr);
- }
-
- return copyOfParameters;
- }
- #endregion
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/MethodBody.cs b/src/mscorlib/src/System/Reflection/MethodBody.cs
index 7cbaeaf9b9..4335177efb 100644
--- a/src/mscorlib/src/System/Reflection/MethodBody.cs
+++ b/src/mscorlib/src/System/Reflection/MethodBody.cs
@@ -2,116 +2,17 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-
-using System;
-using System.Globalization;
using System.Collections.Generic;
-using System.Diagnostics;
-using System.Diagnostics.Contracts;
namespace System.Reflection
-{
- [Flags()]
- public enum ExceptionHandlingClauseOptions: int
- {
- Clause = 0x0,
- Filter = 0x1,
- Finally = 0x2,
- Fault = 0x4,
- }
-
- public class ExceptionHandlingClause
- {
- #region costructor
- // This class can only be created from inside the EE.
- protected ExceptionHandlingClause() { }
- #endregion
-
- #region Private Data Members
- private MethodBody m_methodBody;
- [ContractPublicPropertyName("Flags")]
- private ExceptionHandlingClauseOptions m_flags;
- private int m_tryOffset;
- private int m_tryLength;
- private int m_handlerOffset;
- private int m_handlerLength;
- private int m_catchMetadataToken;
- private int m_filterOffset;
- #endregion
-
- #region Public Members
- public virtual ExceptionHandlingClauseOptions Flags { get { return m_flags; } }
- public virtual int TryOffset { get { return m_tryOffset; } }
- public virtual int TryLength { get { return m_tryLength; } }
- public virtual int HandlerOffset { get { return m_handlerOffset; } }
- public virtual int HandlerLength { get { return m_handlerLength; } }
-
- public virtual int FilterOffset
- {
- get
- {
- if (m_flags != ExceptionHandlingClauseOptions.Filter)
- throw new InvalidOperationException(Environment.GetResourceString("Arg_EHClauseNotFilter"));
-
- return m_filterOffset;
- }
- }
-
- public virtual Type CatchType
- {
- get
- {
- if (m_flags != ExceptionHandlingClauseOptions.Clause)
- throw new InvalidOperationException(Environment.GetResourceString("Arg_EHClauseNotClause"));
-
- Type type = null;
-
- if (!MetadataToken.IsNullToken(m_catchMetadataToken))
- {
- Type declaringType = m_methodBody.m_methodBase.DeclaringType;
- Module module = (declaringType == null) ? m_methodBody.m_methodBase.Module : declaringType.Module;
- type = module.ResolveType(m_catchMetadataToken, (declaringType == null) ? null : declaringType.GetGenericArguments(),
- m_methodBody.m_methodBase is MethodInfo ? m_methodBody.m_methodBase.GetGenericArguments() : null);
- }
-
- return type;
- }
- }
- #endregion
-
- #region Object Overrides
- public override string ToString()
- {
- if (Flags == ExceptionHandlingClauseOptions.Clause)
- {
- return String.Format(CultureInfo.CurrentUICulture,
- "Flags={0}, TryOffset={1}, TryLength={2}, HandlerOffset={3}, HandlerLength={4}, CatchType={5}",
- Flags, TryOffset, TryLength, HandlerOffset, HandlerLength, CatchType);
- }
-
- if (Flags == ExceptionHandlingClauseOptions.Filter)
- {
- return String.Format(CultureInfo.CurrentUICulture,
- "Flags={0}, TryOffset={1}, TryLength={2}, HandlerOffset={3}, HandlerLength={4}, FilterOffset={5}",
- Flags, TryOffset, TryLength, HandlerOffset, HandlerLength, FilterOffset);
- }
-
- return String.Format(CultureInfo.CurrentUICulture,
- "Flags={0}, TryOffset={1}, TryLength={2}, HandlerOffset={3}, HandlerLength={4}",
- Flags, TryOffset, TryLength, HandlerOffset, HandlerLength);
-
- }
- #endregion
- }
-
+{
public class MethodBody
{
#region costructor
// This class can only be created from inside the EE.
protected MethodBody() { }
#endregion
-
+
#region Private Data Members
private byte[] m_IL;
private ExceptionHandlingClause[] m_exceptionHandlingClauses;
@@ -119,7 +20,7 @@ namespace System.Reflection
internal MethodBase m_methodBase;
private int m_localSignatureMetadataToken;
private int m_maxStackSize;
- private bool m_initLocals;
+ private bool m_initLocals;
#endregion
#region Public Members
@@ -130,37 +31,6 @@ namespace System.Reflection
public virtual byte[] GetILAsByteArray() { return m_IL; }
public virtual IList<ExceptionHandlingClause> ExceptionHandlingClauses { get { return Array.AsReadOnly(m_exceptionHandlingClauses); } }
#endregion
- }
-
- public class LocalVariableInfo
- {
- #region Private Data Members
- private RuntimeType m_type;
- private int m_isPinned;
- private int m_localIndex;
- #endregion
-
- #region Constructor
- protected LocalVariableInfo() { }
- #endregion
-
- #region Object Overrides
- public override string ToString()
- {
- string toString = LocalType.ToString() + " (" + LocalIndex + ")";
-
- if (IsPinned)
- toString += " (pinned)";
-
- return toString;
- }
- #endregion
-
- #region Public Members
- public virtual Type LocalType { get { Debug.Assert(m_type != null, "type must be set!"); return m_type; } }
- public virtual bool IsPinned { get { return m_isPinned != 0; } }
- public virtual int LocalIndex { get { return m_localIndex; } }
- #endregion
}
}
diff --git a/src/mscorlib/src/System/Reflection/MethodImplAttributes.cs b/src/mscorlib/src/System/Reflection/MethodImplAttributes.cs
deleted file mode 100644
index 1bd6b9dbd1..0000000000
--- a/src/mscorlib/src/System/Reflection/MethodImplAttributes.cs
+++ /dev/null
@@ -1,43 +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
-{
-
- using System;
- // This Enum matchs the CorMethodImpl defined in CorHdr.h
- [Serializable]
- public enum MethodImplAttributes
- {
- // code impl mask
- CodeTypeMask = 0x0003, // Flags about code type.
- IL = 0x0000, // Method impl is IL.
- Native = 0x0001, // Method impl is native.
- /// <internalonly/>
- OPTIL = 0x0002, // Method impl is OPTIL
- Runtime = 0x0003, // Method impl is provided by the runtime.
- // end code impl mask
-
- // managed mask
- ManagedMask = 0x0004, // Flags specifying whether the code is managed or unmanaged.
- Unmanaged = 0x0004, // Method impl is unmanaged, otherwise managed.
- Managed = 0x0000, // Method impl is managed.
- // end managed mask
-
- // implementation info and interop
- ForwardRef = 0x0010, // Indicates method is not defined; used primarily in merge scenarios.
- PreserveSig = 0x0080, // Indicates method sig is exported exactly as declared.
-
- InternalCall = 0x1000, // Internal Call...
-
- Synchronized = 0x0020, // Method is single threaded through the body.
- NoInlining = 0x0008, // Method may not be inlined.
- AggressiveInlining = 0x0100, // Method should be inlined if possible.
- NoOptimization = 0x0040, // Method may not be optimized.
-
- MaxMethodImplVal = 0xFFFF, // Range check value
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/Missing.cs b/src/mscorlib/src/System/Reflection/Missing.cs
deleted file mode 100644
index f62c5b538c..0000000000
--- a/src/mscorlib/src/System/Reflection/Missing.cs
+++ /dev/null
@@ -1,35 +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
-{
- using System;
- using System.Runtime.Remoting;
- using System.Runtime.Serialization;
- using System.Diagnostics.Contracts;
-
- // This is not serializable because it is a reflection command.
- [Serializable]
- public sealed class Missing : ISerializable
- {
- public static readonly Missing Value = new Missing();
-
- #region Constructor
- private Missing() { }
- #endregion
-
- #region ISerializable
- void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- Contract.EndContractBlock();
-
- UnitySerializationHolder.GetUnitySerializationInfo(info, this);
- }
- #endregion
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/Module.cs b/src/mscorlib/src/System/Reflection/Module.cs
deleted file mode 100644
index bdf95fca26..0000000000
--- a/src/mscorlib/src/System/Reflection/Module.cs
+++ /dev/null
@@ -1,1120 +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
-{
- using System;
- using System.Diagnostics.SymbolStore;
- using System.Runtime.Remoting;
- using System.Runtime.InteropServices;
- using System.Runtime.Serialization;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading;
- using System.Runtime.CompilerServices;
- using System.Security;
- using System.IO;
- using System.Globalization;
- using System.Runtime.Versioning;
- using System.Diagnostics.Contracts;
-
- [Serializable]
- [Flags]
- public enum PortableExecutableKinds
- {
- NotAPortableExecutableImage = 0x0,
-
- ILOnly = 0x1,
-
- Required32Bit = 0x2,
-
- PE32Plus = 0x4,
-
- Unmanaged32Bit = 0x8,
-
- Preferred32Bit = 0x10,
- }
-
- [Serializable]
- public enum ImageFileMachine
- {
- I386 = 0x014c,
-
- IA64 = 0x0200,
-
- AMD64 = 0x8664,
-
- ARM = 0x01c4,
- }
-
- [Serializable]
- public abstract class Module : ISerializable, ICustomAttributeProvider
- {
- #region Static Constructor
- static Module()
- {
- __Filters _fltObj;
- _fltObj = new __Filters();
- FilterTypeName = new TypeFilter(_fltObj.FilterTypeName);
- FilterTypeNameIgnoreCase = new TypeFilter(_fltObj.FilterTypeNameIgnoreCase);
- }
- #endregion
-
- #region Constructor
- protected Module()
- {
- }
- #endregion
-
- #region Public Statics
- public static readonly TypeFilter FilterTypeName;
- public static readonly TypeFilter FilterTypeNameIgnoreCase;
-
- public static bool operator ==(Module left, Module right)
- {
- if (ReferenceEquals(left, right))
- return true;
-
- if ((object)left == null || (object)right == null ||
- left is RuntimeModule || right is RuntimeModule)
- {
- return false;
- }
-
- return left.Equals(right);
- }
-
- public static bool operator !=(Module left, Module right)
- {
- return !(left == right);
- }
-
- public override bool Equals(object o)
- {
- return base.Equals(o);
- }
-
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
- #endregion
-
- #region Literals
- private const BindingFlags DefaultLookup = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
- #endregion
-
- #region object overrides
- public override String ToString()
- {
- return ScopeName;
- }
- #endregion
-
- public virtual IEnumerable<CustomAttributeData> CustomAttributes
- {
- get
- {
- return GetCustomAttributesData();
- }
- }
- #region ICustomAttributeProvider Members
- public virtual Object[] GetCustomAttributes(bool inherit)
- {
- throw new NotImplementedException();
- }
-
- public virtual Object[] GetCustomAttributes(Type attributeType, bool inherit)
- {
- throw new NotImplementedException();
- }
-
- public virtual bool IsDefined(Type attributeType, bool inherit)
- {
- throw new NotImplementedException();
- }
-
- public virtual IList<CustomAttributeData> GetCustomAttributesData()
- {
- throw new NotImplementedException();
- }
- #endregion
-
- #region public instances members
- public MethodBase ResolveMethod(int metadataToken)
- {
- return ResolveMethod(metadataToken, null, null);
- }
-
- public virtual MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.ResolveMethod(metadataToken, genericTypeArguments, genericMethodArguments);
-
- throw new NotImplementedException();
- }
-
- public FieldInfo ResolveField(int metadataToken)
- {
- return ResolveField(metadataToken, null, null);
- }
-
- public virtual FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.ResolveField(metadataToken, genericTypeArguments, genericMethodArguments);
-
- throw new NotImplementedException();
- }
-
- public Type ResolveType(int metadataToken)
- {
- return ResolveType(metadataToken, null, null);
- }
-
- public virtual Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.ResolveType(metadataToken, genericTypeArguments, genericMethodArguments);
-
- throw new NotImplementedException();
- }
-
- public MemberInfo ResolveMember(int metadataToken)
- {
- return ResolveMember(metadataToken, null, null);
- }
-
- public virtual MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.ResolveMember(metadataToken, genericTypeArguments, genericMethodArguments);
-
- throw new NotImplementedException();
- }
-
- public virtual byte[] ResolveSignature(int metadataToken)
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.ResolveSignature(metadataToken);
-
- throw new NotImplementedException();
- }
-
- public virtual string ResolveString(int metadataToken)
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.ResolveString(metadataToken);
-
- throw new NotImplementedException();
- }
-
- public virtual void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine)
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- rtModule.GetPEKind(out peKind, out machine);
-
- throw new NotImplementedException();
- }
-
- public virtual int MDStreamVersion
- {
- get
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.MDStreamVersion;
-
- throw new NotImplementedException();
- }
- }
-
- public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- throw new NotImplementedException();
- }
-
- public virtual Type GetType(String className, bool ignoreCase)
- {
- return GetType(className, false, ignoreCase);
- }
-
- public virtual Type GetType(String className) {
- return GetType(className, false, false);
- }
-
- public virtual Type GetType(String className, bool throwOnError, bool ignoreCase)
- {
- throw new NotImplementedException();
- }
-
- public virtual String FullyQualifiedName
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public virtual Type[] FindTypes(TypeFilter filter,Object filterCriteria)
- {
- Type[] c = GetTypes();
- int cnt = 0;
- for (int i = 0;i<c.Length;i++) {
- if (filter!=null && !filter(c[i],filterCriteria))
- c[i] = null;
- else
- cnt++;
- }
- if (cnt == c.Length)
- return c;
-
- Type[] ret = new Type[cnt];
- cnt=0;
- for (int i=0;i<c.Length;i++) {
- if (c[i] != null)
- ret[cnt++] = c[i];
- }
- return ret;
- }
-
- public virtual Type[] GetTypes()
- {
- throw new NotImplementedException();
- }
-
- public virtual Guid ModuleVersionId
- {
- get
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.ModuleVersionId;
-
- throw new NotImplementedException();
- }
- }
-
- public virtual int MetadataToken
- {
- get
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.MetadataToken;
-
- throw new NotImplementedException();
- }
- }
-
- public virtual bool IsResource()
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.IsResource();
-
- throw new NotImplementedException();
- }
-
- public FieldInfo[] GetFields()
- {
- return GetFields(Module.DefaultLookup);
- }
-
- public virtual FieldInfo[] GetFields(BindingFlags bindingFlags)
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.GetFields(bindingFlags);
-
- throw new NotImplementedException();
- }
-
- public FieldInfo GetField(String name)
- {
- return GetField(name,Module.DefaultLookup);
- }
-
- public virtual FieldInfo GetField(String name, BindingFlags bindingAttr)
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.GetField(name, bindingAttr);
-
- throw new NotImplementedException();
- }
-
- public MethodInfo[] GetMethods()
- {
- return GetMethods(Module.DefaultLookup);
- }
-
- public virtual MethodInfo[] GetMethods(BindingFlags bindingFlags)
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.GetMethods(bindingFlags);
-
- throw new NotImplementedException();
- }
-
- public MethodInfo GetMethod(
- String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
- {
- if (name == null)
- throw new ArgumentNullException(nameof(name));
-
- if (types == null)
- throw new ArgumentNullException(nameof(types));
- Contract.EndContractBlock();
-
- for (int i = 0; i < types.Length; i++)
- {
- if (types[i] == null)
- throw new ArgumentNullException(nameof(types));
- }
-
- return GetMethodImpl(name, bindingAttr, binder, callConvention, types, modifiers);
- }
-
- public MethodInfo GetMethod(String name, Type[] types)
- {
- if (name == null)
- throw new ArgumentNullException(nameof(name));
-
- if (types == null)
- throw new ArgumentNullException(nameof(types));
- Contract.EndContractBlock();
-
- for (int i = 0; i < types.Length; i++)
- {
- if (types[i] == null)
- throw new ArgumentNullException(nameof(types));
- }
-
- return GetMethodImpl(name, Module.DefaultLookup, null, CallingConventions.Any, types, null);
- }
-
- public MethodInfo GetMethod(String name)
- {
- if (name == null)
- throw new ArgumentNullException(nameof(name));
- Contract.EndContractBlock();
-
- return GetMethodImpl(name, Module.DefaultLookup, null, CallingConventions.Any,
- null, null);
- }
-
- protected virtual MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder,
- CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
- {
- throw new NotImplementedException();
- }
-
- public virtual String ScopeName
- {
- get
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.ScopeName;
-
- throw new NotImplementedException();
- }
- }
-
- public virtual String Name
- {
- get
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.Name;
-
- throw new NotImplementedException();
- }
- }
-
- public virtual Assembly Assembly
- {
- [Pure]
- get
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeModule rtModule = this as RuntimeModule;
- if (rtModule != null)
- return rtModule.Assembly;
-
- throw new NotImplementedException();
- }
- }
-
- // This API never fails, it will return an empty handle for non-runtime handles and
- // a valid handle for reflection only modules.
- public ModuleHandle ModuleHandle
- {
- get
- {
- return GetModuleHandle();
- }
- }
-
- // Used to provide implementation and overriding point for ModuleHandle.
- // To get a module handle inside mscorlib, use GetNativeHandle instead.
- internal virtual ModuleHandle GetModuleHandle()
- {
- return ModuleHandle.EmptyHandle;
- }
- #endregion
- }
-
- [Serializable]
- internal class RuntimeModule : Module
- {
- internal RuntimeModule() { throw new NotSupportedException(); }
-
- #region FCalls
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private extern static void GetType(RuntimeModule module, String className, bool ignoreCase, bool throwOnError, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive);
-
- [DllImport(JitHelpers.QCall)]
- [SuppressUnmanagedCodeSecurity]
- private static extern bool nIsTransientInternal(RuntimeModule module);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private extern static void GetScopeName(RuntimeModule module, StringHandleOnStack retString);
-
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private extern static void GetFullyQualifiedName(RuntimeModule module, StringHandleOnStack retString);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern static RuntimeType[] GetTypes(RuntimeModule module);
-
- internal RuntimeType[] GetDefinedTypes()
- {
- return GetTypes(GetNativeHandle());
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern static bool IsResource(RuntimeModule module);
- #endregion
-
- #region Module overrides
- private static RuntimeTypeHandle[] ConvertToTypeHandleArray(Type[] genericArguments)
- {
- if (genericArguments == null)
- return null;
-
- int size = genericArguments.Length;
- RuntimeTypeHandle[] typeHandleArgs = new RuntimeTypeHandle[size];
- for (int i = 0; i < size; i++)
- {
- Type typeArg = genericArguments[i];
- if (typeArg == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidGenericInstArray"));
- typeArg = typeArg.UnderlyingSystemType;
- if (typeArg == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidGenericInstArray"));
- if (!(typeArg is RuntimeType))
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidGenericInstArray"));
- typeHandleArgs[i] = typeArg.GetTypeHandleInternal();
- }
- return typeHandleArgs;
- }
-
- public override byte[] ResolveSignature(int metadataToken)
- {
- MetadataToken tk = new MetadataToken(metadataToken);
-
- if (!MetadataImport.IsValidToken(tk))
- throw new ArgumentOutOfRangeException(nameof(metadataToken),
- Environment.GetResourceString("Argument_InvalidToken", tk, this));
-
- if (!tk.IsMemberRef && !tk.IsMethodDef && !tk.IsTypeSpec && !tk.IsSignature && !tk.IsFieldDef)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidToken", tk, this),
- nameof(metadataToken));
-
- ConstArray signature;
- if (tk.IsMemberRef)
- signature = MetadataImport.GetMemberRefProps(metadataToken);
- else
- signature = MetadataImport.GetSignatureFromToken(metadataToken);
-
- byte[] sig = new byte[signature.Length];
-
- for (int i = 0; i < signature.Length; i++)
- sig[i] = signature[i];
-
- return sig;
- }
-
- public override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
- {
- MetadataToken tk = new MetadataToken(metadataToken);
-
- if (!MetadataImport.IsValidToken(tk))
- throw new ArgumentOutOfRangeException(nameof(metadataToken),
- Environment.GetResourceString("Argument_InvalidToken", tk, this));
-
- RuntimeTypeHandle[] typeArgs = ConvertToTypeHandleArray(genericTypeArguments);
- RuntimeTypeHandle[] methodArgs = ConvertToTypeHandleArray(genericMethodArguments);
-
- try
- {
- if (!tk.IsMethodDef && !tk.IsMethodSpec)
- {
- if (!tk.IsMemberRef)
- throw new ArgumentException(Environment.GetResourceString("Argument_ResolveMethod", tk, this),
- nameof(metadataToken));
-
- unsafe
- {
- ConstArray sig = MetadataImport.GetMemberRefProps(tk);
-
- if (*(MdSigCallingConvention*)sig.Signature.ToPointer() == MdSigCallingConvention.Field)
- throw new ArgumentException(Environment.GetResourceString("Argument_ResolveMethod", tk, this),
- nameof(metadataToken));
- }
- }
-
- IRuntimeMethodInfo methodHandle = ModuleHandle.ResolveMethodHandleInternal(GetNativeHandle(), tk, typeArgs, methodArgs);
- Type declaringType = RuntimeMethodHandle.GetDeclaringType(methodHandle);
-
- if (declaringType.IsGenericType || declaringType.IsArray)
- {
- MetadataToken tkDeclaringType = new MetadataToken(MetadataImport.GetParentToken(tk));
-
- if (tk.IsMethodSpec)
- tkDeclaringType = new MetadataToken(MetadataImport.GetParentToken(tkDeclaringType));
-
- declaringType = ResolveType(tkDeclaringType, genericTypeArguments, genericMethodArguments);
- }
-
- return System.RuntimeType.GetMethodBase(declaringType as RuntimeType, methodHandle);
- }
- catch (BadImageFormatException e)
- {
- throw new ArgumentException(Environment.GetResourceString("Argument_BadImageFormatExceptionResolve"), e);
- }
- }
-
- private FieldInfo ResolveLiteralField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
- {
- MetadataToken tk = new MetadataToken(metadataToken);
-
- if (!MetadataImport.IsValidToken(tk) || !tk.IsFieldDef)
- throw new ArgumentOutOfRangeException(nameof(metadataToken),
- String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Argument_InvalidToken", tk, this)));
-
- int tkDeclaringType;
- string fieldName;
-
- fieldName = MetadataImport.GetName(tk).ToString();
- tkDeclaringType = MetadataImport.GetParentToken(tk);
-
- Type declaringType = ResolveType(tkDeclaringType, genericTypeArguments, genericMethodArguments);
-
- declaringType.GetFields();
-
- try
- {
- return declaringType.GetField(fieldName,
- BindingFlags.Static | BindingFlags.Instance |
- BindingFlags.Public | BindingFlags.NonPublic |
- BindingFlags.DeclaredOnly);
- }
- catch
- {
- throw new ArgumentException(Environment.GetResourceString("Argument_ResolveField", tk, this), nameof(metadataToken));
- }
- }
-
- public override FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
- {
- MetadataToken tk = new MetadataToken(metadataToken);
-
- if (!MetadataImport.IsValidToken(tk))
- throw new ArgumentOutOfRangeException(nameof(metadataToken),
- Environment.GetResourceString("Argument_InvalidToken", tk, this));
-
- RuntimeTypeHandle[] typeArgs = ConvertToTypeHandleArray(genericTypeArguments);
- RuntimeTypeHandle[] methodArgs = ConvertToTypeHandleArray(genericMethodArguments);
-
- try
- {
- IRuntimeFieldInfo fieldHandle = null;
-
- if (!tk.IsFieldDef)
- {
- if (!tk.IsMemberRef)
- throw new ArgumentException(Environment.GetResourceString("Argument_ResolveField", tk, this),
- nameof(metadataToken));
-
- unsafe
- {
- ConstArray sig = MetadataImport.GetMemberRefProps(tk);
-
- if (*(MdSigCallingConvention*)sig.Signature.ToPointer() != MdSigCallingConvention.Field)
- throw new ArgumentException(Environment.GetResourceString("Argument_ResolveField", tk, this),
- nameof(metadataToken));
- }
-
- fieldHandle = ModuleHandle.ResolveFieldHandleInternal(GetNativeHandle(), tk, typeArgs, methodArgs);
- }
-
- fieldHandle = ModuleHandle.ResolveFieldHandleInternal(GetNativeHandle(), metadataToken, typeArgs, methodArgs);
- RuntimeType declaringType = RuntimeFieldHandle.GetApproxDeclaringType(fieldHandle.Value);
-
- if (declaringType.IsGenericType || declaringType.IsArray)
- {
- int tkDeclaringType = ModuleHandle.GetMetadataImport(GetNativeHandle()).GetParentToken(metadataToken);
- declaringType = (RuntimeType)ResolveType(tkDeclaringType, genericTypeArguments, genericMethodArguments);
- }
-
- return System.RuntimeType.GetFieldInfo(declaringType, fieldHandle);
- }
- catch(MissingFieldException)
- {
- return ResolveLiteralField(tk, genericTypeArguments, genericMethodArguments);
- }
- catch (BadImageFormatException e)
- {
- throw new ArgumentException(Environment.GetResourceString("Argument_BadImageFormatExceptionResolve"), e);
- }
- }
-
- public override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
- {
- MetadataToken tk = new MetadataToken(metadataToken);
-
- if (tk.IsGlobalTypeDefToken)
- throw new ArgumentException(Environment.GetResourceString("Argument_ResolveModuleType", tk), nameof(metadataToken));
-
- if (!MetadataImport.IsValidToken(tk))
- throw new ArgumentOutOfRangeException(nameof(metadataToken),
- Environment.GetResourceString("Argument_InvalidToken", tk, this));
-
- if (!tk.IsTypeDef && !tk.IsTypeSpec && !tk.IsTypeRef)
- throw new ArgumentException(Environment.GetResourceString("Argument_ResolveType", tk, this), nameof(metadataToken));
-
- RuntimeTypeHandle[] typeArgs = ConvertToTypeHandleArray(genericTypeArguments);
- RuntimeTypeHandle[] methodArgs = ConvertToTypeHandleArray(genericMethodArguments);
-
- try
- {
- Type t = GetModuleHandle().ResolveTypeHandle(metadataToken, typeArgs, methodArgs).GetRuntimeType();
-
- if (t == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_ResolveType", tk, this), nameof(metadataToken));
-
- return t;
- }
- catch (BadImageFormatException e)
- {
- throw new ArgumentException(Environment.GetResourceString("Argument_BadImageFormatExceptionResolve"), e);
- }
- }
-
- public override MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
- {
- MetadataToken tk = new MetadataToken(metadataToken);
-
- if (tk.IsProperty)
- throw new ArgumentException(Environment.GetResourceString("InvalidOperation_PropertyInfoNotAvailable"));
-
- if (tk.IsEvent)
- throw new ArgumentException(Environment.GetResourceString("InvalidOperation_EventInfoNotAvailable"));
-
- if (tk.IsMethodSpec || tk.IsMethodDef)
- return ResolveMethod(metadataToken, genericTypeArguments, genericMethodArguments);
-
- if (tk.IsFieldDef)
- return ResolveField(metadataToken, genericTypeArguments, genericMethodArguments);
-
- if (tk.IsTypeRef || tk.IsTypeDef || tk.IsTypeSpec)
- return ResolveType(metadataToken, genericTypeArguments, genericMethodArguments);
-
- if (tk.IsMemberRef)
- {
- if (!MetadataImport.IsValidToken(tk))
- throw new ArgumentOutOfRangeException(nameof(metadataToken),
- Environment.GetResourceString("Argument_InvalidToken", tk, this));
-
- ConstArray sig = MetadataImport.GetMemberRefProps(tk);
-
- unsafe
- {
- if (*(MdSigCallingConvention*)sig.Signature.ToPointer() == MdSigCallingConvention.Field)
- {
- return ResolveField(tk, genericTypeArguments, genericMethodArguments);
- }
- else
- {
- return ResolveMethod(tk, genericTypeArguments, genericMethodArguments);
- }
- }
- }
-
- throw new ArgumentException(Environment.GetResourceString("Argument_ResolveMember", tk, this),
- nameof(metadataToken));
- }
-
- public override string ResolveString(int metadataToken)
- {
- MetadataToken tk = new MetadataToken(metadataToken);
- if (!tk.IsString)
- throw new ArgumentException(
- String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Argument_ResolveString"), metadataToken, ToString()));
-
- if (!MetadataImport.IsValidToken(tk))
- throw new ArgumentOutOfRangeException(nameof(metadataToken),
- String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Argument_InvalidToken", tk, this)));
-
- string str = MetadataImport.GetUserString(metadataToken);
-
- if (str == null)
- throw new ArgumentException(
- String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Argument_ResolveString"), metadataToken, ToString()));
-
- return str;
- }
-
- public override void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine)
- {
- ModuleHandle.GetPEKind(GetNativeHandle(), out peKind, out machine);
- }
-
- public override int MDStreamVersion
- {
- get
- {
- return ModuleHandle.GetMDStreamVersion(GetNativeHandle());
- }
- }
- #endregion
-
- #region Data Members
- #pragma warning disable 169
- // If you add any data members, you need to update the native declaration ReflectModuleBaseObject.
- private RuntimeType m_runtimeType;
- private RuntimeAssembly m_runtimeAssembly;
- private IntPtr m_pRefClass;
- private IntPtr m_pData;
- private IntPtr m_pGlobals;
- private IntPtr m_pFields;
-#pragma warning restore 169
- #endregion
-
- #region Protected Virtuals
- protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder,
- CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
- {
- return GetMethodInternal(name, bindingAttr, binder, callConvention, types, modifiers);
- }
-
- internal MethodInfo GetMethodInternal(String name, BindingFlags bindingAttr, Binder binder,
- CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
- {
- if (RuntimeType == null)
- return null;
-
- if (types == null)
- {
- return RuntimeType.GetMethod(name, bindingAttr);
- }
- else
- {
- return RuntimeType.GetMethod(name, bindingAttr, binder, callConvention, types, modifiers);
- }
- }
- #endregion
-
- #region Internal Members
- internal RuntimeType RuntimeType
- {
- get
- {
- if (m_runtimeType == null)
- m_runtimeType = ModuleHandle.GetModuleType(GetNativeHandle());
-
- return m_runtimeType;
- }
- }
-
- internal bool IsTransientInternal()
- {
- return RuntimeModule.nIsTransientInternal(this.GetNativeHandle());
- }
-
- internal MetadataImport MetadataImport
- {
- get
- {
- unsafe
- {
- return ModuleHandle.GetMetadataImport(GetNativeHandle());
- }
- }
- }
- #endregion
-
- #region ICustomAttributeProvider Members
- public override Object[] GetCustomAttributes(bool inherit)
- {
- return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType);
- }
-
- public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
- {
- if (attributeType == null)
- throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
-
- RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
-
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
-
- return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
- }
-
- public override bool IsDefined(Type attributeType, bool inherit)
- {
- if (attributeType == null)
- throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
-
- RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
-
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
-
- return CustomAttribute.IsDefined(this, attributeRuntimeType);
- }
-
- public override IList<CustomAttributeData> GetCustomAttributesData()
- {
- return CustomAttributeData.GetCustomAttributesInternal(this);
- }
- #endregion
-
- #region Public Virtuals
- public override void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- if (info == null)
- {
- throw new ArgumentNullException(nameof(info));
- }
- Contract.EndContractBlock();
- UnitySerializationHolder.GetUnitySerializationInfo(info, UnitySerializationHolder.ModuleUnity, this.ScopeName, this.GetRuntimeAssembly());
- }
-
- public override Type GetType(String className, bool throwOnError, bool ignoreCase)
- {
- // throw on null strings regardless of the value of "throwOnError"
- if (className == null)
- throw new ArgumentNullException(nameof(className));
-
- RuntimeType retType = null;
- Object keepAlive = null;
- GetType(GetNativeHandle(), className, throwOnError, ignoreCase, JitHelpers.GetObjectHandleOnStack(ref retType), JitHelpers.GetObjectHandleOnStack(ref keepAlive));
- GC.KeepAlive(keepAlive);
- return retType;
- }
-
- internal string GetFullyQualifiedName()
- {
- String fullyQualifiedName = null;
- GetFullyQualifiedName(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref fullyQualifiedName));
- return fullyQualifiedName;
- }
-
- public override String FullyQualifiedName
- {
- get
- {
- return GetFullyQualifiedName();
- }
- }
-
- public override Type[] GetTypes()
- {
- return GetTypes(GetNativeHandle());
- }
-
- #endregion
-
- #region Public Members
-
- public override Guid ModuleVersionId
- {
- get
- {
- unsafe
- {
- Guid mvid;
- MetadataImport.GetScopeProps(out mvid);
- return mvid;
- }
- }
- }
-
- public override int MetadataToken
- {
- get
- {
- return ModuleHandle.GetToken(GetNativeHandle());
- }
- }
-
- public override bool IsResource()
- {
- return IsResource(GetNativeHandle());
- }
-
- public override FieldInfo[] GetFields(BindingFlags bindingFlags)
- {
- if (RuntimeType == null)
- return new FieldInfo[0];
-
- return RuntimeType.GetFields(bindingFlags);
- }
-
- public override FieldInfo GetField(String name, BindingFlags bindingAttr)
- {
- if (name == null)
- throw new ArgumentNullException(nameof(name));
-
- if (RuntimeType == null)
- return null;
-
- return RuntimeType.GetField(name, bindingAttr);
- }
-
- public override MethodInfo[] GetMethods(BindingFlags bindingFlags)
- {
- if (RuntimeType == null)
- return new MethodInfo[0];
-
- return RuntimeType.GetMethods(bindingFlags);
- }
-
- public override String ScopeName
- {
- get
- {
- string scopeName = null;
- GetScopeName(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref scopeName));
- return scopeName;
- }
- }
-
- public override String Name
- {
- get
- {
- String s = GetFullyQualifiedName();
-
-#if !FEATURE_PAL
- int i = s.LastIndexOf('\\');
-#else
- int i = s.LastIndexOf(System.IO.Path.DirectorySeparatorChar);
-#endif
- if (i == -1)
- return s;
-
- return s.Substring(i + 1);
- }
- }
-
- public override Assembly Assembly
- {
- [Pure]
- get
- {
- return GetRuntimeAssembly();
- }
- }
-
- internal RuntimeAssembly GetRuntimeAssembly()
- {
- return m_runtimeAssembly;
- }
-
-
- internal override ModuleHandle GetModuleHandle()
- {
- return new ModuleHandle(this);
- }
-
- internal RuntimeModule GetNativeHandle()
- {
- return this;
- }
- #endregion
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/ObfuscateAssemblyAttribute.cs b/src/mscorlib/src/System/Reflection/ObfuscateAssemblyAttribute.cs
deleted file mode 100644
index 787f37bced..0000000000
--- a/src/mscorlib/src/System/Reflection/ObfuscateAssemblyAttribute.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-//
-
-using System;
-using System.Reflection;
-
-
-namespace System.Reflection
-{
- [AttributeUsage (AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
- public sealed class ObfuscateAssemblyAttribute : Attribute
- {
- private bool m_assemblyIsPrivate;
- private bool m_strip = true;
-
- public ObfuscateAssemblyAttribute(bool assemblyIsPrivate)
- {
- m_assemblyIsPrivate = assemblyIsPrivate;
- }
-
- public bool AssemblyIsPrivate
- {
- get
- {
- return m_assemblyIsPrivate;
- }
- }
-
- public bool StripAfterObfuscation
- {
- get
- {
- return m_strip;
- }
- set
- {
- m_strip = value;
- }
- }
- }
-}
-
diff --git a/src/mscorlib/src/System/Reflection/ObfuscationAttribute.cs b/src/mscorlib/src/System/Reflection/ObfuscationAttribute.cs
deleted file mode 100644
index c7c7c18550..0000000000
--- a/src/mscorlib/src/System/Reflection/ObfuscationAttribute.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-//
-
-using System;
-using System.Reflection;
-
-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)]
- public sealed class ObfuscationAttribute: Attribute
- {
- private bool m_strip = true;
- private bool m_exclude = true;
- private bool m_applyToMembers = true;
- private string m_feature = "all";
-
- public ObfuscationAttribute()
- {
- }
-
- public bool StripAfterObfuscation
- {
- get
- {
- return m_strip;
- }
- set
- {
- m_strip = value;
- }
- }
-
- public bool Exclude
- {
- get
- {
- return m_exclude;
- }
- set
- {
- m_exclude = value;
- }
- }
-
- public bool ApplyToMembers
- {
- get
- {
- return m_applyToMembers;
- }
- set
- {
- m_applyToMembers = value;
- }
- }
-
- public string Feature
- {
- get
- {
- return m_feature;
- }
- set
- {
- m_feature = value;
- }
- }
- }
-}
-
diff --git a/src/mscorlib/src/System/Reflection/ParameterAttributes.cs b/src/mscorlib/src/System/Reflection/ParameterAttributes.cs
deleted file mode 100644
index acae3a6ec1..0000000000
--- a/src/mscorlib/src/System/Reflection/ParameterAttributes.cs
+++ /dev/null
@@ -1,35 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// ParameterAttributes is an enum defining the attributes that may be
-//
-// associated with a Parameter. These are defined in CorHdr.h.
-//
-//
-namespace System.Reflection {
-
- using System;
- // This Enum matchs the CorParamAttr defined in CorHdr.h
-[Serializable]
- [Flags]
- public enum ParameterAttributes
- {
- None = 0x0000, // no flag is specified
- In = 0x0001, // Param is [In]
- Out = 0x0002, // Param is [Out]
- Lcid = 0x0004, // Param is [lcid]
- Retval = 0x0008, // Param is [Retval]
- Optional = 0x0010, // Param is optional
-
- // Reserved flags for Runtime use only.
- ReservedMask = 0xf000,
- HasDefault = 0x1000, // Param has default value.
- HasFieldMarshal = 0x2000, // Param has FieldMarshal.
- Reserved3 = 0x4000, // reserved bit
- Reserved4 = 0x8000 // reserved bit
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/ParameterModifier.cs b/src/mscorlib/src/System/Reflection/ParameterModifier.cs
deleted file mode 100644
index a2bfeab934..0000000000
--- a/src/mscorlib/src/System/Reflection/ParameterModifier.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System.Diagnostics.Contracts;
-namespace System.Reflection
-{
- using System;
-
- [Serializable]
- public struct ParameterModifier
- {
- #region Private Data Members
- private bool[] _byRef;
- #endregion
-
- #region Constructor
- public ParameterModifier(int parameterCount)
- {
- if (parameterCount <= 0)
- throw new ArgumentException(Environment.GetResourceString("Arg_ParmArraySize"));
- Contract.EndContractBlock();
-
- _byRef = new bool[parameterCount];
- }
- #endregion
-
- #region Internal Members
- internal bool[] IsByRefArray { get { return _byRef; } }
- #endregion
-
- #region Public Members
- public bool this[int index]
- {
- get
- {
- return _byRef[index];
- }
- set
- {
- _byRef[index] = value;
- }
- }
- #endregion
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/Pointer.cs b/src/mscorlib/src/System/Reflection/Pointer.cs
deleted file mode 100644
index 9f1a38366a..0000000000
--- a/src/mscorlib/src/System/Reflection/Pointer.cs
+++ /dev/null
@@ -1,75 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// This is a wrapper class for Pointers
-//
-//
-//
-//
-//
-namespace System.Reflection {
- using System;
- using CultureInfo = System.Globalization.CultureInfo;
- using System.Runtime.Serialization;
- using System.Security;
- using System.Diagnostics.Contracts;
-
- [CLSCompliant(false)]
- [Serializable]
- public sealed class Pointer : ISerializable
- {
- unsafe private void* _ptr;
- private RuntimeType _ptrType;
-
- private Pointer() {}
-
- private unsafe Pointer(SerializationInfo info, StreamingContext context)
- {
- _ptr = ((IntPtr)(info.GetValue("_ptr", typeof(IntPtr)))).ToPointer();
- _ptrType = (RuntimeType)info.GetValue("_ptrType", typeof(RuntimeType));
- }
-
- // This method will box an pointer. We save both the
- // value and the type so we can access it from the native code
- // during an Invoke.
- public static unsafe Object Box(void *ptr,Type type) {
- if (type == null)
- throw new ArgumentNullException(nameof(type));
- if (!type.IsPointer)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBePointer"),nameof(ptr));
- Contract.EndContractBlock();
-
- RuntimeType rt = type as RuntimeType;
- if (rt == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBePointer"), nameof(ptr));
-
- Pointer x = new Pointer();
- x._ptr = ptr;
- x._ptrType = rt;
- return x;
- }
-
- // Returned the stored pointer.
- public static unsafe void* Unbox(Object ptr) {
- if (!(ptr is Pointer))
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBePointer"),nameof(ptr));
- return ((Pointer)ptr)._ptr;
- }
-
- internal RuntimeType GetPointerType() {
- return _ptrType;
- }
-
- internal unsafe Object GetPointerValue() {
- return (IntPtr)_ptr;
- }
-
- unsafe void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) {
- info.AddValue("_ptr", new IntPtr(_ptr));
- info.AddValue("_ptrType", _ptrType);
- }
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/PropertyAttributes.cs b/src/mscorlib/src/System/Reflection/PropertyAttributes.cs
deleted file mode 100644
index 4a5617ba5e..0000000000
--- a/src/mscorlib/src/System/Reflection/PropertyAttributes.cs
+++ /dev/null
@@ -1,32 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// PropertyAttributes is an enum which defines the attributes that may be associated
-//
-// with a property. The values here are defined in Corhdr.h.
-//
-//
-namespace System.Reflection {
-
- using System;
- // This Enum matchs the CorPropertyAttr defined in CorHdr.h
-[Serializable]
-[Flags]
- public enum PropertyAttributes
- {
- None = 0x0000,
- SpecialName = 0x0200, // property is special. Name describes how.
-
- // Reserved flags for Runtime use only.
- ReservedMask = 0xf400,
- RTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding.
- HasDefault = 0x1000, // Property has default
- Reserved2 = 0x2000, // reserved bit
- Reserved3 = 0x4000, // reserved bit
- Reserved4 = 0x8000 // reserved bit
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/ReflectionContext.cs b/src/mscorlib/src/System/Reflection/ReflectionContext.cs
deleted file mode 100644
index 34f692166c..0000000000
--- a/src/mscorlib/src/System/Reflection/ReflectionContext.cs
+++ /dev/null
@@ -1,36 +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: For Assembly-related stuff.
-**
-**
-=============================================================================*/
-
-namespace System.Reflection
-{
- using System;
-
- public abstract class ReflectionContext
- {
- protected ReflectionContext() { }
-
- public abstract Assembly MapAssembly(Assembly assembly);
-
- public abstract TypeInfo MapType(TypeInfo type);
-
- public virtual TypeInfo GetTypeForObject(object value)
- {
- if (value == null)
- throw new ArgumentNullException(nameof(value));
-
- return MapType(value.GetType().GetTypeInfo());
- }
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs b/src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs
deleted file mode 100644
index cccf060645..0000000000
--- a/src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs
+++ /dev/null
@@ -1,72 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// ReflectionTypeLoadException is thrown when multiple TypeLoadExceptions may occur.
-//
-// Specifically, when you call Module.GetTypes() this causes multiple class loads to occur.
-// If there are failures, we continue to load classes and build an array of the successfully
-// loaded classes. We also build an array of the errors that occur. Then we throw this exception
-// which exposes both the array of classes and the array of TypeLoadExceptions.
-//
-//
-//
-//
-namespace System.Reflection {
-
- using System;
- using System.Runtime.Serialization;
- using System.Diagnostics.Contracts;
- [Serializable]
- public sealed class ReflectionTypeLoadException : SystemException, ISerializable {
- private Type[] _classes;
- private Exception[] _exceptions;
-
- // private constructor. This is not called.
- private ReflectionTypeLoadException()
- : base(Environment.GetResourceString("ReflectionTypeLoad_LoadFailed")) {
- SetErrorCode(__HResults.COR_E_REFLECTIONTYPELOAD);
- }
-
- public ReflectionTypeLoadException(Type[] classes, Exception[] exceptions) : base(null)
- {
- _classes = classes;
- _exceptions = exceptions;
- SetErrorCode(__HResults.COR_E_REFLECTIONTYPELOAD);
- }
-
- public ReflectionTypeLoadException(Type[] classes, Exception[] exceptions, String message) : base(message)
- {
- _classes = classes;
- _exceptions = exceptions;
- SetErrorCode(__HResults.COR_E_REFLECTIONTYPELOAD);
- }
-
- internal ReflectionTypeLoadException(SerializationInfo info, StreamingContext context) : base (info, context) {
- _classes = (Type[])(info.GetValue("Types", typeof(Type[])));
- _exceptions = (Exception[])(info.GetValue("Exceptions", typeof(Exception[])));
- }
-
- public Type[] Types {
- get {return _classes;}
- }
-
- public Exception[] LoaderExceptions {
- get {return _exceptions;}
- }
-
- public override void GetObjectData(SerializationInfo info, StreamingContext context) {
- if (info==null) {
- throw new ArgumentNullException(nameof(info));
- }
- Contract.EndContractBlock();
- base.GetObjectData(info, context);
- info.AddValue("Types", _classes, typeof(Type[]));
- info.AddValue("Exceptions", _exceptions, typeof(Exception[]));
- }
-
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/ResourceAttributes.cs b/src/mscorlib/src/System/Reflection/ResourceAttributes.cs
deleted file mode 100644
index 5c419ebb2d..0000000000
--- a/src/mscorlib/src/System/Reflection/ResourceAttributes.cs
+++ /dev/null
@@ -1,23 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// ResourceAttributes is an enum which defines the attributes that may be associated
-//
-// with a manifest resource. The values here are defined in Corhdr.h.
-//
-//
-namespace System.Reflection {
-
- using System;
-[Serializable]
-[Flags]
- public enum ResourceAttributes
- {
- Public = 0x0001,
- Private = 0x0002,
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/RtFieldInfo.cs b/src/mscorlib/src/System/Reflection/RtFieldInfo.cs
new file mode 100644
index 0000000000..20d6e6392f
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/RtFieldInfo.cs
@@ -0,0 +1,390 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Threading;
+using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
+
+namespace System.Reflection
+{
+ [Serializable]
+ internal unsafe sealed class RtFieldInfo : RuntimeFieldInfo, IRuntimeFieldInfo
+ {
+ #region FCalls
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ static private extern void PerformVisibilityCheckOnField(IntPtr field, Object target, RuntimeType declaringType, FieldAttributes attr, uint invocationFlags);
+ #endregion
+
+ #region Private Data Members
+ // agressive caching
+ private IntPtr m_fieldHandle;
+ private FieldAttributes m_fieldAttributes;
+ // lazy caching
+ private string m_name;
+ private RuntimeType m_fieldType;
+ private INVOCATION_FLAGS m_invocationFlags;
+
+ internal INVOCATION_FLAGS InvocationFlags
+ {
+ get
+ {
+ if ((m_invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_INITIALIZED) == 0)
+ {
+ Type declaringType = DeclaringType;
+ bool fIsReflectionOnlyType = (declaringType is ReflectionOnlyType);
+
+ INVOCATION_FLAGS invocationFlags = 0;
+
+ // first take care of all the NO_INVOKE cases
+ if (
+ (declaringType != null && declaringType.ContainsGenericParameters) ||
+ (declaringType == null && Module.Assembly.ReflectionOnly) ||
+ (fIsReflectionOnlyType)
+ )
+ {
+ invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE;
+ }
+
+ // If the invocationFlags are still 0, then
+ // this should be an usable field, determine the other flags
+ if (invocationFlags == 0)
+ {
+ if ((m_fieldAttributes & FieldAttributes.InitOnly) != (FieldAttributes)0)
+ invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_SPECIAL_FIELD;
+
+ if ((m_fieldAttributes & FieldAttributes.HasFieldRVA) != (FieldAttributes)0)
+ invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_SPECIAL_FIELD;
+
+ // A public field is inaccesible to Transparent code if the field is Critical.
+ bool needsTransparencySecurityCheck = IsSecurityCritical && !IsSecuritySafeCritical;
+ bool needsVisibilitySecurityCheck = ((m_fieldAttributes & FieldAttributes.FieldAccessMask) != FieldAttributes.Public) ||
+ (declaringType != null && declaringType.NeedsReflectionSecurityCheck);
+ if (needsTransparencySecurityCheck || needsVisibilitySecurityCheck)
+ invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY;
+
+ // find out if the field type is one of the following: Primitive, Enum or Pointer
+ Type fieldType = FieldType;
+ if (fieldType.IsPointer || fieldType.IsEnum || fieldType.IsPrimitive)
+ invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_FIELD_SPECIAL_CAST;
+ }
+
+ // must be last to avoid threading problems
+ m_invocationFlags = invocationFlags | INVOCATION_FLAGS.INVOCATION_FLAGS_INITIALIZED;
+ }
+
+ return m_invocationFlags;
+ }
+ }
+ #endregion
+
+ private RuntimeAssembly GetRuntimeAssembly() { return m_declaringType.GetRuntimeAssembly(); }
+
+ #region Constructor
+ internal RtFieldInfo(
+ RuntimeFieldHandleInternal handle, RuntimeType declaringType, RuntimeTypeCache reflectedTypeCache, BindingFlags bindingFlags)
+ : base(reflectedTypeCache, declaringType, bindingFlags)
+ {
+ m_fieldHandle = handle.Value;
+ m_fieldAttributes = RuntimeFieldHandle.GetAttributes(handle);
+ }
+ #endregion
+
+ #region Private Members
+ RuntimeFieldHandleInternal IRuntimeFieldInfo.Value
+ {
+ get
+ {
+ return new RuntimeFieldHandleInternal(m_fieldHandle);
+ }
+ }
+
+ #endregion
+
+ #region Internal Members
+ internal void CheckConsistency(Object target)
+ {
+ // only test instance fields
+ if ((m_fieldAttributes & FieldAttributes.Static) != FieldAttributes.Static)
+ {
+ if (!m_declaringType.IsInstanceOfType(target))
+ {
+ if (target == null)
+ {
+ throw new TargetException(SR.RFLCT_Targ_StatFldReqTarg);
+ }
+ else
+ {
+ throw new ArgumentException(
+ String.Format(CultureInfo.CurrentUICulture, SR.Arg_FieldDeclTarget,
+ Name, m_declaringType, target.GetType()));
+ }
+ }
+ }
+ }
+
+ internal override bool CacheEquals(object o)
+ {
+ RtFieldInfo m = o as RtFieldInfo;
+
+ if ((object)m == null)
+ return false;
+
+ return m.m_fieldHandle == m_fieldHandle;
+ }
+
+ [DebuggerStepThroughAttribute]
+ [Diagnostics.DebuggerHidden]
+ internal void InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, ref StackCrawlMark stackMark)
+ {
+ INVOCATION_FLAGS invocationFlags = InvocationFlags;
+ RuntimeType declaringType = DeclaringType as RuntimeType;
+
+ if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != 0)
+ {
+ if (declaringType != null && declaringType.ContainsGenericParameters)
+ throw new InvalidOperationException(SR.Arg_UnboundGenField);
+
+ if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType)
+ throw new InvalidOperationException(SR.Arg_ReflectionOnlyField);
+
+ throw new FieldAccessException();
+ }
+
+ CheckConsistency(obj);
+
+ RuntimeType fieldType = (RuntimeType)FieldType;
+ value = fieldType.CheckValue(value, binder, culture, invokeAttr);
+
+ #region Security Check
+ if ((invocationFlags & (INVOCATION_FLAGS.INVOCATION_FLAGS_SPECIAL_FIELD | INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY)) != 0)
+ PerformVisibilityCheckOnField(m_fieldHandle, obj, m_declaringType, m_fieldAttributes, (uint)m_invocationFlags);
+ #endregion
+
+ bool domainInitialized = false;
+ if (declaringType == null)
+ {
+ RuntimeFieldHandle.SetValue(this, obj, value, fieldType, m_fieldAttributes, null, ref domainInitialized);
+ }
+ else
+ {
+ domainInitialized = declaringType.DomainInitialized;
+ RuntimeFieldHandle.SetValue(this, obj, value, fieldType, m_fieldAttributes, declaringType, ref domainInitialized);
+ declaringType.DomainInitialized = domainInitialized;
+ }
+ }
+
+ // UnsafeSetValue doesn't perform any consistency or visibility check.
+ // It is the caller's responsibility to ensure the operation is safe.
+ // When the caller needs to perform visibility checks they should call
+ // InternalSetValue() instead. When the caller needs to perform
+ // consistency checks they should call CheckConsistency() before
+ // calling this method.
+ [DebuggerStepThroughAttribute]
+ [Diagnostics.DebuggerHidden]
+ internal void UnsafeSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
+ {
+ RuntimeType declaringType = DeclaringType as RuntimeType;
+ RuntimeType fieldType = (RuntimeType)FieldType;
+ value = fieldType.CheckValue(value, binder, culture, invokeAttr);
+
+ bool domainInitialized = false;
+ if (declaringType == null)
+ {
+ RuntimeFieldHandle.SetValue(this, obj, value, fieldType, m_fieldAttributes, null, ref domainInitialized);
+ }
+ else
+ {
+ domainInitialized = declaringType.DomainInitialized;
+ RuntimeFieldHandle.SetValue(this, obj, value, fieldType, m_fieldAttributes, declaringType, ref domainInitialized);
+ declaringType.DomainInitialized = domainInitialized;
+ }
+ }
+
+ [DebuggerStepThroughAttribute]
+ [Diagnostics.DebuggerHidden]
+ internal Object InternalGetValue(Object obj, ref StackCrawlMark stackMark)
+ {
+ INVOCATION_FLAGS invocationFlags = InvocationFlags;
+ RuntimeType declaringType = DeclaringType as RuntimeType;
+
+ if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != 0)
+ {
+ if (declaringType != null && DeclaringType.ContainsGenericParameters)
+ throw new InvalidOperationException(SR.Arg_UnboundGenField);
+
+ if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType)
+ throw new InvalidOperationException(SR.Arg_ReflectionOnlyField);
+
+ throw new FieldAccessException();
+ }
+
+ CheckConsistency(obj);
+
+ RuntimeType fieldType = (RuntimeType)FieldType;
+ if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY) != 0)
+ PerformVisibilityCheckOnField(m_fieldHandle, obj, m_declaringType, m_fieldAttributes, (uint)(m_invocationFlags & ~INVOCATION_FLAGS.INVOCATION_FLAGS_SPECIAL_FIELD));
+
+ return UnsafeGetValue(obj);
+ }
+
+ // UnsafeGetValue doesn't perform any consistency or visibility check.
+ // It is the caller's responsibility to ensure the operation is safe.
+ // When the caller needs to perform visibility checks they should call
+ // InternalGetValue() instead. When the caller needs to perform
+ // consistency checks they should call CheckConsistency() before
+ // calling this method.
+ [DebuggerStepThroughAttribute]
+ [Diagnostics.DebuggerHidden]
+ internal Object UnsafeGetValue(Object obj)
+ {
+ RuntimeType declaringType = DeclaringType as RuntimeType;
+
+ RuntimeType fieldType = (RuntimeType)FieldType;
+
+ bool domainInitialized = false;
+ if (declaringType == null)
+ {
+ return RuntimeFieldHandle.GetValue(this, obj, fieldType, null, ref domainInitialized);
+ }
+ else
+ {
+ domainInitialized = declaringType.DomainInitialized;
+ object retVal = RuntimeFieldHandle.GetValue(this, obj, fieldType, declaringType, ref domainInitialized);
+ declaringType.DomainInitialized = domainInitialized;
+ return retVal;
+ }
+ }
+
+ #endregion
+
+ #region MemberInfo Overrides
+ public override String Name
+ {
+ get
+ {
+ if (m_name == null)
+ m_name = RuntimeFieldHandle.GetName(this);
+
+ return m_name;
+ }
+ }
+
+ internal String FullName
+ {
+ get
+ {
+ return String.Format("{0}.{1}", DeclaringType.FullName, Name);
+ }
+ }
+
+ public override int MetadataToken
+ {
+ get { return RuntimeFieldHandle.GetToken(this); }
+ }
+
+ internal override RuntimeModule GetRuntimeModule()
+ {
+ return RuntimeTypeHandle.GetModule(RuntimeFieldHandle.GetApproxDeclaringType(this));
+ }
+
+ #endregion
+
+ #region FieldInfo Overrides
+ public override Object GetValue(Object obj)
+ {
+ StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
+ return InternalGetValue(obj, ref stackMark);
+ }
+
+ public override object GetRawConstantValue() { throw new InvalidOperationException(); }
+
+ [DebuggerStepThroughAttribute]
+ [Diagnostics.DebuggerHidden]
+ public override Object GetValueDirect(TypedReference obj)
+ {
+ if (obj.IsNull)
+ throw new ArgumentException(SR.Arg_TypedReference_Null);
+ Contract.EndContractBlock();
+
+ unsafe
+ {
+ // Passing TypedReference by reference is easier to make correct in native code
+ return RuntimeFieldHandle.GetValueDirect(this, (RuntimeType)FieldType, &obj, (RuntimeType)DeclaringType);
+ }
+ }
+
+ [DebuggerStepThroughAttribute]
+ [Diagnostics.DebuggerHidden]
+ public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
+ {
+ StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
+ InternalSetValue(obj, value, invokeAttr, binder, culture, ref stackMark);
+ }
+
+ [DebuggerStepThroughAttribute]
+ [Diagnostics.DebuggerHidden]
+ public override void SetValueDirect(TypedReference obj, Object value)
+ {
+ if (obj.IsNull)
+ throw new ArgumentException(SR.Arg_TypedReference_Null);
+ Contract.EndContractBlock();
+
+ unsafe
+ {
+ // Passing TypedReference by reference is easier to make correct in native code
+ RuntimeFieldHandle.SetValueDirect(this, (RuntimeType)FieldType, &obj, value, (RuntimeType)DeclaringType);
+ }
+ }
+
+ public override RuntimeFieldHandle FieldHandle
+ {
+ get
+ {
+ Type declaringType = DeclaringType;
+ if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType)
+ throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInReflectionOnly);
+ return new RuntimeFieldHandle(this);
+ }
+ }
+
+ internal IntPtr GetFieldHandle()
+ {
+ return m_fieldHandle;
+ }
+
+ public override FieldAttributes Attributes
+ {
+ get
+ {
+ return m_fieldAttributes;
+ }
+ }
+
+ public override Type FieldType
+ {
+ get
+ {
+ if (m_fieldType == null)
+ m_fieldType = new Signature(this, m_declaringType).FieldType;
+
+ return m_fieldType;
+ }
+ }
+
+ public override Type[] GetRequiredCustomModifiers()
+ {
+ return new Signature(this, m_declaringType).GetCustomModifiers(1, true);
+ }
+
+ public override Type[] GetOptionalCustomModifiers()
+ {
+ return new Signature(this, m_declaringType).GetCustomModifiers(1, false);
+ }
+
+ #endregion
+ }
+}
diff --git a/src/mscorlib/src/System/Reflection/Assembly.cs b/src/mscorlib/src/System/Reflection/RuntimeAssembly.cs
index eaedc6ded4..4632525453 100644
--- a/src/mscorlib/src/System/Reflection/Assembly.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimeAssembly.cs
@@ -2,763 +2,22 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-/*=============================================================================
-**
-**
-**
-**
-**
-**
-** Purpose: For Assembly-related stuff.
-**
-**
-=============================================================================*/
-
-namespace System.Reflection
+using System.Collections.Generic;
+using CultureInfo = System.Globalization.CultureInfo;
+using System.Security;
+using System.Security.Policy;
+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 System.Runtime.Serialization;
+using System.Threading;
+using System.Diagnostics.Contracts;
+
+namespace System.Reflection
{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using CultureInfo = System.Globalization.CultureInfo;
- using System.Security;
- using System.Security.Policy;
- 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 System.Runtime.Serialization;
- using Microsoft.Win32;
- using System.Threading;
- using __HResults = System.__HResults;
- using System.Runtime.Versioning;
- using System.Diagnostics.Contracts;
- using System.Runtime.Loader;
-
- [Serializable]
- public delegate Module ModuleResolveEventHandler(Object sender, ResolveEventArgs e);
-
-
- [Serializable]
- public abstract class Assembly : ICustomAttributeProvider, ISerializable
- {
- protected Assembly() {}
-
-#region public static methods
-
- public static String CreateQualifiedName(String assemblyName, String typeName)
- {
- return typeName + ", " + assemblyName;
- }
-
- public static Assembly GetAssembly(Type type)
- {
- if (type == null)
- throw new ArgumentNullException(nameof(type));
- Contract.EndContractBlock();
-
- Module m = type.Module;
- if (m == null)
- return null;
- else
- return m.Assembly;
- }
-
- public static bool operator ==(Assembly left, Assembly right)
- {
- if (ReferenceEquals(left, right))
- return true;
-
- if ((object)left == null || (object)right == null ||
- left is RuntimeAssembly || right is RuntimeAssembly)
- {
- return false;
- }
- return left.Equals(right);
- }
-
- public static bool operator !=(Assembly left, Assembly right)
- {
- return !(left == right);
- }
-
- public override bool Equals(object o)
- {
- return base.Equals(o);
- }
-
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
-
- public static Assembly LoadFrom(String assemblyFile)
- {
- if(assemblyFile == null)
- throw new ArgumentNullException(nameof(assemblyFile));
- string fullPath = Path.GetFullPath(assemblyFile);
- return AssemblyLoadContext.Default.LoadFromAssemblyPath(fullPath);
- }
-
- // Locate an assembly for reflection by the name of the file containing the manifest.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly ReflectionOnlyLoadFrom(String assemblyFile)
- {
- 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
- internal static Assembly LoadFrom(String assemblyFile,
- Evidence securityEvidence)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-
- return RuntimeAssembly.InternalLoadFrom(
- assemblyFile,
- securityEvidence,
- null, // hashValue
- AssemblyHashAlgorithm.None,
- false,// forIntrospection);
- ref stackMark);
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly LoadFrom(String assemblyFile,
- byte[] hashValue,
- AssemblyHashAlgorithm hashAlgorithm)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_AssemblyLoadFromHash"));
- }
-
- public static Assembly UnsafeLoadFrom(string assemblyFile)
- {
- return LoadFrom(assemblyFile);
- }
-
- // Locate an assembly by the long form of the assembly name.
- // eg. "Toolbox.dll, version=1.1.10.1220, locale=en, publickey=1234567890123456789012345678901234567890"
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly Load(String assemblyString)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.InternalLoad(assemblyString, null, ref stackMark, false /*forIntrospection*/);
- }
-
- // Returns type from the assembly while keeping compatibility with Assembly.Load(assemblyString).GetType(typeName) for managed types.
- // Calls Type.GetType for WinRT types.
- // Note: Type.GetType fails for assembly names that start with weird characters like '['. By calling it for managed types we would
- // break AppCompat.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- internal static Type GetType_Compat(String assemblyString, String typeName)
- {
- // Normally we would get the stackMark only in public APIs. This is internal API, but it is AppCompat replacement of public API
- // call Assembly.Load(assemblyString).GetType(typeName), therefore we take the stackMark here as well, to be fully compatible with
- // the call sequence.
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-
- RuntimeAssembly assembly;
- AssemblyName assemblyName = RuntimeAssembly.CreateAssemblyName(
- assemblyString,
- false /*forIntrospection*/,
- out assembly);
-
- if (assembly == null) {
- if (assemblyName.ContentType == AssemblyContentType.WindowsRuntime) {
- return Type.GetType(typeName + ", " + assemblyString, true /*throwOnError*/, false /*ignoreCase*/);
- }
-
- assembly = RuntimeAssembly.InternalLoadAssemblyName(
- assemblyName, null, null, ref stackMark,
- true /*thrownOnFileNotFound*/, false /*forIntrospection*/);
- }
- return assembly.GetType(typeName, true /*throwOnError*/, false /*ignoreCase*/);
- }
-
- // Locate an assembly for reflection by the long form of the assembly name.
- // eg. "Toolbox.dll, version=1.1.10.1220, locale=en, publickey=1234567890123456789012345678901234567890"
- //
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly ReflectionOnlyLoad(String assemblyString)
- {
- 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
- // weak. The assembly is loaded into the domain of the caller.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly Load(AssemblyName assemblyRef)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
- if (assemblyRef != null && assemblyRef.CodeBase != null)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_AssemblyLoadCodeBase"));
- }
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/);
- }
-
- // Locate an assembly by its name. The name can be strong or
- // weak. The assembly is loaded into the domain of the caller.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- internal static Assembly Load(AssemblyName assemblyRef, IntPtr ptrLoadContextBinder)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
- if (assemblyRef != null && assemblyRef.CodeBase != null)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_AssemblyLoadCodeBase"));
- }
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- 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")]
- public static Assembly LoadWithPartialName(String partialName)
- {
- if(partialName == null)
- throw new ArgumentNullException(nameof(partialName));
- return Load(partialName);
- }
-
- // Loads the assembly with a COFF based IMAGE containing
- // an emitted assembly. The assembly is loaded into the domain
- // of the caller.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly Load(byte[] rawAssembly)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
- AppDomain.CheckLoadByteArraySupported();
-
- return Load(rawAssembly, null);
- }
-
- // Loads the assembly for reflection with a COFF based IMAGE containing
- // an emitted assembly. The assembly is loaded into the domain
- // of the caller.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly ReflectionOnlyLoad(byte[] rawAssembly)
- {
- if (rawAssembly == null)
- throw new ArgumentNullException(nameof(rawAssembly));
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReflectionOnlyLoad"));
- }
-
- // Loads the assembly with a COFF based IMAGE containing
- // an emitted assembly. The assembly is loaded into the domain
- // of the caller. The second parameter is the raw bytes
- // representing the symbol store that matches the assembly.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly Load(byte[] rawAssembly,
- byte[] rawSymbolStore)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
- AppDomain.CheckLoadByteArraySupported();
-
- if(rawAssembly == null)
- throw new ArgumentNullException(nameof(rawAssembly));
- AssemblyLoadContext alc = new IndividualAssemblyLoadContext();
- MemoryStream assemblyStream = new MemoryStream(rawAssembly);
- MemoryStream symbolStream = (rawSymbolStore!=null)?new MemoryStream(rawSymbolStore):null;
- return alc.LoadFromStream(assemblyStream, symbolStream);
- }
-
- private static Dictionary<string, Assembly> s_loadfile = new Dictionary<string, Assembly>();
-
- public static Assembly LoadFile(String path)
- {
- Contract.Ensures(Contract.Result<Assembly>() != null);
- Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly);
-
- AppDomain.CheckLoadFileSupported();
-
- Assembly result = null;
- if(path == null)
- throw new ArgumentNullException(nameof(path));
-
- if (PathInternal.IsPartiallyQualified(path))
- {
- throw new ArgumentException(Environment.GetResourceString("Argument_AbsolutePathRequired"), nameof(path));
- }
-
- string normalizedPath = Path.GetFullPath(path);
-
- lock(s_loadfile)
- {
- if(s_loadfile.TryGetValue(normalizedPath, out result))
- return result;
- AssemblyLoadContext alc = new IndividualAssemblyLoadContext();
- result = alc.LoadFromAssemblyPath(normalizedPath);
- s_loadfile.Add(normalizedPath, result);
- }
- return result;
- }
-
- /*
- * Get the assembly that the current code is running from.
- */
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly GetExecutingAssembly()
- {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return RuntimeAssembly.GetExecutingAssembly(ref stackMark);
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- public static Assembly GetCallingAssembly()
- {
- // LookForMyCallersCaller is not guarantee to return the correct stack frame
- // because of inlining, tail calls, etc. As a result GetCallingAssembly is not
- // ganranteed to return the correct result. We should document it as such.
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCallersCaller;
- return RuntimeAssembly.GetExecutingAssembly(ref stackMark);
- }
-
- public static Assembly GetEntryAssembly() {
- AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager;
- if (domainManager == null)
- domainManager = new AppDomainManager();
- return domainManager.EntryAssembly;
- }
-
-#endregion // public static methods
-
-#region public methods
- public virtual event ModuleResolveEventHandler ModuleResolve
- {
- add
- {
- throw new NotImplementedException();
- }
- remove
- {
- throw new NotImplementedException();
- }
- }
-
- public virtual String CodeBase
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public virtual String EscapedCodeBase
- {
- get
- {
- return AssemblyName.EscapeCodeBase(CodeBase);
- }
- }
-
- public virtual AssemblyName GetName()
- {
- return GetName(false);
- }
-
- public virtual AssemblyName GetName(bool copiedName)
- {
- throw new NotImplementedException();
- }
-
- public virtual String FullName
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public virtual MethodInfo EntryPoint
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public virtual Type GetType(String name)
- {
- return GetType(name, false, false);
- }
-
- public virtual Type GetType(String name, bool throwOnError)
- {
- return GetType(name, throwOnError, false);
- }
-
- public virtual Type GetType(String name, bool throwOnError, bool ignoreCase)
- {
- throw new NotImplementedException();
- }
-
- public virtual IEnumerable<Type> ExportedTypes
- {
- get
- {
- return GetExportedTypes();
- }
- }
-
- public virtual Type[] GetExportedTypes()
- {
- throw new NotImplementedException();
- }
-
- public virtual IEnumerable<TypeInfo> DefinedTypes
- {
- get
- {
- Type[] types = GetTypes();
-
- TypeInfo[] typeinfos = new TypeInfo[types.Length];
-
- for (int i = 0; i < types.Length; i++)
- {
-
- TypeInfo typeinfo = types[i].GetTypeInfo();
- if (typeinfo == null)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NoTypeInfo", types[i].FullName));
-
- typeinfos[i] = typeinfo;
- }
-
- return typeinfos;
- }
- }
-
- public virtual Type[] GetTypes()
- {
- Module[] m = GetModules(false);
-
- int iFinalLength = 0;
- Type[][] ModuleTypes = new Type[m.Length][];
-
- for (int i = 0; i < ModuleTypes.Length; i++)
- {
- ModuleTypes[i] = m[i].GetTypes();
- iFinalLength += ModuleTypes[i].Length;
- }
-
- int iCurrent = 0;
- Type[] ret = new Type[iFinalLength];
- for (int i = 0; i < ModuleTypes.Length; i++)
- {
- int iLength = ModuleTypes[i].Length;
- Array.Copy(ModuleTypes[i], 0, ret, iCurrent, iLength);
- iCurrent += iLength;
- }
-
- return ret;
- }
-
- // Load a resource based on the NameSpace of the type.
- public virtual Stream GetManifestResourceStream(Type type, String name)
- {
- throw new NotImplementedException();
- }
-
- public virtual Stream GetManifestResourceStream(String name)
- {
- throw new NotImplementedException();
- }
-
- public virtual Assembly GetSatelliteAssembly(CultureInfo culture)
- {
- throw new NotImplementedException();
- }
-
- // Useful for binding to a very specific version of a satellite assembly
- public virtual Assembly GetSatelliteAssembly(CultureInfo culture, Version version)
- {
- throw new NotImplementedException();
- }
-
- public bool IsFullyTrusted
- {
- get
- {
- return true;
- }
- }
-
- public virtual SecurityRuleSet SecurityRuleSet
- {
- get
- {
- return SecurityRuleSet.None;
- }
- }
-
- // ISerializable implementation
- public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- throw new NotImplementedException();
- }
-
- public virtual Module ManifestModule
- {
- get
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeAssembly rtAssembly = this as RuntimeAssembly;
- if (rtAssembly != null)
- return rtAssembly.ManifestModule;
-
- throw new NotImplementedException();
- }
- }
-
- public virtual IEnumerable<CustomAttributeData> CustomAttributes
- {
- get
- {
- return GetCustomAttributesData();
- }
- }
- public virtual Object[] GetCustomAttributes(bool inherit)
- {
- Contract.Ensures(Contract.Result<Object[]>() != null);
- throw new NotImplementedException();
- }
-
- public virtual Object[] GetCustomAttributes(Type attributeType, bool inherit)
- {
- Contract.Ensures(Contract.Result<Object[]>() != null);
- throw new NotImplementedException();
- }
-
- public virtual bool IsDefined(Type attributeType, bool inherit)
- {
- throw new NotImplementedException();
- }
-
- public virtual IList<CustomAttributeData> GetCustomAttributesData()
- {
- throw new NotImplementedException();
- }
-
- public virtual bool ReflectionOnly
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Module LoadModule(String moduleName,
- byte[] rawModule)
- {
- return LoadModule(moduleName, rawModule, null);
- }
-
- public virtual Module LoadModule(String moduleName,
- byte[] rawModule,
- byte[] rawSymbolStore)
- {
- throw new NotImplementedException();
- }
-
- //
- // Locates a type from this assembly and creates an instance of it using
- // the system activator.
- //
- public Object CreateInstance(String typeName)
- {
- return CreateInstance(typeName,
- false, // ignore case
- BindingFlags.Public | BindingFlags.Instance,
- null, // binder
- null, // args
- null, // culture
- null); // activation attributes
- }
-
- public Object CreateInstance(String typeName,
- bool ignoreCase)
- {
- return CreateInstance(typeName,
- ignoreCase,
- BindingFlags.Public | BindingFlags.Instance,
- null, // binder
- null, // args
- null, // culture
- null); // activation attributes
- }
-
- public virtual Object CreateInstance(String typeName,
- bool ignoreCase,
- BindingFlags bindingAttr,
- Binder binder,
- Object[] args,
- CultureInfo culture,
- Object[] activationAttributes)
- {
- Type t = GetType(typeName, false, ignoreCase);
- if (t == null) return null;
- return Activator.CreateInstance(t,
- bindingAttr,
- binder,
- args,
- culture,
- activationAttributes);
- }
-
- public virtual IEnumerable<Module> Modules
- {
- get
- {
- return GetLoadedModules(true);
- }
- }
-
- public Module[] GetLoadedModules()
- {
- return GetLoadedModules(false);
- }
-
- public virtual Module[] GetLoadedModules(bool getResourceModules)
- {
- throw new NotImplementedException();
- }
-
- public Module[] GetModules()
- {
- return GetModules(false);
- }
-
- public virtual Module[] GetModules(bool getResourceModules)
- {
- throw new NotImplementedException();
- }
-
- public virtual Module GetModule(String name)
- {
- throw new NotImplementedException();
- }
-
- // Returns the file in the File table of the manifest that matches the
- // given name. (Name should not include path.)
- public virtual FileStream GetFile(String name)
- {
- throw new NotImplementedException();
- }
-
- public virtual FileStream[] GetFiles()
- {
- return GetFiles(false);
- }
-
- public virtual FileStream[] GetFiles(bool getResourceModules)
- {
- throw new NotImplementedException();
- }
-
- // Returns the names of all the resources
- public virtual String[] GetManifestResourceNames()
- {
- throw new NotImplementedException();
- }
-
- public virtual AssemblyName[] GetReferencedAssemblies()
- {
- throw new NotImplementedException();
- }
-
- public virtual ManifestResourceInfo GetManifestResourceInfo(String resourceName)
- {
- throw new NotImplementedException();
- }
-
- public override String ToString()
- {
- String displayName = FullName;
- if (displayName == null)
- return base.ToString();
- else
- return displayName;
- }
-
- public virtual String Location
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public virtual String ImageRuntimeVersion
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- /*
- Returns true if the assembly was loaded from the global assembly cache.
- */
- public virtual bool GlobalAssemblyCache
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public virtual Int64 HostContext
- {
- get
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeAssembly rtAssembly = this as RuntimeAssembly;
- if (rtAssembly != null)
- return rtAssembly.HostContext;
-
- throw new NotImplementedException();
- }
- }
-
- public virtual bool IsDynamic
- {
- get
- {
- return false;
- }
- }
-#endregion // public methods
-
- }
-
[Serializable]
internal class RuntimeAssembly : Assembly
{
@@ -767,11 +26,10 @@ namespace System.Reflection
// the cached ctor token of [DynamicallyInvocableAttribute].
private enum ASSEMBLY_FLAGS : uint
{
- ASSEMBLY_FLAGS_UNKNOWN = 0x00000000,
- ASSEMBLY_FLAGS_INITIALIZED = 0x01000000,
- ASSEMBLY_FLAGS_FRAMEWORK = 0x02000000,
- ASSEMBLY_FLAGS_SAFE_REFLECTION = 0x04000000,
- ASSEMBLY_FLAGS_TOKEN_MASK = 0x00FFFFFF,
+ ASSEMBLY_FLAGS_UNKNOWN = 0x00000000,
+ ASSEMBLY_FLAGS_INITIALIZED = 0x01000000,
+ ASSEMBLY_FLAGS_FRAMEWORK = 0x02000000,
+ ASSEMBLY_FLAGS_TOKEN_MASK = 0x00FFFFFF,
}
#endif // FEATURE_APPX
@@ -779,7 +37,7 @@ namespace System.Reflection
internal RuntimeAssembly() { throw new NotSupportedException(); }
-#region private data members
+ #region private data members
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
@@ -788,19 +46,9 @@ namespace System.Reflection
#if FEATURE_APPX
private ASSEMBLY_FLAGS m_flags;
#endif
-#endregion
+ #endregion
#if FEATURE_APPX
- internal int InvocableAttributeCtorToken
- {
- get
- {
- int token = (int)(Flags & ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_TOKEN_MASK);
-
- return token | (int)MetadataTokenType.MethodDef;
- }
- }
-
private ASSEMBLY_FLAGS Flags
{
get
@@ -808,7 +56,7 @@ namespace System.Reflection
if ((m_flags & ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_INITIALIZED) == 0)
{
ASSEMBLY_FLAGS flags = ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_UNKNOWN
- | ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_FRAMEWORK | ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_SAFE_REFLECTION;
+ | ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_FRAMEWORK;
m_flags = flags | ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_INITIALIZED;
}
@@ -829,7 +77,7 @@ namespace System.Reflection
return m_syncRoot;
}
}
-
+
public override event ModuleResolveEventHandler ModuleResolve
{
add
@@ -846,8 +94,8 @@ namespace System.Reflection
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- private static extern void GetCodeBase(RuntimeAssembly assembly,
- bool copiedName,
+ private static extern void GetCodeBase(RuntimeAssembly assembly,
+ bool copiedName,
StringHandleOnStack retString);
internal String GetCodeBase(bool copiedName)
@@ -859,7 +107,8 @@ namespace System.Reflection
public override String CodeBase
{
- get {
+ get
+ {
String codeBase = GetCodeBase(false);
return codeBase;
}
@@ -879,7 +128,7 @@ namespace System.Reflection
String codeBase = GetCodeBase(copiedName);
- an.Init(GetSimpleName(),
+ an.Init(GetSimpleName(),
GetPublicKey(),
null, // public key token
GetVersion(),
@@ -892,14 +141,14 @@ namespace System.Reflection
PortableExecutableKinds pek;
ImageFileMachine ifm;
-
+
Module manifestModule = ManifestModule;
if (manifestModule != null)
{
if (manifestModule.MDStreamVersion > 0x10000)
{
ManifestModule.GetPEKind(out pek, out ifm);
- an.SetProcArchIndex(pek,ifm);
+ an.SetProcArchIndex(pek, ifm);
}
}
return an;
@@ -911,7 +160,8 @@ namespace System.Reflection
public override String FullName
{
- get {
+ get
+ {
// If called by Object.ToString(), return val may be NULL.
if (m_fullname == null)
{
@@ -927,30 +177,31 @@ namespace System.Reflection
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void GetEntryPoint(RuntimeAssembly assembly, ObjectHandleOnStack retMethod);
-
+
public override MethodInfo EntryPoint
{
- get {
+ get
+ {
IRuntimeMethodInfo methodHandle = null;
GetEntryPoint(GetNativeHandle(), JitHelpers.GetObjectHandleOnStack(ref methodHandle));
if (methodHandle == null)
return null;
- return (MethodInfo)RuntimeType.GetMethodBase(methodHandle);
+ return (MethodInfo)RuntimeType.GetMethodBase(methodHandle);
}
}
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- private static extern void GetType(RuntimeAssembly assembly,
- String name,
- bool throwOnError,
+ private static extern void GetType(RuntimeAssembly assembly,
+ String name,
+ bool throwOnError,
bool ignoreCase,
ObjectHandleOnStack type,
ObjectHandleOnStack keepAlive);
-
- public override Type GetType(String name, bool throwOnError, bool ignoreCase)
+
+ public override Type GetType(String name, bool throwOnError, bool ignoreCase)
{
// throw on null strings regardless of the value of "throwOnError"
if (name == null)
@@ -960,14 +211,14 @@ namespace System.Reflection
Object keepAlive = null;
GetType(GetNativeHandle(), name, throwOnError, ignoreCase, JitHelpers.GetObjectHandleOnStack(ref type), JitHelpers.GetObjectHandleOnStack(ref keepAlive));
GC.KeepAlive(keepAlive);
-
+
return type;
}
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- private extern static void GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes);
-
+ private extern static void GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes);
+
public override Type[] GetExportedTypes()
{
Type[] types = null;
@@ -993,14 +244,14 @@ namespace System.Reflection
}
// Load a resource based on the NameSpace of the type.
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Stream GetManifestResourceStream(Type type, String name)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return GetManifestResourceStream(type, name, false, ref stackMark);
}
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Stream GetManifestResourceStream(String name)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
@@ -1010,14 +261,14 @@ namespace System.Reflection
// ISerializable implementation
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
- if (info==null)
+ if (info == null)
throw new ArgumentNullException(nameof(info));
Contract.EndContractBlock();
UnitySerializationHolder.GetUnitySerializationInfo(info,
- UnitySerializationHolder.AssemblyUnity,
- this.FullName,
+ UnitySerializationHolder.AssemblyUnity,
+ this.FullName,
this);
}
@@ -1044,8 +295,8 @@ namespace System.Reflection
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
}
@@ -1058,8 +309,8 @@ namespace System.Reflection
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.IsDefined(this, attributeRuntimeType);
}
@@ -1069,10 +320,10 @@ namespace System.Reflection
return CustomAttributeData.GetCustomAttributesInternal(this);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
- internal static RuntimeAssembly InternalLoadFrom(String assemblyFile,
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
+ internal static RuntimeAssembly InternalLoadFrom(String assemblyFile,
Evidence securityEvidence,
- byte[] hashValue,
+ byte[] hashValue,
AssemblyHashAlgorithm hashAlgorithm,
bool forIntrospection,
ref StackCrawlMark stackMark)
@@ -1095,10 +346,10 @@ namespace System.Reflection
ref StackCrawlMark stackMark,
bool forIntrospection)
{
- return InternalLoad(assemblyString, assemblySecurity, ref stackMark, IntPtr.Zero, forIntrospection);
+ return InternalLoad(assemblyString, assemblySecurity, ref stackMark, IntPtr.Zero, forIntrospection);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
internal static RuntimeAssembly InternalLoad(String assemblyString,
Evidence assemblySecurity,
ref StackCrawlMark stackMark,
@@ -1108,20 +359,21 @@ namespace System.Reflection
RuntimeAssembly assembly;
AssemblyName an = CreateAssemblyName(assemblyString, forIntrospection, out assembly);
- if (assembly != null) {
+ if (assembly != null)
+ {
// The assembly was returned from ResolveAssemblyEvent
return assembly;
}
- return InternalLoadAssemblyName(an, assemblySecurity, null, ref stackMark,
+ return InternalLoadAssemblyName(an, assemblySecurity, null, ref stackMark,
pPrivHostBinder,
true /*thrownOnFileNotFound*/, forIntrospection);
}
-
+
// Creates AssemblyName. Fills assembly if AssemblyResolve event has been raised.
internal static AssemblyName CreateAssemblyName(
- String assemblyString,
- bool forIntrospection,
+ String assemblyString,
+ bool forIntrospection,
out RuntimeAssembly assemblyFromResolveEvent)
{
if (assemblyString == null)
@@ -1130,7 +382,7 @@ namespace System.Reflection
if ((assemblyString.Length == 0) ||
(assemblyString[0] == '\0'))
- throw new ArgumentException(Environment.GetResourceString("Format_StringZeroLength"));
+ throw new ArgumentException(SR.Format_StringZeroLength);
if (forIntrospection)
AppDomain.CheckReflectionOnlyLoadSupported();
@@ -1139,10 +391,10 @@ namespace System.Reflection
an.Name = assemblyString;
an.nInit(out assemblyFromResolveEvent, forIntrospection, true);
-
+
return an;
}
-
+
// Wrapper function to wrap the typical use of InternalLoadAssemblyName.
internal static RuntimeAssembly InternalLoadAssemblyName(
AssemblyName assemblyRef,
@@ -1157,16 +409,15 @@ namespace System.Reflection
}
internal static RuntimeAssembly InternalLoadAssemblyName(
- AssemblyName assemblyRef,
+ AssemblyName assemblyRef,
Evidence assemblySecurity,
RuntimeAssembly reqAssembly,
ref StackCrawlMark stackMark,
IntPtr pPrivHostBinder,
- bool throwOnFileNotFound,
+ bool throwOnFileNotFound,
bool forIntrospection,
IntPtr ptrLoadContextBinder = default(IntPtr))
{
-
if (assemblyRef == null)
throw new ArgumentNullException(nameof(assemblyRef));
Contract.EndContractBlock();
@@ -1178,7 +429,8 @@ namespace System.Reflection
assemblyRef = (AssemblyName)assemblyRef.Clone();
if (!forIntrospection &&
- (assemblyRef.ProcessorArchitecture != ProcessorArchitecture.None)) {
+ (assemblyRef.ProcessorArchitecture != ProcessorArchitecture.None))
+ {
// PA does not have a semantics for by-name binds for execution
assemblyRef.ProcessorArchitecture = ProcessorArchitecture.None;
}
@@ -1194,7 +446,7 @@ namespace System.Reflection
// on behalf of user code. We allow framework code to invoke non-W8P
// framework APIs but don't want user code to gain that privilege
// through these assemblies. So we blaklist them.
- static string[] s_unsafeFrameworkAssemblyNames = new string[] {
+ private static string[] s_unsafeFrameworkAssemblyNames = new string[] {
"System.Reflection.Context",
"Microsoft.VisualBasic"
};
@@ -1205,14 +457,6 @@ namespace System.Reflection
ASSEMBLY_FLAGS flags = Flags;
return (flags & ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_FRAMEWORK) != 0;
}
-
- // Returns true if we want to allow this assembly to invoke non-W8P
- // framework APIs through reflection.
- internal bool IsSafeForReflection()
- {
- ASSEMBLY_FLAGS flags = Flags;
- return (flags & ASSEMBLY_FLAGS.ASSEMBLY_FLAGS_SAFE_REFLECTION) != 0;
- }
#endif
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -1314,7 +558,7 @@ namespace System.Reflection
GetExecutingAssembly(JitHelpers.GetStackCrawlMarkHandle(ref stackMark), JitHelpers.GetObjectHandleOnStack(ref retAssembly));
return retAssembly;
}
-
+
// Returns the names of all the resources
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern AssemblyName[] GetReferencedAssemblies(RuntimeAssembly assembly);
@@ -1332,13 +576,13 @@ namespace System.Reflection
StringHandleOnStack retFileName,
StackCrawlMarkHandle stackMark);
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override ManifestResourceInfo GetManifestResourceInfo(String resourceName)
{
RuntimeAssembly retAssembly = null;
String fileName = null;
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- int location = GetManifestResourceInfo(GetNativeHandle(), resourceName,
+ int location = GetManifestResourceInfo(GetNativeHandle(), resourceName,
JitHelpers.GetObjectHandleOnStack(ref retAssembly),
JitHelpers.GetStringHandleOnStack(ref fileName),
JitHelpers.GetStackCrawlMarkHandle(ref stackMark));
@@ -1347,7 +591,7 @@ namespace System.Reflection
return null;
return new ManifestResourceInfo(retAssembly, fileName,
- (ResourceLocation) location);
+ (ResourceLocation)location);
}
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
@@ -1356,7 +600,8 @@ namespace System.Reflection
public override String Location
{
- get {
+ get
+ {
String location = null;
GetLocation(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref location));
@@ -1371,7 +616,8 @@ namespace System.Reflection
public override String ImageRuntimeVersion
{
- get{
+ get
+ {
String s = null;
GetImageRuntimeVersion(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref s));
return s;
@@ -1396,7 +642,7 @@ namespace System.Reflection
private static String VerifyCodeBase(String codebase)
{
- if(codebase == null)
+ if (codebase == null)
return null;
int len = codebase.Length;
@@ -1406,12 +652,12 @@ namespace System.Reflection
int j = codebase.IndexOf(':');
// Check to see if the url has a prefix
- if( (j != -1) &&
- (j+2 < len) &&
- ((codebase[j+1] == '/') || (codebase[j+1] == '\\')) &&
- ((codebase[j+2] == '/') || (codebase[j+2] == '\\')) )
+ if ((j != -1) &&
+ (j + 2 < len) &&
+ ((codebase[j + 1] == '/') || (codebase[j + 1] == '\\')) &&
+ ((codebase[j + 2] == '/') || (codebase[j + 2] == '\\')))
return codebase;
-#if !PLATFORM_UNIX
+#if PLATFORM_WINDOWS
else if ((len > 2) && (codebase[0] == '\\') && (codebase[1] == '\\'))
return "file://" + codebase;
else
@@ -1419,7 +665,7 @@ namespace System.Reflection
#else
else
return "file://" + Path.GetFullPath(codebase);
-#endif // !PLATFORM_UNIX
+#endif // PLATFORM_WINDOWS
}
internal Stream GetManifestResourceStream(
@@ -1429,20 +675,23 @@ namespace System.Reflection
ref StackCrawlMark stackMark)
{
StringBuilder sb = new StringBuilder();
- if(type == null) {
+ if (type == null)
+ {
if (name == null)
throw new ArgumentNullException(nameof(type));
}
- else {
+ else
+ {
String nameSpace = type.Namespace;
- if(nameSpace != null) {
+ if (nameSpace != null)
+ {
sb.Append(nameSpace);
- if(name != null)
+ if (name != null)
sb.Append(Type.Delimiter);
}
}
- if(name != null)
+ if (name != null)
sb.Append(name);
return GetManifestResourceStream(sb.ToString(), ref stackMark, skipSecurityCheck);
@@ -1462,10 +711,11 @@ namespace System.Reflection
ulong length = 0;
byte* pbInMemoryResource = GetResource(GetNativeHandle(), name, out length, JitHelpers.GetStackCrawlMarkHandle(ref stackMark), skipSecurityCheck);
- if (pbInMemoryResource != null) {
+ if (pbInMemoryResource != null)
+ {
//Console.WriteLine("Creating an unmanaged memory stream of length "+length);
if (length > Int64.MaxValue)
- throw new NotImplementedException(Environment.GetResourceString("NotImplemented_ResourcesLongerThan2^63"));
+ throw new NotImplementedException(SR.NotImplemented_ResourcesLongerThanInt64Max);
return new UnmanagedMemoryStream(pbInMemoryResource, (long)length, (long)length, FileAccess.Read);
}
@@ -1476,9 +726,9 @@ namespace System.Reflection
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- private static extern void GetVersion(RuntimeAssembly assembly,
- out int majVer,
- out int minVer,
+ private static extern void GetVersion(RuntimeAssembly assembly,
+ out int majVer,
+ out int minVer,
out int buildNum,
out int revNum);
@@ -1486,7 +736,7 @@ namespace System.Reflection
{
int majorVer, minorVer, build, revision;
GetVersion(GetNativeHandle(), out majorVer, out minorVer, out build, out revision);
- return new Version (majorVer, minorVer, build, revision);
+ return new Version(majorVer, minorVer, build, revision);
}
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
@@ -1510,7 +760,8 @@ namespace System.Reflection
public override bool IsDynamic
{
- get {
+ get
+ {
return FCallIsDynamic(GetNativeHandle());
}
}
@@ -1534,7 +785,7 @@ namespace System.Reflection
{
return GetHashAlgorithm(GetNativeHandle());
}
-
+
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private extern static AssemblyNameFlags GetFlags(RuntimeAssembly assembly);
@@ -1575,8 +826,9 @@ namespace System.Reflection
Delegate[] ds = moduleResolve.GetInvocationList();
int len = ds.Length;
- for (int i = 0; i < len; i++) {
- RuntimeModule ret = (RuntimeModule)((ModuleResolveEventHandler) ds[i])(this, new ResolveEventArgs(moduleName,this));
+ for (int i = 0; i < len; i++)
+ {
+ RuntimeModule ret = (RuntimeModule)((ModuleResolveEventHandler)ds[i])(this, new ResolveEventArgs(moduleName, this));
if (ret != null)
return ret;
}
@@ -1584,7 +836,7 @@ namespace System.Reflection
return null;
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Assembly GetSatelliteAssembly(CultureInfo culture)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
@@ -1592,14 +844,14 @@ namespace System.Reflection
}
// Useful for binding to a very specific version of a satellite assembly
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Assembly GetSatelliteAssembly(CultureInfo culture, Version version)
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return InternalGetSatelliteAssembly(culture, version, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
internal Assembly InternalGetSatelliteAssembly(CultureInfo culture,
Version version,
ref StackCrawlMark stackMark)
@@ -1613,14 +865,13 @@ namespace System.Reflection
return InternalGetSatelliteAssembly(name, culture, version, true, ref stackMark);
}
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
internal RuntimeAssembly InternalGetSatelliteAssembly(String name,
CultureInfo culture,
Version version,
bool throwOnFileNotFound,
ref StackCrawlMark stackMark)
{
-
AssemblyName an = new AssemblyName();
an.SetPublicKey(GetPublicKey());
@@ -1634,13 +885,13 @@ namespace System.Reflection
an.CultureInfo = culture;
an.Name = name;
- RuntimeAssembly retAssembly = nLoad(an, null, null, this, ref stackMark,
+ RuntimeAssembly retAssembly = nLoad(an, null, null, this, ref stackMark,
IntPtr.Zero,
throwOnFileNotFound, false);
if (retAssembly == this || (retAssembly == null && throwOnFileNotFound))
{
- throw new FileNotFoundException(String.Format(culture, Environment.GetResourceString("IO.FileNotFound_FileName"), an.Name));
+ throw new FileNotFoundException(String.Format(culture, SR.IO_FileNotFound_FileName, an.Name));
}
return retAssembly;
@@ -1648,11 +899,11 @@ namespace System.Reflection
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- private extern static void GetModules(RuntimeAssembly assembly,
- bool loadIfNotFound,
- bool getResourceModules,
+ private extern static void GetModules(RuntimeAssembly assembly,
+ bool loadIfNotFound,
+ bool getResourceModules,
ObjectHandleOnStack retModuleHandles);
-
+
private RuntimeModule[] GetModulesInternal(bool loadIfNotFound,
bool getResourceModules)
{
diff --git a/src/mscorlib/src/System/Reflection/ConstructorInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs
index c8d71bc1f9..8c3b1fce98 100644
--- a/src/mscorlib/src/System/Reflection/ConstructorInfo.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs
@@ -2,94 +2,15 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+using System.Globalization;
+using System.Runtime.Serialization;
+using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
namespace System.Reflection
{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
- using System.Globalization;
- using System.Runtime;
- using System.Runtime.ConstrainedExecution;
- using System.Runtime.InteropServices;
- using System.Runtime.Serialization;
- using System.Security;
- using System.Threading;
- using MemberListType = System.RuntimeType.MemberListType;
- using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
- using System.Runtime.CompilerServices;
-
- [Serializable]
- public abstract class ConstructorInfo : MethodBase
- {
- #region Static Members
- public readonly static String ConstructorName = ".ctor";
-
- public readonly static String TypeConstructorName = ".cctor";
- #endregion
-
- #region Constructor
- protected ConstructorInfo() { }
- #endregion
-
- public static bool operator ==(ConstructorInfo left, ConstructorInfo right)
- {
- if (ReferenceEquals(left, right))
- return true;
-
- if ((object)left == null || (object)right == null ||
- left is RuntimeConstructorInfo || right is RuntimeConstructorInfo)
- {
- return false;
- }
- return left.Equals(right);
- }
-
- public static bool operator !=(ConstructorInfo left, ConstructorInfo right)
- {
- return !(left == right);
- }
-
- public override bool Equals(object obj)
- {
- return base.Equals(obj);
- }
-
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
-
- #region Internal Members
- internal virtual Type GetReturnType() { throw new NotImplementedException(); }
- #endregion
-
- #region MemberInfo Overrides
- public override MemberTypes MemberType { get { return System.Reflection.MemberTypes.Constructor; } }
- #endregion
-
- #region Public Abstract\Virtual Members
- public abstract Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture);
- #endregion
-
- #region Public Members
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public Object Invoke(Object[] parameters)
- {
- // Theoretically we should set up a LookForMyCaller stack mark here and pass that along.
- // But to maintain backward compatibility we can't switch to calling an
- // internal overload that takes a stack mark.
- // Fortunately the stack walker skips all the reflection invocation frames including this one.
- // So this method will never be returned by the stack walker as the caller.
- // See SystemDomain::CallersMethodCallbackWithStackMark in AppDomain.cpp.
- return Invoke(BindingFlags.Default, null, parameters, null);
- }
- #endregion
- }
-
[Serializable]
internal sealed class RuntimeConstructorInfo : ConstructorInfo, ISerializable, IRuntimeMethodInfo
{
@@ -109,28 +30,6 @@ namespace System.Reflection
private volatile Signature m_signature;
private INVOCATION_FLAGS m_invocationFlags;
-#if FEATURE_APPX
- private bool IsNonW8PFrameworkAPI()
- {
- if (DeclaringType.IsArray && IsPublic && !IsStatic)
- return false;
-
- RuntimeAssembly rtAssembly = GetRuntimeAssembly();
- if (rtAssembly.IsFrameworkAssembly())
- {
- int ctorToken = rtAssembly.InvocableAttributeCtorToken;
- if (System.Reflection.MetadataToken.IsNullToken(ctorToken) ||
- !CustomAttribute.IsAttributeDefined(GetRuntimeModule(), MetadataToken, ctorToken))
- return true;
- }
-
- if (GetRuntimeType().IsNonW8PFrameworkAPI())
- return true;
-
- return false;
- }
-#endif // FEATURE_APPX
-
internal INVOCATION_FLAGS InvocationFlags
{
get
@@ -143,7 +42,7 @@ namespace System.Reflection
//
// first take care of all the NO_INVOKE cases.
- if ( declaringType == typeof(void) ||
+ if (declaringType == typeof(void) ||
(declaringType != null && declaringType.ContainsGenericParameters) ||
((CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs) ||
((Attributes & MethodAttributes.RequireSecObject) == MethodAttributes.RequireSecObject))
@@ -160,9 +59,9 @@ namespace System.Reflection
// this should be an invocable method, determine the other flags that participate in invocation
invocationFlags |= RuntimeMethodHandle.GetSecurityFlags(this);
- if ( (invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY) == 0 &&
+ if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY) == 0 &&
((Attributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Public ||
- (declaringType != null && declaringType.NeedsReflectionSecurityCheck)) )
+ (declaringType != null && declaringType.NeedsReflectionSecurityCheck)))
{
// If method is non-public, or declaring type is not visible
invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY;
@@ -174,11 +73,6 @@ namespace System.Reflection
invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_IS_DELEGATE_CTOR;
}
-#if FEATURE_APPX
- if (AppDomain.ProfileAPICheck && IsNonW8PFrameworkAPI())
- invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API;
-#endif // FEATURE_APPX
-
m_invocationFlags = invocationFlags | INVOCATION_FLAGS.INVOCATION_FLAGS_INITIALIZED;
}
@@ -233,24 +127,24 @@ namespace System.Reflection
}
private RuntimeType ReflectedTypeInternal
- {
- get
- {
- return m_reflectedTypeCache.GetRuntimeType();
- }
+ {
+ get
+ {
+ return m_reflectedTypeCache.GetRuntimeType();
+ }
}
- private void CheckConsistency(Object target)
+ private void CheckConsistency(Object target)
{
if (target == null && IsStatic)
return;
if (!m_declaringType.IsInstanceOfType(target))
{
- if (target == null)
- throw new TargetException(Environment.GetResourceString("RFLCT.Targ_StatMethReqTarg"));
+ if (target == null)
+ throw new TargetException(SR.RFLCT_Targ_StatMethReqTarg);
- throw new TargetException(Environment.GetResourceString("RFLCT.Targ_ITargMismatch"));
+ throw new TargetException(SR.RFLCT_Targ_ITargMismatch);
}
}
@@ -258,7 +152,7 @@ namespace System.Reflection
#endregion
#region Object Overrides
- public override String ToString()
+ public override String ToString()
{
// "Void" really doesn't make sense here. But we'll keep it for compat reasons.
if (m_toString == null)
@@ -282,8 +176,8 @@ namespace System.Reflection
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
}
@@ -296,12 +190,12 @@ namespace System.Reflection
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.IsDefined(this, attributeRuntimeType);
}
-
+
public override IList<CustomAttributeData> GetCustomAttributesData()
{
return CustomAttributeData.GetCustomAttributesInternal(this);
@@ -315,12 +209,12 @@ namespace System.Reflection
get { return RuntimeMethodHandle.GetName(this); }
}
public override MemberTypes MemberType { get { return MemberTypes.Constructor; } }
-
- public override Type DeclaringType
- {
- get
- {
- return m_reflectedTypeCache.IsGlobal ? null : m_declaringType;
+
+ public override Type DeclaringType
+ {
+ get
+ {
+ return m_reflectedTypeCache.IsGlobal ? null : m_declaringType;
}
}
@@ -349,8 +243,8 @@ namespace System.Reflection
#region MethodBase Overrides
// This seems to always returns System.Void.
- internal override Type GetReturnType() { return Signature.ReturnType; }
-
+ internal override Type GetReturnType() { return Signature.ReturnType; }
+
internal override ParameterInfo[] GetParametersNoCopy()
{
if (m_parameters == null)
@@ -366,7 +260,7 @@ namespace System.Reflection
if (parameters.Length == 0)
return parameters;
-
+
ParameterInfo[] ret = new ParameterInfo[parameters.Length];
Array.Copy(parameters, ret, parameters.Length);
return ret;
@@ -377,18 +271,18 @@ namespace System.Reflection
return RuntimeMethodHandle.GetImplAttributes(this);
}
- public override RuntimeMethodHandle MethodHandle
+ public override RuntimeMethodHandle MethodHandle
{
get
{
Type declaringType = DeclaringType;
if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInReflectionOnly"));
+ throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInReflectionOnly);
return new RuntimeMethodHandle(this);
}
}
- public override MethodAttributes Attributes
+ public override MethodAttributes Attributes
{
get
{
@@ -396,7 +290,7 @@ namespace System.Reflection
}
}
- public override CallingConventions CallingConvention
+ public override CallingConventions CallingConvention
{
get
{
@@ -409,39 +303,39 @@ namespace System.Reflection
if (declaringType == null)
throw new ArgumentNullException(nameof(declaringType));
Contract.EndContractBlock();
-
+
// ctor is ReflectOnly
if (declaringType is ReflectionOnlyType)
- throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyInvoke"));
-
+ throw new InvalidOperationException(SR.Arg_ReflectionOnlyInvoke);
+
// ctor is declared on interface class
else if (declaringType.IsInterface)
throw new MemberAccessException(
- String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Acc_CreateInterfaceEx"), declaringType));
-
+ String.Format(CultureInfo.CurrentUICulture, SR.Acc_CreateInterfaceEx, declaringType));
+
// ctor is on an abstract class
else if (declaringType.IsAbstract)
throw new MemberAccessException(
- String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Acc_CreateAbstEx"), declaringType));
-
+ String.Format(CultureInfo.CurrentUICulture, SR.Acc_CreateAbstEx, declaringType));
+
// ctor is on a class that contains stack pointers
else if (declaringType.GetRootElementType() == typeof(ArgIterator))
throw new NotSupportedException();
-
+
// ctor is vararg
else if (isVarArg)
throw new NotSupportedException();
-
+
// ctor is generic or on a generic class
else if (declaringType.ContainsGenericParameters)
{
throw new MemberAccessException(
- String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Acc_CreateGenericEx"), declaringType));
+ String.Format(CultureInfo.CurrentUICulture, SR.Acc_CreateGenericEx, declaringType));
}
// ctor is declared on System.Void
else if (declaringType == typeof(void))
- throw new MemberAccessException(Environment.GetResourceString("Access_Void"));
+ throw new MemberAccessException(SR.Access_Void);
}
internal void ThrowNoInvokeException()
@@ -450,35 +344,25 @@ namespace System.Reflection
// ctor is .cctor
if ((Attributes & MethodAttributes.Static) == MethodAttributes.Static)
- throw new MemberAccessException(Environment.GetResourceString("Acc_NotClassInit"));
-
+ throw new MemberAccessException(SR.Acc_NotClassInit);
+
throw new TargetException();
}
[DebuggerStepThroughAttribute]
[Diagnostics.DebuggerHidden]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Object Invoke(
Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
INVOCATION_FLAGS invocationFlags = InvocationFlags;
- if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != 0)
+ if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != 0)
ThrowNoInvokeException();
// check basic method consistency. This call will throw if there are problems in the target/method relationship
CheckConsistency(obj);
-#if FEATURE_APPX
- if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- RuntimeAssembly caller = RuntimeAssembly.GetExecutingAssembly(ref stackMark);
- if (caller != null && !caller.IsSafeForReflection())
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", FullName));
- }
-#endif
-
if (obj != null)
{
// For unverifiable code, we require the caller to be critical.
@@ -490,17 +374,17 @@ namespace System.Reflection
// get the signature
int formalCount = sig.Arguments.Length;
- int actualCount =(parameters != null) ? parameters.Length : 0;
+ int actualCount = (parameters != null) ? parameters.Length : 0;
if (formalCount != actualCount)
- throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt"));
-
+ throw new TargetParameterCountException(SR.Arg_ParmCnt);
+
// if we are here we passed all the previous checks. Time to look at the arguments
- if (actualCount > 0)
+ if (actualCount > 0)
{
Object[] arguments = CheckArguments(parameters, binder, invokeAttr, culture, sig);
Object retValue = RuntimeMethodHandle.InvokeMethod(obj, arguments, sig, false);
// copy out. This should be made only if ByRef are present.
- for (int index = 0; index < arguments.Length; index++)
+ for (int index = 0; index < arguments.Length; index++)
parameters[index] = arguments[index];
return retValue;
}
@@ -510,7 +394,7 @@ namespace System.Reflection
public override MethodBody GetMethodBody()
{
MethodBody mb = RuntimeMethodHandle.GetMethodBody(this, ReflectedTypeInternal);
- if (mb != null)
+ if (mb != null)
mb.m_methodBase = this;
return mb;
}
@@ -542,66 +426,49 @@ namespace System.Reflection
#region ConstructorInfo Overrides
[DebuggerStepThroughAttribute]
[Diagnostics.DebuggerHidden]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
INVOCATION_FLAGS invocationFlags = InvocationFlags;
// get the declaring TypeHandle early for consistent exceptions in IntrospectionOnly context
RuntimeTypeHandle declaringTypeHandle = m_declaringType.TypeHandle;
-
+
if ((invocationFlags & (INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE | INVOCATION_FLAGS.INVOCATION_FLAGS_CONTAINS_STACK_POINTERS | INVOCATION_FLAGS.INVOCATION_FLAGS_NO_CTOR_INVOKE)) != 0)
ThrowNoInvokeException();
-#if FEATURE_APPX
- if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- RuntimeAssembly caller = RuntimeAssembly.GetExecutingAssembly(ref stackMark);
- if (caller != null && !caller.IsSafeForReflection())
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", FullName));
- }
-#endif
-
// get the signature
Signature sig = Signature;
int formalCount = sig.Arguments.Length;
- int actualCount =(parameters != null) ? parameters.Length : 0;
+ int actualCount = (parameters != null) ? parameters.Length : 0;
if (formalCount != actualCount)
- throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt"));
+ throw new TargetParameterCountException(SR.Arg_ParmCnt);
// We don't need to explicitly invoke the class constructor here,
// JIT/NGen will insert the call to .cctor in the instance ctor.
// if we are here we passed all the previous checks. Time to look at the arguments
- if (actualCount > 0)
+ if (actualCount > 0)
{
Object[] arguments = CheckArguments(parameters, binder, invokeAttr, culture, sig);
Object retValue = RuntimeMethodHandle.InvokeMethod(null, arguments, sig, true);
// copy out. This should be made only if ByRef are present.
- for (int index = 0; index < arguments.Length; index++)
+ for (int index = 0; index < arguments.Length; index++)
parameters[index] = arguments[index];
return retValue;
}
return RuntimeMethodHandle.InvokeMethod(null, null, sig, true);
}
#endregion
-
+
#region ISerializable Implementation
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
throw new ArgumentNullException(nameof(info));
Contract.EndContractBlock();
- MemberInfoSerializationHolder.GetSerializationInfo(
- info,
- Name,
- ReflectedTypeInternal,
- ToString(),
- SerializationToString(),
- MemberTypes.Constructor,
- null);
+ MemberInfoSerializationHolder.GetSerializationInfo(info, this);
}
internal string SerializationToString()
@@ -609,6 +476,6 @@ namespace System.Reflection
// We don't need the return type for constructors.
return FormatNameAndSig(true);
}
- #endregion
+ #endregion
}
}
diff --git a/src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs
new file mode 100644
index 0000000000..930e1820bd
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs
@@ -0,0 +1,220 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+using System.Runtime.Serialization;
+using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
+
+namespace System.Reflection
+{
+ [Serializable]
+ internal unsafe sealed class RuntimeEventInfo : EventInfo, ISerializable
+ {
+ #region Private Data Members
+ private int m_token;
+ private EventAttributes m_flags;
+ private string m_name;
+ private void* m_utf8name;
+ private RuntimeTypeCache m_reflectedTypeCache;
+ private RuntimeMethodInfo m_addMethod;
+ private RuntimeMethodInfo m_removeMethod;
+ private RuntimeMethodInfo m_raiseMethod;
+ private MethodInfo[] m_otherMethod;
+ private RuntimeType m_declaringType;
+ private BindingFlags m_bindingFlags;
+ #endregion
+
+ #region Constructor
+ internal RuntimeEventInfo()
+ {
+ // Used for dummy head node during population
+ }
+ internal RuntimeEventInfo(int tkEvent, RuntimeType declaredType, RuntimeTypeCache reflectedTypeCache, out bool isPrivate)
+ {
+ Contract.Requires(declaredType != null);
+ Contract.Requires(reflectedTypeCache != null);
+ Debug.Assert(!reflectedTypeCache.IsGlobal);
+
+ MetadataImport scope = declaredType.GetRuntimeModule().MetadataImport;
+
+ m_token = tkEvent;
+ m_reflectedTypeCache = reflectedTypeCache;
+ m_declaringType = declaredType;
+
+
+ RuntimeType reflectedType = reflectedTypeCache.GetRuntimeType();
+
+ scope.GetEventProps(tkEvent, out m_utf8name, out m_flags);
+
+ RuntimeMethodInfo dummy;
+ Associates.AssignAssociates(scope, tkEvent, declaredType, reflectedType,
+ out m_addMethod, out m_removeMethod, out m_raiseMethod,
+ out dummy, out dummy, out m_otherMethod, out isPrivate, out m_bindingFlags);
+ }
+ #endregion
+
+ #region Internal Members
+ internal override bool CacheEquals(object o)
+ {
+ RuntimeEventInfo m = o as RuntimeEventInfo;
+
+ if ((object)m == null)
+ return false;
+
+ return m.m_token == m_token &&
+ RuntimeTypeHandle.GetModule(m_declaringType).Equals(
+ RuntimeTypeHandle.GetModule(m.m_declaringType));
+ }
+
+ internal BindingFlags BindingFlags { get { return m_bindingFlags; } }
+ #endregion
+
+ #region Object Overrides
+ public override String ToString()
+ {
+ if (m_addMethod == null || m_addMethod.GetParametersNoCopy().Length == 0)
+ throw new InvalidOperationException(SR.InvalidOperation_NoPublicAddMethod);
+
+ return m_addMethod.GetParametersNoCopy()[0].ParameterType.FormatTypeName() + " " + Name;
+ }
+ #endregion
+
+ #region ICustomAttributeProvider
+ public override Object[] GetCustomAttributes(bool inherit)
+ {
+ return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType);
+ }
+
+ public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
+ {
+ if (attributeType == null)
+ throw new ArgumentNullException(nameof(attributeType));
+ Contract.EndContractBlock();
+
+ RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
+
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
+
+ return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
+ }
+
+ public override bool IsDefined(Type attributeType, bool inherit)
+ {
+ if (attributeType == null)
+ throw new ArgumentNullException(nameof(attributeType));
+ Contract.EndContractBlock();
+
+ RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
+
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
+
+ return CustomAttribute.IsDefined(this, attributeRuntimeType);
+ }
+
+ public override IList<CustomAttributeData> GetCustomAttributesData()
+ {
+ return CustomAttributeData.GetCustomAttributesInternal(this);
+ }
+ #endregion
+
+ #region MemberInfo Overrides
+ public override MemberTypes MemberType { get { return MemberTypes.Event; } }
+ public override String Name
+ {
+ get
+ {
+ if (m_name == null)
+ m_name = new Utf8String(m_utf8name).ToString();
+
+ return m_name;
+ }
+ }
+ public override Type DeclaringType { get { return m_declaringType; } }
+ public override Type ReflectedType
+ {
+ get
+ {
+ return ReflectedTypeInternal;
+ }
+ }
+
+ private RuntimeType ReflectedTypeInternal
+ {
+ get
+ {
+ return m_reflectedTypeCache.GetRuntimeType();
+ }
+ }
+
+ public override int MetadataToken { get { return m_token; } }
+ public override Module Module { get { return GetRuntimeModule(); } }
+ internal RuntimeModule GetRuntimeModule() { return m_declaringType.GetRuntimeModule(); }
+ #endregion
+
+ #region ISerializable
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ if (info == null)
+ throw new ArgumentNullException(nameof(info));
+ Contract.EndContractBlock();
+
+ MemberInfoSerializationHolder.GetSerializationInfo(info, this);
+ }
+ #endregion
+
+ #region EventInfo Overrides
+ public override MethodInfo[] GetOtherMethods(bool nonPublic)
+ {
+ List<MethodInfo> ret = new List<MethodInfo>();
+
+ if ((object)m_otherMethod == null)
+ return new MethodInfo[0];
+
+ for (int i = 0; i < m_otherMethod.Length; i++)
+ {
+ if (Associates.IncludeAccessor((MethodInfo)m_otherMethod[i], nonPublic))
+ ret.Add(m_otherMethod[i]);
+ }
+
+ return ret.ToArray();
+ }
+
+ public override MethodInfo GetAddMethod(bool nonPublic)
+ {
+ if (!Associates.IncludeAccessor(m_addMethod, nonPublic))
+ return null;
+
+ return m_addMethod;
+ }
+
+ public override MethodInfo GetRemoveMethod(bool nonPublic)
+ {
+ if (!Associates.IncludeAccessor(m_removeMethod, nonPublic))
+ return null;
+
+ return m_removeMethod;
+ }
+
+ public override MethodInfo GetRaiseMethod(bool nonPublic)
+ {
+ if (!Associates.IncludeAccessor(m_raiseMethod, nonPublic))
+ return null;
+
+ return m_raiseMethod;
+ }
+
+ public override EventAttributes Attributes
+ {
+ get
+ {
+ return m_flags;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs
new file mode 100644
index 0000000000..29cc97d225
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs
@@ -0,0 +1,136 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Collections.Generic;
+using System.Diagnostics.Contracts;
+using System.Runtime.Serialization;
+using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
+
+namespace System.Reflection
+{
+ [Serializable]
+ internal abstract class RuntimeFieldInfo : FieldInfo, ISerializable
+ {
+ #region Private Data Members
+ private BindingFlags m_bindingFlags;
+ protected RuntimeTypeCache m_reflectedTypeCache;
+ protected RuntimeType m_declaringType;
+ #endregion
+
+ #region Constructor
+ protected RuntimeFieldInfo()
+ {
+ // Used for dummy head node during population
+ }
+ protected RuntimeFieldInfo(RuntimeTypeCache reflectedTypeCache, RuntimeType declaringType, BindingFlags bindingFlags)
+ {
+ m_bindingFlags = bindingFlags;
+ m_declaringType = declaringType;
+ m_reflectedTypeCache = reflectedTypeCache;
+ }
+ #endregion
+
+ #region NonPublic Members
+ internal BindingFlags BindingFlags { get { return m_bindingFlags; } }
+ private RuntimeType ReflectedTypeInternal
+ {
+ get
+ {
+ return m_reflectedTypeCache.GetRuntimeType();
+ }
+ }
+
+ internal RuntimeType GetDeclaringTypeInternal()
+ {
+ return m_declaringType;
+ }
+
+ internal RuntimeType GetRuntimeType() { return m_declaringType; }
+ internal abstract RuntimeModule GetRuntimeModule();
+ #endregion
+
+ #region MemberInfo Overrides
+ public override MemberTypes MemberType { get { return MemberTypes.Field; } }
+ public override Type ReflectedType
+ {
+ get
+ {
+ return m_reflectedTypeCache.IsGlobal ? null : ReflectedTypeInternal;
+ }
+ }
+
+ public override Type DeclaringType
+ {
+ get
+ {
+ return m_reflectedTypeCache.IsGlobal ? null : m_declaringType;
+ }
+ }
+
+ public override Module Module { get { return GetRuntimeModule(); } }
+ #endregion
+
+ #region Object Overrides
+ public unsafe override String ToString()
+ {
+ return FieldType.FormatTypeName() + " " + Name;
+ }
+ #endregion
+
+ #region ICustomAttributeProvider
+ public override Object[] GetCustomAttributes(bool inherit)
+ {
+ return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType);
+ }
+
+ public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
+ {
+ if (attributeType == null)
+ throw new ArgumentNullException(nameof(attributeType));
+ Contract.EndContractBlock();
+
+ RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
+
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
+
+ return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
+ }
+
+ public override bool IsDefined(Type attributeType, bool inherit)
+ {
+ if (attributeType == null)
+ throw new ArgumentNullException(nameof(attributeType));
+ Contract.EndContractBlock();
+
+ RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
+
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
+
+ return CustomAttribute.IsDefined(this, attributeRuntimeType);
+ }
+
+ public override IList<CustomAttributeData> GetCustomAttributesData()
+ {
+ return CustomAttributeData.GetCustomAttributesInternal(this);
+ }
+ #endregion
+
+ #region FieldInfo Overrides
+ // All implemented on derived classes
+ #endregion
+
+ #region ISerializable Implementation
+ public void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ if (info == null)
+ throw new ArgumentNullException(nameof(info));
+ Contract.EndContractBlock();
+
+ MemberInfoSerializationHolder.GetSerializationInfo(info, this);
+ }
+ #endregion
+ }
+}
diff --git a/src/mscorlib/src/System/Reflection/MethodInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs
index 5ce124614c..b8a2341e4e 100644
--- a/src/mscorlib/src/System/Reflection/MethodInfo.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs
@@ -2,90 +2,23 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+using System.Globalization;
+using System.Runtime.Serialization;
+using System.Security;
+using System.Text;
+using System.Threading;
+using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
namespace System.Reflection
{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
- using System.Globalization;
- using System.Runtime;
- using System.Runtime.InteropServices;
- using System.Runtime.ConstrainedExecution;
- using System.Runtime.Serialization;
- using System.Security;
- using System.Text;
- using System.Threading;
- using MemberListType = System.RuntimeType.MemberListType;
- using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
- using System.Runtime.CompilerServices;
-
- [Serializable]
- public abstract class MethodInfo : MethodBase
- {
- #region Constructor
- protected MethodInfo() { }
- #endregion
-
- public static bool operator ==(MethodInfo left, MethodInfo right)
- {
- if (ReferenceEquals(left, right))
- return true;
-
- if ((object)left == null || (object)right == null ||
- left is RuntimeMethodInfo || right is RuntimeMethodInfo)
- {
- return false;
- }
- return left.Equals(right);
- }
-
- public static bool operator !=(MethodInfo left, MethodInfo right)
- {
- return !(left == right);
- }
-
- public override bool Equals(object obj)
- {
- return base.Equals(obj);
- }
-
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
-
- #region MemberInfo Overrides
- public override MemberTypes MemberType { get { return System.Reflection.MemberTypes.Method; } }
- #endregion
-
- #region Public Abstract\Virtual Members
- public virtual Type ReturnType { get { throw new NotImplementedException(); } }
-
- public virtual ParameterInfo ReturnParameter { get { throw new NotImplementedException(); } }
-
- public abstract ICustomAttributeProvider ReturnTypeCustomAttributes { get; }
-
- public abstract MethodInfo GetBaseDefinition();
-
- public override Type[] GetGenericArguments() { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride")); }
-
- 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")); }
-
- public virtual Delegate CreateDelegate(Type delegateType) { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride")); }
- public virtual Delegate CreateDelegate(Type delegateType, Object target) { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride")); }
- #endregion
- }
-
[Serializable]
internal sealed class RuntimeMethodInfo : MethodInfo, ISerializable, IRuntimeMethodInfo
{
#region Private Data Members
- private IntPtr m_handle;
+ private IntPtr m_handle;
private RuntimeTypeCache m_reflectedTypeCache;
private string m_name;
private string m_toString;
@@ -98,37 +31,6 @@ namespace System.Reflection
private object m_keepalive;
private INVOCATION_FLAGS m_invocationFlags;
-#if FEATURE_APPX
- private bool IsNonW8PFrameworkAPI()
- {
- if (m_declaringType.IsArray && IsPublic && !IsStatic)
- return false;
-
- RuntimeAssembly rtAssembly = GetRuntimeAssembly();
- if (rtAssembly.IsFrameworkAssembly())
- {
- int ctorToken = rtAssembly.InvocableAttributeCtorToken;
- if (System.Reflection.MetadataToken.IsNullToken(ctorToken) ||
- !CustomAttribute.IsAttributeDefined(GetRuntimeModule(), MetadataToken, ctorToken))
- return true;
- }
-
- if (GetRuntimeType().IsNonW8PFrameworkAPI())
- return true;
-
- if (IsGenericMethod && !IsGenericMethodDefinition)
- {
- foreach (Type t in GetGenericArguments())
- {
- if (((RuntimeType)t).IsNonW8PFrameworkAPI())
- return true;
- }
- }
-
- return false;
- }
-#endif
-
internal INVOCATION_FLAGS InvocationFlags
{
get
@@ -157,8 +59,8 @@ namespace System.Reflection
if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY) == 0)
{
- if ( (Attributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Public ||
- (declaringType != null && declaringType.NeedsReflectionSecurityCheck) )
+ if ((Attributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Public ||
+ (declaringType != null && declaringType.NeedsReflectionSecurityCheck))
{
// If method is non-public, or declaring type is not visible
invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY;
@@ -179,11 +81,6 @@ namespace System.Reflection
}
}
-#if FEATURE_APPX
- if (AppDomain.ProfileAPICheck && IsNonW8PFrameworkAPI())
- invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API;
-#endif // FEATURE_APPX
-
m_invocationFlags = invocationFlags | INVOCATION_FLAGS.INVOCATION_FLAGS_INITIALIZED;
}
@@ -194,13 +91,13 @@ namespace System.Reflection
#region Constructor
internal RuntimeMethodInfo(
- RuntimeMethodHandleInternal handle, RuntimeType declaringType,
+ RuntimeMethodHandleInternal handle, RuntimeType declaringType,
RuntimeTypeCache reflectedTypeCache, MethodAttributes methodAttributes, BindingFlags bindingFlags, object keepalive)
{
Contract.Ensures(!m_handle.IsNull());
Debug.Assert(!handle.IsNullHandle());
- Debug.Assert(methodAttributes == RuntimeMethodHandle.GetAttributes(handle));
+ Debug.Assert(methodAttributes == RuntimeMethodHandle.GetAttributes(handle));
m_bindingFlags = bindingFlags;
m_declaringType = declaringType;
@@ -221,11 +118,11 @@ namespace System.Reflection
}
private RuntimeType ReflectedTypeInternal
- {
- get
- {
- return m_reflectedTypeCache.GetRuntimeType();
- }
+ {
+ get
+ {
+ return m_reflectedTypeCache.GetRuntimeType();
+ }
}
private ParameterInfo[] FetchNonReturnParameters()
@@ -265,15 +162,15 @@ namespace System.Reflection
return sbName.ToString();
}
- internal override bool CacheEquals(object o)
- {
+ internal override bool CacheEquals(object o)
+ {
RuntimeMethodInfo m = o as RuntimeMethodInfo;
if ((object)m == null)
return false;
return m.m_handle == m_handle;
- }
+ }
internal Signature Signature
{
@@ -315,7 +212,7 @@ namespace System.Reflection
#endregion
#region Object Overrides
- public override String ToString()
+ public override String ToString()
{
if (m_toString == null)
m_toString = ReturnType.FormatTypeName() + " " + FormatNameAndSig();
@@ -389,8 +286,8 @@ namespace System.Reflection
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType, inherit);
}
@@ -403,8 +300,8 @@ namespace System.Reflection
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.IsDefined(this, attributeRuntimeType, inherit);
}
@@ -416,7 +313,7 @@ namespace System.Reflection
#endregion
#region MemberInfo Overrides
- public override String Name
+ public override String Name
{
get
{
@@ -427,7 +324,7 @@ namespace System.Reflection
}
}
- public override Type DeclaringType
+ public override Type DeclaringType
{
get
{
@@ -438,7 +335,7 @@ namespace System.Reflection
}
}
- public override Type ReflectedType
+ public override Type ReflectedType
{
get
{
@@ -453,13 +350,13 @@ namespace System.Reflection
public override int MetadataToken
{
get { return RuntimeMethodHandle.GetMethodDef(this); }
- }
+ }
public override Module Module { get { return GetRuntimeModule(); } }
internal RuntimeType GetRuntimeType() { return m_declaringType; }
internal RuntimeModule GetRuntimeModule() { return m_declaringType.GetRuntimeModule(); }
internal RuntimeAssembly GetRuntimeAssembly() { return GetRuntimeModule().GetRuntimeAssembly(); }
- public override bool IsSecurityCritical
+ public override bool IsSecurityCritical
{
get { return true; }
}
@@ -471,9 +368,9 @@ namespace System.Reflection
{
get { return false; }
}
-#endregion
+ #endregion
-#region MethodBase Overrides
+ #region MethodBase Overrides
internal override ParameterInfo[] GetParametersNoCopy()
{
FetchNonReturnParameters();
@@ -501,48 +398,48 @@ namespace System.Reflection
return RuntimeMethodHandle.GetImplAttributes(this);
}
- public override RuntimeMethodHandle MethodHandle
- {
- get
- {
+ public override RuntimeMethodHandle MethodHandle
+ {
+ get
+ {
Type declaringType = DeclaringType;
if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInReflectionOnly"));
- return new RuntimeMethodHandle(this);
- }
+ throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInReflectionOnly);
+ return new RuntimeMethodHandle(this);
+ }
}
public override MethodAttributes Attributes { get { return m_methodAttributes; } }
-
- public override CallingConventions CallingConvention
- {
- get
- {
- return Signature.CallingConvention;
- }
+
+ public override CallingConventions CallingConvention
+ {
+ get
+ {
+ return Signature.CallingConvention;
+ }
}
public override MethodBody GetMethodBody()
{
MethodBody mb = RuntimeMethodHandle.GetMethodBody(this, ReflectedTypeInternal);
- if (mb != null)
+ if (mb != null)
mb.m_methodBase = this;
return mb;
- }
-#endregion
+ }
+ #endregion
-#region Invocation Logic(On MemberBase)
- private void CheckConsistency(Object target)
+ #region Invocation Logic(On MemberBase)
+ private void CheckConsistency(Object target)
{
// only test instance methods
- if ((m_methodAttributes & MethodAttributes.Static) != MethodAttributes.Static)
+ if ((m_methodAttributes & MethodAttributes.Static) != MethodAttributes.Static)
{
if (!m_declaringType.IsInstanceOfType(target))
{
- if (target == null)
- throw new TargetException(Environment.GetResourceString("RFLCT.Targ_StatMethReqTarg"));
+ if (target == null)
+ throw new TargetException(SR.RFLCT_Targ_StatMethReqTarg);
else
- throw new TargetException(Environment.GetResourceString("RFLCT.Targ_ITargMismatch"));
+ throw new TargetException(SR.RFLCT_Targ_ITargMismatch);
}
}
}
@@ -553,7 +450,7 @@ namespace System.Reflection
Type declaringType = DeclaringType;
if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType)
{
- throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyInvoke"));
+ throw new InvalidOperationException(SR.Arg_ReflectionOnlyInvoke);
}
// method is on a class that contains stack pointers
else if ((InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_CONTAINS_STACK_POINTERS) != 0)
@@ -568,7 +465,7 @@ namespace System.Reflection
// method is generic or on a generic class
else if (DeclaringType.ContainsGenericParameters || ContainsGenericParameters)
{
- throw new InvalidOperationException(Environment.GetResourceString("Arg_UnboundGenParam"));
+ throw new InvalidOperationException(SR.Arg_UnboundGenParam);
}
// method is abstract class
else if (IsAbstract)
@@ -578,33 +475,19 @@ namespace System.Reflection
// ByRef return are not allowed in reflection
else if (ReturnType.IsByRef)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_ByRefReturn"));
+ throw new NotSupportedException(SR.NotSupported_ByRefReturn);
}
throw new TargetException();
}
-
+
[DebuggerStepThroughAttribute]
[Diagnostics.DebuggerHidden]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
object[] arguments = InvokeArgumentsCheck(obj, invokeAttr, binder, parameters, culture);
-#region Security Check
- INVOCATION_FLAGS invocationFlags = InvocationFlags;
-
-#if FEATURE_APPX
- if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
- {
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- RuntimeAssembly caller = RuntimeAssembly.GetExecutingAssembly(ref stackMark);
- if (caller != null && !caller.IsSafeForReflection())
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", FullName));
- }
-#endif
-#endregion
-
return UnsafeInvokeInternal(obj, parameters, arguments);
}
@@ -657,7 +540,7 @@ namespace System.Reflection
CheckConsistency(obj);
if (formalCount != actualCount)
- throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt"));
+ throw new TargetParameterCountException(SR.Arg_ParmCnt);
if (actualCount != 0)
return CheckArguments(parameters, binder, invokeAttr, culture, sig);
@@ -665,20 +548,20 @@ namespace System.Reflection
return null;
}
-#endregion
+ #endregion
-#region MethodInfo Overrides
- public override Type ReturnType
- {
- get { return Signature.ReturnType; }
+ #region MethodInfo Overrides
+ public override Type ReturnType
+ {
+ get { return Signature.ReturnType; }
}
- public override ICustomAttributeProvider ReturnTypeCustomAttributes
- {
- get { return ReturnParameter; }
+ public override ICustomAttributeProvider ReturnTypeCustomAttributes
+ {
+ get { return ReturnParameter; }
}
- public override ParameterInfo ReturnParameter
+ public override ParameterInfo ReturnParameter
{
get
{
@@ -699,7 +582,8 @@ namespace System.Reflection
RuntimeType baseDeclaringType = declaringType;
RuntimeMethodHandleInternal baseMethodHandle = new RuntimeMethodHandleInternal();
- do {
+ do
+ {
int cVtblSlots = RuntimeTypeHandle.GetNumVirtuals(declaringType);
if (cVtblSlots <= slot)
@@ -711,7 +595,7 @@ namespace System.Reflection
declaringType = (RuntimeType)declaringType.BaseType;
} while (declaringType != null);
- return(MethodInfo)RuntimeType.GetMethodBase(baseDeclaringType, baseMethodHandle);
+ return (MethodInfo)RuntimeType.GetMethodBase(baseDeclaringType, baseMethodHandle);
}
public override Delegate CreateDelegate(Type delegateType)
@@ -758,34 +642,34 @@ namespace System.Reflection
RuntimeType rtType = delegateType as RuntimeType;
if (rtType == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), nameof(delegateType));
+ throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(delegateType));
if (!rtType.IsDelegate())
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), nameof(delegateType));
+ throw new ArgumentException(SR.Arg_MustBeDelegate, nameof(delegateType));
Delegate d = Delegate.CreateDelegateInternal(rtType, this, firstArgument, bindingFlags, ref stackMark);
if (d == null)
{
- throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
+ throw new ArgumentException(SR.Arg_DlgtTargMeth);
}
return d;
}
-#endregion
+ #endregion
-#region Generics
+ #region Generics
public override MethodInfo MakeGenericMethod(params Type[] methodInstantiation)
{
- if (methodInstantiation == null)
+ if (methodInstantiation == null)
throw new ArgumentNullException(nameof(methodInstantiation));
- Contract.EndContractBlock();
+ Contract.EndContractBlock();
RuntimeType[] methodInstantionRuntimeType = new RuntimeType[methodInstantiation.Length];
if (!IsGenericMethodDefinition)
throw new InvalidOperationException(
- Environment.GetResourceString("Arg_NotGenericMethodDefinition", this));
+ SR.Format(SR.Arg_NotGenericMethodDefinition, this));
for (int i = 0; i < methodInstantiation.Length; i++)
{
@@ -813,18 +697,18 @@ namespace System.Reflection
RuntimeType.SanityCheckGenericArguments(methodInstantionRuntimeType, genericParameters);
MethodInfo ret = null;
-
+
try
{
ret = RuntimeType.GetMethodBase(ReflectedTypeInternal,
- RuntimeMethodHandle.GetStubIfNeeded(new RuntimeMethodHandleInternal(this.m_handle), m_declaringType, methodInstantionRuntimeType)) as MethodInfo;
+ RuntimeMethodHandle.GetStubIfNeeded(new RuntimeMethodHandleInternal(m_handle), m_declaringType, methodInstantionRuntimeType)) as MethodInfo;
}
catch (VerificationException e)
{
RuntimeType.ValidateGenericArguments(this, methodInstantionRuntimeType, e);
throw;
}
-
+
return ret;
}
@@ -833,23 +717,23 @@ namespace System.Reflection
return RuntimeMethodHandle.GetMethodInstantiationInternal(this);
}
- public override Type[] GetGenericArguments()
+ public override Type[] GetGenericArguments()
{
Type[] types = RuntimeMethodHandle.GetMethodInstantiationPublic(this);
if (types == null)
{
- types = EmptyArray<Type>.Value;
+ types = Array.Empty<Type>();
}
return types;
}
- public override MethodInfo GetGenericMethodDefinition()
+ public override MethodInfo GetGenericMethodDefinition()
{
if (!IsGenericMethod)
throw new InvalidOperationException();
Contract.EndContractBlock();
-
+
return RuntimeType.GetMethodBase(m_declaringType, RuntimeMethodHandle.StripMethodInstantiation(this)) as MethodInfo;
}
@@ -861,11 +745,11 @@ namespace System.Reflection
public override bool IsGenericMethodDefinition
{
get { return RuntimeMethodHandle.IsGenericMethodDefinition(this); }
- }
+ }
- public override bool ContainsGenericParameters
- {
- get
+ public override bool ContainsGenericParameters
+ {
+ get
{
if (DeclaringType != null && DeclaringType.ContainsGenericParameters)
return true;
@@ -873,7 +757,7 @@ namespace System.Reflection
if (!IsGenericMethod)
return false;
- Type[] pis = GetGenericArguments();
+ Type[] pis = GetGenericArguments();
for (int i = 0; i < pis.Length; i++)
{
if (pis[i].ContainsGenericParameters)
@@ -881,11 +765,11 @@ namespace System.Reflection
}
return false;
- }
+ }
}
-#endregion
+ #endregion
-#region ISerializable Implementation
+ #region ISerializable Implementation
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
@@ -893,34 +777,27 @@ namespace System.Reflection
Contract.EndContractBlock();
if (m_reflectedTypeCache.IsGlobal)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_GlobalMethodSerialization"));
+ throw new NotSupportedException(SR.NotSupported_GlobalMethodSerialization);
- MemberInfoSerializationHolder.GetSerializationInfo(
- info,
- Name,
- ReflectedTypeInternal,
- ToString(),
- SerializationToString(),
- MemberTypes.Method,
- IsGenericMethod & !IsGenericMethodDefinition ? GetGenericArguments() : null);
+ MemberInfoSerializationHolder.GetSerializationInfo(info, this);
}
internal string SerializationToString()
{
return ReturnType.FormatTypeName(true) + " " + FormatNameAndSig(true);
}
-#endregion
+ #endregion
-#region Legacy Internal
+ #region Legacy Internal
internal static MethodBase InternalGetCurrentMethod(ref StackCrawlMark stackMark)
{
IRuntimeMethodInfo method = RuntimeMethodHandle.GetCurrentMethod(ref stackMark);
- if (method == null)
+ if (method == null)
return null;
-
+
return RuntimeType.GetMethodBase(method);
}
-#endregion
+ #endregion
}
}
diff --git a/src/mscorlib/src/System/Reflection/RuntimeModule.cs b/src/mscorlib/src/System/Reflection/RuntimeModule.cs
new file mode 100644
index 0000000000..75809cba01
--- /dev/null
+++ b/src/mscorlib/src/System/Reflection/RuntimeModule.cs
@@ -0,0 +1,602 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+using System.Security;
+using System.Globalization;
+using System.Diagnostics.Contracts;
+
+namespace System.Reflection
+{
+ [Serializable]
+ internal class RuntimeModule : Module
+ {
+ internal RuntimeModule() { throw new NotSupportedException(); }
+
+ #region FCalls
+ [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+ [SuppressUnmanagedCodeSecurity]
+ private extern static void GetType(RuntimeModule module, String className, bool throwOnError, bool ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive);
+
+ [DllImport(JitHelpers.QCall)]
+ [SuppressUnmanagedCodeSecurity]
+ private static extern bool nIsTransientInternal(RuntimeModule module);
+
+ [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+ [SuppressUnmanagedCodeSecurity]
+ private extern static void GetScopeName(RuntimeModule module, StringHandleOnStack retString);
+
+ [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+ [SuppressUnmanagedCodeSecurity]
+ private extern static void GetFullyQualifiedName(RuntimeModule module, StringHandleOnStack retString);
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private extern static RuntimeType[] GetTypes(RuntimeModule module);
+
+ internal RuntimeType[] GetDefinedTypes()
+ {
+ return GetTypes(GetNativeHandle());
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private extern static bool IsResource(RuntimeModule module);
+ #endregion
+
+ #region Module overrides
+ private static RuntimeTypeHandle[] ConvertToTypeHandleArray(Type[] genericArguments)
+ {
+ if (genericArguments == null)
+ return null;
+
+ int size = genericArguments.Length;
+ RuntimeTypeHandle[] typeHandleArgs = new RuntimeTypeHandle[size];
+ for (int i = 0; i < size; i++)
+ {
+ Type typeArg = genericArguments[i];
+ if (typeArg == null)
+ throw new ArgumentException(SR.Argument_InvalidGenericInstArray);
+ typeArg = typeArg.UnderlyingSystemType;
+ if (typeArg == null)
+ throw new ArgumentException(SR.Argument_InvalidGenericInstArray);
+ if (!(typeArg is RuntimeType))
+ throw new ArgumentException(SR.Argument_InvalidGenericInstArray);
+ typeHandleArgs[i] = typeArg.GetTypeHandleInternal();
+ }
+ return typeHandleArgs;
+ }
+
+ public override byte[] ResolveSignature(int metadataToken)
+ {
+ MetadataToken tk = new MetadataToken(metadataToken);
+
+ if (!MetadataImport.IsValidToken(tk))
+ throw new ArgumentOutOfRangeException(nameof(metadataToken),
+ SR.Format(SR.Argument_InvalidToken, tk, this));
+
+ if (!tk.IsMemberRef && !tk.IsMethodDef && !tk.IsTypeSpec && !tk.IsSignature && !tk.IsFieldDef)
+ throw new ArgumentException(SR.Format(SR.Argument_InvalidToken, tk, this),
+ nameof(metadataToken));
+
+ ConstArray signature;
+ if (tk.IsMemberRef)
+ signature = MetadataImport.GetMemberRefProps(metadataToken);
+ else
+ signature = MetadataImport.GetSignatureFromToken(metadataToken);
+
+ byte[] sig = new byte[signature.Length];
+
+ for (int i = 0; i < signature.Length; i++)
+ sig[i] = signature[i];
+
+ return sig;
+ }
+
+ public override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
+ {
+ MetadataToken tk = new MetadataToken(metadataToken);
+
+ if (!MetadataImport.IsValidToken(tk))
+ throw new ArgumentOutOfRangeException(nameof(metadataToken),
+ SR.Format(SR.Argument_InvalidToken, tk, this));
+
+ RuntimeTypeHandle[] typeArgs = ConvertToTypeHandleArray(genericTypeArguments);
+ RuntimeTypeHandle[] methodArgs = ConvertToTypeHandleArray(genericMethodArguments);
+
+ try
+ {
+ if (!tk.IsMethodDef && !tk.IsMethodSpec)
+ {
+ if (!tk.IsMemberRef)
+ throw new ArgumentException(SR.Format(SR.Argument_ResolveMethod, tk, this),
+ nameof(metadataToken));
+
+ unsafe
+ {
+ ConstArray sig = MetadataImport.GetMemberRefProps(tk);
+
+ if (*(MdSigCallingConvention*)sig.Signature.ToPointer() == MdSigCallingConvention.Field)
+ throw new ArgumentException(SR.Format(SR.Argument_ResolveMethod, tk, this),
+ nameof(metadataToken));
+ }
+ }
+
+ IRuntimeMethodInfo methodHandle = ModuleHandle.ResolveMethodHandleInternal(GetNativeHandle(), tk, typeArgs, methodArgs);
+ Type declaringType = RuntimeMethodHandle.GetDeclaringType(methodHandle);
+
+ if (declaringType.IsGenericType || declaringType.IsArray)
+ {
+ MetadataToken tkDeclaringType = new MetadataToken(MetadataImport.GetParentToken(tk));
+
+ if (tk.IsMethodSpec)
+ tkDeclaringType = new MetadataToken(MetadataImport.GetParentToken(tkDeclaringType));
+
+ declaringType = ResolveType(tkDeclaringType, genericTypeArguments, genericMethodArguments);
+ }
+
+ return System.RuntimeType.GetMethodBase(declaringType as RuntimeType, methodHandle);
+ }
+ catch (BadImageFormatException e)
+ {
+ throw new ArgumentException(SR.Argument_BadImageFormatExceptionResolve, e);
+ }
+ }
+
+ private FieldInfo ResolveLiteralField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
+ {
+ MetadataToken tk = new MetadataToken(metadataToken);
+
+ if (!MetadataImport.IsValidToken(tk) || !tk.IsFieldDef)
+ throw new ArgumentOutOfRangeException(nameof(metadataToken),
+ String.Format(CultureInfo.CurrentUICulture, SR.Format(SR.Argument_InvalidToken, tk, this)));
+
+ int tkDeclaringType;
+ string fieldName;
+
+ fieldName = MetadataImport.GetName(tk).ToString();
+ tkDeclaringType = MetadataImport.GetParentToken(tk);
+
+ Type declaringType = ResolveType(tkDeclaringType, genericTypeArguments, genericMethodArguments);
+
+ declaringType.GetFields();
+
+ try
+ {
+ return declaringType.GetField(fieldName,
+ BindingFlags.Static | BindingFlags.Instance |
+ BindingFlags.Public | BindingFlags.NonPublic |
+ BindingFlags.DeclaredOnly);
+ }
+ catch
+ {
+ throw new ArgumentException(SR.Format(SR.Argument_ResolveField, tk, this), nameof(metadataToken));
+ }
+ }
+
+ public override FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
+ {
+ MetadataToken tk = new MetadataToken(metadataToken);
+
+ if (!MetadataImport.IsValidToken(tk))
+ throw new ArgumentOutOfRangeException(nameof(metadataToken),
+ SR.Format(SR.Argument_InvalidToken, tk, this));
+
+ RuntimeTypeHandle[] typeArgs = ConvertToTypeHandleArray(genericTypeArguments);
+ RuntimeTypeHandle[] methodArgs = ConvertToTypeHandleArray(genericMethodArguments);
+
+ try
+ {
+ IRuntimeFieldInfo fieldHandle = null;
+
+ if (!tk.IsFieldDef)
+ {
+ if (!tk.IsMemberRef)
+ throw new ArgumentException(SR.Format(SR.Argument_ResolveField, tk, this),
+ nameof(metadataToken));
+
+ unsafe
+ {
+ ConstArray sig = MetadataImport.GetMemberRefProps(tk);
+
+ if (*(MdSigCallingConvention*)sig.Signature.ToPointer() != MdSigCallingConvention.Field)
+ throw new ArgumentException(SR.Format(SR.Argument_ResolveField, tk, this),
+ nameof(metadataToken));
+ }
+
+ fieldHandle = ModuleHandle.ResolveFieldHandleInternal(GetNativeHandle(), tk, typeArgs, methodArgs);
+ }
+
+ fieldHandle = ModuleHandle.ResolveFieldHandleInternal(GetNativeHandle(), metadataToken, typeArgs, methodArgs);
+ RuntimeType declaringType = RuntimeFieldHandle.GetApproxDeclaringType(fieldHandle.Value);
+
+ if (declaringType.IsGenericType || declaringType.IsArray)
+ {
+ int tkDeclaringType = ModuleHandle.GetMetadataImport(GetNativeHandle()).GetParentToken(metadataToken);
+ declaringType = (RuntimeType)ResolveType(tkDeclaringType, genericTypeArguments, genericMethodArguments);
+ }
+
+ return System.RuntimeType.GetFieldInfo(declaringType, fieldHandle);
+ }
+ catch (MissingFieldException)
+ {
+ return ResolveLiteralField(tk, genericTypeArguments, genericMethodArguments);
+ }
+ catch (BadImageFormatException e)
+ {
+ throw new ArgumentException(SR.Argument_BadImageFormatExceptionResolve, e);
+ }
+ }
+
+ public override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
+ {
+ MetadataToken tk = new MetadataToken(metadataToken);
+
+ if (tk.IsGlobalTypeDefToken)
+ throw new ArgumentException(SR.Format(SR.Argument_ResolveModuleType, tk), nameof(metadataToken));
+
+ if (!MetadataImport.IsValidToken(tk))
+ throw new ArgumentOutOfRangeException(nameof(metadataToken),
+ SR.Format(SR.Argument_InvalidToken, tk, this));
+
+ if (!tk.IsTypeDef && !tk.IsTypeSpec && !tk.IsTypeRef)
+ throw new ArgumentException(SR.Format(SR.Argument_ResolveType, tk, this), nameof(metadataToken));
+
+ RuntimeTypeHandle[] typeArgs = ConvertToTypeHandleArray(genericTypeArguments);
+ RuntimeTypeHandle[] methodArgs = ConvertToTypeHandleArray(genericMethodArguments);
+
+ try
+ {
+ Type t = GetModuleHandleImpl().ResolveTypeHandle(metadataToken, typeArgs, methodArgs).GetRuntimeType();
+
+ if (t == null)
+ throw new ArgumentException(SR.Format(SR.Argument_ResolveType, tk, this), nameof(metadataToken));
+
+ return t;
+ }
+ catch (BadImageFormatException e)
+ {
+ throw new ArgumentException(SR.Argument_BadImageFormatExceptionResolve, e);
+ }
+ }
+
+ public override MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
+ {
+ MetadataToken tk = new MetadataToken(metadataToken);
+
+ if (tk.IsProperty)
+ throw new ArgumentException(SR.InvalidOperation_PropertyInfoNotAvailable);
+
+ if (tk.IsEvent)
+ throw new ArgumentException(SR.InvalidOperation_EventInfoNotAvailable);
+
+ if (tk.IsMethodSpec || tk.IsMethodDef)
+ return ResolveMethod(metadataToken, genericTypeArguments, genericMethodArguments);
+
+ if (tk.IsFieldDef)
+ return ResolveField(metadataToken, genericTypeArguments, genericMethodArguments);
+
+ if (tk.IsTypeRef || tk.IsTypeDef || tk.IsTypeSpec)
+ return ResolveType(metadataToken, genericTypeArguments, genericMethodArguments);
+
+ if (tk.IsMemberRef)
+ {
+ if (!MetadataImport.IsValidToken(tk))
+ throw new ArgumentOutOfRangeException(nameof(metadataToken),
+ SR.Format(SR.Argument_InvalidToken, tk, this));
+
+ ConstArray sig = MetadataImport.GetMemberRefProps(tk);
+
+ unsafe
+ {
+ if (*(MdSigCallingConvention*)sig.Signature.ToPointer() == MdSigCallingConvention.Field)
+ {
+ return ResolveField(tk, genericTypeArguments, genericMethodArguments);
+ }
+ else
+ {
+ return ResolveMethod(tk, genericTypeArguments, genericMethodArguments);
+ }
+ }
+ }
+
+ throw new ArgumentException(SR.Format(SR.Argument_ResolveMember, tk, this),
+ nameof(metadataToken));
+ }
+
+ public override string ResolveString(int metadataToken)
+ {
+ MetadataToken tk = new MetadataToken(metadataToken);
+ if (!tk.IsString)
+ throw new ArgumentException(
+ String.Format(CultureInfo.CurrentUICulture, SR.Argument_ResolveString, metadataToken, ToString()));
+
+ if (!MetadataImport.IsValidToken(tk))
+ throw new ArgumentOutOfRangeException(nameof(metadataToken),
+ String.Format(CultureInfo.CurrentUICulture, SR.Format(SR.Argument_InvalidToken, tk, this)));
+
+ string str = MetadataImport.GetUserString(metadataToken);
+
+ if (str == null)
+ throw new ArgumentException(
+ String.Format(CultureInfo.CurrentUICulture, SR.Argument_ResolveString, metadataToken, ToString()));
+
+ return str;
+ }
+
+ public override void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine)
+ {
+ ModuleHandle.GetPEKind(GetNativeHandle(), out peKind, out machine);
+ }
+
+ public override int MDStreamVersion
+ {
+ get
+ {
+ return ModuleHandle.GetMDStreamVersion(GetNativeHandle());
+ }
+ }
+ #endregion
+
+ #region Data Members
+#pragma warning disable 169
+ // If you add any data members, you need to update the native declaration ReflectModuleBaseObject.
+ private RuntimeType m_runtimeType;
+ private RuntimeAssembly m_runtimeAssembly;
+ private IntPtr m_pRefClass;
+ private IntPtr m_pData;
+ private IntPtr m_pGlobals;
+ private IntPtr m_pFields;
+#pragma warning restore 169
+ #endregion
+
+ #region Protected Virtuals
+ protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder,
+ CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
+ {
+ return GetMethodInternal(name, bindingAttr, binder, callConvention, types, modifiers);
+ }
+
+ internal MethodInfo GetMethodInternal(String name, BindingFlags bindingAttr, Binder binder,
+ CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
+ {
+ if (RuntimeType == null)
+ return null;
+
+ if (types == null)
+ {
+ return RuntimeType.GetMethod(name, bindingAttr);
+ }
+ else
+ {
+ return RuntimeType.GetMethod(name, bindingAttr, binder, callConvention, types, modifiers);
+ }
+ }
+ #endregion
+
+ #region Internal Members
+ internal RuntimeType RuntimeType
+ {
+ get
+ {
+ if (m_runtimeType == null)
+ m_runtimeType = ModuleHandle.GetModuleType(GetNativeHandle());
+
+ return m_runtimeType;
+ }
+ }
+
+ internal bool IsTransientInternal()
+ {
+ return RuntimeModule.nIsTransientInternal(this.GetNativeHandle());
+ }
+
+ internal MetadataImport MetadataImport
+ {
+ get
+ {
+ unsafe
+ {
+ return ModuleHandle.GetMetadataImport(GetNativeHandle());
+ }
+ }
+ }
+ #endregion
+
+ #region ICustomAttributeProvider Members
+ public override Object[] GetCustomAttributes(bool inherit)
+ {
+ return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType);
+ }
+
+ public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
+ {
+ if (attributeType == null)
+ throw new ArgumentNullException(nameof(attributeType));
+ Contract.EndContractBlock();
+
+ RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
+
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
+
+ return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
+ }
+
+ public override bool IsDefined(Type attributeType, bool inherit)
+ {
+ if (attributeType == null)
+ throw new ArgumentNullException(nameof(attributeType));
+ Contract.EndContractBlock();
+
+ RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
+
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
+
+ return CustomAttribute.IsDefined(this, attributeRuntimeType);
+ }
+
+ public override IList<CustomAttributeData> GetCustomAttributesData()
+ {
+ return CustomAttributeData.GetCustomAttributesInternal(this);
+ }
+ #endregion
+
+ #region Public Virtuals
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ if (info == null)
+ {
+ throw new ArgumentNullException(nameof(info));
+ }
+ Contract.EndContractBlock();
+ UnitySerializationHolder.GetUnitySerializationInfo(info, UnitySerializationHolder.ModuleUnity, this.ScopeName, this.GetRuntimeAssembly());
+ }
+
+ public override Type GetType(String className, bool throwOnError, bool ignoreCase)
+ {
+ // throw on null strings regardless of the value of "throwOnError"
+ if (className == null)
+ throw new ArgumentNullException(nameof(className));
+
+ RuntimeType retType = null;
+ Object keepAlive = null;
+ GetType(GetNativeHandle(), className, throwOnError, ignoreCase, JitHelpers.GetObjectHandleOnStack(ref retType), JitHelpers.GetObjectHandleOnStack(ref keepAlive));
+ GC.KeepAlive(keepAlive);
+ return retType;
+ }
+
+ internal string GetFullyQualifiedName()
+ {
+ String fullyQualifiedName = null;
+ GetFullyQualifiedName(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref fullyQualifiedName));
+ return fullyQualifiedName;
+ }
+
+ public override String FullyQualifiedName
+ {
+ get
+ {
+ return GetFullyQualifiedName();
+ }
+ }
+
+ public override Type[] GetTypes()
+ {
+ return GetTypes(GetNativeHandle());
+ }
+
+ #endregion
+
+ #region Public Members
+
+ public override Guid ModuleVersionId
+ {
+ get
+ {
+ unsafe
+ {
+ Guid mvid;
+ MetadataImport.GetScopeProps(out mvid);
+ return mvid;
+ }
+ }
+ }
+
+ public override int MetadataToken
+ {
+ get
+ {
+ return ModuleHandle.GetToken(GetNativeHandle());
+ }
+ }
+
+ public override bool IsResource()
+ {
+ return IsResource(GetNativeHandle());
+ }
+
+ public override FieldInfo[] GetFields(BindingFlags bindingFlags)
+ {
+ if (RuntimeType == null)
+ return new FieldInfo[0];
+
+ return RuntimeType.GetFields(bindingFlags);
+ }
+
+ public override FieldInfo GetField(String name, BindingFlags bindingAttr)
+ {
+ if (name == null)
+ throw new ArgumentNullException(nameof(name));
+
+ if (RuntimeType == null)
+ return null;
+
+ return RuntimeType.GetField(name, bindingAttr);
+ }
+
+ public override MethodInfo[] GetMethods(BindingFlags bindingFlags)
+ {
+ if (RuntimeType == null)
+ return new MethodInfo[0];
+
+ return RuntimeType.GetMethods(bindingFlags);
+ }
+
+ public override String ScopeName
+ {
+ get
+ {
+ string scopeName = null;
+ GetScopeName(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref scopeName));
+ return scopeName;
+ }
+ }
+
+ public override String Name
+ {
+ get
+ {
+ String s = GetFullyQualifiedName();
+
+#if !FEATURE_PAL
+ int i = s.LastIndexOf('\\');
+#else
+ int i = s.LastIndexOf(System.IO.Path.DirectorySeparatorChar);
+#endif
+ if (i == -1)
+ return s;
+
+ return s.Substring(i + 1);
+ }
+ }
+
+ public override Assembly Assembly
+ {
+ [Pure]
+ get
+ {
+ return GetRuntimeAssembly();
+ }
+ }
+
+ internal RuntimeAssembly GetRuntimeAssembly()
+ {
+ return m_runtimeAssembly;
+ }
+
+ protected override ModuleHandle GetModuleHandleImpl()
+ {
+ return new ModuleHandle(this);
+ }
+
+ internal RuntimeModule GetNativeHandle()
+ {
+ return this;
+ }
+ #endregion
+ }
+}
diff --git a/src/mscorlib/src/System/Reflection/ParameterInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs
index fad4402aff..addf68e75d 100644
--- a/src/mscorlib/src/System/Reflection/ParameterInfo.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs
@@ -2,232 +2,15 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+using System.Runtime.Serialization;
+using System.Runtime.CompilerServices;
+using MdToken = System.Reflection.MetadataToken;
namespace System.Reflection
{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
- using System.Runtime.InteropServices;
- using System.Runtime.Serialization;
- using System.Runtime.CompilerServices;
- using System.Threading;
- using MdToken = System.Reflection.MetadataToken;
-
- [Serializable]
- public class ParameterInfo : ICustomAttributeProvider, IObjectReference
- {
- #region Legacy Protected Members
- protected String NameImpl;
- protected Type ClassImpl;
- protected int PositionImpl;
- protected ParameterAttributes AttrsImpl;
- protected Object DefaultValueImpl; // cannot cache this as it may be non agile user defined enum
- protected MemberInfo MemberImpl;
- #endregion
-
- #region Legacy Private Members
- // These are here only for backwards compatibility -- they are not set
- // until this instance is serialized, so don't rely on their values from
- // arbitrary code.
-#pragma warning disable 169
- [OptionalField]
- private IntPtr _importer;
- [OptionalField]
- private int _token;
- [OptionalField]
- private bool bExtraConstChecked;
-#pragma warning restore 169
- #endregion
-
- #region Constructor
- protected ParameterInfo()
- {
- }
- #endregion
-
- #region Internal Members
- // this is an internal api for DynamicMethod. A better solution is to change the relationship
- // between ParameterInfo and ParameterBuilder so that a ParameterBuilder can be seen as a writer
- // api over a ParameterInfo. However that is a possible breaking change so it needs to go through some process first
- internal void SetName(String name)
- {
- NameImpl = name;
- }
-
- internal void SetAttributes(ParameterAttributes attributes)
- {
- AttrsImpl = attributes;
- }
- #endregion
-
- #region Public Methods
- public virtual Type ParameterType
- {
- get
- {
- return ClassImpl;
- }
- }
-
- public virtual String Name
- {
- get
- {
- return NameImpl;
- }
- }
-
- public virtual bool HasDefaultValue { get { throw new NotImplementedException(); } }
-
- public virtual Object DefaultValue { get { throw new NotImplementedException(); } }
- public virtual Object RawDefaultValue { get { throw new NotImplementedException(); } }
-
- public virtual int Position { get { return PositionImpl; } }
- public virtual ParameterAttributes Attributes { get { return AttrsImpl; } }
-
- public virtual MemberInfo Member {
- get {
- Contract.Ensures(Contract.Result<MemberInfo>() != null);
- return MemberImpl;
- }
- }
-
- public bool IsIn { get { return((Attributes & ParameterAttributes.In) != 0); } }
- public bool IsOut { get { return((Attributes & ParameterAttributes.Out) != 0); } }
- public bool IsLcid { get { return((Attributes & ParameterAttributes.Lcid) != 0); } }
- public bool IsRetval { get { return((Attributes & ParameterAttributes.Retval) != 0); } }
- public bool IsOptional { get { return((Attributes & ParameterAttributes.Optional) != 0); } }
-
- public virtual int MetadataToken
- {
- get
- {
- // This API was made virtual in V4. Code compiled against V2 might use
- // "call" rather than "callvirt" to call it.
- // This makes sure those code still works.
- RuntimeParameterInfo rtParam = this as RuntimeParameterInfo;
- if (rtParam != null)
- return rtParam.MetadataToken;
-
- // return a null token
- return (int)MetadataTokenType.ParamDef;
- }
- }
-
- public virtual Type[] GetRequiredCustomModifiers()
- {
- return EmptyArray<Type>.Value;
- }
-
- public virtual Type[] GetOptionalCustomModifiers()
- {
- return EmptyArray<Type>.Value;
- }
- #endregion
-
- #region Object Overrides
- public override String ToString()
- {
- return ParameterType.FormatTypeName() + " " + Name;
- }
- #endregion
-
- public virtual IEnumerable<CustomAttributeData> CustomAttributes
- {
- get
- {
- return GetCustomAttributesData();
- }
- }
- #region ICustomAttributeProvider
- public virtual Object[] GetCustomAttributes(bool inherit)
- {
- return EmptyArray<Object>.Value;
- }
-
- public virtual Object[] GetCustomAttributes(Type attributeType, bool inherit)
- {
- if (attributeType == null)
- throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
-
- return EmptyArray<Object>.Value;
- }
-
- public virtual bool IsDefined(Type attributeType, bool inherit)
- {
- if (attributeType == null)
- throw new ArgumentNullException(nameof(attributeType));
- Contract.EndContractBlock();
-
- return false;
- }
-
- public virtual IList<CustomAttributeData> GetCustomAttributesData()
- {
- throw new NotImplementedException();
- }
- #endregion
-
- #region _ParameterInfo implementation
-
- #endregion
-
- #region IObjectReference
- // In V4 RuntimeParameterInfo is introduced.
- // To support deserializing ParameterInfo instances serialized in earlier versions
- // we need to implement IObjectReference.
- public object GetRealObject(StreamingContext context)
- {
- Contract.Ensures(Contract.Result<Object>() != null);
-
- // Once all the serializable fields have come in we can set up the real
- // instance based on just two of them (MemberImpl and PositionImpl).
-
- if (MemberImpl == null)
- throw new SerializationException(Environment.GetResourceString(ResId.Serialization_InsufficientState));
-
- ParameterInfo[] args = null;
-
- switch (MemberImpl.MemberType)
- {
- case MemberTypes.Constructor:
- case MemberTypes.Method:
- if (PositionImpl == -1)
- {
- if (MemberImpl.MemberType == MemberTypes.Method)
- return ((MethodInfo)MemberImpl).ReturnParameter;
- else
- throw new SerializationException(Environment.GetResourceString(ResId.Serialization_BadParameterInfo));
- }
- else
- {
- args = ((MethodBase)MemberImpl).GetParametersNoCopy();
-
- if (args != null && PositionImpl < args.Length)
- return args[PositionImpl];
- else
- throw new SerializationException(Environment.GetResourceString(ResId.Serialization_BadParameterInfo));
- }
-
- case MemberTypes.Property:
- args = ((RuntimePropertyInfo)MemberImpl).GetIndexParametersNoCopy();
-
- if (args != null && PositionImpl > -1 && PositionImpl < args.Length)
- return args[PositionImpl];
- else
- throw new SerializationException(Environment.GetResourceString(ResId.Serialization_BadParameterInfo));
-
- default:
- throw new SerializationException(Environment.GetResourceString(ResId.Serialization_NoParameterInfo));
- }
- }
- #endregion
- }
-
[Serializable]
internal unsafe sealed class RuntimeParameterInfo : ParameterInfo, ISerializable
{
@@ -273,7 +56,7 @@ namespace System.Reflection
// Not all parameters have tokens. Parameters may have no token
// if they have no name and no attributes.
if (cParamDefs > sigArgCount + 1 /* return type */)
- throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch"));
+ throw new BadImageFormatException(SR.BadImageFormat_ParameterSignatureMismatch);
for (int i = 0; i < cParamDefs; i++)
{
@@ -289,7 +72,7 @@ namespace System.Reflection
{
// more than one return parameter?
if (returnParameter != null)
- throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch"));
+ throw new BadImageFormatException(SR.BadImageFormat_ParameterSignatureMismatch);
returnParameter = new RuntimeParameterInfo(sig, scope, tkParamDef, position, attr, member);
}
@@ -297,7 +80,7 @@ namespace System.Reflection
{
// position beyong sigArgCount?
if (position >= sigArgCount)
- throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch"));
+ throw new BadImageFormatException(SR.BadImageFormat_ParameterSignatureMismatch);
args[position] = new RuntimeParameterInfo(sig, scope, tkParamDef, position, attr, member);
}
@@ -366,6 +149,18 @@ namespace System.Reflection
}
#endregion
+ #region Internal Methods
+ internal void SetName(string name)
+ {
+ NameImpl = name;
+ }
+
+ internal void SetAttributes(ParameterAttributes attributes)
+ {
+ AttrsImpl = attributes;
+ }
+ #endregion
+
#region VTS magic to serialize/deserialized to/from pre-Whidbey endpoints.
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
@@ -413,7 +208,7 @@ namespace System.Reflection
{
// Change ownership
MemberImpl = member;
-
+
// The original owner should always be a method, because this method is only used to
// change the owner from a method to a property.
m_originalMember = accessor.MemberImpl as MethodBase;
@@ -665,7 +460,7 @@ namespace System.Reflection
{
get
{
- return m_tkParamDef;
+ return m_tkParamDef;
}
}
@@ -685,7 +480,7 @@ namespace System.Reflection
public override Object[] GetCustomAttributes(bool inherit)
{
if (MdToken.IsNullToken(m_tkParamDef))
- return EmptyArray<Object>.Value;
+ return Array.Empty<Object>();
return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType);
}
@@ -697,12 +492,12 @@ namespace System.Reflection
Contract.EndContractBlock();
if (MdToken.IsNullToken(m_tkParamDef))
- return EmptyArray<Object>.Value;
+ return Array.Empty<Object>();
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(attributeType));
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
}
@@ -719,7 +514,7 @@ namespace System.Reflection
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(attributeType));
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.IsDefined(this, attributeRuntimeType);
}
diff --git a/src/mscorlib/src/System/Reflection/PropertyInfo.cs b/src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs
index e8c2837785..b6a4792e4f 100644
--- a/src/mscorlib/src/System/Reflection/PropertyInfo.cs
+++ b/src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs
@@ -2,152 +2,16 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+using System.Globalization;
+using System.Runtime.Serialization;
+using System.Text;
+using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
namespace System.Reflection
{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
- using System.Globalization;
- using System.Runtime;
- using System.Runtime.ConstrainedExecution;
- using System.Runtime.InteropServices;
- using System.Runtime.Serialization;
- using System.Text;
- using RuntimeTypeCache = System.RuntimeType.RuntimeTypeCache;
-
- [Serializable]
- public abstract class PropertyInfo : MemberInfo
- {
- #region Constructor
- protected PropertyInfo() { }
- #endregion
-
- public static bool operator ==(PropertyInfo left, PropertyInfo right)
- {
- if (ReferenceEquals(left, right))
- return true;
-
- if ((object)left == null || (object)right == null ||
- left is RuntimePropertyInfo || right is RuntimePropertyInfo)
- {
- return false;
- }
- return left.Equals(right);
- }
-
- public static bool operator !=(PropertyInfo left, PropertyInfo right)
- {
- return !(left == right);
- }
-
- public override bool Equals(object obj)
- {
- return base.Equals(obj);
- }
-
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
-
- #region MemberInfo Overrides
- public override MemberTypes MemberType { get { return System.Reflection.MemberTypes.Property; } }
- #endregion
-
- #region Public Abstract\Virtual Members
- public virtual object GetConstantValue()
- {
- throw new NotImplementedException();
- }
-
- public virtual object GetRawConstantValue()
- {
- throw new NotImplementedException();
- }
-
- public abstract Type PropertyType { get; }
-
- public abstract void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture);
-
- public abstract MethodInfo[] GetAccessors(bool nonPublic);
-
- public abstract MethodInfo GetGetMethod(bool nonPublic);
-
- public abstract MethodInfo GetSetMethod(bool nonPublic);
-
- public abstract ParameterInfo[] GetIndexParameters();
-
- public abstract PropertyAttributes Attributes { get; }
-
- public abstract bool CanRead { get; }
-
- public abstract bool CanWrite { get; }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public Object GetValue(Object obj)
- {
- return GetValue(obj, null);
- }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public virtual Object GetValue(Object obj,Object[] index)
- {
- return GetValue(obj, BindingFlags.Default, null, index, null);
- }
-
- public abstract Object GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture);
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public void SetValue(Object obj, Object value)
- {
- SetValue(obj, value, null);
- }
-
- [DebuggerStepThroughAttribute]
- [Diagnostics.DebuggerHidden]
- public virtual void SetValue(Object obj, Object value, Object[] index)
- {
- SetValue(obj, value, BindingFlags.Default, null, index, null);
- }
- #endregion
-
- #region Public Members
- public virtual Type[] GetRequiredCustomModifiers() { return EmptyArray<Type>.Value; }
-
- public virtual Type[] GetOptionalCustomModifiers() { return EmptyArray<Type>.Value; }
-
- public MethodInfo[] GetAccessors() { return GetAccessors(false); }
-
- public virtual MethodInfo GetMethod
- {
- get
- {
- return GetGetMethod(true);
- }
- }
-
- public virtual MethodInfo SetMethod
- {
- get
- {
- return GetSetMethod(true);
- }
- }
-
- public MethodInfo GetGetMethod() { return GetGetMethod(false); }
-
- public MethodInfo GetSetMethod() { return GetSetMethod(false); }
-
- public bool IsSpecialName { get { return(Attributes & PropertyAttributes.SpecialName) != 0; } }
- #endregion
- }
-
[Serializable]
internal unsafe sealed class RuntimePropertyInfo : PropertyInfo, ISerializable
{
@@ -177,14 +41,14 @@ namespace System.Reflection
MetadataImport scope = declaredType.GetRuntimeModule().MetadataImport;
m_token = tkProperty;
- m_reflectedTypeCache = reflectedTypeCache;
+ m_reflectedTypeCache = reflectedTypeCache;
m_declaringType = declaredType;
ConstArray sig;
scope.GetPropertyProps(tkProperty, out m_utf8name, out m_flags, out sig);
RuntimeMethodInfo dummy;
- Associates.AssignAssociates(scope, tkProperty, declaredType, reflectedTypeCache.GetRuntimeType(),
+ Associates.AssignAssociates(scope, tkProperty, declaredType, reflectedTypeCache.GetRuntimeType(),
out dummy, out dummy, out dummy,
out m_getterMethod, out m_setterMethod, out m_otherMethod,
out isPrivate, out m_bindingFlags);
@@ -297,8 +161,8 @@ namespace System.Reflection
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
}
@@ -311,8 +175,8 @@ namespace System.Reflection
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
- if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
+ if (attributeRuntimeType == null)
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.IsDefined(this, attributeRuntimeType);
}
@@ -325,21 +189,21 @@ namespace System.Reflection
#region MemberInfo Overrides
public override MemberTypes MemberType { get { return MemberTypes.Property; } }
- public override String Name
+ public override String Name
{
- get
+ get
{
if (m_name == null)
m_name = new Utf8String(m_utf8name).ToString();
-
- return m_name;
- }
- }
- public override Type DeclaringType
- {
- get
- {
- return m_declaringType;
+
+ return m_name;
+ }
+ }
+ public override Type DeclaringType
+ {
+ get
+ {
+ return m_declaringType;
}
}
@@ -358,9 +222,9 @@ namespace System.Reflection
return m_reflectedTypeCache.GetRuntimeType();
}
}
-
+
public override int MetadataToken { get { return m_token; } }
-
+
public override Module Module { get { return GetRuntimeModule(); } }
internal RuntimeModule GetRuntimeModule() { return m_declaringType.GetRuntimeModule(); }
#endregion
@@ -373,7 +237,7 @@ namespace System.Reflection
{
return Signature.GetCustomModifiers(0, true);
}
-
+
public override Type[] GetOptionalCustomModifiers()
{
return Signature.GetCustomModifiers(0, false);
@@ -382,19 +246,19 @@ namespace System.Reflection
internal object GetConstantValue(bool raw)
{
Object defaultValue = MdConstant.GetValue(GetRuntimeModule().MetadataImport, m_token, PropertyType.GetTypeHandleInternal(), raw);
-
+
if (defaultValue == DBNull.Value)
// Arg_EnumLitValueNotFound -> "Literal value was not found."
- throw new InvalidOperationException(Environment.GetResourceString("Arg_EnumLitValueNotFound"));
-
+ throw new InvalidOperationException(SR.Arg_EnumLitValueNotFound);
+
return defaultValue;
}
-
+
public override object GetConstantValue() { return GetConstantValue(false); }
public override object GetRawConstantValue() { return GetConstantValue(true); }
- public override MethodInfo[] GetAccessors(bool nonPublic)
+ public override MethodInfo[] GetAccessors(bool nonPublic)
{
List<MethodInfo> accessorList = new List<MethodInfo>();
@@ -406,7 +270,7 @@ namespace System.Reflection
if ((object)m_otherMethod != null)
{
- for(int i = 0; i < m_otherMethod.Length; i ++)
+ for (int i = 0; i < m_otherMethod.Length; i++)
{
if (Associates.IncludeAccessor(m_otherMethod[i] as MethodInfo, nonPublic))
accessorList.Add(m_otherMethod[i]);
@@ -415,12 +279,12 @@ namespace System.Reflection
return accessorList.ToArray();
}
- public override Type PropertyType
+ public override Type PropertyType
{
get { return Signature.ReturnType; }
}
- public override MethodInfo GetGetMethod(bool nonPublic)
+ public override MethodInfo GetGetMethod(bool nonPublic)
{
if (!Associates.IncludeAccessor(m_getterMethod, nonPublic))
return null;
@@ -428,7 +292,7 @@ namespace System.Reflection
return m_getterMethod;
}
- public override MethodInfo GetSetMethod(bool nonPublic)
+ public override MethodInfo GetSetMethod(bool nonPublic)
{
if (!Associates.IncludeAccessor(m_setterMethod, nonPublic))
return null;
@@ -436,7 +300,7 @@ namespace System.Reflection
return m_setterMethod;
}
- public override ParameterInfo[] GetIndexParameters()
+ public override ParameterInfo[] GetIndexParameters()
{
ParameterInfo[] indexParams = GetIndexParametersNoCopy();
@@ -496,7 +360,7 @@ namespace System.Reflection
return m_parameters;
}
- public override PropertyAttributes Attributes
+ public override PropertyAttributes Attributes
{
get
{
@@ -504,7 +368,7 @@ namespace System.Reflection
}
}
- public override bool CanRead
+ public override bool CanRead
{
get
{
@@ -512,7 +376,7 @@ namespace System.Reflection
}
}
- public override bool CanWrite
+ public override bool CanWrite
{
get
{
@@ -524,21 +388,20 @@ namespace System.Reflection
#region Dynamic
[DebuggerStepThroughAttribute]
[Diagnostics.DebuggerHidden]
- public override Object GetValue(Object obj,Object[] index)
+ public override Object GetValue(Object obj, Object[] index)
{
- return GetValue(obj, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static,
+ return GetValue(obj, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static,
null, index, null);
}
[DebuggerStepThroughAttribute]
[Diagnostics.DebuggerHidden]
- public override Object GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
+ public override Object GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
{
-
MethodInfo m = GetGetMethod(true);
if (m == null)
- throw new ArgumentException(System.Environment.GetResourceString("Arg_GetMethNotFnd"));
- return m.Invoke(obj, invokeAttr, binder, index, null);
+ throw new ArgumentException(System.SR.Arg_GetMethNotFnd);
+ return m.Invoke(obj, invokeAttr, binder, index, null);
}
[DebuggerStepThroughAttribute]
@@ -547,9 +410,9 @@ namespace System.Reflection
{
SetValue(obj,
value,
- BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static,
- null,
- index,
+ BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static,
+ null,
+ index,
null);
}
@@ -557,24 +420,23 @@ namespace System.Reflection
[Diagnostics.DebuggerHidden]
public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
{
-
MethodInfo m = GetSetMethod(true);
if (m == null)
- throw new ArgumentException(System.Environment.GetResourceString("Arg_SetMethNotFnd"));
+ throw new ArgumentException(System.SR.Arg_SetMethNotFnd);
Object[] args = null;
- if (index != null)
+ if (index != null)
{
args = new Object[index.Length + 1];
- for(int i=0;i<index.Length;i++)
+ for (int i = 0; i < index.Length; i++)
args[i] = index[i];
args[index.Length] = value;
}
- else
+ else
{
args = new Object[1];
args[0] = value;
@@ -593,14 +455,7 @@ namespace System.Reflection
throw new ArgumentNullException(nameof(info));
Contract.EndContractBlock();
- MemberInfoSerializationHolder.GetSerializationInfo(
- info,
- Name,
- ReflectedTypeInternal,
- ToString(),
- SerializationToString(),
- MemberTypes.Property,
- null);
+ MemberInfoSerializationHolder.GetSerializationInfo(info, this);
}
internal string SerializationToString()
@@ -609,5 +464,4 @@ namespace System.Reflection
}
#endregion
}
-
}
diff --git a/src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs b/src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs
deleted file mode 100644
index 49262634e3..0000000000
--- a/src/mscorlib/src/System/Reflection/RuntimeReflectionExtensions.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections.Generic;
-
-namespace System.Reflection
-{
- public static class RuntimeReflectionExtensions
- {
- private const BindingFlags everything = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
-
- private static void CheckAndThrow(Type type)
- {
- if (type == null) throw new ArgumentNullException(nameof(type));
- if (!(type is RuntimeType)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
- }
-
- private static void CheckAndThrow(MethodInfo method)
- {
- 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)
- {
- CheckAndThrow(type);
- return type.GetProperties(everything);
- }
- public static IEnumerable<EventInfo> GetRuntimeEvents(this Type type)
- {
- CheckAndThrow(type);
- return type.GetEvents(everything);
- }
-
- public static IEnumerable<MethodInfo> GetRuntimeMethods(this Type type)
- {
- CheckAndThrow(type);
- return type.GetMethods(everything);
- }
-
- public static IEnumerable<FieldInfo> GetRuntimeFields(this Type type)
- {
- CheckAndThrow(type);
- return type.GetFields(everything);
- }
-
- public static PropertyInfo GetRuntimeProperty(this Type type, string name)
- {
- CheckAndThrow(type);
- return type.GetProperty(name);
- }
- public static EventInfo GetRuntimeEvent(this Type type, string name)
- {
- CheckAndThrow(type);
- return type.GetEvent(name);
- }
- public static MethodInfo GetRuntimeMethod(this Type type, string name, Type[] parameters)
- {
- CheckAndThrow(type);
- return type.GetMethod(name, parameters);
- }
- public static FieldInfo GetRuntimeField(this Type type, string name)
- {
- CheckAndThrow(type);
- return type.GetField(name);
- }
- public static MethodInfo GetRuntimeBaseDefinition(this MethodInfo method){
- CheckAndThrow(method);
- return method.GetBaseDefinition();
- }
-
- public static InterfaceMapping GetRuntimeInterfaceMap(this TypeInfo typeInfo, Type interfaceType)
- {
- if (typeInfo == null) throw new ArgumentNullException(nameof(typeInfo));
- if (!(typeInfo is RuntimeType)) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
-
- return typeInfo.GetInterfaceMap(interfaceType);
- }
-
- public static MethodInfo GetMethodInfo(this Delegate del)
- {
- if (del == null) throw new ArgumentNullException(nameof(del));
-
- return del.Method;
- }
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/StrongNameKeyPair.cs b/src/mscorlib/src/System/Reflection/StrongNameKeyPair.cs
deleted file mode 100644
index 0121982489..0000000000
--- a/src/mscorlib/src/System/Reflection/StrongNameKeyPair.cs
+++ /dev/null
@@ -1,95 +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: Encapsulate access to a public/private key pair
-** used to sign strong name assemblies.
-**
-**
-===========================================================*/
-namespace System.Reflection
-{
- using System;
- using System.IO;
- using System.Runtime.CompilerServices;
- using System.Runtime.ConstrainedExecution;
- using System.Runtime.InteropServices;
- using System.Runtime.Serialization;
- using System.Security;
- using System.Runtime.Versioning;
- using Microsoft.Win32;
- using System.Diagnostics.Contracts;
-
- [Serializable]
- public class StrongNameKeyPair : IDeserializationCallback, ISerializable
- {
- private bool _keyPairExported;
- private byte[] _keyPairArray;
- private String _keyPairContainer;
- private byte[] _publicKey;
-
- // Build key pair from file.
- public StrongNameKeyPair(FileStream keyPairFile)
- {
- if (keyPairFile == null)
- throw new ArgumentNullException(nameof(keyPairFile));
- Contract.EndContractBlock();
-
- int length = (int)keyPairFile.Length;
- _keyPairArray = new byte[length];
- keyPairFile.Read(_keyPairArray, 0, length);
-
- _keyPairExported = true;
- }
-
- // Build key pair from byte array in memory.
- public StrongNameKeyPair(byte[] keyPairArray)
- {
- if (keyPairArray == null)
- throw new ArgumentNullException(nameof(keyPairArray));
- Contract.EndContractBlock();
-
- _keyPairArray = new byte[keyPairArray.Length];
- Array.Copy(keyPairArray, _keyPairArray, keyPairArray.Length);
-
- _keyPairExported = true;
- }
-
- protected StrongNameKeyPair (SerializationInfo info, StreamingContext context) {
- _keyPairExported = (bool) info.GetValue("_keyPairExported", typeof(bool));
- _keyPairArray = (byte[]) info.GetValue("_keyPairArray", typeof(byte[]));
- _keyPairContainer = (string) info.GetValue("_keyPairContainer", typeof(string));
- _publicKey = (byte[]) info.GetValue("_publicKey", typeof(byte[]));
- }
-
- public StrongNameKeyPair(String keyPairContainer)
- {
- throw new PlatformNotSupportedException();
- }
-
- public byte[] PublicKey
- {
- get
- {
- throw new PlatformNotSupportedException();
- }
- }
-
- /// <internalonly/>
- void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context) {
- info.AddValue("_keyPairExported", _keyPairExported);
- info.AddValue("_keyPairArray", _keyPairArray);
- info.AddValue("_keyPairContainer", _keyPairContainer);
- info.AddValue("_publicKey", _publicKey);
- }
-
- /// <internalonly/>
- void IDeserializationCallback.OnDeserialization (Object sender) {}
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/TargetException.cs b/src/mscorlib/src/System/Reflection/TargetException.cs
deleted file mode 100644
index dcbb38833e..0000000000
--- a/src/mscorlib/src/System/Reflection/TargetException.cs
+++ /dev/null
@@ -1,37 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// TargetException is thrown when the target to an Invoke is invalid. This may
-//
-// occur because the caller doesn't have access to the member, or the target doesn't
-// define the member, etc.
-//
-//
-//
-//
-namespace System.Reflection {
-
- using System;
- using System.Runtime.Serialization;
- [Serializable]
- public class TargetException : ApplicationException {
- public TargetException() : base() {
- SetErrorCode(__HResults.COR_E_TARGET);
- }
-
- public TargetException(String message) : base(message) {
- SetErrorCode(__HResults.COR_E_TARGET);
- }
-
- public TargetException(String message, Exception inner) : base(message, inner) {
- SetErrorCode(__HResults.COR_E_TARGET);
- }
-
- protected TargetException(SerializationInfo info, StreamingContext context) : base (info, context) {
- }
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/TargetInvocationException.cs b/src/mscorlib/src/System/Reflection/TargetInvocationException.cs
deleted file mode 100644
index 7bbc93df2a..0000000000
--- a/src/mscorlib/src/System/Reflection/TargetInvocationException.cs
+++ /dev/null
@@ -1,46 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// TargetInvocationException is used to report an exception that was thrown
-//
-// by the target of an invocation.
-//
-//
-//
-//
-namespace System.Reflection {
-
-
- using System;
- using System.Runtime.Serialization;
- [Serializable]
- public sealed class TargetInvocationException : ApplicationException {
- // This exception is not creatable without specifying the
- // inner exception.
- private TargetInvocationException()
- : base(Environment.GetResourceString("Arg_TargetInvocationException")) {
- SetErrorCode(__HResults.COR_E_TARGETINVOCATION);
- }
-
- // This is called from within the runtime.
- private TargetInvocationException(String message) : base(message) {
- SetErrorCode(__HResults.COR_E_TARGETINVOCATION);
- }
-
- public TargetInvocationException(System.Exception inner)
- : base(Environment.GetResourceString("Arg_TargetInvocationException"), inner) {
- SetErrorCode(__HResults.COR_E_TARGETINVOCATION);
- }
-
- public TargetInvocationException(String message, Exception inner) : base(message, inner) {
- SetErrorCode(__HResults.COR_E_TARGETINVOCATION);
- }
-
- internal TargetInvocationException(SerializationInfo info, StreamingContext context) : base (info, context) {
- }
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/TargetParameterCountException.cs b/src/mscorlib/src/System/Reflection/TargetParameterCountException.cs
deleted file mode 100644
index 7a07b20acd..0000000000
--- a/src/mscorlib/src/System/Reflection/TargetParameterCountException.cs
+++ /dev/null
@@ -1,40 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// TargetParameterCountException is thrown when the number of parameter to an
-//
-// invocation doesn't match the number expected.
-//
-//
-//
-//
-namespace System.Reflection {
-
- using System;
- using SystemException = System.SystemException;
- using System.Runtime.Serialization;
- [Serializable]
- public sealed class TargetParameterCountException : ApplicationException {
- public TargetParameterCountException()
- : base(Environment.GetResourceString("Arg_TargetParameterCountException")) {
- SetErrorCode(__HResults.COR_E_TARGETPARAMCOUNT);
- }
-
- public TargetParameterCountException(String message)
- : base(message) {
- SetErrorCode(__HResults.COR_E_TARGETPARAMCOUNT);
- }
-
- public TargetParameterCountException(String message, Exception inner)
- : base(message, inner) {
- SetErrorCode(__HResults.COR_E_TARGETPARAMCOUNT);
- }
-
- internal TargetParameterCountException(SerializationInfo info, StreamingContext context) : base (info, context) {
- }
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/TypeAttributes.cs b/src/mscorlib/src/System/Reflection/TypeAttributes.cs
deleted file mode 100644
index 25aa113d2e..0000000000
--- a/src/mscorlib/src/System/Reflection/TypeAttributes.cs
+++ /dev/null
@@ -1,64 +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 {
- using System.Runtime.InteropServices;
- using System;
- // This Enum matchs the CorTypeAttr defined in CorHdr.h
-[Serializable]
-[Flags]
- public enum TypeAttributes
- {
- VisibilityMask = 0x00000007,
- NotPublic = 0x00000000, // Class is not public scope.
- Public = 0x00000001, // Class is public scope.
- NestedPublic = 0x00000002, // Class is nested with public visibility.
- NestedPrivate = 0x00000003, // Class is nested with private visibility.
- NestedFamily = 0x00000004, // Class is nested with family visibility.
- NestedAssembly = 0x00000005, // Class is nested with assembly visibility.
- NestedFamANDAssem = 0x00000006, // Class is nested with family and assembly visibility.
- NestedFamORAssem = 0x00000007, // Class is nested with family or assembly visibility.
-
- // Use this mask to retrieve class layout informaiton
- // 0 is AutoLayout, 0x2 is SequentialLayout, 4 is ExplicitLayout
- LayoutMask = 0x00000018,
- AutoLayout = 0x00000000, // Class fields are auto-laid out
- SequentialLayout = 0x00000008, // Class fields are laid out sequentially
- ExplicitLayout = 0x00000010, // Layout is supplied explicitly
- // end layout mask
-
- // Use this mask to distinguish whether a type declaration is an interface. (Class vs. ValueType done based on whether it subclasses S.ValueType)
- ClassSemanticsMask= 0x00000020,
- Class = 0x00000000, // Type is a class (or a value type).
- Interface = 0x00000020, // Type is an interface.
-
- // Special semantics in addition to class semantics.
- Abstract = 0x00000080, // Class is abstract
- Sealed = 0x00000100, // Class is concrete and may not be extended
- SpecialName = 0x00000400, // Class name is special. Name describes how.
-
- // Implementation attributes.
- Import = 0x00001000, // Class / interface is imported
- Serializable = 0x00002000, // The class is Serializable.
-
- WindowsRuntime = 0x00004000, // Type is a Windows Runtime type.
-
- // Use tdStringFormatMask to retrieve string information for native interop
- StringFormatMask = 0x00030000,
- AnsiClass = 0x00000000, // LPTSTR is interpreted as ANSI in this class
- UnicodeClass = 0x00010000, // LPTSTR is interpreted as UNICODE
- AutoClass = 0x00020000, // LPTSTR is interpreted automatically
- CustomFormatClass = 0x00030000, // A non-standard encoding specified by CustomFormatMask
- CustomFormatMask = 0x00C00000, // Use this mask to retrieve non-standard encoding information for native interop. The meaning of the values of these 2 bits is unspecified.
-
- // end string format mask
-
- BeforeFieldInit = 0x00100000, // Initialize the class any time before first static field access.
-
- // Flags reserved for runtime use.
- ReservedMask = 0x00040800,
- RTSpecialName = 0x00000800, // Runtime should check name encoding.
- HasSecurity = 0x00040000, // Class has security associate with it.
- }
-}
diff --git a/src/mscorlib/src/System/Reflection/TypeDelegator.cs b/src/mscorlib/src/System/Reflection/TypeDelegator.cs
deleted file mode 100644
index 6a77a95853..0000000000
--- a/src/mscorlib/src/System/Reflection/TypeDelegator.cs
+++ /dev/null
@@ -1,257 +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.
-
-// TypeDelegator
-//
-// This class wraps a Type object and delegates all methods to that Type.
-
-namespace System.Reflection {
-
- using System;
- using System.Runtime.InteropServices;
- using System.Diagnostics.Contracts;
- using CultureInfo = System.Globalization.CultureInfo;
-
- [Serializable]
- public class TypeDelegator : TypeInfo
- {
- public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
- if(typeInfo==null) return false;
- return IsAssignableFrom(typeInfo.AsType());
- }
-
- protected Type typeImpl;
-
- protected TypeDelegator() {}
-
- public TypeDelegator(Type delegatingType) {
- if (delegatingType == null)
- throw new ArgumentNullException(nameof(delegatingType));
- Contract.EndContractBlock();
-
- typeImpl = delegatingType;
- }
-
- public override Guid GUID {
- get {return typeImpl.GUID;}
- }
-
- public override int MetadataToken { get { return typeImpl.MetadataToken; } }
-
- public override Object InvokeMember(String name,BindingFlags invokeAttr,Binder binder,Object target,
- Object[] args,ParameterModifier[] modifiers,CultureInfo culture,String[] namedParameters)
- {
- return typeImpl.InvokeMember(name,invokeAttr,binder,target,args,modifiers,culture,namedParameters);
- }
-
- public override Module Module {
- get {return typeImpl.Module;}
- }
-
- public override Assembly Assembly {
- get {return typeImpl.Assembly;}
- }
-
- public override RuntimeTypeHandle TypeHandle {
- get{return typeImpl.TypeHandle;}
- }
-
- public override String Name {
- get{return typeImpl.Name;}
- }
-
- public override String FullName {
- get{return typeImpl.FullName;}
- }
-
- public override String Namespace {
- get{return typeImpl.Namespace;}
- }
-
- public override String AssemblyQualifiedName {
- get {
- return typeImpl.AssemblyQualifiedName;
- }
- }
-
- public override Type BaseType {
- get{return typeImpl.BaseType;}
- }
-
- protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr,Binder binder,
- CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers)
- {
- return typeImpl.GetConstructor(bindingAttr,binder,callConvention,types,modifiers);
- }
-
- public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
- {
- return typeImpl.GetConstructors(bindingAttr);
- }
-
- protected override MethodInfo GetMethodImpl(String name,BindingFlags bindingAttr,Binder binder,
- CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers)
- {
- // This is interesting there are two paths into the impl. One that validates
- // type as non-null and one where type may be null.
- if (types == null)
- return typeImpl.GetMethod(name,bindingAttr);
- else
- return typeImpl.GetMethod(name,bindingAttr,binder,callConvention,types,modifiers);
- }
-
- public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
- {
- return typeImpl.GetMethods(bindingAttr);
- }
-
- public override FieldInfo GetField(String name, BindingFlags bindingAttr)
- {
- return typeImpl.GetField(name,bindingAttr);
- }
-
- public override FieldInfo[] GetFields(BindingFlags bindingAttr)
- {
- return typeImpl.GetFields(bindingAttr);
- }
-
- public override Type GetInterface(String name, bool ignoreCase)
- {
- return typeImpl.GetInterface(name,ignoreCase);
- }
-
- public override Type[] GetInterfaces()
- {
- return typeImpl.GetInterfaces();
- }
-
- public override EventInfo GetEvent(String name,BindingFlags bindingAttr)
- {
- return typeImpl.GetEvent(name,bindingAttr);
- }
-
- public override EventInfo[] GetEvents()
- {
- return typeImpl.GetEvents();
- }
-
- protected override PropertyInfo GetPropertyImpl(String name,BindingFlags bindingAttr,Binder binder,
- Type returnType, Type[] types, ParameterModifier[] modifiers)
- {
- if (returnType == null && types == null)
- return typeImpl.GetProperty(name,bindingAttr);
- else
- return typeImpl.GetProperty(name,bindingAttr,binder,returnType,types,modifiers);
- }
-
- public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
- {
- return typeImpl.GetProperties(bindingAttr);
- }
-
- public override EventInfo[] GetEvents(BindingFlags bindingAttr)
- {
- return typeImpl.GetEvents(bindingAttr);
- }
-
- public override Type[] GetNestedTypes(BindingFlags bindingAttr)
- {
- return typeImpl.GetNestedTypes(bindingAttr);
- }
-
- public override Type GetNestedType(String name, BindingFlags bindingAttr)
- {
- return typeImpl.GetNestedType(name,bindingAttr);
- }
-
- public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr)
- {
- return typeImpl.GetMember(name,type,bindingAttr);
- }
-
- public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
- {
- return typeImpl.GetMembers(bindingAttr);
- }
-
- protected override TypeAttributes GetAttributeFlagsImpl()
- {
- return typeImpl.Attributes;
- }
-
- protected override bool IsArrayImpl()
- {
- return typeImpl.IsArray;
- }
-
- protected override bool IsPrimitiveImpl()
- {
- return typeImpl.IsPrimitive;
- }
-
- protected override bool IsByRefImpl()
- {
- return typeImpl.IsByRef;
- }
-
- protected override bool IsPointerImpl()
- {
- return typeImpl.IsPointer;
- }
-
- protected override bool IsValueTypeImpl()
- {
- return typeImpl.IsValueType;
- }
-
- protected override bool IsCOMObjectImpl()
- {
- return typeImpl.IsCOMObject;
- }
-
- public override bool IsConstructedGenericType
- {
- get
- {
- return typeImpl.IsConstructedGenericType;
- }
- }
-
- public override Type GetElementType()
- {
- return typeImpl.GetElementType();
- }
-
- protected override bool HasElementTypeImpl()
- {
- return typeImpl.HasElementType;
- }
-
- public override Type UnderlyingSystemType
- {
- get {return typeImpl.UnderlyingSystemType;}
- }
-
- // ICustomAttributeProvider
- public override Object[] GetCustomAttributes(bool inherit)
- {
- return typeImpl.GetCustomAttributes(inherit);
- }
-
- public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
- {
- return typeImpl.GetCustomAttributes(attributeType, inherit);
- }
-
- public override bool IsDefined(Type attributeType, bool inherit)
- {
- return typeImpl.IsDefined(attributeType, inherit);
- }
-
- 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
deleted file mode 100644
index 4837a303a1..0000000000
--- a/src/mscorlib/src/System/Reflection/TypeFilter.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-// TypeFilter defines a delegate that is as a callback function for filtering
-//
-// a list of Types.
-//
-//
-namespace System.Reflection {
-
- // Define the delegate
- [Serializable]
- 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
deleted file mode 100644
index 61d7bb27a9..0000000000
--- a/src/mscorlib/src/System/Reflection/TypeInfo.cs
+++ /dev/null
@@ -1,194 +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: Notion of a type definition
-**
-**
-=============================================================================*/
-
-namespace System.Reflection
-{
- using System;
- using System.Runtime.CompilerServices;
- using System.Collections.Generic;
- using System.Diagnostics.Contracts;
-
- //all today's runtime Type derivations derive now from TypeInfo
- //we make TypeInfo implement IRCT - simplifies work
- [Serializable]
- public abstract class TypeInfo:Type,IReflectableType
- {
- [FriendAccessAllowed]
- internal TypeInfo() { }
-
- TypeInfo IReflectableType.GetTypeInfo(){
- return this;
- }
- public virtual Type AsType(){
- return (Type)this;
- }
-
- public virtual Type[] GenericTypeParameters{
- get{
- if(IsGenericTypeDefinition){
- return GetGenericArguments();
- }
- else{
- return Type.EmptyTypes;
- }
-
- }
- }
- //a re-implementation of ISAF from Type, skipping the use of UnderlyingType
- [Pure]
- public virtual bool IsAssignableFrom(TypeInfo typeInfo)
- {
- if (typeInfo == null)
- return false;
-
- if (this == typeInfo)
- return true;
-
- // If c is a subclass of this class, then c can be cast to this type.
- if (typeInfo.IsSubclassOf(this))
- return true;
-
- if (this.IsInterface)
- {
- return typeInfo.ImplementInterface(this);
- }
- else if (IsGenericParameter)
- {
- Type[] constraints = GetGenericParameterConstraints();
- for (int i = 0; i < constraints.Length; i++)
- if (!constraints[i].IsAssignableFrom(typeInfo))
- return false;
-
- return true;
- }
-
- return false;
- }
-#region moved over from Type
- // Fields
-
- public virtual EventInfo GetDeclaredEvent(String name)
- {
- return GetEvent(name, Type.DeclaredOnlyLookup);
- }
- public virtual FieldInfo GetDeclaredField(String name)
- {
- return GetField(name, Type.DeclaredOnlyLookup);
- }
- public virtual MethodInfo GetDeclaredMethod(String name)
- {
- return GetMethod(name, Type.DeclaredOnlyLookup);
- }
-
- public virtual IEnumerable<MethodInfo> GetDeclaredMethods(String name)
- {
- foreach (MethodInfo method in GetMethods(Type.DeclaredOnlyLookup))
- {
- if (method.Name == name)
- yield return method;
- }
- }
- public virtual System.Reflection.TypeInfo GetDeclaredNestedType(String name)
- {
- var nt=GetNestedType(name, Type.DeclaredOnlyLookup);
- if(nt == null){
- return null; //the extension method GetTypeInfo throws for null
- }else{
- return nt.GetTypeInfo();
- }
- }
- public virtual PropertyInfo GetDeclaredProperty(String name)
- {
- return GetProperty(name, Type.DeclaredOnlyLookup);
- }
-
-
-
-
-
- // Properties
-
- public virtual IEnumerable<ConstructorInfo> DeclaredConstructors
- {
- get
- {
- return GetConstructors(Type.DeclaredOnlyLookup);
- }
- }
-
- public virtual IEnumerable<EventInfo> DeclaredEvents
- {
- get
- {
- return GetEvents(Type.DeclaredOnlyLookup);
- }
- }
-
- public virtual IEnumerable<FieldInfo> DeclaredFields
- {
- get
- {
- return GetFields(Type.DeclaredOnlyLookup);
- }
- }
-
- public virtual IEnumerable<MemberInfo> DeclaredMembers
- {
- get
- {
- return GetMembers(Type.DeclaredOnlyLookup);
- }
- }
-
- public virtual IEnumerable<MethodInfo> DeclaredMethods
- {
- get
- {
- return GetMethods(Type.DeclaredOnlyLookup);
- }
- }
- public virtual IEnumerable<System.Reflection.TypeInfo> DeclaredNestedTypes
- {
- get
- {
- foreach (var t in GetNestedTypes(Type.DeclaredOnlyLookup)){
- yield return t.GetTypeInfo();
- }
- }
- }
-
- public virtual IEnumerable<PropertyInfo> DeclaredProperties
- {
- get
- {
- return GetProperties(Type.DeclaredOnlyLookup);
- }
- }
-
-
- public virtual IEnumerable<Type> ImplementedInterfaces
- {
- get
- {
- return GetInterfaces();
- }
- }
-
-
-#endregion
-
- }
-}
-
diff --git a/src/mscorlib/src/System/Reflection/__Filters.cs b/src/mscorlib/src/System/Reflection/__Filters.cs
deleted file mode 100644
index 8edcd0d7cb..0000000000
--- a/src/mscorlib/src/System/Reflection/__Filters.cs
+++ /dev/null
@@ -1,67 +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.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-//
-//
-// This class defines the delegate methods for the COM+ implemented filters.
-// This is the reflection version of these. There is also a _Filters class in
-// runtime which is related to this.
-//
-//
-//
-//
-namespace System.Reflection {
- using System;
- using System.Globalization;
-
- [Serializable]
- internal class __Filters {
-
- // FilterTypeName
- // This method will filter the class based upon the name. It supports
- // a trailing wild card.
- public virtual bool FilterTypeName(Type cls,Object filterCriteria)
- {
- // Check that the criteria object is a String object
- if (filterCriteria == null || !(filterCriteria is String))
- throw new InvalidFilterCriteriaException(System.Environment.GetResourceString("RFLCT.FltCritString"));
-
- String str = (String) filterCriteria;
- //str = str.Trim();
-
- // Check to see if this is a prefix or exact match requirement
- if (str.Length > 0 && str[str.Length - 1] == '*') {
- str = str.Substring(0, str.Length - 1);
- return cls.Name.StartsWith(str, StringComparison.Ordinal);
- }
-
- return cls.Name.Equals(str);
- }
-
- // FilterFieldNameIgnoreCase
- // This method filter the Type based upon name, it ignores case.
- public virtual bool FilterTypeNameIgnoreCase(Type cls, Object filterCriteria)
- {
- // Check that the criteria object is a String object
- if(filterCriteria == null || !(filterCriteria is String))
- throw new InvalidFilterCriteriaException(System.Environment.GetResourceString("RFLCT.FltCritString"));
-
- String str = (String) filterCriteria;
- //str = str.Trim();
-
- // Check to see if this is a prefix or exact match requirement
- if (str.Length > 0 && str[str.Length - 1] == '*') {
- str = str.Substring(0, str.Length - 1);
- String name = cls.Name;
- if (name.Length >= str.Length)
- return (String.Compare(name,0,str,0,str.Length, StringComparison.OrdinalIgnoreCase)==0);
- else
- return false;
- }
- return (String.Compare(str,cls.Name, StringComparison.OrdinalIgnoreCase) == 0);
- }
- }
-}