private ImmutableArray <ParameterSymbol> RetargetParameters() { var list = _underlyingProperty.Parameters; int count = list.Length; if (count == 0) { return(ImmutableArray <ParameterSymbol> .Empty); } else { ParameterSymbol[] parameters = new ParameterSymbol[count]; for (int i = 0; i < count; i++) { parameters[i] = new RetargetingPropertyParameterSymbol(this, list[i]); } return(parameters.AsImmutableOrNull()); } }
private static ImmutableArray <ParameterSymbol> GetParameters( PEModuleSymbol moduleSymbol, PEPropertySymbol property, ParamInfo <TypeSymbol>[] propertyParams, ParamInfo <TypeSymbol>[] accessorParams, bool isPropertyVirtual, out bool anyParameterIsBad) { anyParameterIsBad = false; // First parameter is the property type. if (propertyParams.Length < 2) { return(ImmutableArray <ParameterSymbol> .Empty); } var numAccessorParams = accessorParams.Length; var parameters = new ParameterSymbol[propertyParams.Length - 1]; for (int i = 1; i < propertyParams.Length; i++) // from 1 to skip property/return type { // NOTE: this is a best guess at the Dev10 behavior. The actual behavior is // in the unmanaged helper code that Dev10 uses to load the metadata. var propertyParam = propertyParams[i]; var paramHandle = i < numAccessorParams ? accessorParams[i].Handle : propertyParam.Handle; var ordinal = i - 1; bool isBad; parameters[ordinal] = PEParameterSymbol.Create(moduleSymbol, property, isPropertyVirtual, ordinal, paramHandle, propertyParam, nullableContext: property, out isBad); if (isBad) { anyParameterIsBad = true; } } return(parameters.AsImmutableOrNull()); }
private static ImmutableArray<ParameterSymbol> GetParameters( PEModuleSymbol moduleSymbol, PEPropertySymbol property, MetadataDecoder.ParamInfo[] propertyParams, MetadataDecoder.ParamInfo[] accessorParams, out bool anyParameterIsBad) { anyParameterIsBad = false; // First parameter is the property type. if (propertyParams.Length < 2) { return ImmutableArray<ParameterSymbol>.Empty; } var numAccessorParams = accessorParams.Length; var parameters = new ParameterSymbol[propertyParams.Length - 1]; for (int i = 1; i < propertyParams.Length; i++) // from 1 to skip property/return type { // NOTE: this is a best guess at the Dev10 behavior. The actual behavior is // in the unmanaged helper code that Dev10 uses to load the metadata. var propertyParam = propertyParams[i]; var paramHandle = i < numAccessorParams ? accessorParams[i].Handle : propertyParam.Handle; var ordinal = i - 1; bool isBad; parameters[ordinal] = new PEParameterSymbol(moduleSymbol, property, ordinal, paramHandle, propertyParam, out isBad); if (isBad) { anyParameterIsBad = true; } } return parameters.AsImmutableOrNull(); }
private void LoadSignature() { var moduleSymbol = _containingType.ContainingPEModule; SignatureHeader signatureHeader; BadImageFormatException mrEx; ParamInfo <TypeSymbol>[] paramInfo = new MetadataDecoder(moduleSymbol, this).GetSignatureForMethod(_handle, out signatureHeader, out mrEx); bool makeBad = (mrEx != null); // If method is not generic, let's assign empty list for type parameters if (!signatureHeader.IsGeneric && _lazyTypeParameters.IsDefault) { ImmutableInterlocked.InterlockedCompareExchange(ref _lazyTypeParameters, ImmutableArray <TypeParameterSymbol> .Empty, default(ImmutableArray <TypeParameterSymbol>)); } int count = paramInfo.Length - 1; ImmutableArray <ParameterSymbol> @params; bool isBadParameter; if (count > 0) { ParameterSymbol[] parameterCreation = new ParameterSymbol[count]; for (int i = 0; i < count; i++) { parameterCreation[i] = new PEParameterSymbol(moduleSymbol, this, i, paramInfo[i + 1], out isBadParameter); if (isBadParameter) { makeBad = true; } } @params = parameterCreation.AsImmutableOrNull(); } else { @params = ImmutableArray <ParameterSymbol> .Empty; } // paramInfo[0] contains information about return "parameter" Debug.Assert(!paramInfo[0].IsByRef); // Dynamify object type if necessary paramInfo[0].Type = paramInfo[0].Type.AsDynamicIfNoPia(_containingType); var returnParam = new PEParameterSymbol(moduleSymbol, this, 0, paramInfo[0], out isBadParameter); if (makeBad || isBadParameter) { var old = Interlocked.CompareExchange(ref _lazyUseSiteDiagnostic, new CSDiagnosticInfo(ErrorCode.ERR_BindToBogus, this), CSDiagnosticInfo.EmptyErrorInfo); Debug.Assert((object)old == (object)CSDiagnosticInfo.EmptyErrorInfo || ((object)old != null && old.Code == (int)ErrorCode.ERR_BindToBogus && old.Arguments.Length == 1 && old.Arguments[0] == (object)this)); } var signature = new SignatureData(signatureHeader, @params, returnParam); Interlocked.CompareExchange(ref _lazySignature, signature, null); }
private void LoadSignature() { var moduleSymbol = this.containingType.ContainingPEModule; byte callingConvention; BadImageFormatException mrEx; MetadataDecoder.ParamInfo[] paramInfo = new MetadataDecoder(moduleSymbol, this).GetSignatureForMethod(this.handle, out callingConvention, out mrEx); bool makeBad = (mrEx != null); // If method is not generic, let's assign empty list for type parameters if (!SignatureHeader.IsGeneric(callingConvention) && lazyTypeParameters.IsDefault) { ImmutableInterlocked.InterlockedCompareExchange(ref lazyTypeParameters, ImmutableArray<TypeParameterSymbol>.Empty, default(ImmutableArray<TypeParameterSymbol>)); } int count = paramInfo.Length - 1; ImmutableArray<ParameterSymbol> @params; bool isBadParameter; if (count > 0) { ParameterSymbol[] parameterCreation = new ParameterSymbol[count]; for (int i = 0; i < count; i++) { parameterCreation[i] = new PEParameterSymbol(moduleSymbol, this, i, paramInfo[i + 1], out isBadParameter); if (isBadParameter) { makeBad = true; } } @params = parameterCreation.AsImmutableOrNull(); } else { @params = ImmutableArray<ParameterSymbol>.Empty; } // paramInfo[0] contains information about return "parameter" Debug.Assert(!paramInfo[0].IsByRef); // Dynamify object type if necessary paramInfo[0].Type = paramInfo[0].Type.AsDynamicIfNoPia(this.containingType); var returnParam = new PEParameterSymbol(moduleSymbol, this, 0, paramInfo[0], out isBadParameter); if (makeBad || isBadParameter) { var old = Interlocked.CompareExchange(ref lazyUseSiteDiagnostic, new CSDiagnosticInfo(ErrorCode.ERR_BindToBogus, this), CSDiagnosticInfo.EmptyErrorInfo); Debug.Assert((object)old == (object)CSDiagnosticInfo.EmptyErrorInfo || ((object)old != null && old.Code == (int)ErrorCode.ERR_BindToBogus && old.Arguments.Length == 1 && old.Arguments[0] == (object)this)); } var signature = new SignatureData(callingConvention, @params, returnParam); Interlocked.CompareExchange(ref lazySignature, signature, null); }