summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Reflection/ParameterInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Reflection/ParameterInfo.cs')
-rw-r--r--src/mscorlib/src/System/Reflection/ParameterInfo.cs90
1 files changed, 16 insertions, 74 deletions
diff --git a/src/mscorlib/src/System/Reflection/ParameterInfo.cs b/src/mscorlib/src/System/Reflection/ParameterInfo.cs
index 63c6330b0a..6592e5aa20 100644
--- a/src/mscorlib/src/System/Reflection/ParameterInfo.cs
+++ b/src/mscorlib/src/System/Reflection/ParameterInfo.cs
@@ -8,13 +8,11 @@ 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;
-#if FEATURE_REMOTING
- using System.Runtime.Remoting.Metadata;
-#endif //FEATURE_REMOTING
using System.Security.Permissions;
using System.Threading;
using MdToken = System.Reflection.MetadataToken;
@@ -157,7 +155,7 @@ namespace System.Reflection
public virtual Object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (attributeType == null)
- throw new ArgumentNullException("attributeType");
+ throw new ArgumentNullException(nameof(attributeType));
Contract.EndContractBlock();
return EmptyArray<Object>.Value;
@@ -166,7 +164,7 @@ namespace System.Reflection
public virtual bool IsDefined(Type attributeType, bool inherit)
{
if (attributeType == null)
- throw new ArgumentNullException("attributeType");
+ throw new ArgumentNullException(nameof(attributeType));
Contract.EndContractBlock();
return false;
@@ -180,35 +178,12 @@ namespace System.Reflection
#region _ParameterInfo implementation
-#if !FEATURE_CORECLR
- void _ParameterInfo.GetTypeInfoCount(out uint pcTInfo)
- {
- throw new NotImplementedException();
- }
-
- void _ParameterInfo.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
- {
- throw new NotImplementedException();
- }
-
- void _ParameterInfo.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
- {
- throw new NotImplementedException();
- }
-
- void _ParameterInfo.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
- {
- throw new NotImplementedException();
- }
-#endif
-
#endregion
#region IObjectReference
// In V4 RuntimeParameterInfo is introduced.
// To support deserializing ParameterInfo instances serialized in earlier versions
// we need to implement IObjectReference.
- [System.Security.SecurityCritical]
public object GetRealObject(StreamingContext context)
{
Contract.Ensures(Contract.Result<Object>() != null);
@@ -261,26 +236,23 @@ namespace System.Reflection
internal unsafe sealed class RuntimeParameterInfo : ParameterInfo, ISerializable
{
#region Static Members
- [System.Security.SecurityCritical] // auto-generated
internal unsafe static ParameterInfo[] GetParameters(IRuntimeMethodInfo method, MemberInfo member, Signature sig)
{
- Contract.Assert(method is RuntimeMethodInfo || method is RuntimeConstructorInfo);
+ Debug.Assert(method is RuntimeMethodInfo || method is RuntimeConstructorInfo);
ParameterInfo dummy;
return GetParameters(method, member, sig, out dummy, false);
}
- [System.Security.SecurityCritical] // auto-generated
internal unsafe static ParameterInfo GetReturnParameter(IRuntimeMethodInfo method, MemberInfo member, Signature sig)
{
- Contract.Assert(method is RuntimeMethodInfo || method is RuntimeConstructorInfo);
+ Debug.Assert(method is RuntimeMethodInfo || method is RuntimeConstructorInfo);
ParameterInfo returnParameter;
GetParameters(method, member, sig, out returnParameter, true);
return returnParameter;
}
- [System.Security.SecurityCritical] // auto-generated
internal unsafe static ParameterInfo[] GetParameters(
IRuntimeMethodInfo methodHandle, MemberInfo member, Signature sig, out ParameterInfo returnParameter, bool fetchReturnParameter)
{
@@ -392,18 +364,17 @@ namespace System.Reflection
get
{
MethodBase result = m_originalMember != null ? m_originalMember : MemberImpl as MethodBase;
- Contract.Assert(result != null);
+ Debug.Assert(result != null);
return result;
}
}
#endregion
#region VTS magic to serialize/deserialized to/from pre-Whidbey endpoints.
- [System.Security.SecurityCritical]
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
Contract.EndContractBlock();
// We could be serializing for consumption by a pre-Whidbey
@@ -450,7 +421,7 @@ namespace System.Reflection
// 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;
- Contract.Assert(m_originalMember != null);
+ Debug.Assert(m_originalMember != null);
// Populate all the caches -- we inherit this behavior from RTM
NameImpl = accessor.Name;
@@ -470,8 +441,8 @@ namespace System.Reflection
int position, ParameterAttributes attributes, MemberInfo member)
{
Contract.Requires(member != null);
- Contract.Assert(MdToken.IsNullToken(tkParamDef) == scope.Equals(MetadataImport.EmptyImport));
- Contract.Assert(MdToken.IsNullToken(tkParamDef) || MdToken.IsTokenOfType(tkParamDef, MetadataTokenType.ParamDef));
+ Debug.Assert(MdToken.IsNullToken(tkParamDef) == scope.Equals(MetadataImport.EmptyImport));
+ Debug.Assert(MdToken.IsNullToken(tkParamDef) || MdToken.IsTokenOfType(tkParamDef, MetadataTokenType.ParamDef));
PositionImpl = position;
MemberImpl = member;
@@ -513,7 +484,7 @@ namespace System.Reflection
else
parameterType = m_signature.Arguments[PositionImpl];
- Contract.Assert(parameterType != null);
+ Debug.Assert(parameterType != null);
// different thread could only write ClassImpl to the same value, so a race condition is not a problem here
ClassImpl = parameterType;
}
@@ -524,7 +495,6 @@ namespace System.Reflection
public override String Name
{
- [System.Security.SecuritySafeCritical] // auto-generated
get
{
if (!m_nameIsCached)
@@ -588,10 +558,9 @@ namespace System.Reflection
}
// returns DBNull.Value if the parameter doesn't have a default value
- [System.Security.SecuritySafeCritical]
private Object GetDefaultValueInternal(bool raw)
{
- Contract.Assert(!m_noMetadata);
+ Debug.Assert(!m_noMetadata);
if (m_noDefaultValue)
return DBNull.Value;
@@ -728,7 +697,7 @@ namespace System.Reflection
public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (attributeType == null)
- throw new ArgumentNullException("attributeType");
+ throw new ArgumentNullException(nameof(attributeType));
Contract.EndContractBlock();
if (MdToken.IsNullToken(m_tkParamDef))
@@ -737,16 +706,15 @@ namespace System.Reflection
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "attributeType");
+ throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(attributeType));
return CustomAttribute.GetCustomAttributes(this, attributeRuntimeType);
}
- [System.Security.SecuritySafeCritical] // auto-generated
public override bool IsDefined(Type attributeType, bool inherit)
{
if (attributeType == null)
- throw new ArgumentNullException("attributeType");
+ throw new ArgumentNullException(nameof(attributeType));
Contract.EndContractBlock();
if (MdToken.IsNullToken(m_tkParamDef))
@@ -755,7 +723,7 @@ namespace System.Reflection
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "attributeType");
+ throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(attributeType));
return CustomAttribute.IsDefined(this, attributeRuntimeType);
}
@@ -765,31 +733,5 @@ namespace System.Reflection
return CustomAttributeData.GetCustomAttributesInternal(this);
}
#endregion
-
-#if FEATURE_REMOTING
- #region Remoting Cache
- private RemotingParameterCachedData m_cachedData;
-
- internal RemotingParameterCachedData RemotingCache
- {
- get
- {
- // This grabs an internal copy of m_cachedData and uses
- // that instead of looking at m_cachedData directly because
- // the cache may get cleared asynchronously. This prevents
- // us from having to take a lock.
- RemotingParameterCachedData cache = m_cachedData;
- if (cache == null)
- {
- cache = new RemotingParameterCachedData(this);
- RemotingParameterCachedData ret = Interlocked.CompareExchange(ref m_cachedData, cache, null);
- if (ret != null)
- cache = ret;
- }
- return cache;
- }
- }
- #endregion
-#endif //FEATURE_REMOTING
}
}