private static TypeSymbol DecodeTupleTypesInternal(TypeSymbol metadataType, AssemblySymbol containingAssembly, ImmutableArray <string> elementNames, bool hasTupleElementNamesAttribute) { Debug.Assert((object)metadataType != null); Debug.Assert((object)containingAssembly != null); var decoder = new TupleTypeDecoder(elementNames, containingAssembly); try { var decoded = decoder.DecodeType(metadataType); // If not all of the names have been used, the metadata is bad if (!hasTupleElementNamesAttribute || decoder._namesIndex == 0) { return(decoded); } } catch (InvalidOperationException) { // Indicates that the tuple info in the attribute didn't match // the type. Bad metadata. } // Bad metadata return(new UnsupportedMetadataTypeSymbol()); }
private static TypeSymbol DecodeTupleTypesInternal(TypeSymbol metadataType, ImmutableArray <string?> elementNames, bool hasTupleElementNamesAttribute) { RoslynDebug.AssertNotNull(metadataType); var decoder = new TupleTypeDecoder(elementNames); try { var decoded = decoder.DecodeType(metadataType); // If not all of the names have been used, the metadata is bad if (!hasTupleElementNamesAttribute || decoder._namesIndex == 0) { return(decoded); } } catch (InvalidOperationException) { // Indicates that the tuple info in the attribute didn't match // the type. Bad metadata. } if (metadataType.HasUseSiteError) { return(metadataType); } // Bad metadata return(new UnsupportedMetadataTypeSymbol()); }
private static TypeSymbol DecodeTupleTypesInternal( TypeSymbol metadataType, ImmutableArray <string?> elementNames, bool hasTupleElementNamesAttribute ) { RoslynDebug.AssertNotNull(metadataType); var decoder = new TupleTypeDecoder(elementNames); var decoded = decoder.DecodeType(metadataType); if (!decoder._decodingFailed) { if (!hasTupleElementNamesAttribute || decoder._namesIndex == 0) { return(decoded); } } // If not all of the names have been used, the metadata is bad if (decoder._foundUsableErrorType) { return(metadataType); } // Bad metadata return(new UnsupportedMetadataTypeSymbol()); }
private static TypeSymbol DecodeTupleTypesInternal(TypeSymbol metadataType, AssemblySymbol containingAssembly, ImmutableArray<string> elementNames, bool hasTupleElementNamesAttribute) { Debug.Assert((object)metadataType != null); Debug.Assert((object)containingAssembly != null); var decoder = new TupleTypeDecoder(elementNames, containingAssembly); try { var decoded = decoder.DecodeType(metadataType); // If not all of the names have been used, the metadata is bad if (!hasTupleElementNamesAttribute || decoder._namesIndex == 0) { return decoded; } } catch (InvalidOperationException) { // Indicates that the tuple info in the attribute didn't match // the type. Bad metadata. } // Bad metadata return new UnsupportedMetadataTypeSymbol(); }
public static TypeSymbol DecodeTupleTypesIfApplicable( TypeSymbol metadataType, EntityHandle targetSymbolToken, PEModuleSymbol containingModule) { Debug.Assert((object)metadataType != null); Debug.Assert((object)containingModule != null); ImmutableArray<string> elementNames; var hasTupleElementNamesAttribute = containingModule .Module .HasTupleElementNamesAttribute(targetSymbolToken, out elementNames); // If we have the TupleElementNamesAttribute, but no names, that's // bad metadata if (hasTupleElementNamesAttribute && elementNames.IsDefaultOrEmpty) { return new UnsupportedMetadataTypeSymbol(); } var decoder = new TupleTypeDecoder(elementNames, containingModule.ContainingAssembly); try { var decoded = decoder.DecodeType(metadataType); // If not all of the names have been used, the metadata is bad if (!hasTupleElementNamesAttribute || decoder._namesIndex == 0) { return decoded; } } catch (InvalidOperationException) { // Indicates that the tuple info in the attribute didn't match // the type. Bad metadata. } // Bad metadata return new UnsupportedMetadataTypeSymbol(); }