internal static Attribute GetCustomAttribute(RuntimeParameterInfo parameter) { if (!parameter.IsOptional) { return null; } return new OptionalAttribute(); }
private RuntimeParameterInfo(RuntimeParameterInfo accessor, MemberInfo member) { base.MemberImpl = member; this.m_originalMember = accessor.MemberImpl as MethodBase; base.NameImpl = accessor.Name; this.m_nameIsCached = true; base.ClassImpl = accessor.ParameterType; base.PositionImpl = accessor.Position; base.AttrsImpl = accessor.Attributes; this.m_tkParamDef = System.Reflection.MetadataToken.IsNullToken(accessor.MetadataToken) ? 0x8000000 : accessor.MetadataToken; this.m_scope = accessor.m_scope; }
internal static Attribute[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType, out int count) { count = 0; bool flag = (caType == ((RuntimeType) typeof(object))) || (caType == ((RuntimeType) typeof(Attribute))); if (!flag && (s_pca.GetValueOrDefault(caType) == null)) { return null; } Attribute[] attributeArray = new Attribute[s_pcasCount]; Attribute customAttribute = null; if (flag || (caType == ((RuntimeType) typeof(InAttribute)))) { customAttribute = InAttribute.GetCustomAttribute(parameter); if (customAttribute != null) { attributeArray[count++] = customAttribute; } } if (flag || (caType == ((RuntimeType) typeof(OutAttribute)))) { customAttribute = OutAttribute.GetCustomAttribute(parameter); if (customAttribute != null) { attributeArray[count++] = customAttribute; } } if (flag || (caType == ((RuntimeType) typeof(OptionalAttribute)))) { customAttribute = OptionalAttribute.GetCustomAttribute(parameter); if (customAttribute != null) { attributeArray[count++] = customAttribute; } } if (flag || (caType == ((RuntimeType) typeof(MarshalAsAttribute)))) { customAttribute = MarshalAsAttribute.GetCustomAttribute(parameter); if (customAttribute != null) { attributeArray[count++] = customAttribute; } } return attributeArray; }
internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeParameterInfo target) { IList<CustomAttributeData> customAttributes = GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken); int count = 0; Attribute[] attributeArray = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, out count); if (count == 0) { return customAttributes; } CustomAttributeData[] array = new CustomAttributeData[customAttributes.Count + count]; customAttributes.CopyTo(array, count); for (int i = 0; i < count; i++) { array[i] = new CustomAttributeData(attributeArray[i]); } return Array.AsReadOnly<CustomAttributeData>(array); }
internal static Attribute GetCustomAttribute(RuntimeParameterInfo parameter) { return parameter.IsOptional ? new OptionalAttribute() : null; }
[System.Security.SecurityCritical] // auto-generated internal static bool IsDefined(RuntimeParameterInfo parameter) { return GetCustomAttribute(parameter) != null; }
[System.Security.SecurityCritical] // auto-generated internal static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType caType) { bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute); if (!all && s_pca.GetValueOrDefault(caType) == null) return false; if (all || caType == (RuntimeType)typeof(InAttribute)) { if (InAttribute.IsDefined(parameter)) return true; } if (all || caType == (RuntimeType)typeof(OutAttribute)) { if (OutAttribute.IsDefined(parameter)) return true; } if (all || caType == (RuntimeType)typeof(OptionalAttribute)) { if (OptionalAttribute.IsDefined(parameter)) return true; } if (all || caType == (RuntimeType)typeof(MarshalAsAttribute)) { if (MarshalAsAttribute.IsDefined(parameter)) return true; } return false; }
internal static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType caType) { bool flag = (caType == ((RuntimeType) typeof(object))) || (caType == ((RuntimeType) typeof(Attribute))); if (!flag && (s_pca.GetValueOrDefault(caType) == null)) { return false; } return (((flag || (caType == ((RuntimeType) typeof(InAttribute)))) && InAttribute.IsDefined(parameter)) || (((flag || (caType == ((RuntimeType) typeof(OutAttribute)))) && OutAttribute.IsDefined(parameter)) || (((flag || (caType == ((RuntimeType) typeof(OptionalAttribute)))) && OptionalAttribute.IsDefined(parameter)) || ((flag || (caType == ((RuntimeType) typeof(MarshalAsAttribute)))) && MarshalAsAttribute.IsDefined(parameter))))); }
internal ParameterInfo[] LoadParameters() { if (this.m_parameters == null) { Type[] parameterTypes = this.m_owner.m_parameterTypes; ParameterInfo[] infoArray = new ParameterInfo[parameterTypes.Length]; for (int i = 0; i < parameterTypes.Length; i++) { infoArray[i] = new RuntimeParameterInfo(this, null, parameterTypes[i], i); } if (this.m_parameters == null) { this.m_parameters = infoArray; } } return this.m_parameters; }
internal static ParameterInfo[] GetParameters(IRuntimeMethodInfo method, MemberInfo member, Signature sig) { ParameterInfo returnParameter; return(RuntimeParameterInfo.GetParameters(method, member, sig, out returnParameter, false)); }
private ParameterInfo FetchReturnParameter() => m_returnParameter ??= RuntimeParameterInfo.GetReturnParameter(this, this, Signature);
private ParameterInfo[] FetchNonReturnParameters() => m_parameters ??= RuntimeParameterInfo.GetParameters(this, this, Signature);
internal static ParameterInfo GetReturnParameterInfo(RuntimeMethodInfo method) { return(RuntimeParameterInfo.New(GetReturnType(method.mhandle), method, get_retval_marshal(method.mhandle))); }
internal RemotingCachedData(RuntimeParameterInfo ri) { this.RI = ri; }
internal static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType caType) { return(PseudoCustomAttribute.IsDefined(parameter, caType) || IsCustomAttributeDefined(parameter.GetRuntimeModule(), parameter.MetadataToken, caType)); }
private static bool AllowCriticalCustomAttributes(RuntimeParameterInfo parameter) { return(AllowCriticalCustomAttributes(parameter.DefiningMethod)); }
// used by RuntimePropertyInfo internal RuntimeParameterInfo(RuntimeParameterInfo accessor, RuntimePropertyInfo property) : this(accessor, (MemberInfo)property) { m_signature = property.Signature; }
internal static unsafe ParameterInfo[] GetParameters(IRuntimeMethodInfo methodHandle, MemberInfo member, Signature sig, out ParameterInfo returnParameter, bool fetchReturnParameter) { returnParameter = null; int length = sig.Arguments.Length; ParameterInfo[] infoArray = fetchReturnParameter ? null : new ParameterInfo[length]; int methodDef = RuntimeMethodHandle.GetMethodDef(methodHandle); int count = 0; if (!System.Reflection.MetadataToken.IsNullToken(methodDef)) { MetadataImport metadataImport = RuntimeTypeHandle.GetMetadataImport(RuntimeMethodHandle.GetDeclaringType(methodHandle)); count = metadataImport.EnumParamsCount(methodDef); int* result = (int*) stackalloc byte[(((IntPtr) count) * 4)]; metadataImport.EnumParams(methodDef, result, count); if (count > (length + 1)) { throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch")); } for (uint i = 0; i < count; i++) { ParameterAttributes attributes; int num5; int parameterToken = result[(int) ((int*) i)]; metadataImport.GetParamDefProps(parameterToken, out num5, out attributes); num5--; if (fetchReturnParameter && (num5 == -1)) { if (returnParameter != null) { throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch")); } returnParameter = new RuntimeParameterInfo(sig, metadataImport, parameterToken, num5, attributes, member); } else if (!fetchReturnParameter && (num5 >= 0)) { if (num5 >= length) { throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch")); } infoArray[num5] = new RuntimeParameterInfo(sig, metadataImport, parameterToken, num5, attributes, member); } } } if (fetchReturnParameter) { if (returnParameter == null) { returnParameter = new RuntimeParameterInfo(sig, MetadataImport.EmptyImport, 0, -1, ParameterAttributes.None, member); } return infoArray; } if (count < (infoArray.Length + 1)) { for (int j = 0; j < infoArray.Length; j++) { if (infoArray[j] == null) { infoArray[j] = new RuntimeParameterInfo(sig, MetadataImport.EmptyImport, 0, j, ParameterAttributes.None, member); } } } return infoArray; }
}// GetCachedRemotingAttribute internal static RemotingCachedData GetReflectionCachedData(RuntimeParameterInfo reflectionObject) { RemotingCachedData cache = null; cache = (RemotingCachedData)reflectionObject.RemotingCache[CacheObjType.RemotingData]; if (cache == null) { cache = new RemotingCachedData(reflectionObject); reflectionObject.RemotingCache[CacheObjType.RemotingData] = cache; } return cache; } // GetCachedRemotingAttribute
private static bool AllowCriticalCustomAttributes(RuntimeParameterInfo parameter) { // Since parameters have no transparency state, we look at the defining method instead. return AllowCriticalCustomAttributes(parameter.DefiningMethod); }
internal ParameterInfo[] GetIndexParametersNoCopy() { // @History - Logic ported from RTM // No need to lock because we don't guarantee the uniqueness of ParameterInfo objects if (m_parameters == null) { int numParams = 0; ParameterInfo[] methParams = null; // First try to get the Get method. MethodInfo m = GetGetMethod(true); if (m != null) { // There is a Get method so use it. methParams = m.GetParametersNoCopy(); numParams = methParams.Length; } else { // If there is no Get method then use the Set method. m = GetSetMethod(true); if (m != null) { methParams = m.GetParametersNoCopy(); numParams = methParams.Length - 1; } } // Now copy over the parameter info's and change their // owning member info to the current property info. ParameterInfo[] propParams = new ParameterInfo[numParams]; for (int i = 0; i < numParams; i++) propParams[i] = new RuntimeParameterInfo((RuntimeParameterInfo)methParams[i], this); m_parameters = propParams; } return m_parameters; }
[System.Security.SecuritySafeCritical] // auto-generated internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeParameterInfo target) { Contract.Assert(target != null); IList<CustomAttributeData> cad = GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken); int pcaCount = 0; Attribute[] a = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, out pcaCount); if (pcaCount == 0) return cad; CustomAttributeData[] pca = new CustomAttributeData[cad.Count + pcaCount]; cad.CopyTo(pca, pcaCount); for (int i = 0; i < pcaCount; i++) pca[i] = new CustomAttributeData(a[i]); return Array.AsReadOnly(pca); }
[System.Security.SecurityCritical] // auto-generated internal static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType caType) { Contract.Requires(parameter != null); Contract.Requires(caType != null); if (PseudoCustomAttribute.IsDefined(parameter, caType)) return true; return IsCustomAttributeDefined(parameter.GetRuntimeModule(), parameter.MetadataToken, caType); }
internal static RemotingCachedData GetReflectionCachedData(RuntimeParameterInfo reflectionObject) { RemotingCachedData data = null; data = (RemotingCachedData) reflectionObject.RemotingCache[CacheObjType.RemotingData]; if (data == null) { data = new RemotingCachedData(reflectionObject); reflectionObject.RemotingCache[CacheObjType.RemotingData] = data; } return data; }
[System.Security.SecuritySafeCritical] // auto-generated internal static Object[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType) { Contract.Requires(parameter != null); Contract.Requires(caType != null); int pcaCount = 0; Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(parameter, caType, out pcaCount); 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 override ParameterInfo[] GetParametersNoCopy() => m_parameters ??= RuntimeParameterInfo.GetParameters(this, this, Signature);
[System.Security.SecurityCritical] // auto-generated internal static Attribute[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType, out int count) { Contract.Requires(parameter != null); Contract.Requires(caType != null); count = 0; bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute); if (!all && s_pca.GetValueOrDefault(caType) == null) return null; Attribute[] pcas = new Attribute[s_pcasCount]; Attribute pca = null; if (all || caType == (RuntimeType)typeof(InAttribute)) { pca = InAttribute.GetCustomAttribute(parameter); if (pca != null) pcas[count++] = pca; } if (all || caType == (RuntimeType)typeof(OutAttribute)) { pca = OutAttribute.GetCustomAttribute(parameter); if (pca != null) pcas[count++] = pca; } if (all || caType == (RuntimeType)typeof(OptionalAttribute)) { pca = OptionalAttribute.GetCustomAttribute(parameter); if (pca != null) pcas[count++] = pca; } if (all || caType == (RuntimeType)typeof(MarshalAsAttribute)) { pca = MarshalAsAttribute.GetCustomAttribute(parameter); if (pca != null) pcas[count++] = pca; } return pcas; }
internal static ParameterInfo[] GetParameters( IRuntimeMethodInfo methodHandle, MemberInfo member, Signature sig, out ParameterInfo?returnParameter, bool fetchReturnParameter) { returnParameter = null; int sigArgCount = sig.Arguments.Length; ParameterInfo[] args = fetchReturnParameter ? null ! : new ParameterInfo[sigArgCount]; int tkMethodDef = RuntimeMethodHandle.GetMethodDef(methodHandle); int cParamDefs = 0; // Not all methods have tokens. Arrays, pointers and byRef types do not have tokens as they // are generated on the fly by the runtime. if (!MdToken.IsNullToken(tkMethodDef)) { MetadataImport scope = RuntimeTypeHandle.GetMetadataImport(RuntimeMethodHandle.GetDeclaringType(methodHandle)); MetadataEnumResult tkParamDefs; scope.EnumParams(tkMethodDef, out tkParamDefs); cParamDefs = tkParamDefs.Length; // 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(SR.BadImageFormat_ParameterSignatureMismatch); } for (int i = 0; i < cParamDefs; i++) { #region Populate ParameterInfos ParameterAttributes attr; int position, tkParamDef = tkParamDefs[i]; scope.GetParamDefProps(tkParamDef, out position, out attr); position--; if (fetchReturnParameter && position == -1) { // more than one return parameter? if (returnParameter != null) { throw new BadImageFormatException(SR.BadImageFormat_ParameterSignatureMismatch); } returnParameter = new RuntimeParameterInfo(sig, scope, tkParamDef, position, attr, member); } else if (!fetchReturnParameter && position >= 0) { // position beyong sigArgCount? if (position >= sigArgCount) { throw new BadImageFormatException(SR.BadImageFormat_ParameterSignatureMismatch); } args[position] = new RuntimeParameterInfo(sig, scope, tkParamDef, position, attr, member); } #endregion } } // Fill in empty ParameterInfos for those without tokens if (fetchReturnParameter) { returnParameter ??= new RuntimeParameterInfo(sig, MetadataImport.EmptyImport, 0, -1, (ParameterAttributes)0, member); } else { if (cParamDefs < args.Length + 1) { for (int i = 0; i < args.Length; i++) { if (args[i] != null) { continue; } args[i] = new RuntimeParameterInfo(sig, MetadataImport.EmptyImport, 0, i, (ParameterAttributes)0, member); } } } return(args); }
[System.Security.SecurityCritical] // auto-generated internal static Attribute GetCustomAttribute(RuntimeParameterInfo parameter) { return GetCustomAttribute(parameter.MetadataToken, parameter.GetRuntimeModule()); }
// used by RuntimePropertyInfo internal RuntimeParameterInfo(RuntimeParameterInfo accessor, RuntimePropertyInfo property) : this(accessor, (MemberInfo)property) { m_signature = property.Signature; }
internal static Attribute GetCustomAttribute(RuntimeParameterInfo parameter) { return parameter.IsIn ? new InAttribute() : null; }
internal ParameterInfo[] GetIndexParametersNoCopy() { if (this.m_parameters == null) { int length = 0; ParameterInfo[] parametersNoCopy = null; MethodInfo getMethod = this.GetGetMethod(true); if (getMethod != null) { parametersNoCopy = getMethod.GetParametersNoCopy(); length = parametersNoCopy.Length; } else { getMethod = this.GetSetMethod(true); if (getMethod != null) { parametersNoCopy = getMethod.GetParametersNoCopy(); length = parametersNoCopy.Length - 1; } } ParameterInfo[] infoArray2 = new ParameterInfo[length]; for (int i = 0; i < length; i++) { infoArray2[i] = new RuntimeParameterInfo((RuntimeParameterInfo) parametersNoCopy[i], this); } this.m_parameters = infoArray2; } return this.m_parameters; }
internal static bool IsDefined(RuntimeParameterInfo parameter) { return parameter.IsOptional; }
internal static RemotingCachedData GetReflectionCachedData(RuntimeParameterInfo reflectionObject) { return reflectionObject.RemotingCache; }
[System.Security.SecurityCritical] // auto-generated internal unsafe static ParameterInfo[] GetParameters( IRuntimeMethodInfo methodHandle, MemberInfo member, Signature sig, out ParameterInfo returnParameter, bool fetchReturnParameter) { returnParameter = null; int sigArgCount = sig.Arguments.Length; ParameterInfo[] args = fetchReturnParameter ? null : new ParameterInfo[sigArgCount]; int tkMethodDef = RuntimeMethodHandle.GetMethodDef(methodHandle); int cParamDefs = 0; // Not all methods have tokens. Arrays, pointers and byRef types do not have tokens as they // are generated on the fly by the runtime. if (!MdToken.IsNullToken(tkMethodDef)) { MetadataImport scope = RuntimeTypeHandle.GetMetadataImport(RuntimeMethodHandle.GetDeclaringType(methodHandle)); MetadataEnumResult tkParamDefs; scope.EnumParams(tkMethodDef, out tkParamDefs); cParamDefs = tkParamDefs.Length; // 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")); for (int i = 0; i < cParamDefs; i++) { #region Populate ParameterInfos ParameterAttributes attr; int position, tkParamDef = tkParamDefs[i]; scope.GetParamDefProps(tkParamDef, out position, out attr); position--; if (fetchReturnParameter == true && position == -1) { // more than one return parameter? if (returnParameter != null) throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch")); returnParameter = new RuntimeParameterInfo(sig, scope, tkParamDef, position, attr, member); } else if (fetchReturnParameter == false && position >= 0) { // position beyong sigArgCount? if (position >= sigArgCount) throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch")); args[position] = new RuntimeParameterInfo(sig, scope, tkParamDef, position, attr, member); } #endregion } } // Fill in empty ParameterInfos for those without tokens if (fetchReturnParameter) { if (returnParameter == null) { returnParameter = new RuntimeParameterInfo(sig, MetadataImport.EmptyImport, 0, -1, (ParameterAttributes)0, member); } } else { if (cParamDefs < args.Length + 1) { for (int i = 0; i < args.Length; i++) { if (args[i] != null) continue; args[i] = new RuntimeParameterInfo(sig, MetadataImport.EmptyImport, 0, i, (ParameterAttributes)0, member); } } } return args; }
[System.Security.SecurityCritical] // auto-generated internal static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType caType) { Contract.Requires(parameter != null); Contract.Requires(caType != null); #if !FEATURE_CORECLR if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage) && caType != null) { FrameworkEventSource.Log.QueryAttributeIsDefined(caType.GetFullNameForEtw()); } #endif if (PseudoCustomAttribute.IsDefined(parameter, caType)) return true; return IsCustomAttributeDefined(parameter.GetRuntimeModule(), parameter.MetadataToken, caType); }
private RuntimeParameterInfo(RuntimeParameterInfo accessor, MemberInfo member) { // 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; Contract.Assert(m_originalMember != null); // Populate all the caches -- we inherit this behavior from RTM NameImpl = accessor.Name; m_nameIsCached = true; ClassImpl = accessor.ParameterType; PositionImpl = accessor.Position; AttrsImpl = accessor.Attributes; // Strictly speeking, property's don't contain paramter tokens // However we need this to make ca's work... oh well... m_tkParamDef = MdToken.IsNullToken(accessor.MetadataToken) ? (int)MetadataTokenType.ParamDef : accessor.MetadataToken; m_scope = accessor.m_scope; }
private RuntimeParameterInfo RI; // reflection structure on which this data structure is stored internal RemotingParameterCachedData(RuntimeParameterInfo ri) { RI = ri; }
// // private implementation // internal ParameterInfo[] 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++) parameters[i] = new RuntimeParameterInfo(this, null, parameterTypes[i], i); if (m_parameters == null) // should we interlockexchange? m_parameters = parameters; } return m_parameters; }
internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeParameterInfo target) { return(CustomAttribute.GetCustomAttributesData(target)); }