Example #1
0
        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);
                }
            }
        }
Example #2
0
 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);
 }
        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);
        }
Example #4
0
 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));
 }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        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);
        }
 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);
 }
Example #10
0
        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);
                }
            }
        }
Example #11
0
        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;
                }
            }
        }
Example #12
0
        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);
                }
            }
        }
Example #13
0
        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);
                }
            }
        }
Example #14
0
        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;
                }
            }
        }
Example #15
0
 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;
 }
Example #16
0
		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);
		}
Example #17
0
 public DmdMethodSpec(DmdMethodDef genericMethodDefinition, IList <DmdType> genericArguments)
 {
     this.genericMethodDefinition = genericMethodDefinition ?? throw new ArgumentNullException(nameof(genericMethodDefinition));
     methodSignature       = genericMethodDefinition.GetMethodSignature(genericArguments);
     this.genericArguments = ReadOnlyCollectionHelpers.Create(genericArguments);
 }