summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-12-27 16:46:08 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2016-12-27 16:46:08 +0900
commitdb20f3f1bb8595633a7e16c8900fd401a453a6b5 (patch)
treee5435159cd1bf0519276363a6fe1663d1721bed3 /src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
parent4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (diff)
downloadcoreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.gz
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.bz2
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.zip
Imported Upstream version 1.0.0.9127upstream/1.0.0.9127
Diffstat (limited to 'src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs')
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs69
1 files changed, 24 insertions, 45 deletions
diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
index b66fdad1e2..9e1d82986a 100644
--- a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
@@ -9,7 +9,6 @@ namespace System.Reflection.Emit
using System;
using System.Globalization;
- using TextWriter = System.IO.TextWriter;
using System.Diagnostics.SymbolStore;
using System.Runtime.InteropServices;
using System.Reflection;
@@ -17,6 +16,7 @@ namespace System.Reflection.Emit
using System.Collections.Generic;
using System.Security.Permissions;
using System.Threading;
+ using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Security;
@@ -36,7 +36,6 @@ namespace System.Reflection.Emit
}
- [System.Security.SecurityCritical] // auto-generated
internal void GetCallableMethod(RuntimeModule module, DynamicMethod dm)
{
dm.m_methodHandle = ModuleHandle.GetDynamicMethod(dm,
@@ -62,7 +61,7 @@ namespace System.Reflection.Emit
{
LocalBuilder localBuilder;
if (localType == null)
- throw new ArgumentNullException("localType");
+ throw new ArgumentNullException(nameof(localType));
Contract.EndContractBlock();
RuntimeType rtType = localType as RuntimeType;
@@ -87,11 +86,10 @@ namespace System.Reflection.Emit
// Token resolution calls
//
//
- [System.Security.SecuritySafeCritical] // auto-generated
public override void Emit(OpCode opcode, MethodInfo meth)
{
if (meth == null)
- throw new ArgumentNullException("meth");
+ throw new ArgumentNullException(nameof(meth));
Contract.EndContractBlock();
int stackchange = 0;
@@ -101,7 +99,7 @@ namespace System.Reflection.Emit
{
RuntimeMethodInfo rtMeth = meth as RuntimeMethodInfo;
if (rtMeth == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), "meth");
+ throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(meth));
RuntimeType declaringType = rtMeth.GetRuntimeType();
if (declaringType != null && (declaringType.IsGenericType || declaringType.IsArray))
@@ -148,12 +146,12 @@ namespace System.Reflection.Emit
public override void Emit(OpCode opcode, ConstructorInfo con)
{
if (con == null)
- throw new ArgumentNullException("con");
+ throw new ArgumentNullException(nameof(con));
Contract.EndContractBlock();
RuntimeConstructorInfo rtConstructor = con as RuntimeConstructorInfo;
if (rtConstructor == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), "con");
+ throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(con));
RuntimeType declaringType = rtConstructor.GetRuntimeType();
int token;
@@ -176,7 +174,7 @@ namespace System.Reflection.Emit
public override void Emit(OpCode opcode, Type type)
{
if (type == null)
- throw new ArgumentNullException("type");
+ throw new ArgumentNullException(nameof(type));
Contract.EndContractBlock();
RuntimeType rtType = type as RuntimeType;
@@ -193,12 +191,12 @@ namespace System.Reflection.Emit
public override void Emit(OpCode opcode, FieldInfo field)
{
if (field == null)
- throw new ArgumentNullException("field");
+ throw new ArgumentNullException(nameof(field));
Contract.EndContractBlock();
RuntimeFieldInfo runtimeField = field as RuntimeFieldInfo;
if (runtimeField == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo"), "field");
+ throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo"), nameof(field));
int token;
if (field.DeclaringType == null)
@@ -214,7 +212,7 @@ namespace System.Reflection.Emit
public override void Emit(OpCode opcode, String str)
{
if (str == null)
- throw new ArgumentNullException("str");
+ throw new ArgumentNullException(nameof(str));
Contract.EndContractBlock();
int tempVal = GetTokenForString(str);
@@ -228,7 +226,6 @@ namespace System.Reflection.Emit
// Signature related calls (vararg, calli)
//
//
- [System.Security.SecuritySafeCritical] // overrides SC
public override void EmitCalli(OpCode opcode,
CallingConventions callingConvention,
Type returnType,
@@ -307,20 +304,19 @@ namespace System.Reflection.Emit
PutInteger4(token);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public override void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[] optionalParameterTypes)
{
if (methodInfo == null)
- throw new ArgumentNullException("methodInfo");
+ 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"), "opcode");
+ throw new ArgumentException(Environment.GetResourceString("Argument_NotMethodCallOpcode"), nameof(opcode));
if (methodInfo.ContainsGenericParameters)
- throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), "methodInfo");
+ throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(methodInfo));
if (methodInfo.DeclaringType != null && methodInfo.DeclaringType.ContainsGenericParameters)
- throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), "methodInfo");
+ throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(methodInfo));
Contract.EndContractBlock();
int tk;
@@ -351,7 +347,7 @@ namespace System.Reflection.Emit
public override void Emit(OpCode opcode, SignatureHelper signature)
{
if (signature == null)
- throw new ArgumentNullException("signature");
+ throw new ArgumentNullException(nameof(signature));
Contract.EndContractBlock();
int stackchange = 0;
@@ -365,7 +361,7 @@ namespace System.Reflection.Emit
// SignatureHelper.
if (opcode.StackBehaviourPop == StackBehaviour.Varpop)
{
- Contract.Assert(opcode.Equals(OpCodes.Calli),
+ Debug.Assert(opcode.Equals(OpCodes.Calli),
"Unexpected opcode encountered for StackBehaviour VarPop.");
// Pop the arguments..
stackchange -= signature.ArgumentCount;
@@ -421,7 +417,7 @@ namespace System.Reflection.Emit
{
// execute this branch if previous clause is Catch or Fault
if (exceptionType == null)
- throw new ArgumentNullException("exceptionType");
+ throw new ArgumentNullException(nameof(exceptionType));
if (rtType == null)
throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
@@ -482,7 +478,6 @@ namespace System.Reflection.Emit
throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod"));
}
- [System.Security.SecurityCritical] // auto-generated
private int GetMemberRefToken(MethodBase methodInfo, Type[] optionalParameterTypes)
{
Type[] parameterTypes;
@@ -494,7 +489,7 @@ namespace System.Reflection.Emit
DynamicMethod dm = methodInfo as DynamicMethod;
if (rtMeth == null && dm == null)
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), "methodInfo");
+ throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(methodInfo));
ParameterInfo[] paramInfo = methodInfo.GetParametersNoCopy();
if (paramInfo != null && paramInfo.Length != 0)
@@ -519,7 +514,6 @@ namespace System.Reflection.Emit
return GetTokenForVarArgMethod(dm, sig);
}
- [System.Security.SecurityCritical] // auto-generated
internal override SignatureHelper GetMemberRefSignature(
CallingConventions call,
Type returnType,
@@ -704,9 +698,6 @@ namespace System.Reflection.Emit
m_method.m_resolver = this;
}
-#if FEATURE_CORECLR
- [System.Security.SecurityCritical] // auto-generated
-#endif
internal DynamicResolver(DynamicILInfo dynamicILInfo)
{
m_stackSize = dynamicILInfo.MaxStackSize;
@@ -774,7 +765,6 @@ namespace System.Reflection.Emit
{
internal RuntimeMethodHandleInternal m_methodHandle;
- [System.Security.SecuritySafeCritical] // auto-generated
~DestroyScout()
{
if (m_methodHandle.IsNullHandle())
@@ -887,7 +877,6 @@ namespace System.Reflection.Emit
return m_exceptionHeader;
}
- [System.Security.SecurityCritical] // auto-generated
internal override unsafe void GetEHInfo(int excNumber, void* exc)
{
CORINFO_EH_CLAUSE* exception = (CORINFO_EH_CLAUSE*)exc;
@@ -922,7 +911,6 @@ namespace System.Reflection.Emit
}
#endif // FEATURE_COMPRESSEDSTACK
- [System.Security.SecurityCritical]
internal override void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle, out IntPtr fieldHandle)
{
typeHandle = new IntPtr();
@@ -1003,9 +991,6 @@ namespace System.Reflection.Emit
}
-#if FEATURE_CORECLR
-[System.Security.SecurityCritical] // auto-generated
-#endif
[System.Runtime.InteropServices.ComVisible(true)]
public class DynamicILInfo
{
@@ -1032,7 +1017,6 @@ namespace System.Reflection.Emit
#endregion
#region Internal Methods
- [System.Security.SecurityCritical] // auto-generated
internal void GetCallableMethod(RuntimeModule module, DynamicMethod dm)
{
dm.m_methodHandle = ModuleHandle.GetDynamicMethod(dm,
@@ -1064,15 +1048,14 @@ namespace System.Reflection.Emit
m_maxStackSize = maxStackSize;
}
- [System.Security.SecurityCritical] // auto-generated
[CLSCompliant(false)]
public unsafe void SetCode(byte* code, int codeSize, int maxStackSize)
{
if (codeSize < 0)
- throw new ArgumentOutOfRangeException("codeSize", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
+ throw new ArgumentOutOfRangeException(nameof(codeSize), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
if (codeSize > 0 && code == null)
- throw new ArgumentNullException("code");
+ throw new ArgumentNullException(nameof(code));
Contract.EndContractBlock();
m_code = new byte[codeSize];
@@ -1090,15 +1073,14 @@ namespace System.Reflection.Emit
m_exceptions = (exceptions != null) ? (byte[])exceptions.Clone() : EmptyArray<Byte>.Value;
}
- [System.Security.SecurityCritical] // auto-generated
[CLSCompliant(false)]
public unsafe void SetExceptions(byte* exceptions, int exceptionsSize)
{
if (exceptionsSize < 0)
- throw new ArgumentOutOfRangeException("exceptionsSize", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
+ throw new ArgumentOutOfRangeException(nameof(exceptionsSize), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
if (exceptionsSize > 0 && exceptions == null)
- throw new ArgumentNullException("exceptions");
+ throw new ArgumentNullException(nameof(exceptions));
Contract.EndContractBlock();
m_exceptions = new byte[exceptionsSize];
@@ -1115,15 +1097,14 @@ namespace System.Reflection.Emit
m_localSignature = (localSignature != null) ? (byte[])localSignature.Clone() : EmptyArray<Byte>.Value;
}
- [System.Security.SecurityCritical] // auto-generated
[CLSCompliant(false)]
public unsafe void SetLocalSignature(byte* localSignature, int signatureSize)
{
if (signatureSize < 0)
- throw new ArgumentOutOfRangeException("signatureSize", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
+ throw new ArgumentOutOfRangeException(nameof(signatureSize), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
if (signatureSize > 0 && localSignature == null)
- throw new ArgumentNullException("localSignature");
+ throw new ArgumentNullException(nameof(localSignature));
Contract.EndContractBlock();
m_localSignature = new byte[signatureSize];
@@ -1136,7 +1117,6 @@ namespace System.Reflection.Emit
#endregion
#region Public Scope Methods
- [System.Security.SecuritySafeCritical] // auto-generated
public int GetTokenFor(RuntimeMethodHandle method)
{
return DynamicScope.GetTokenFor(method);
@@ -1222,7 +1202,6 @@ namespace System.Reflection.Emit
#endregion
#region Public Methods
- [System.Security.SecuritySafeCritical] // auto-generated
public int GetTokenFor(RuntimeMethodHandle method)
{
IRuntimeMethodInfo methodReal = method.GetMethodInfo();