private static IMethodSymbol Resolve( SymbolKeyReader reader, bool isPartialMethodImplementationPart, IMethodSymbol method) { var originalParameterTypeResolutions = reader.ReadSymbolKeyArray(); var returnType = GetFirstSymbol <ITypeSymbol>(reader.ReadSymbolKey()); var originalParameterTypes = originalParameterTypeResolutions.Select( r => GetFirstSymbol <ITypeSymbol>(r)).ToArray(); if (!originalParameterTypes.Any(s_typeIsNull)) { if (reader.ParameterTypesMatch(method.OriginalDefinition.Parameters, originalParameterTypes)) { if (returnType == null || reader.Comparer.Equals(returnType, method.ReturnType)) { if (isPartialMethodImplementationPart) { method = method.PartialImplementationPart ?? method; } Debug.Assert(method != null); return(method); } } } return(null); }
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var metadataName = reader.ReadString(); var containingSymbolResolution = reader.ReadSymbolKey(); var isIndexer = reader.ReadBoolean(); var refKinds = reader.ReadRefKindArray(); var originalParameterTypes = reader.ReadSymbolKeyArray().Select( r => GetFirstSymbol <ITypeSymbol>(r)).ToArray(); if (originalParameterTypes.Any(s_typeIsNull)) { return(default(SymbolKeyResolution)); } var properties = containingSymbolResolution.GetAllSymbols().OfType <INamedTypeSymbol>() .SelectMany(t => t.GetMembers()) .OfType <IPropertySymbol>() .Where(p => p.Parameters.Length == refKinds.Length && p.MetadataName == metadataName && p.IsIndexer == isIndexer); var matchingProperties = properties.Where(p => ParameterRefKindsMatch(p.OriginalDefinition.Parameters, refKinds) && reader.ParameterTypesMatch(p.OriginalDefinition.Parameters, originalParameterTypes)); return(CreateSymbolInfo(matchingProperties)); }
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);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var constructedFrom = reader.ReadSymbolKey(); using var typeArguments = reader.ReadSymbolKeyArray <ITypeSymbol>(); if (constructedFrom.SymbolCount == 0 || typeArguments.IsDefault) { return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var metadataName = reader.ReadString(); var containingSymbolResolution = reader.ReadSymbolKey(); var isIndexer = reader.ReadBoolean(); var refKinds = reader.ReadRefKindArray(); var originalParameterTypes = reader.ReadSymbolKeyArray().Select( r => GetFirstSymbol <ITypeSymbol>(r)).ToArray(); if (originalParameterTypes.Any(s_typeIsNull)) { return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var constructedFromResolution = reader.ReadSymbolKey(); var typeArgumentResolutions = reader.ReadSymbolKeyArray(); Debug.Assert(!typeArgumentResolutions.IsDefault); var typeArguments = typeArgumentResolutions.Select( r => GetFirstSymbol <ITypeSymbol>(r)).ToArray(); if (typeArguments.Any(s_typeIsNull)) { return(default);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var metadataName = reader.ReadString(); var containingTypeResolution = reader.ReadSymbolKey(); var isIndexer = reader.ReadBoolean(); using var refKinds = reader.ReadRefKindArray(); using var parameterTypes = reader.ReadSymbolKeyArray <ITypeSymbol>(); if (parameterTypes.IsDefault) { return(default);
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) { 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) { var isError = reader.ReadBoolean(); if (isError) { using var elementTypes = reader.ReadSymbolKeyArray <ITypeSymbol>(); using var elementNames = reader.ReadStringArray(); var elementLocations = ReadElementLocations(reader); if (!elementTypes.IsDefault) { try { var result = reader.Compilation.CreateTupleTypeSymbol( elementTypes.ToImmutable(), elementNames.ToImmutable(), elementLocations); return(new SymbolKeyResolution(result)); } catch (ArgumentException) { } } } else { var underlyingTypeResolution = reader.ReadSymbolKey(); using var elementNamesBuilder = reader.ReadStringArray(); var elementLocations = ReadElementLocations(reader); try { using var result = PooledArrayBuilder <INamedTypeSymbol> .GetInstance(); var elementNames = elementNamesBuilder.ToImmutable(); foreach (var namedType in underlyingTypeResolution.OfType <INamedTypeSymbol>()) { result.AddIfNotNull(reader.Compilation.CreateTupleTypeSymbol( namedType, elementNames, elementLocations)); } return(CreateResolution(result)); } catch (ArgumentException) { } } return(new SymbolKeyResolution(reader.Compilation.ObjectType)); }
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);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var isError = reader.ReadBoolean(); if (isError) { var elementTypes = reader.ReadSymbolKeyArray().SelectAsArray(r => r.GetAnySymbol() as ITypeSymbol); var elementNames = reader.ReadStringArray(); var elementLocations = ReadElementLocations(reader); if (!elementTypes.Any(t => t == null)) { try { var result = reader.Compilation.CreateTupleTypeSymbol( elementTypes, elementNames, elementLocations); return(new SymbolKeyResolution(result)); } catch (ArgumentException) { } } } else { var underlyingTypeResolution = reader.ReadSymbolKey(); var elementNames = reader.ReadStringArray(); var elementLocations = ReadElementLocations(reader); try { var result = GetAllSymbols <INamedTypeSymbol>(underlyingTypeResolution).Select( t => reader.Compilation.CreateTupleTypeSymbol(t, elementNames, elementLocations)); return(CreateSymbolInfo(result)); } catch (ArgumentException) { } } return(new SymbolKeyResolution(reader.Compilation.ObjectType)); }
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 constructedFromResolution = reader.ReadSymbolKey(); var typeArgumentResolutions = reader.ReadSymbolKeyArray(); Debug.Assert(!typeArgumentResolutions.IsDefault); var typeArguments = typeArgumentResolutions.Select( r => GetFirstSymbol <ITypeSymbol>(r)).ToArray(); if (typeArguments.Any(s_typeIsNull)) { return(default(SymbolKeyResolution)); } var result = constructedFromResolution.GetAllSymbols() .OfType <IMethodSymbol>() .Select(m => m.Construct(typeArguments)); return(CreateSymbolInfo(result)); }
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);
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { var propertyTypeSymbols = reader.ReadSymbolKeyArray(); var propertyTypes = propertyTypeSymbols.Select(r => GetFirstSymbol <ITypeSymbol>(r)).ToImmutableArray(); var propertyNames = reader.ReadStringArray(); if (propertyTypes.Length == propertyNames.Length) { try { var anonymousType = reader.Compilation.CreateAnonymousTypeSymbol(propertyTypes, propertyNames); return(new SymbolKeyResolution(anonymousType)); } catch (ArgumentException) { } } return(new SymbolKeyResolution(reader.Compilation.ObjectType)); }
public static SymbolKeyResolution Resolve(SymbolKeyReader reader) { using var propertyTypes = reader.ReadSymbolKeyArray <ITypeSymbol>(); using var propertyNames = reader.ReadStringArray(); using var propertyIsReadOnly = reader.ReadBooleanArray(); using var propertyLocations = reader.ReadLocationArray(); if (!propertyTypes.IsDefault) { try { var anonymousType = reader.Compilation.CreateAnonymousTypeSymbol( propertyTypes.ToImmutable(), propertyNames.ToImmutable(), propertyIsReadOnly.ToImmutable(), propertyLocations.ToImmutable()); return(new SymbolKeyResolution(anonymousType)); } catch (ArgumentException) { } } return(new SymbolKeyResolution(reader.Compilation.ObjectType)); }