void InitializeParameters() { if (__parameters_DONT_USE != null) { return; } var newRP = new DmdCreatedParameterInfo(this, genericMethodDefinition.ReturnParameter, methodSignature.ReturnType); var defParameters = genericMethodDefinition.GetParameters(); var paramTypes = methodSignature.GetParameterTypes(); var parameters = defParameters.Count == 0 ? Array.Empty <DmdParameterInfo>() : new DmdParameterInfo[Math.Min(paramTypes.Count, defParameters.Count)]; for (int i = 0; i < parameters.Length; i++) { parameters[i] = new DmdCreatedParameterInfo(this, defParameters[i], paramTypes[i]); } lock (LockObject) { if (__parameters_DONT_USE == null) { __returnParameter_DONT_USE = newRP; __parameters_DONT_USE = ReadOnlyCollectionHelpers.Create(parameters); } } }
public DmdGenericInstanceTypeRef(DmdTypeRef genericTypeRef, IList <DmdType> typeArguments, IList <DmdCustomModifier> customModifiers) : base(customModifiers) { if (typeArguments == null) { throw new ArgumentNullException(nameof(typeArguments)); } this.genericTypeRef = genericTypeRef ?? throw new ArgumentNullException(nameof(genericTypeRef)); this.typeArguments = ReadOnlyCollectionHelpers.Create(typeArguments); }
static ReadOnlyCollection<DmdType> GetGenericArguments(DmdType type) { if (!type.IsMetadataReference) return type.GetGenericArguments(); var resolvedType = type.ResolveNoThrow(); if ((object)resolvedType != null) return resolvedType.GetGenericArguments(); return ReadOnlyCollectionHelpers.Empty<DmdType>(); }
public sealed override ReadOnlyCollection <DmdType> GetGenericParameterConstraints() { if (__genericParameterConstraints_DONT_USE != null) { return(__genericParameterConstraints_DONT_USE); } var res = CreateGenericParameterConstraints(); Interlocked.CompareExchange(ref __genericParameterConstraints_DONT_USE, ReadOnlyCollectionHelpers.Create(res), null); return(__genericParameterConstraints_DONT_USE); }
public override ReadOnlyCollection <DmdCustomAttributeData> GetSecurityAttributesData() { if (securityAttributes != null) { return(securityAttributes); } var cas = metadataReader.ReadSecurityAttributes(0x20000001); Interlocked.CompareExchange(ref securityAttributes, ReadOnlyCollectionHelpers.Create(cas), null); return(securityAttributes); }
public DmdMethodBodyImpl(int localSignatureMetadataToken, int maxStackSize, bool initLocals, DmdLocalVariableInfo[] localVariables, DmdExceptionHandlingClause[] exceptionHandlingClauses, IList <DmdType>?genericTypeArguments, IList <DmdType>?genericMethodArguments, byte[] ilBytes) { LocalSignatureMetadataToken = localSignatureMetadataToken; MaxStackSize = maxStackSize; InitLocals = initLocals; LocalVariables = ReadOnlyCollectionHelpers.Create(localVariables); ExceptionHandlingClauses = ReadOnlyCollectionHelpers.Create(exceptionHandlingClauses); GenericTypeArguments = ReadOnlyCollectionHelpers.Create(genericTypeArguments); GenericMethodArguments = ReadOnlyCollectionHelpers.Create(genericMethodArguments); this.ilBytes = ilBytes ?? throw new ArgumentNullException(nameof(ilBytes)); }
public sealed override ReadOnlyCollection <DmdParameterInfo> GetParameters() { if (__parameters_DONT_USE != null) { return(__parameters_DONT_USE); } var info = CreateParameters(); Debug.Assert(info.Length == GetMethodSignature().GetParameterTypes().Count); Interlocked.CompareExchange(ref __parameters_DONT_USE, ReadOnlyCollectionHelpers.Create(info), null); return(__parameters_DONT_USE); }
void InitializeIndexParameters() { var f = ExtraFields; if (f.__indexParameters_DONT_USE != null) { return; } var info = CreateIndexParameters(); Interlocked.CompareExchange(ref f.__indexParameters_DONT_USE, ReadOnlyCollectionHelpers.Create(info), null); }
public sealed override ReadOnlyCollection <DmdType> GetGenericArguments() { var f = ExtraFields; if (f.__genericParameters_DONT_USE != null) { return(f.__genericParameters_DONT_USE); } var res = CreateGenericParameters(); Interlocked.CompareExchange(ref f.__genericParameters_DONT_USE, ReadOnlyCollectionHelpers.Create(res), null); return(f.__genericParameters_DONT_USE); }
static ReadOnlyCollection <DmdType> GetGenericArguments(DmdType type) { if (!type.IsMetadataReference) { return(type.GetGenericArguments()); } var resolvedType = type.ResolveNoThrow(); if (!(resolvedType is null)) { return(resolvedType.GetGenericArguments()); } return(ReadOnlyCollectionHelpers.Empty <DmdType>()); }
public DmdGenericInstanceType(DmdTypeDef genericTypeDefinition, IList <DmdType> typeArguments, IList <DmdCustomModifier> customModifiers) : base(customModifiers) { if ((object)genericTypeDefinition == null) { throw new ArgumentNullException(nameof(genericTypeDefinition)); } if (typeArguments == null) { throw new ArgumentNullException(nameof(typeArguments)); } if (genericTypeDefinition.GetGenericArguments().Count != typeArguments.Count) { throw new ArgumentException(); } this.genericTypeDefinition = genericTypeDefinition; this.typeArguments = ReadOnlyCollectionHelpers.Create(typeArguments); IsFullyResolved = DmdTypeUtilities.IsFullyResolved(typeArguments); }
void InitializePropertyMethods() { var f = ExtraFields; if (f.__otherMethods_DONT_USE != null) { return; } GetMethods(out var getMethod, out var setMethod, out var otherMethods); lock (LockObject) { if (f.__otherMethods_DONT_USE == null) { f.__getMethod_DONT_USE = getMethod; f.__setMethod_DONT_USE = setMethod; f.__otherMethods_DONT_USE = ReadOnlyCollectionHelpers.Create(otherMethods); } } }
void InitializeCustomAttributes() { if (__customAttributes_DONT_USE != null) { return; } var info = CreateCustomAttributes(); var newSAs = ReadOnlyCollectionHelpers.Create(info.sas); var newCAs = CustomAttributesHelper.AddPseudoCustomAttributes(this, info.cas, newSAs); lock (LockObject) { if (__customAttributes_DONT_USE == null) { __securityAttributes_DONT_USE = newSAs; __customAttributes_DONT_USE = newCAs; } } }
void InitializeEventMethods() { var f = ExtraFields; if (f.__otherMethods_DONT_USE != null) { return; } GetMethods(out var addMethod, out var removeMethod, out var raiseMethod, out var otherMethods); lock (LockObject) { if (f.__otherMethods_DONT_USE == null) { f.__addMethod_DONT_USE = addMethod; f.__removeMethod_DONT_USE = removeMethod; f.__raiseMethod_DONT_USE = raiseMethod; f.__otherMethods_DONT_USE = ReadOnlyCollectionHelpers.Create(otherMethods); } } }
void InitializeParameters() { var f = ExtraFields; if (f.__parameters_DONT_USE != null) { return; } var info = CreateParameters(); Debug.Assert(info.parameters.Length == GetMethodSignature().GetParameterTypes().Count); lock (LockObject) { if (f.__parameters_DONT_USE == null) { f.__returnParameter_DONT_USE = info.returnParameter; f.__parameters_DONT_USE = ReadOnlyCollectionHelpers.Create(info.parameters); } } }
void InitializeCustomAttributes() { var f = ExtraFields; if (!(f.__customAttributes_DONT_USE is null)) { return; } var info = CreateCustomAttributes(); var newSAs = ReadOnlyCollectionHelpers.Create(info.sas); var newCAs = CustomAttributesHelper.AddPseudoCustomAttributes(this, info.cas, newSAs, info.implMap); lock (LockObject) { if (f.__customAttributes_DONT_USE is null) { f.__securityAttributes_DONT_USE = newSAs; f.__customAttributes_DONT_USE = newCAs; } } }
public DmdMDArrayType(DmdTypeBase elementType, int rank, IList <int> sizes, IList <int> lowerBounds, IList <DmdCustomModifier>?customModifiers) : base(customModifiers) { // Allow 0, it's allowed in the MD if (rank < 0) { throw new ArgumentOutOfRangeException(nameof(rank)); } if (sizes is null) { throw new ArgumentNullException(nameof(sizes)); } if (lowerBounds is null) { throw new ArgumentNullException(nameof(lowerBounds)); } this.rank = rank; this.elementType = elementType ?? throw new ArgumentNullException(nameof(elementType)); this.sizes = ReadOnlyCollectionHelpers.Create(sizes); this.lowerBounds = ReadOnlyCollectionHelpers.Create(lowerBounds); IsMetadataReference = elementType.IsMetadataReference; IsFullyResolved = elementType.IsFullyResolved; }
DmdCustomAttributeTypedArgument ReadArrayArgument(DmdType arrayType) { if (!arrayType.IsSZArray) throw new ArgumentException(); if (!IncrementRecursionCounter()) throw new CABlobParserException("Stack overflow"); object argValue; int arrayCount = reader.ReadInt32(); if (arrayCount == -1)// -1 if it's null argValue = null; else if (arrayCount < 0) throw new CABlobParserException("Array is too big"); else { var array = new DmdCustomAttributeTypedArgument[arrayCount]; var elemType = FixTypeSig(arrayType.GetElementType()); for (int i = 0; i < array.Length; i++) array[i] = ReadFixedArg(elemType); argValue = ReadOnlyCollectionHelpers.Create(array); } DecrementRecursionCounter(); return new DmdCustomAttributeTypedArgument(arrayType, argValue); }
public override ReadOnlyCollection <DmdType> GetGenericArguments() => methodSignature.GenericParameterCount == 0 ? ReadOnlyCollectionHelpers.Empty <DmdType>() : ResolvedConstructor.GetGenericArguments();
public DmdMethodSpec(DmdMethodDef genericMethodDefinition, IList <DmdType> genericArguments) { this.genericMethodDefinition = genericMethodDefinition ?? throw new ArgumentNullException(nameof(genericMethodDefinition)); methodSignature = genericMethodDefinition.GetMethodSignature(genericArguments); this.genericArguments = ReadOnlyCollectionHelpers.Create(genericArguments); }
public override ReadOnlyCollection <int> GetArrayLowerBounds() => ReadOnlyCollectionHelpers.Empty <int>();
public override ReadOnlyCollection <int> GetArraySizes() => ReadOnlyCollectionHelpers.Empty <int>();