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));
            }
Beispiel #2
0
            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 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);
Beispiel #4
0
            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));
            }