private SignatureData 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.InterlockedInitialize(ref _lazyTypeParameters, ImmutableArray <TypeParameterSymbol> .Empty); } int count = paramInfo.Length - 1; ImmutableArray <ParameterSymbol> @params; bool isBadParameter; if (count > 0) { var builder = ImmutableArray.CreateBuilder <ParameterSymbol>(count); for (int i = 0; i < count; i++) { builder.Add(PEParameterSymbol.Create(moduleSymbol, this, i, paramInfo[i + 1], out isBadParameter)); if (isBadParameter) { makeBad = true; } } @params = builder.ToImmutable(); } else { @params = ImmutableArray <ParameterSymbol> .Empty; } // Dynamify object type if necessary var returnType = paramInfo[0].Type.AsDynamicIfNoPia(_containingType); // Check for tuple type returnType = TupleTypeDecoder.DecodeTupleTypesIfApplicable(returnType, paramInfo[0].Handle, moduleSymbol); paramInfo[0].Type = returnType; var returnParam = PEParameterSymbol.Create(moduleSymbol, this, 0, paramInfo[0], out isBadParameter); if (makeBad || isBadParameter) { InitializeUseSiteDiagnostic(new CSDiagnosticInfo(ErrorCode.ERR_BindToBogus, this)); } var signature = new SignatureData(signatureHeader, @params, returnParam); return(InterlockedOperations.Initialize(ref _lazySignature, signature)); }
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; // https://github.com/dotnet/roslyn/issues/29821: handle extra annotations parameters[ordinal] = PEParameterSymbol.Create(moduleSymbol, property, isPropertyVirtual, ordinal, paramHandle, propertyParam, nullableContext: property, extraAnnotations: default, out isBad);
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, out isBad); if (isBad) { anyParameterIsBad = true; } } return(parameters.AsImmutableOrNull()); }