public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var methodIndex = reader.ReadInteger(); var ordinal = reader.ReadInteger(); var typeParameter = reader.ResolveMethod(methodIndex).TypeParameters[ordinal]; return(new SymbolKeyResolution(typeParameter)); }
public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string failureReason) { var methodIndex = reader.ReadInteger(); var ordinal = reader.ReadInteger(); var method = reader.ResolveMethod(methodIndex); var typeParameter = method?.TypeParameters[ordinal]; if (typeParameter == null) { failureReason = $"({nameof(TypeParameterOrdinalSymbolKey)} failed)"; return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string?failureReason) { var cancellationToken = reader.CancellationToken; var name = reader.ReadString(); var kind = (SymbolKind)reader.ReadInteger(); var locations = reader.ReadLocationArray(out var locationsFailureReason); var ordinal = reader.ReadInteger(); if (locationsFailureReason != null) { failureReason = $"({nameof(BodyLevelSymbolKey)} {nameof(locations)} failed -> {locationsFailureReason})"; return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var metadataName = reader.ReadString(); var containingSymbolResolution = reader.ReadSymbolKey(); var arity = reader.ReadInteger(); var typeKind = (TypeKind)reader.ReadInteger(); var isUnboundGenericType = reader.ReadBoolean(); var typeArgumentsOpt = reader.ReadSymbolKeyArray(); var types = GetAllSymbols <INamespaceOrTypeSymbol>(containingSymbolResolution).SelectMany( s => Resolve(reader, s, metadataName, arity, typeKind, isUnboundGenericType, typeArgumentsOpt)); return(CreateSymbolInfo(types)); }
public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string?failureReason) { var cancellationToken = reader.CancellationToken; var name = reader.ReadString() !; var kind = (SymbolKind)reader.ReadInteger(); #pragma warning disable IDE0007 // Use implicit type PooledArrayBuilder <Location> locations = reader.ReadLocationArray(out var locationsFailureReason) !; #pragma warning restore IDE0007 // Use implicit type var ordinal = reader.ReadInteger(); if (locationsFailureReason != null) { failureReason = $"({nameof(BodyLevelSymbolKey)} {nameof(locations)} failed -> {locationsFailureReason})"; return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var elementTypeResolution = reader.ReadSymbolKey(); var rank = reader.ReadInteger(); return(CreateSymbolInfo(GetAllSymbols <ITypeSymbol>(elementTypeResolution) .Select(s => reader.Compilation.CreateArrayTypeSymbol(s, rank)))); }
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var name = reader.ReadString(); var containingSymbolResolution = reader.ReadSymbolKey(); var arity = reader.ReadInteger(); using var typeArguments = reader.ReadSymbolKeyArray <ITypeSymbol>(); if (typeArguments.IsDefault) { return(default);
protected sealed override SymbolKeyResolution Resolve( SymbolKeyReader reader, IFunctionPointerTypeSymbol?contextualSymbol, out string?failureReason) { var callingConvention = (SignatureCallingConvention)reader.ReadInteger(); var callingConventionModifiers = ImmutableArray <INamedTypeSymbol> .Empty; if (callingConvention == SignatureCallingConvention.Unmanaged) { using var modifiersBuilder = reader.ReadSymbolKeyArray <IFunctionPointerTypeSymbol, INamedTypeSymbol>( contextualSymbol,
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var metadataName = reader.ReadString(); var containingSymbolResolution = reader.ReadSymbolKey(); var arity = reader.ReadInteger(); var isPartialMethodImplementationPart = reader.ReadBoolean(); var parameterRefKinds = reader.ReadRefKindArray(); // For each method that we look at, we'll have to resolve the parameter list and // return type in the context of that method. i.e. if we have Foo<T>(IList<T> list) // then we'll need to have marked that we're on the Foo<T> method so that we know // 'T' in IList<T> resolves to. // // Because of this, we keep track of where we are in the reader. Before resolving // every parameter list, we'll mark which method we're on and we'll rewind to this // point. var beforeParametersPosition = reader.Position; var result = new List <IMethodSymbol>(); var namedTypes = containingSymbolResolution.GetAllSymbols().OfType <INamedTypeSymbol>(); foreach (var namedType in namedTypes) { var method = Resolve(reader, metadataName, arity, isPartialMethodImplementationPart, parameterRefKinds, beforeParametersPosition, namedType); // Note: after finding the first method that matches we stop. That's necessary // as we cache results while searching. We don't want to override these positive // matches with a negative ones if we were to continue searching. if (method != null) { result.Add(method); break; } } if (reader.Position == beforeParametersPosition) { // We didn't find any candidates. We still need to stream through this // method signature so the reader is in a proper position. // Push an null-method to our stack so that any method-type-parameters // can at least be read (if not resolved) properly. reader.PushMethod(methodOpt: null); var parameterTypeResolutions = reader.ReadSymbolKeyArray(); var returnType = GetFirstSymbol <ITypeSymbol>(reader.ReadSymbolKey()); reader.PopMethod(methodOpt: null); } return(CreateSymbolInfo(result)); }
public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string failureReason) { var name = reader.ReadString(); var containingSymbolResolution = ResolveContainer(reader, out var containingSymbolFailureReason); var arity = reader.ReadInteger(); using var typeArguments = reader.ReadSymbolKeyArray <ITypeSymbol>(out var typeArgumentsFailureReason); if (containingSymbolFailureReason != null) { failureReason = $"({nameof(ErrorTypeSymbolKey)} {nameof(containingSymbolResolution)} failed -> {containingSymbolFailureReason})"; return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var cancellationToken = reader.CancellationToken; var name = reader.ReadString(); var kind = (SymbolKind)reader.ReadInteger(); var locations = reader.ReadLocationArray(); var ordinal = reader.ReadInteger(); // First check if we can recover the symbol just through the original location. foreach (var loc in locations) { var resolutionOpt = reader.ResolveLocation(loc); if (resolutionOpt.HasValue) { var resolution = resolutionOpt.Value; var symbol = resolution.GetAnySymbol(); if (symbol?.Kind == kind && SymbolKey.Equals(reader.Compilation, name, symbol.Name)) { return(resolution); } } } // Couldn't recover. See if we can still find a match across the textual drift. if (ordinal != int.MaxValue && TryGetSemanticModel(reader.Compilation, locations[0].SourceTree, out var semanticModel)) { foreach (var symbol in EnumerateSymbols(semanticModel, kind, name, cancellationToken)) { if (symbol.ordinal == ordinal) { return(new SymbolKeyResolution(symbol.symbol)); } } } return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string?failureReason) { var metadataName = reader.ReadString() !; var containingSymbolResolution = reader.ReadSymbolKey(out var containingSymbolFailureReason); var arity = reader.ReadInteger(); var isUnboundGenericType = reader.ReadBoolean(); using var typeArguments = reader.ReadSymbolKeyArray <ITypeSymbol>(out var typeArgumentsFailureReason); if (containingSymbolFailureReason != null) { failureReason = $"({nameof(NamedTypeSymbolKey)} {nameof(containingSymbolFailureReason)} failed -> {containingSymbolFailureReason})"; return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader, out string?failureReason) { var callingConvention = (SignatureCallingConvention)reader.ReadInteger(); var callingConventionModifiers = ImmutableArray <INamedTypeSymbol> .Empty; if (callingConvention == SignatureCallingConvention.Unmanaged) { using var modifiersBuilder = reader.ReadSymbolKeyArray <INamedTypeSymbol>(out var conventionTypesFailureReason); if (conventionTypesFailureReason != null) { failureReason = $"({nameof(FunctionPointerTypeSymbolKey)} {nameof(callingConventionModifiers)} failed -> {conventionTypesFailureReason})"; return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var localName = reader.ReadString(); var containingSymbolResolution = reader.ReadSymbolKey(); var ordinal = reader.ReadInteger(); var kind = (SymbolKind)reader.ReadInteger(); var containingSymbol = containingSymbolResolution.Symbol; if (containingSymbol != null) { foreach (var symbol in EnumerateSymbols( reader.Compilation, containingSymbol, kind, localName, reader.CancellationToken)) { if (symbol.ordinal == ordinal) { return(new SymbolKeyResolution(symbol.symbol)); } } } return(new SymbolKeyResolution()); }
protected sealed override SymbolKeyResolution Resolve( SymbolKeyReader reader, INamedTypeSymbol?contextualType, out string?failureReason) { var name = reader.ReadRequiredString(); var containingSymbolResolution = ResolveContainer(reader, contextualType, out var containingSymbolFailureReason); var arity = reader.ReadInteger(); var isConstructed = reader.ReadBoolean(); using var typeArguments = reader.ReadSymbolKeyArray <INamedTypeSymbol, ITypeSymbol>( contextualType, getContextualSymbol: static (contextualType, i) => SafeGet(contextualType.TypeArguments, i), out var typeArgumentsFailureReason); if (containingSymbolFailureReason != null) { failureReason = $"({nameof(ErrorTypeSymbolKey)} {nameof(containingSymbolResolution)} failed -> {containingSymbolFailureReason})"; return(default);
protected sealed override SymbolKeyResolution Resolve( SymbolKeyReader reader, INamedTypeSymbol?contextualSymbol, out string?failureReason) { var containingSymbolResolution = reader.ReadSymbolKey(contextualSymbol?.ContainingSymbol, out var containingSymbolFailureReason); var name = reader.ReadRequiredString(); var arity = reader.ReadInteger(); var filePath = reader.ReadString(); var isUnboundGenericType = reader.ReadBoolean(); using var typeArguments = reader.ReadSymbolKeyArray <INamedTypeSymbol, ITypeSymbol>( contextualSymbol, getContextualSymbol: static (contextualType, i) => SafeGet(contextualType.TypeArguments, i), out var typeArgumentsFailureReason); if (typeArgumentsFailureReason != null) { Contract.ThrowIfFalse(typeArguments.IsDefault); failureReason = $"({nameof(NamedTypeSymbolKey)} {nameof(typeArguments)} failed -> {typeArgumentsFailureReason})"; return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var name = reader.ReadString(); var containingSymbolResolution = reader.ReadSymbolKey(); var arity = reader.ReadInteger(); var typeArgumentResolutions = reader.ReadSymbolKeyArray(); var errorTypes = ResolveErrorTypes(reader, containingSymbolResolution, name, arity); if (typeArgumentResolutions.IsDefault) { return(CreateSymbolInfo(errorTypes)); } var typeArguments = typeArgumentResolutions.Select( r => GetFirstSymbol <ITypeSymbol>(r)).ToArray(); if (typeArguments.Any(s_typeIsNull)) { return(default);
protected sealed override SymbolKeyResolution Resolve( SymbolKeyReader reader, INamespaceSymbol?contextualSymbol, out string?failureReason) { var metadataName = reader.ReadRequiredString(); var containerKind = reader.ReadInteger(); var containingContextualSymbol = containerKind switch { 0 => contextualSymbol?.ContainingNamespace, 1 => contextualSymbol?.ContainingModule, 2 => contextualSymbol?.ContainingAssembly, 3 => (ISymbol?)null, _ => throw ExceptionUtilities.UnexpectedValue(containerKind), }; // Namespaces are never parented by types, so there can be no contextual type to resolve our container. var containingSymbolResolution = reader.ReadSymbolKey( containingContextualSymbol, out var containingSymbolFailureReason); if (containingSymbolFailureReason != null) { failureReason = $"({nameof(EventSymbolKey)} {nameof(containingSymbolResolution)} failed -> {containingSymbolFailureReason})"; return(default);