Binder\Binder.cs (19)
240internal virtual Symbol? ContainingMemberOrLambda
426var member = this.ContainingMemberOrLambda;
444var containingMember = this.ContainingMemberOrLambda;
592internal void ReportDiagnosticsIfObsolete(DiagnosticBag diagnostics, Symbol symbol, SyntaxNode node, bool hasBaseReceiver)
602internal void ReportDiagnosticsIfObsolete(DiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, bool hasBaseReceiver)
616internal void ReportDiagnosticsIfObsolete(BindingDiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, bool hasBaseReceiver)
634Symbol symbol,
637Symbol? containingMember,
661Symbol leastOverriddenSymbol = symbol.GetLeastOverriddenMember(containingType);
700Symbol symbol,
703Symbol? containingMember,
713internal static ObsoleteDiagnosticKind ReportDiagnosticsIfObsoleteInternal(DiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, Symbol? containingMember, BinderFlags location)
744internal static void ReportDiagnosticsIfObsoleteInternal(BindingDiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, Symbol containingMember, BinderFlags location)
772Symbol symbol,
780Symbol symbol,
789Symbol symbol,
917var currentContainer = scope.ContainingMemberOrLambda;
Binder\Binder.ValueChecks.cs (18)
32internal Symbol Symbol { get; }
56private MethodInfo(Symbol symbol, MethodSymbol? method, MethodSymbol? setMethod)
595Symbol otherSymbol = null;
630(object)otherSymbol == null ? ImmutableArray<Symbol>.Empty : ImmutableArray.Create(otherSymbol),
1415Symbol containing = this.ContainingMemberOrLambda;
1624private static bool RequiresVariableReceiver(BoundExpression receiver, Symbol symbol)
1728var containing = this.ContainingMemberOrLambda;
1883var containingMember = ContainingMemberOrLambda;
1899private bool IsBadBaseAccess(SyntaxNode node, BoundExpression receiverOpt, Symbol member, BindingDiagnosticBag diagnostics,
1900Symbol propertyOrEventSymbolOpt = null)
2141var symbol = methodInfo.Symbol;
2233var symbol = methodInfo.Symbol;
2501static bool hasRefLikeReturn(Symbol symbol)
2729Symbol symbol,
2741var symbol = argument switch
2790var symbol = methodInfo.Symbol;
3027public override Symbol ContainingSymbol
3259private static void ReportReadOnlyError(Symbol symbol, SyntaxNode node, BindValueKind kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
Binder\Binder_Attributes.cs (7)
30ImmutableArray<Binder> binders, ImmutableArray<AttributeSyntax> attributesToBind, Symbol ownerSymbol, NamedTypeSymbol[] boundAttributeTypes,
138internal BoundAttribute BindAttribute(AttributeSyntax node, NamedTypeSymbol attributeType, Symbol? attributedMember, BindingDiagnosticBag diagnostics)
155private static BoundAttribute BindAttributeCore(Binder binder, AttributeSyntax node, NamedTypeSymbol attributeType, Symbol? attributedMember, BindingDiagnosticBag diagnostics)
528Symbol namedArgumentNameSymbol = BindNamedAttributeArgumentName(namedArgument, attributeType, diagnostics, out wasError, out resultKind);
592private Symbol BindNamedAttributeArgumentName(AttributeArgumentSyntax namedArgument, NamedTypeSymbol attributeType, BindingDiagnosticBag diagnostics, out bool wasError, out LookupResultKind resultKind)
601Symbol resultSymbol = this.ResultSymbol(result, name, 0, identifierName, diagnostics, false, out wasError, qualifierOpt: null);
607private TypeSymbol BindNamedAttributeArgumentType(AttributeArgumentSyntax namedArgument, Symbol namedArgumentNameSymbol, NamedTypeSymbol attributeType, BindingDiagnosticBag diagnostics)
Binder\Binder_Crefs.cs (71)
18internal ImmutableArray<Symbol> BindCref(CrefSyntax syntax, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
20ImmutableArray<Symbol> symbols = BindCrefInternal(syntax, out ambiguityWinner, diagnostics);
26private ImmutableArray<Symbol> BindCrefInternal(CrefSyntax syntax, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
44private ImmutableArray<Symbol> BindTypeCref(TypeCrefSyntax syntax, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
60return ImmutableArray.Create<Symbol>(result);
63private ImmutableArray<Symbol> BindQualifiedCref(QualifiedCrefSyntax syntax, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
99private ImmutableArray<Symbol> BindMemberCref(MemberCrefSyntax syntax, NamespaceOrTypeSymbol? containerOpt, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
110return ImmutableArray<Symbol>.Empty;
113ImmutableArray<Symbol> result;
142private ImmutableArray<Symbol> BindNameMemberCref(NameMemberCrefSyntax syntax, NamespaceOrTypeSymbol? containerOpt, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
172return ImmutableArray<Symbol>.Empty;
175ImmutableArray<Symbol> sortedSymbols = ComputeSortedCrefMembers(syntax, containerOpt, memberName, memberNameText, arity, syntax.Parameters != null, diagnostics);
180return ImmutableArray<Symbol>.Empty;
193private ImmutableArray<Symbol> BindIndexerMemberCref(IndexerMemberCrefSyntax syntax, NamespaceOrTypeSymbol? containerOpt, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
197ImmutableArray<Symbol> sortedSymbols = ComputeSortedCrefMembers(syntax, containerOpt, WellKnownMemberNames.Indexer, memberNameText: WellKnownMemberNames.Indexer, arity, syntax.Parameters != null, diagnostics);
202return ImmutableArray<Symbol>.Empty;
221private ImmutableArray<Symbol> BindOperatorMemberCref(OperatorMemberCrefSyntax syntax, NamespaceOrTypeSymbol? containerOpt, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
242return ImmutableArray<Symbol>.Empty;
245ImmutableArray<Symbol> sortedSymbols = ComputeSortedCrefMembers(syntax, containerOpt, memberName, memberNameText: memberName, arity, syntax.Parameters != null, diagnostics);
250return ImmutableArray<Symbol>.Empty;
264private ImmutableArray<Symbol> BindConversionOperatorMemberCref(ConversionOperatorMemberCrefSyntax syntax, NamespaceOrTypeSymbol? containerOpt, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
277return ImmutableArray<Symbol>.Empty;
291ImmutableArray<Symbol> sortedSymbols = ComputeSortedCrefMembers(syntax, containerOpt, memberName, memberNameText: memberName, arity, syntax.Parameters != null, diagnostics);
296return ImmutableArray<Symbol>.Empty;
308return ImmutableArray<Symbol>.Empty;
329private ImmutableArray<Symbol> ComputeSortedCrefMembers(CSharpSyntaxNode syntax, NamespaceOrTypeSymbol? containerOpt, string memberName, string memberNameText, int arity, bool hasParameterList, BindingDiagnosticBag diagnostics)
337private ImmutableArray<Symbol> ComputeSortedCrefMembers(NamespaceOrTypeSymbol? containerOpt, string memberName, string memberNameText, int arity, bool hasParameterList, CSharpSyntaxNode syntax,
342ArrayBuilder<Symbol> builder;
360builder = ArrayBuilder<Symbol>.GetInstance();
372builder = ArrayBuilder<Symbol>.GetInstance();
447return ImmutableArray<Symbol>.Empty;
450builder = ArrayBuilder<Symbol>.GetInstance(numInstanceConstructors);
455return ImmutableArray<Symbol>.Empty;
476private ImmutableArray<Symbol> ProcessCrefMemberLookupResults(
477ImmutableArray<Symbol> symbols,
482out Symbol? ambiguityWinner,
492ArrayBuilder<Symbol> candidates = ArrayBuilder<Symbol>.GetInstance();
496ImmutableArray<Symbol> results = PerformCrefOverloadResolution(candidates, parameterSymbols, arity, memberSyntax, out ambiguityWinner, diagnostics);
627private ImmutableArray<Symbol> ProcessParameterlessCrefMemberLookupResults(
628ImmutableArray<Symbol> symbols,
632out Symbol? ambiguityWinner,
642foreach (Symbol s in symbols)
673Symbol symbol = symbols[0];
680ArrayBuilder<Symbol> unwrappedSymbols = ArrayBuilder<Symbol>.GetInstance(symbols.Length);
682foreach (Symbol wrapped in symbols)
725return ImmutableArray.Create<Symbol>(ConstructWithCrefTypeParameters(arity, typeArgumentListSyntax, symbol));
732private void GetCrefOverloadResolutionCandidates(ImmutableArray<Symbol> symbols, int arity, TypeArgumentListSyntax? typeArgumentListSyntax, ArrayBuilder<Symbol> candidates)
734foreach (Symbol candidate in symbols)
736Symbol constructedCandidate = ConstructWithCrefTypeParameters(arity, typeArgumentListSyntax, candidate);
758private static ImmutableArray<Symbol> PerformCrefOverloadResolution(ArrayBuilder<Symbol> candidates, ImmutableArray<ParameterSymbol> parameterSymbols, int arity, MemberCrefSyntax memberSyntax, out Symbol? ambiguityWinner, BindingDiagnosticBag diagnostics)
760ArrayBuilder<Symbol>? viable = null;
762foreach (Symbol candidate in candidates)
770Symbol signatureMember;
834viable = ArrayBuilder<Symbol>.GetInstance();
861return ImmutableArray<Symbol>.Empty;
881private Symbol ConstructWithCrefTypeParameters(int arity, TypeArgumentListSyntax? typeArgumentListSyntax, Symbol symbol)
Binder\Binder_Expressions.cs (77)
37var memberOpt = this.ContainingMemberOrLambda?.ContainingNonLambdaMember();
108return BadExpression(syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty);
116return BadExpression(syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, childNode);
124return BadExpression(syntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, childNodes);
132return BadExpression(syntax, lookupResultKind, ImmutableArray<Symbol>.Empty);
140return BadExpression(syntax, lookupResultKind, ImmutableArray<Symbol>.Empty, childNode);
146private BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray<Symbol> symbols)
159private BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray<Symbol> symbols, BoundExpression childNode)
172private BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray<Symbol> symbols, ImmutableArray<BoundExpression> childNodes, bool wasCompilerGenerated = false)
214ArrayBuilder<Symbol> symbols = ArrayBuilder<Symbol>.GetInstance();
315if (op.NoCommonTypeError == ErrorCode.ERR_InvalidQM && trueArg is Symbol trueSymbol && falseArg is Symbol falseSymbol)
854node, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, ImmutableArray.Create<BoundExpression>(BindToTypeForErrorRecovery(BindValue(node.Expression, BindingDiagnosticBag.Discarded, BindValueKind.RefersToLocation))),
1041argumentSyntax, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty,
1325Symbol container = this.ContainingMemberOrLambda;
1604var members = ArrayBuilder<Symbol>.GetInstance();
1605Symbol symbol = GetSymbolOrMethodOrPropertyGroup(lookupResult, node, name, node.Arity, members, diagnostics, out isError, qualifierOpt: null); // reports diagnostics in result.
1728void reportPrimaryConstructorParameterShadowing(SimpleNameSyntax node, Symbol symbol, string name, bool invoked, LookupResult lookupResult, ArrayBuilder<Symbol> members, BindingDiagnosticBag diagnostics)
1840private BoundExpression SynthesizeMethodGroupReceiver(CSharpSyntaxNode syntax, ArrayBuilder<Symbol> members)
1933private bool IsBadLocalOrParameterCapture(Symbol symbol, TypeSymbol type, RefKind refKind)
1950private BoundExpression BindNonMethod(SimpleNameSyntax node, Symbol symbol, BindingDiagnosticBag diagnostics, LookupResultKind resultKind, bool indexed, bool isError)
2228private bool ReportSimpleProgramLocalReferencedOutsideOfTopLevelStatement(SimpleNameSyntax node, Symbol symbol, BindingDiagnosticBag diagnostics)
2245private BoundExpression SynthesizeReceiver(SyntaxNode node, Symbol member, BindingDiagnosticBag diagnostics)
2281var containingMember = ContainingMember();
2316internal Symbol ContainingMember()
2346var containingMember = this.ContainingMemberOrLambda;
2425var symbol = this.BindNamespaceAliasSymbol(node, diagnostics);
2429private static BoundExpression CreateBoundNamespaceOrTypeExpression(ExpressionSyntax node, Symbol symbol)
3245internal static void CheckRestrictedTypeInAsyncMethod(Symbol containingSymbol, TypeSymbol type, BindingDiagnosticBag diagnostics, SyntaxNode syntax)
3262foreach (Symbol member in ContainingType?.GetMembers(identifier) ?? ImmutableArray<Symbol>.Empty)
3383where TMember : Symbol
4454ImmutableArray<Symbol>.Empty,
4493ImmutableArray<Symbol>.Empty,
4825symbols: ImmutableArray<Symbol>.Empty,
4836symbols: ImmutableArray<Symbol>.Empty, //CONSIDER: we could look for a matching constructor on System.ValueType
4879symbols: ImmutableArray<Symbol>.Empty, //CONSIDER: we could look for a matching constructor on System.ValueType
5200return new BoundBadExpression(syntax, LookupResultKind.Empty, ImmutableArray<Symbol?>.Empty, ImmutableArray<BoundExpression>.Empty, CreateErrorType());
5409return new BoundBadExpression(node, LookupResultKind.NotInvocable, StaticCast<Symbol>.From(type.InstanceConstructors), ImmutableArray.Create(argument), type);
5456return new BoundBadExpression(node, LookupResultKind.OverloadResolutionFailure, StaticCast<Symbol>.From(type.InstanceConstructors), childNodes, type);
5553return new BoundBadExpression(node, LookupResultKind.NotCreatable, ImmutableArray.Create<Symbol?>(type), children.ToImmutableAndFree(), type) { WasCompilerGenerated = wasCompilerGenerated };
6082private static ImmutableSegmentedDictionary<string, Symbol> GetMembersRequiringInitialization(MethodSymbol constructor)
6087return ImmutableSegmentedDictionary<string, Symbol>.Empty;
6099ImmutableSegmentedDictionary<string, Symbol> requiredMembers = GetMembersRequiringInitialization(constructor);
6121var memberSymbol = assignmentOperator.Left switch
6159private static void ReportMembersRequiringInitialization(SyntaxNode creationSyntax, ImmutableSegmentedDictionary<string, Symbol>.Builder requiredMembersBuilder, BindingDiagnosticBag diagnostics)
6389return BadExpression(elementInitializer, LookupResultKind.NotInvocable, ImmutableArray<Symbol>.Empty, boundElementInitializerExpressions);
6840ArrayBuilder<Symbol> symbols = ArrayBuilder<Symbol>.GetInstance();
7020return new BoundBadExpression(node, LookupResultKind.OverloadResolutionFailure, ImmutableArray<Symbol>.Empty, children, interfaceType);
7448Symbol leftSymbol;
7769ArrayBuilder<Symbol> symbols = lookupResult.Symbols;
7774Symbol sym = ResultSymbol(lookupResult, rightName, rightArity, node, diagnostics, false, out wasError, ns, options);
8050ReportQueryLookupFailed(node, boundLeft, plainName, ImmutableArray<Symbol>.Empty, diagnostics);
8113return this.BindMemberAccessBadResult(syntax, node.Name, node.ReceiverOpt, node.LookupError, StaticCast<Symbol>.From(node.Methods), node.ResultKind);
8124ImmutableArray<Symbol> symbols,
8130foreach (var s in symbols)
8156var symbolOpt = symbols.Length == 1 ? symbols[0] : null;
8160(object)symbolOpt == null ? ImmutableArray<Symbol>.Empty : ImmutableArray.Create(symbolOpt),
8165private TypeSymbol GetNonMethodMemberType(Symbol symbolOpt)
8236var members = ArrayBuilder<Symbol>.GetInstance();
8239Symbol symbol = GetSymbolOrMethodOrPropertyGroup(lookupResult, right, plainName, arity, members, diagnostics, out wasError,
8484var members = ArrayBuilder<Symbol>.GetInstance();
8486Symbol symbol = GetSymbolOrMethodOrPropertyGroup(lookupResult, node, rightName, arity, members, diagnostics, out wasError, qualifierOpt: null);
8692private void CheckReceiverAndRuntimeSupportForSymbolAccess(SyntaxNode node, BoundExpression receiverOpt, Symbol symbol, BindingDiagnosticBag diagnostics)
8744static bool isNotImplementableInstanceMember(Symbol symbol)
8800Symbol symbol,
8848private Symbol GetSymbolOrMethodOrPropertyGroup(LookupResult result, SyntaxNode node, string plainName, int arity, ArrayBuilder<Symbol> methodOrPropertyGroup, BindingDiagnosticBag diagnostics, out bool wasError, NamespaceOrTypeSymbol qualifierOpt)
8858Symbol other = null; // different member type from 'methodOrPropertyGroup'
8930private static bool IsMethodOrPropertyGroup(ArrayBuilder<Symbol> members)
9268return new BoundBadExpression(node, LookupResultKind.Empty, ImmutableArray<Symbol>.Empty, childBoundNodes, CreateErrorType(), hasErrors: true);
9614foreach (Symbol symbol in lookupResult.Symbols)
10934return Symbol.ReportUseSiteDiagnostic(diagnosticInfo, diagnostics, getErrorLocation());
11032internal static bool MethodOrLambdaRequiresValue(Symbol symbol, CSharpCompilation compilation)
Binder\Binder_Lookup.cs (46)
302Symbol existingDefinition = submissionSymbols.Symbols.First();
336Symbol firstSymbol = submissionSymbols.Symbols.First();
447foreach (Symbol member in members)
521Symbol symbolWithoutSuffix;
527Symbol symbolWithSuffix = null;
587private bool IsAmbiguousResult(LookupResult result, out Symbol resultSymbol)
613private Symbol ResolveMultipleSymbolsInAttributeTypeLookup(ArrayBuilder<Symbol> symbols)
645private static bool NameAndArityMatchRecursively(Symbol x, Symbol y)
665static bool isRoot(Symbol symbol) => symbol is null || symbol is NamespaceSymbol { IsGlobalNamespace: true };
668private bool IsSingleViableAttributeType(LookupResult result, out Symbol symbol, ref CompoundUseSiteInfo<AssemblySymbol> attributeTypeViabilityUseSiteInfo)
684private SingleLookupResult GenerateNonViableAttributeTypeResult(Symbol symbol, DiagnosticInfo diagInfo, bool diagnose)
694private bool CheckAttributeTypeViability(Symbol symbol, bool diagnose, ref DiagnosticInfo diagInfo, ref CompoundUseSiteInfo<AssemblySymbol> attributeTypeViabilityUseSiteInfo)
768foreach (Symbol member in members)
838var other = GetNearestOtherSymbol(basesBeingResolved, type);
893var allMembers = new HashSet<Symbol>(comparer);
894var conflictingMembers = new HashSet<Symbol>(comparer);
947foreach (var sym in allMembers)
988private static Symbol GetNearestOtherSymbol(ConsList<TypeSymbol> list, TypeSymbol type)
1288private static bool IsMethodOrIndexer(Symbol symbol)
1293internal static ImmutableArray<Symbol> GetCandidateMembers(NamespaceOrTypeSymbol nsOrType, string name, LookupOptions options, Binder originalBinder)
1297return nsOrType.GetTypeMembers(name).Cast<NamedTypeSymbol, Symbol>();
1305return ImmutableArray<Symbol>.Empty;
1317internal static ImmutableArray<Symbol> GetCandidateMembers(NamespaceOrTypeSymbol nsOrType, LookupOptions options, Binder originalBinder)
1321return StaticCast<Symbol>.From(nsOrType.GetTypeMembersUnordered());
1329return ImmutableArray<Symbol>.Empty;
1337private bool IsInScopeOfAssociatedSyntaxTree(Symbol symbol)
1385internal SingleLookupResult CheckViability(Symbol symbol, int arity, LookupOptions options, TypeSymbol accessThroughType, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConsList<TypeSymbol> basesBeingResolved = null)
1441var unwrappedSymbols = ImmutableArray.Create<Symbol>(unwrappedSymbol);
1466diagInfo = new CSDiagnosticInfo(ErrorCode.ERR_BadAccess, new[] { unwrappedSymbol }, ImmutableArray.Create<Symbol>(unwrappedSymbol), additionalLocations: ImmutableArray<Location>.Empty);
1540private CSDiagnosticInfo MakeCallMethodsDirectlyDiagnostic(Symbol symbol)
1577/// Does not consider <see cref="Symbol.CanBeReferencedByName"/> - that is left to the caller.
1579internal bool CanAddLookupSymbolInfo(Symbol symbol, LookupOptions options, LookupSymbolsInfo info, TypeSymbol accessThroughType, AliasSymbol aliasSymbol = null)
1645private bool IsCrefAccessible(Symbol symbol)
1650private static bool IsEffectivelyPrivate(Symbol symbol)
1652for (Symbol s = symbol; (object)s != null; s = s.ContainingSymbol)
1667internal bool IsAccessible(Symbol symbol, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, TypeSymbol accessThroughType = null, ConsList<TypeSymbol> basesBeingResolved = null)
1673internal bool IsAccessible(Symbol symbol, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
1686internal bool IsAccessible(Symbol symbol, TypeSymbol accessThroughType, out bool failedThroughTypeCheck, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConsList<TypeSymbol> basesBeingResolved = null)
1698/// Should only be called by <see cref="IsAccessible(Symbol, TypeSymbol, out bool, ref CompoundUseSiteInfo{AssemblySymbol}, ConsList{TypeSymbol})"/>,
1701internal virtual bool IsAccessibleHelper(Symbol symbol, TypeSymbol accessThroughType, out bool failedThroughTypeCheck, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConsList<TypeSymbol> basesBeingResolved)
1707internal bool IsNonInvocableMember(Symbol symbol)
1723private bool IsInvocableMember(Symbol symbol)
1748private static bool IsInstance(Symbol symbol)
1765private static bool WrongArity(Symbol symbol, int arity, bool diagnose, LookupOptions options, out DiagnosticInfo diagInfo)
Binder\Binder_Patterns.cs (10)
334out Symbol? variableSymbol, out BoundExpression? variableAccess);
370lengthAccess = new BoundBadExpression(node, LookupResultKind.Empty, ImmutableArray<Symbol?>.Empty, ImmutableArray<BoundExpression>.Empty, CreateErrorType(), hasErrors: true) { WasCompilerGenerated = true };
847hasErrors: ref hasErrors, variableSymbol: out Symbol? variableSymbol, variableAccess: out BoundExpression? variableAccess);
872out Symbol? variableSymbol,
1034ref hasErrors, out Symbol? variableSymbol, out BoundExpression? variableAccess);
1299foreach (var symbol in tupleType.GetMembers(name))
1331Symbol foundSymbol = BindTypeOrAliasOrKeyword(node.VarKeyword, node, diagnostics, out bool isVar).Symbol;
1361variableSymbol: out Symbol? variableSymbol, variableAccess: out BoundExpression? variableAccess);
1513Symbol? symbol = null;
1539private Symbol? BindPropertyPatternMember(
Binder\Binder_Query.cs (6)
302state.selectOrGroup, LookupResultKind.OverloadResolutionFailure, ImmutableArray<Symbol?>.Empty,
736yExpression = new BoundBadExpression(yExpression.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol?>.Empty, ImmutableArray.Create(yExpression), CreateErrorType());
742yExpression = new BoundBadExpression(yExpression.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol?>.Empty, ImmutableArray.Create(yExpression), yExpression.Type);
803field2Value = new BoundBadExpression(field2Value.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol?>.Empty, ImmutableArray.Create(field2Value), field2Value.Type, true);
975receiver = new BoundBadExpression(receiver.Syntax, LookupResultKind.NotAValue, ImmutableArray<Symbol?>.Empty, ImmutableArray.Create(receiver), CreateErrorType());
997receiver = new BoundBadExpression(receiver.Syntax, LookupResultKind.NotAValue, ImmutableArray<Symbol?>.Empty, ImmutableArray.Create(receiver), CreateErrorType());
Binder\Binder_QueryErrors.cs (3)
29ImmutableArray<Symbol> symbols,
164internal static void ReportQueryInferenceFailed(CSharpSyntaxNode queryClause, string methodName, BoundExpression receiver, AnalyzedArguments arguments, ImmutableArray<Symbol> symbols, BindingDiagnosticBag diagnostics)
213private static bool ReportQueryInferenceFailedSelectMany(FromClauseSyntax fromClause, string methodName, BoundExpression receiver, AnalyzedArguments arguments, ImmutableArray<Symbol> symbols, BindingDiagnosticBag diagnostics)
Binder\Binder_Symbols.cs (46)
196Symbol symbol = null;
348private NamespaceOrTypeSymbol GetContainingNamespaceOrType(Symbol symbol)
353internal Symbol BindNamespaceAliasSymbol(IdentifierNameSyntax node, BindingDiagnosticBag diagnostics)
368Symbol bindingResult = ResultSymbol(result, plainName, 0, node, diagnostics, false, out wasError, qualifierOpt: null, options: LookupOptions.NamespaceAliasesOnly);
579var bindingResult = BindNamespaceAliasSymbol(node.Alias, diagnostics);
878Symbol bindingResult = null;
1051Symbol.ReportUseSiteDiagnostic(info, diagnostics, node.Location);
1084private static Symbol UnwrapAliasNoDiagnostics(Symbol symbol, ConsList<TypeSymbol> basesBeingResolved = null)
1116private Symbol UnwrapAlias(Symbol symbol, BindingDiagnosticBag diagnostics, SyntaxNode syntax, ConsList<TypeSymbol> basesBeingResolved = null)
1122private Symbol UnwrapAlias(Symbol symbol, out AliasSymbol alias, BindingDiagnosticBag diagnostics, SyntaxNode syntax, ConsList<TypeSymbol> basesBeingResolved = null)
1280Symbol lookupResultSymbol = ResultSymbol(lookupResult, plainName, arity, node, diagnostics, (basesBeingResolved != null), out wasError, qualifierOpt, options);
1309ImmutableArray.Create<Symbol>(lookupResultSymbol),
1421ArrayBuilder<Symbol> members,
1469receiver = new BoundBadExpression(receiver.Syntax, LookupResultKind.Ambiguous, ImmutableArray<Symbol>.Empty, ImmutableArray.Create(receiver), receiver.Type, hasErrors: true).MakeCompilerGenerated();
1523ArrayBuilder<Symbol> members, TypeSymbol receiverType,
1565private static readonly Func<Symbol, MethodSymbol> s_toMethodSymbolFunc = s => (MethodSymbol)s;
1566private static readonly Func<Symbol, PropertySymbol> s_toPropertySymbolFunc = s => (PropertySymbol)s;
1674internal Symbol GetSpecialTypeMember(SpecialMember member, BindingDiagnosticBag diagnostics, SyntaxNode syntax)
1679internal static Symbol GetSpecialTypeMember(CSharpCompilation compilation, SpecialMember member, BindingDiagnosticBag diagnostics, SyntaxNode syntax)
1681Symbol memberSymbol;
1688where TSymbol : Symbol
1728private static UseSiteInfo<AssemblySymbol> GetUseSiteInfoForWellKnownMemberOrContainingType(Symbol symbol)
1743internal static bool ReportUseSite(Symbol symbol, BindingDiagnosticBag diagnostics, SyntaxNode node)
1748internal static bool ReportUseSite(Symbol symbol, BindingDiagnosticBag diagnostics, SyntaxToken token)
1759internal static bool ReportUseSite(Symbol symbol, BindingDiagnosticBag diagnostics, Location location)
1811internal Symbol GetWellKnownTypeMember(WellKnownMember member, BindingDiagnosticBag diagnostics, Location location = null, SyntaxNode syntax = null, bool isOptional = false)
1820internal static Symbol GetWellKnownTypeMember(CSharpCompilation compilation, WellKnownMember member, BindingDiagnosticBag diagnostics, Location location = null, SyntaxNode syntax = null, bool isOptional = false)
1825Symbol memberSymbol = GetWellKnownTypeMember(compilation, member, out useSiteInfo, isOptional);
1834internal static Symbol GetWellKnownTypeMember(CSharpCompilation compilation, WellKnownMember member, out UseSiteInfo<AssemblySymbol> useSiteInfo, bool isOptional = false)
1836Symbol memberSymbol = compilation.GetWellKnownTypeMember(member);
1877private class ConsistentSymbolOrder : IComparer<Symbol>
1880public int Compare(Symbol fst, Symbol snd)
1902internal Symbol ResultSymbol(
1913Symbol symbol = resultSymbol(result, simpleName, arity, where, diagnostics, suppressUseSiteDiagnostics, out wasError, qualifierOpt, options);
1931Symbol resultSymbol(
2032Debug.Assert(!Symbol.Equals(originalSymbols[best.Index], originalSymbols[secondBest.Index], TypeCompareKind.ConsiderEverything) || options.IsAttributeTypeLookup(),
2035Debug.Assert(!Symbol.Equals(first, second, TypeCompareKind.ConsiderEverything) || !Symbol.Equals(originalSymbols[best.Index], originalSymbols[secondBest.Index], TypeCompareKind.ConsiderEverything),
2191!Symbol.Equals(originalSymbols[best.Index], originalSymbols[secondBest.Index], TypeCompareKind.ConsiderEverything),
2354private static AssemblySymbol GetContainingAssembly(Symbol symbol)
2474private BestSymbolInfo GetBestSymbolInfo(ArrayBuilder<Symbol> symbols, out BestSymbolInfo secondBest)
2520private static BestSymbolLocation GetLocation(CSharpCompilation compilation, Symbol symbol)
Binder\BinderFactory.BinderFactoryVisitor.cs (11)
24private Symbol _memberOpt;
27internal void Initialize(BinderFactory factory, int position, CSharpSyntaxNode memberDeclarationOpt, Symbol memberOpt)
436Symbol containingSymbol = binder.ContainingMemberOrLambda;
560private Symbol GetMemberSymbol(string memberName, TextSpan memberSpan, NamedTypeSymbol container, SymbolKind kind)
566foreach (Symbol sym in sourceMemberContainerTypeSymbol.GetMembersToMatchAgainstDeclarationSpan())
573if (sym.Name == memberName && checkSymbol(sym, memberSpan, kind, out Symbol result))
581foreach (Symbol sym in container.GetMembers(memberName))
583if (checkSymbol(sym, memberSpan, kind, out Symbol result))
592bool checkSymbol(Symbol sym, TextSpan memberSpan, SymbolKind kind, out Symbol result)
614MethodSymbol method => (Symbol)method.PartialImplementationPart,
Binder\BindingDiagnosticBag.cs (7)
87internal void AddDependencies(Symbol? symbol)
95internal bool ReportUseSite(Symbol? symbol, SyntaxNode node)
100internal bool ReportUseSite(Symbol? symbol, SyntaxToken token)
105internal bool ReportUseSite(Symbol? symbol, Location location)
108internal bool ReportUseSite<TData>(Symbol? symbol, Func<TData, Location> getLocation, TData data)
151return Symbol.ReportUseSiteDiagnostic(diagnosticInfo, diagnosticBag, location);
174internal CSDiagnosticInfo Add(ErrorCode code, Location location, ImmutableArray<Symbol> symbols, params object[] args)
Binder\InMethodBinder.cs (10)
26private SmallDictionary<string, Symbol> _lazyDefinitionMap;
48private static void RecordDefinition<T>(SmallDictionary<string, Symbol> declarationMap, ImmutableArray<T> definitions) where T : Symbol
50foreach (Symbol s in definitions)
71internal override Symbol ContainingMemberOrLambda
242private static bool ReportConflictWithParameter(Symbol parameter, Symbol newSymbol, string name, Location newLocation, BindingDiagnosticBag diagnostics)
322internal override bool EnsureSingleDefinition(Symbol symbol, string name, Location location, BindingDiagnosticBag diagnostics)
336map = new SmallDictionary<string, Symbol>();
343Symbol existingDeclaration;
Binder\LookupResult.cs (17)
17internal delegate SingleLookupResult LookupFilter(Symbol sym);
68private readonly ArrayBuilder<Symbol> _symbolList;
79_symbolList = new ArrayBuilder<Symbol>();
109internal Symbol SingleSymbolOrDefault
117internal ArrayBuilder<Symbol> Symbols
155internal static SingleLookupResult Good(Symbol symbol)
160internal static SingleLookupResult WrongArity(Symbol symbol, DiagnosticInfo error)
170internal static SingleLookupResult NotReferencable(Symbol symbol, DiagnosticInfo error)
175internal static SingleLookupResult StaticInstanceMismatch(Symbol symbol, DiagnosticInfo error)
180internal static SingleLookupResult Inaccessible(Symbol symbol, DiagnosticInfo error)
185internal static SingleLookupResult NotInvocable(Symbol unwrappedSymbol, Symbol symbol, bool diagnose)
191internal static SingleLookupResult NotLabel(Symbol symbol, DiagnosticInfo error)
196internal static SingleLookupResult NotTypeOrNamespace(Symbol symbol, DiagnosticInfo error)
201internal static SingleLookupResult NotTypeOrNamespace(Symbol unwrappedSymbol, Symbol symbol, bool diagnose)
208internal static SingleLookupResult NotAnAttributeType(Symbol symbol, DiagnosticInfo error)
Binder\Semantics\AccessCheck.cs (11)
25Symbol symbol,
38Symbol symbol,
53Symbol symbol,
67internal static bool IsEffectivelyPublicOrInternal(Symbol symbol, out bool isInternal)
134Symbol symbol,
135Symbol within, // must be assembly or named type symbol
223private static bool IsNamedTypeAccessible(NamedTypeSymbol type, Symbol within, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConsList<TypeSymbol> basesBeingResolved = null)
259Symbol within)
300Symbol within,
344Symbol within,
493Symbol within,
Binder\Semantics\OverloadResolution\OverloadResolution.cs (60)
66where TMember : Symbol
80where TMember : Symbol
195where TMember : Symbol
320where TMember : Symbol
359where TMember : Symbol
439where TMember : Symbol
491private static readonly ObjectPool<PooledHashSet<Symbol>> s_HiddenSymbolsSetPool = PooledHashSet<Symbol>.CreatePool(Microsoft.CodeAnalysis.CSharp.Symbols.SymbolEqualityComparer.AllIgnoreOptions);
494where TMember : Symbol
496PooledHashSet<Symbol> hiddenSymbols = null;
507foreach (Symbol hidden in getHiddenMembers(result.LeastOverriddenMember.ConstructedFrom()))
539static ImmutableArray<Symbol> getHiddenMembers(Symbol member)
550return ImmutableArray<Symbol>.Empty;
582BoundExpression receiverOpt) where TMember : Symbol
609private static void RemoveStaticInstanceMismatches<TMember>(ArrayBuilder<MemberResolutionResult<TMember>> results, bool requireStatic) where TMember : Symbol
622private static void RemoveMethodsNotDeclaredStatic<TMember>(ArrayBuilder<MemberResolutionResult<TMember>> results) where TMember : Symbol
638private void RemoveConstraintViolations<TMember>(ArrayBuilder<MemberResolutionResult<TMember>> results, CompoundUseSiteInfo<AssemblySymbol> template) where TMember : Symbol
652var member = (MethodSymbol)(Symbol)result.Member;
665private void RemoveCallingConventionMismatches<TMember>(ArrayBuilder<MemberResolutionResult<TMember>> results, in CallingConventionInfo expectedConvention) where TMember : Symbol
688var member = (MethodSymbol)(Symbol)result.Member;
841bool isFunctionPointerConversion) where TMember : Symbol
857var method = (MethodSymbol)(Symbol)result.Member;
889private static Dictionary<NamedTypeSymbol, ArrayBuilder<TMember>> PartitionMembersByContainingType<TMember>(ArrayBuilder<TMember> members) where TMember : Symbol
907private static void ClearContainingTypeMap<TMember>(ref Dictionary<NamedTypeSymbol, ArrayBuilder<TMember>> containingTypeMapOpt) where TMember : Symbol
1056where TMember : Symbol
1224where TMember : Symbol
1285public static bool IsValidParams(Binder binder, Symbol member, bool disallowExpandedNonArrayParams, out TypeWithAnnotations definitionElementType)
1369Symbol member,
1370Symbol moreDerivedOverride,
1402where TMember : Symbol
1426where TMember : Symbol
1446private static bool HidesByName(Symbol member)
1460where TMember : Symbol
1482where TMember : Symbol
1605where TMember : Symbol
1648where TMember : Symbol
1766where TMember : Symbol
1775where TMember : Symbol
1836where TMember : Symbol
1923where TMember : Symbol
2083where TMember : Symbol
2123where TMember : Symbol
2583where TMember : Symbol
2607where TMember : Symbol
2666private static void GetParameterCounts<TMember>(MemberResolutionResult<TMember> m, ArrayBuilder<BoundExpression> arguments, out int declaredParameterCount, out int parametersUsedIncludingExpansionAndOptional) where TMember : Symbol
3820out bool hasAnyRefOmittedArgument) where TMember : Symbol
3959Options options) where TMember : Symbol
3972out bool hasAnyRefOmittedArgument) where TMember : Symbol
4030where TMember : Symbol
4111where TMember : Symbol
4179where TMember : Symbol
4188member.Kind == SymbolKind.Method && (method = (MethodSymbol)(Symbol)member).Arity > 0)
4190MethodSymbol leastOverriddenMethod = (MethodSymbol)(Symbol)leastOverriddenMember;
4231member = (TMember)(Symbol)method.Construct(typeArguments);
4232leastOverriddenMember = (TMember)(Symbol)leastOverriddenMethod.ConstructedFrom.Construct(typeArguments);
4360Symbol candidate, // method or property
4559Symbol candidate, // method or property
4635private static TMember GetConstructedFrom<TMember>(TMember member) where TMember : Symbol
4642return (TMember)(Symbol)(member as MethodSymbol).ConstructedFrom;
Binder\Semantics\OverloadResolution\OverloadResolution_ArgsToParameters.cs (1)
59Symbol symbol,
Binder\Semantics\OverloadResolution\OverloadResolutionResult.cs (25)
26internal class OverloadResolutionResult<TMember> where TMember : Symbol
204bool isParamsModifierValidation = false) where T : Symbol
215var symbols = StaticCast<Symbol>.From(memberGroup);
580private static void ReportUnsupportedMetadata(Location location, BindingDiagnosticBag diagnostics, ImmutableArray<Symbol> symbols, MemberResolutionResult<TMember> firstUnsupported)
592Symbol.ReportUseSiteDiagnostic(diagInfo, diagnostics, location);
595private static void ReportWrongCallingConvention(Location location, BindingDiagnosticBag diagnostics, ImmutableArray<Symbol> symbols, MemberResolutionResult<TMember> firstSupported, MethodSymbol target)
622ImmutableArray<Symbol> symbols,
641ImmutableArray<Symbol> symbols,
656Symbol symbol = staticInstanceMismatch.Member;
710var method = (MethodSymbol)(Symbol)mismatch.Member;
740ImmutableArray<Symbol> symbols,
793ImmutableArray<Symbol> symbols)
813ImmutableArray<Symbol> symbols)
846ImmutableArray<Symbol> symbols)
881ImmutableArray<Symbol> symbols,
926ImmutableArray<Symbol> symbols,
1045MethodSymbol method = (MethodSymbol)(Symbol)result.Member;
1085ImmutableArray<Symbol> symbols,
1154ImmutableArray<Symbol> symbols,
1377static Symbol unwrapIfParamsCollection(MemberResolutionResult<TMember> badArg, ParameterSymbol parameter, bool isLastParameter)
1389private bool HadAmbiguousWorseMethods(BindingDiagnosticBag diagnostics, ImmutableArray<Symbol> symbols, Location location, bool isQuery, BoundExpression receiver, string name)
1453private bool HadAmbiguousBestMethods(BindingDiagnosticBag diagnostics, ImmutableArray<Symbol> symbols, Location location)
1505private static DiagnosticInfoWithSymbols CreateAmbiguousCallDiagnosticInfo(Symbol first, Symbol second, ImmutableArray<Symbol> symbols)
CommandLine\CSharpCompiler.cs (6)
247Symbol? entryPoint = comp.ScriptClass;
386var symbol = diag switch
388{ Code: (int)ErrorCode.ERR_BadAccess, Arguments: [Symbol s] } => s,
389{ Code: (int)ErrorCode.ERR_InaccessibleGetter, Arguments: [Symbol s] } => s,
390{ Code: (int)ErrorCode.ERR_InaccessibleSetter, Arguments: [Symbol s] } => s,
391{ Code: (int)ErrorCode.ERR_ImplicitImplementationOfInaccessibleInterfaceMember, Arguments: [_, Symbol s, _] } => s,
Compilation\AttributeSemanticModel.cs (11)
19private readonly Symbol? _attributeTarget;
24Symbol? attributeTarget,
28ImmutableDictionary<Symbol, Symbol>? parentRemappedSymbolsOpt = null)
39public static AttributeSemanticModel Create(PublicSemanticModel containingSemanticModel, AttributeSyntax syntax, NamedTypeSymbol attributeType, AliasSymbol aliasOpt, Symbol? attributeTarget, Binder rootBinder, ImmutableDictionary<Symbol, Symbol>? parentRemappedSymbolsOpt)
48public static SpeculativeSemanticModelWithMemberModel CreateSpeculative(SyntaxTreeSemanticModel parentSemanticModel, AttributeSyntax syntax, NamedTypeSymbol attributeType, AliasSymbol aliasOpt, Binder rootBinder, ImmutableDictionary<Symbol, Symbol> parentRemappedSymbolsOpt, int position)
108ref ImmutableDictionary<Symbol, Symbol>? remappedSymbols)
Compilation\CSharpCompilation.cs (27)
1188internal new Symbol? GetAssemblyOrModuleSymbol(MetadataReference reference)
1209return (TSymbol?)(object?)symbol.GetSymbol<Symbol>();
1749internal Symbol GetSpecialTypeMember(SpecialMember specialMember)
1778ImmutableArray<Symbol>.Empty,
2059var taskCandidates = taskEntryPoints.SelectAsArray(s => (Symbol)s.Candidate);
2133symbols: viableEntryPoints.OfType<Symbol>().AsImmutable(),
2157ArrayBuilder<MethodSymbol> entryPointCandidates, IEnumerable<Symbol> members)
2159foreach (var member in members)
2401Symbol? symbol0 = symbol.EnsureCSharpSymbolOrNull(nameof(symbol));
2402Symbol? within0 = within.EnsureCSharpSymbolOrNull(nameof(within));
2939private void GetDiagnosticsWithoutSeverityFiltering(CompilationStage stage, bool includeEarlierStages, BindingDiagnosticBag builder, Predicate<Symbol>? symbolFilter, CancellationToken cancellationToken)
3071private static bool IsDefinedOrImplementedInSourceTree(Symbol symbol, SyntaxTree tree, TextSpan? span)
3177filterOpt: filterTree is object ? (Predicate<Symbol>?)(s => IsDefinedOrImplementedInSourceTree(s, filterTree, filterSpan)) : (Predicate<Symbol>?)null,
3219private ReadOnlyBindingDiagnostic<AssemblySymbol> GetSourceDeclarationDiagnostics(SyntaxTree? syntaxTree = null, TextSpan? filterSpanWithinTree = null, Func<IEnumerable<Diagnostic>, SyntaxTree, TextSpan?, IEnumerable<Diagnostic>>? locationFilterOpt = null, Predicate<Symbol>? symbolFilter = null, CancellationToken cancellationToken = default)
3593foreach (var childSymbol in symbol.GetMembers())
4645internal IEnumerable<Symbol> GetSymbolsWithNameCore(string name, SymbolFilter filter = SymbolFilter.TypeAndMember, CancellationToken cancellationToken = default)
4708internal bool ShouldEmitNullableAttributes(Symbol symbol)
4734static Symbol getExplicitAccessibilitySymbol(Symbol symbol)
4760internal void SymbolDeclaredEvent(Symbol symbol)
4826var sustainedLowLatency = GetWellKnownTypeMember(WellKnownMember.System_Runtime_GCLatencyMode__SustainedLowLatency);
4860public IEnumerable<Symbol> GetSymbolsWithName()
4862var result = new HashSet<Symbol>();
4874HashSet<Symbol> set)
4928ArrayBuilder<MergedNamespaceOrTypeDeclaration> spine, MergedTypeDeclaration current, HashSet<Symbol> set)
4936foreach (var member in container.GetMembers())
Compilation\CSharpSemanticModel.cs (128)
167internal abstract BoundExpression GetSpeculativelyBoundExpression(int position, ExpressionSyntax expression, SpeculativeBindingOption bindingOption, out Binder binder, out ImmutableArray<Symbol> crefSymbols);
177internal abstract ImmutableArray<Symbol> GetMemberGroupWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken = default(CancellationToken));
279protected BoundExpression GetSpeculativelyBoundExpressionWithoutNullability(int position, ExpressionSyntax expression, SpeculativeBindingOption bindingOption, out Binder binder, out ImmutableArray<Symbol> crefSymbols)
286crefSymbols = default(ImmutableArray<Symbol>);
298crefSymbols = ImmutableArray.Create<Symbol>(binder.BindType(expression, BindingDiagnosticBag.Discarded).Type);
324internal static ImmutableArray<Symbol> BindCref(CrefSyntax crefSyntax, Binder binder)
326Symbol unusedAmbiguityWinner;
336ImmutableArray<Symbol> symbols = BindCref(crefSyntax, binder);
365private static SymbolInfo GetCrefSymbolInfo(OneOrMany<Symbol> symbols, SymbolInfoOptions options, bool hasParameterList)
721ImmutableArray<Symbol> crefSymbols;
1051ImmutableArray<Symbol> crefSymbols;
1198ImmutableArray<Symbol> crefSymbols;
1690Symbol uniqueSymbol;
1752Symbol singleSymbol = binder.ResultSymbol(lookupResult, name, arity, this.Root, BindingDiagnosticBag.Discarded, true, out wasError, container, options);
1778private Symbol RemapSymbolIfNecessary(Symbol symbol)
1796internal abstract Symbol RemapSymbolIfNecessaryCore(Symbol symbol);
1813public bool IsAccessible(int position, Symbol symbol)
1865Constraint = "Provide " + nameof(ArrayBuilder<Symbol>) + " capacity to reduce number of allocations.")]
1902OneOrMany<Symbol> symbols = GetSemanticSymbols(
1903boundExpr, boundNodeForSyntacticParent, binderOpt, options, out bool isDynamic, out LookupResultKind resultKind, out ImmutableArray<Symbol> unusedMemberGroup);
1909ImmutableArray<Symbol> unusedHighestMemberGroup;
1910OneOrMany<Symbol> highestSymbols = GetSemanticSymbols(
1949return SymbolInfoFactory.Create(ImmutableArray<Symbol>.Empty, LookupResultKind.Empty, isDynamic);
1955var builder = ArrayBuilder<Symbol>.GetInstance(symbols.Count);
1956foreach (Symbol symbol in symbols)
1977private static SymbolInfo GetSymbolInfoForSubpattern(Symbol subpatternSymbol)
1992private static void AddUnwrappingErrorTypes(ArrayBuilder<Symbol> builder, Symbol s)
2272internal ImmutableArray<Symbol> GetMemberGroupForNode(
2281ImmutableArray<Symbol> memberGroup;
2288return ImmutableArray<Symbol>.Empty;
2310internal static SymbolInfo GetSymbolInfoForSymbol(Symbol symbol, SymbolInfoOptions options)
2315Symbol unwrapped = UnwrapAlias(symbol);
2324var symbols = OneOrMany<Symbol>.Empty;
2342var symbolToReturn = ((options & SymbolInfoOptions.ResolveAliases) != 0) ? unwrapped : symbol;
2348internal static CSharpTypeInfo GetTypeInfoForSymbol(Symbol symbol)
2358protected static Symbol UnwrapAlias(Symbol symbol)
2363protected static OneOrMany<Symbol> UnwrapAliases(OneOrMany<Symbol> symbols)
2367foreach (Symbol symbol in symbols)
2376ArrayBuilder<Symbol> builder = ArrayBuilder<Symbol>.GetInstance();
2377foreach (Symbol symbol in symbols)
3341private OneOrMany<Symbol> GetSemanticSymbols(
3348out ImmutableArray<Symbol> memberGroup)
3350memberGroup = ImmutableArray<Symbol>.Empty;
3351OneOrMany<Symbol> symbols = OneOrMany<Symbol>.Empty;
3406var typeSymbol = boundType.AliasOpt ?? (Symbol)boundType.Type;
3449symbols = StaticCast<Symbol>.From(CreateReducedExtensionMethodsFromOriginalsIfNecessary(call, Compilation));
3458symbols = OneOrMany.Create<Symbol>(invocation.FunctionPointer);
3487symbols = originalIndexersOpt.IsDefault ? OneOrMany.Create<Symbol>(indexerAccess.Indexer) : StaticCast<Symbol>.From(OneOrMany.Create(originalIndexersOpt));
3502symbols = OneOrMany<Symbol>.Empty;
3507symbols = OneOrMany.Create<Symbol>(methodSymbol);
3513boundNode.ExpressionSymbol is Symbol accessSymbol &&
3519symbols = OneOrMany.Create<Symbol>(parentOperator.Event);
3532symbols = OneOrMany.Create<Symbol>(ReducedExtensionMethodSymbol.Create(symbol));
3617var builder = ArrayBuilder<Symbol>.GetInstance();
3628memberGroup = dynamicInvocation.ApplicableMethods.Cast<MethodSymbol, Symbol>();
3636memberGroup = collectionInit.ApplicableMethods.Cast<MethodSymbol, Symbol>();
3644memberGroup = dynamicIndexer.ApplicableIndexers.Cast<PropertySymbol, Symbol>();
3656memberGroup = objectCreation.ApplicableMethods.Cast<MethodSymbol, Symbol>();
3667symbols = OneOrMany.Create<Symbol>(boundObjectCreation.Constructor);
3671symbols = StaticCast<Symbol>.From(OneOrMany.Create(boundObjectCreation.ConstructorsGroup));
3675memberGroup = boundObjectCreation.ConstructorsGroup.Cast<MethodSymbol, Symbol>();
3683var containingMember = binder.ContainingMember();
3686symbols = thisParam != null ? OneOrMany.Create<Symbol>(thisParam) : OneOrMany<Symbol>.Empty;
3695symbols = OneOrMany.Create<Symbol>(fromEndIndexExpression.MethodOpt);
3705symbols = OneOrMany.Create<Symbol>(rangeExpression.MethodOpt);
3712if (boundNode.ExpressionSymbol is Symbol symbol)
3730private static ParameterSymbol GetThisParameter(TypeSymbol typeOfThis, NamedTypeSymbol containingType, Symbol containingMember, out LookupResultKind resultKind)
3793private static void GetSymbolsAndResultKind(BoundUnaryOperator unaryOperator, out bool isDynamic, ref LookupResultKind resultKind, ref OneOrMany<Symbol> symbols)
3809symbols = OneOrMany.Create<Symbol>(new SynthesizedIntrinsicOperatorSymbol(unaryOperator.Operand.Type.StrippedType(),
3816private static void GetSymbolsAndResultKind(BoundIncrementOperator increment, out bool isDynamic, ref LookupResultKind resultKind, ref OneOrMany<Symbol> symbols)
3833symbols = OneOrMany.Create<Symbol>(new SynthesizedIntrinsicOperatorSymbol(opType,
3840private static void GetSymbolsAndResultKind(BoundBinaryOperator binaryOperator, out bool isDynamic, ref LookupResultKind resultKind, ref OneOrMany<Symbol> symbols)
3866symbols = OneOrMany.Create<Symbol>(new SynthesizedIntrinsicOperatorSymbol(objectType,
3884private static Symbol GetIntrinsicOperatorSymbol(BinaryOperatorKind op, bool isDynamic, TypeSymbol leftType, TypeSymbol rightType, TypeSymbol returnType, bool isChecked)
3913private static void GetSymbolsAndResultKind(BoundCompoundAssignmentOperator compoundAssignment, out bool isDynamic, ref LookupResultKind resultKind, ref OneOrMany<Symbol> symbols)
3939private static void GetSymbolsAndResultKind(BoundExpression node, Symbol symbolOpt, ImmutableArray<MethodSymbol> originalCandidates, out OneOrMany<Symbol> symbols, out LookupResultKind resultKind)
3948symbols = StaticCast<Symbol>.From(OneOrMany.Create(originalCandidates));
3953symbols = OneOrMany<Symbol>.Empty;
3966ref OneOrMany<Symbol> symbols,
3967ref ImmutableArray<Symbol> memberGroup)
4019ref OneOrMany<Symbol> symbols,
4020ref ImmutableArray<Symbol> memberGroup)
4060symbols = OneOrMany.Create<Symbol>(constructorOpt);
4064symbols = StaticCast<Symbol>.From(OneOrMany.Create(candidateConstructors));
4069memberGroup = candidateConstructors.Cast<MethodSymbol, Symbol>();
4110PooledHashSet<Symbol> hiddenSymbols = null;
4113Symbol symbol = iSymbol.GetSymbol();
4119foreach (Symbol overridden in overriddenOrHiddenMembers.OverriddenMembers)
4123hiddenSymbols = PooledHashSet<Symbol>.GetInstance();
4131foreach (Symbol hidden in overriddenOrHiddenMembers.HiddenMembers)
4135hiddenSymbols = PooledHashSet<Symbol>.GetInstance();
4203HashSet<Symbol> hiddenSymbols = new HashSet<Symbol>();
4208foreach (Symbol overridden in overriddenOrHiddenMembers.OverriddenMembers)
4216foreach (Symbol hidden in overriddenOrHiddenMembers.HiddenMembers)
4232private OneOrMany<Symbol> GetMethodGroupSemanticSymbols(
4238out ImmutableArray<Symbol> methodGroup)
4242OneOrMany<Symbol> symbols = OneOrMany<Symbol>.Empty;
4254methodGroup = GetReducedAndFilteredMethodGroupSymbols(binder, boundNode).Cast<MethodSymbol, Symbol>();
4277symbols = StaticCast<Symbol>.From(CreateReducedExtensionMethodsFromOriginalsIfNecessary(call, Compilation));
4314symbols = OneOrMany.Create((Symbol)method);
4326symbols = OneOrMany.Create(dynamicInvocation.ApplicableMethods.Cast<MethodSymbol, Symbol>());
4332ImmutableArray<Symbol> myMethodGroup = methodGroup;
4385private OneOrMany<Symbol> GetPropertyGroupSemanticSymbols(
4390out ImmutableArray<Symbol> propertyGroup)
4394OneOrMany<Symbol> symbols = OneOrMany<Symbol>.Empty;
4403propertyGroup = boundNode.Properties.Cast<PropertySymbol, Symbol>();
4420symbols = OneOrMany.Create<Symbol>(indexer.Indexer);
4426symbols = StaticCast<Symbol>.From(OneOrMany.Create(indexer.OriginalIndexersOpt));
4433ImmutableArray<Symbol> myPropertyGroup = propertyGroup;
4591var otherSymbol = node.LookupSymbolOpt;
4784private OneOrMany<Symbol> CreateReducedExtensionMethodIfPossible(BoundCall call)
4798return OneOrMany.Create<Symbol>(method);
4801private OneOrMany<Symbol> CreateReducedExtensionMethodIfPossible(BoundDelegateCreationExpression delegateCreation, BoundExpression receiverOpt)
4811return OneOrMany.Create<Symbol>(method);
Compilation\InitializerSemanticModel.cs (10)
27Symbol symbol,
30ImmutableDictionary<Symbol, Symbol> parentRemappedSymbolsOpt = null) :
59internal static InitializerSemanticModel Create(PublicSemanticModel containingSemanticModel, ParameterSyntax syntax, ParameterSymbol parameterSymbol, Binder rootBinder, ImmutableDictionary<Symbol, Symbol> parentRemappedSymbolsOpt)
69internal static SpeculativeSemanticModelWithMemberModel CreateSpeculative(SyntaxTreeSemanticModel parentSemanticModel, Symbol owner, EqualsValueClauseSyntax syntax, Binder rootBinder, ImmutableDictionary<Symbol, Symbol> parentRemappedSymbolsOpt, int position)
259ref ImmutableDictionary<Symbol, Symbol> remappedSymbols)
Compilation\MemberSemanticModel.cs (26)
28private readonly Symbol _memberSymbol;
36private ImmutableDictionary<Symbol, Symbol> _lazyRemappedSymbols;
37private readonly ImmutableDictionary<Symbol, Symbol> _parentRemappedSymbolsOpt;
47Symbol memberSymbol,
50ImmutableDictionary<Symbol, Symbol> parentRemappedSymbolsOpt)
84internal Symbol MemberSymbol
162internal ImmutableDictionary<Symbol, Symbol> GetRemappedSymbols()
191internal override BoundExpression GetSpeculativelyBoundExpression(int position, ExpressionSyntax expression, SpeculativeBindingOption bindingOption, out Binder binder, out ImmutableArray<Symbol> crefSymbols)
205ImmutableDictionary<Symbol, Symbol> ignored = null;
720private T GetRemappedSymbol<T>(T originalSymbol) where T : Symbol
725if (_lazyRemappedSymbols.TryGetValue(originalSymbol, out Symbol? remappedSymbol))
1232internal override ImmutableArray<Symbol> GetMemberGroupWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken = default(CancellationToken))
1473protected void UnguardedAddBoundTreeForStandaloneSyntax(SyntaxNode syntax, BoundNode bound, NullableWalker.SnapshotManager manager = null, ImmutableDictionary<Symbol, Symbol> remappedSymbols = null)
1481protected void GuardedAddBoundTreeForStandaloneSyntax(SyntaxNode syntax, BoundNode bound, NullableWalker.SnapshotManager manager = null, ImmutableDictionary<Symbol, Symbol> remappedSymbols = null)
2045ref ImmutableDictionary<Symbol, Symbol>? remappedSymbols);
2340internal override Symbol RemapSymbolIfNecessaryCore(Symbol symbol)
2351if (_lazyRemappedSymbols.TryGetValue(symbol, out var remappedSymbol))
Compilation\SpeculativeSemanticModelWithMemberModel.cs (15)
48ImmutableDictionary<Symbol, Symbol>? parentRemappedSymbolsOpt)
57static Symbol? getAttributeTargetFromPosition(int position, SyntaxTreeSemanticModel model)
74Symbol owner,
77ImmutableDictionary<Symbol, Symbol>? parentRemappedSymbolsOpt)
90Symbol owner,
93ImmutableDictionary<Symbol, Symbol>? parentRemappedSymbolsOpt,
106ImmutableDictionary<Symbol, Symbol>? parentRemappedSymbolsOpt,
460internal override ImmutableArray<Symbol> GetMemberGroupWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken = default(CancellationToken))
500internal override Symbol RemapSymbolIfNecessaryCore(Symbol symbol)
565internal override BoundExpression GetSpeculativelyBoundExpression(int position, ExpressionSyntax expression, SpeculativeBindingOption bindingOption, out Binder binder, out ImmutableArray<Symbol> crefSymbols)
Compilation\SyntaxTreeSemanticModel.cs (17)
284var symbol = GetSemanticInfoSymbolInNonMemberContext(node, bindVarAsAliasFirst: (options & SymbolInfoOptions.PreserveAliases) != 0);
322var symbol = GetSemanticInfoSymbolInNonMemberContext(node, bindVarAsAliasFirst: false); // Don't care about aliases here.
330private Symbol GetSemanticInfoSymbolInNonMemberContext(CSharpSyntaxNode node, bool bindVarAsAliasFirst)
356Symbol result = bindVarAsAliasFirst
397internal override ImmutableArray<Symbol> GetMemberGroupWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken = default(CancellationToken))
403return model == null ? ImmutableArray<Symbol>.Empty : model.GetMemberGroupWorker(node, options, cancellationToken);
738internal override BoundExpression GetSpeculativelyBoundExpression(int position, ExpressionSyntax expression, SpeculativeBindingOption bindingOption, out Binder binder, out ImmutableArray<Symbol> crefSymbols)
1751private Symbol GetDeclaredMember(NamespaceOrTypeSymbol container, TextSpan declarationSpan, bool isKnownToBeANamespace, string name = null)
1779Symbol zeroWidthMatch = null;
1780foreach (var symbol in collection)
1786var result = GetDeclaredMember(namedType, declarationSpan, isKnownToBeANamespace, name);
1803Symbol partial = symbol switch
1843var result = this.GetDeclaredMember(container, declarationSyntax.Span, isKnownToBeANamespace: false, declarationSyntax.Identifier.ValueText);
2293private static BoundNode GetBoundRoot(MemberSemanticModel memberModel, out Symbol member)
2345private Symbol GetDeclaredMemberSymbol(CSharpSyntaxNode declarationSyntax)
2384internal override Symbol RemapSymbolIfNecessaryCore(Symbol symbol)
Compiler\ClsComplianceChecker.cs (36)
32private readonly ConcurrentDictionary<Symbol, Compliance> _declaredOrInheritedCompliance;
52_declaredOrInheritedCompliance = new ConcurrentDictionary<Symbol, Compliance>(Symbols.SymbolEqualityComparer.ConsiderEverything);
212foreach (var m in symbol.GetMembersUnordered())
230foreach (var m in symbol.GetMembersUnordered())
267foreach (var m in symbol.GetMembersUnordered())
420private bool VisitTypeOrMember(Symbol symbol, Compliance compliance)
497private void CheckForNonCompliantAbstractMember(Symbol symbol)
541private void CheckForCompliantWithinNonCompliant(Symbol symbol)
585private void CheckForAttributeWithArrayArgument(Symbol symbol)
680Symbol container = parameters[0].ContainingSymbol;
683Symbol associated = ((MethodSymbol)container).AssociatedSymbol;
711private void CheckReturnTypeCompliance(Symbol symbol)
784private bool CheckForDeclarationWithoutAssemblyDeclaration(Symbol symbol, Compliance compliance)
807MultiDictionary<string, Symbol> seenByName = new MultiDictionary<string, Symbol>(CaseInsensitiveComparison.Comparer);
823foreach (Symbol member in @interface.GetMembersUnordered())
838foreach (Symbol member in baseType.GetMembersUnordered())
855foreach (Symbol member in symbol.GetMembers())
884private void CheckSymbolDistinctness(Symbol symbol, string symbolName, MultiDictionary<string, Symbol>.ValueSet sameNameSymbols)
891foreach (Symbol other in sameNameSymbols)
906foreach (Symbol other in sameNameSymbols)
927private void CheckName(Symbol symbol)
960private bool DoNotVisit(Symbol symbol)
973private bool IsSyntacticallyFilteredOut(Symbol symbol)
1114private Compliance GetDeclaredOrInheritedCompliance(Symbol symbol)
1127Symbol associated = method.AssociatedSymbol;
1170private Compliance GetInheritedCompliance(Symbol symbol)
1174Symbol containing = (Symbol)symbol.ContainingType ?? symbol.ContainingAssembly;
1184private bool? GetDeclaredCompliance(Symbol symbol, out Location attributeLocation)
1220private static bool IsAccessibleOutsideAssembly(Symbol symbol)
1233private static bool IsAccessibleIfContainerIsAccessible(Symbol symbol)
1267private static bool IsImplicitClass(Symbol symbol)
1316private static bool TryGetCollisionErrorCode(Symbol x, Symbol y, out ErrorCode code)
Emitter\Model\PEModuleBuilder.cs (21)
29protected readonly ConcurrentDictionary<Symbol, Cci.IModuleReference> AssemblyOrModuleSymbolToModuleRefMap = new ConcurrentDictionary<Symbol, Cci.IModuleReference>();
30private readonly ConcurrentDictionary<Symbol, object> _genericInstanceMap = new ConcurrentDictionary<Symbol, object>(Symbols.SymbolEqualityComparer.ConsiderEverything);
357foreach (var member in symbol.GetMembers())
380foreach (var member in symbol.GetMembers())
441private void AddSymbolLocation(MultiDictionary<Cci.DebugSourceDocument, Cci.DefinitionWithLocation> result, Symbol symbol)
468private Location GetSmallestSourceLocationOrNull(Symbol symbol)
567foreach (var member in ns.GetMembers())
600foreach (var member in symbol.GetMembers())
823Symbol.ReportUseSiteDiagnostic(info,
1072private object GetCciAdapter(Symbol symbol)
1393var container = param.ContainingSymbol;
1429private static bool ContainerIsGeneric(Symbol container)
1492internal SynthesizedAttributeData SynthesizeIsReadOnlyAttribute(Symbol symbol)
1525internal SynthesizedAttributeData SynthesizeIsUnmanagedAttribute(Symbol symbol)
1536internal SynthesizedAttributeData SynthesizeIsByRefLikeAttribute(Symbol symbol)
1552internal SynthesizedAttributeData SynthesizeNullableAttributeIfNecessary(Symbol symbol, byte? nullableContextValue, TypeWithAnnotations type)
1612internal SynthesizedAttributeData SynthesizeNullableContextAttribute(Symbol symbol, byte value)
1637internal SynthesizedAttributeData SynthesizeNativeIntegerAttribute(Symbol symbol, TypeSymbol type)
1967Symbol.ReportUseSiteDiagnostic(info, diagnostics, syntaxNode.Location);
Errors\CSDiagnosticInfo.cs (4)
23: this(code, Array.Empty<object>(), ImmutableArray<Symbol>.Empty, ImmutableArray<Location>.Empty)
28: this(code, args, ImmutableArray<Symbol>.Empty, ImmutableArray<Location>.Empty)
32internal CSDiagnosticInfo(ErrorCode code, ImmutableArray<Symbol> symbols, object[] args)
37internal CSDiagnosticInfo(ErrorCode code, object[] args, ImmutableArray<Symbol> symbols, ImmutableArray<Location> additionalLocations)
FlowAnalysis\DataFlowsInWalker.cs (10)
25private readonly HashSet<Symbol> _dataFlowsIn = new HashSet<Symbol>();
27private DataFlowsInWalker(CSharpCompilation compilation, Symbol member, BoundNode node, BoundNode firstInRegion, BoundNode lastInRegion,
28HashSet<Symbol> unassignedVariables, HashSet<PrefixUnaryExpressionSyntax> unassignedVariableAddressOfSyntaxes)
33internal static HashSet<Symbol> Analyze(CSharpCompilation compilation, Symbol member, BoundNode node, BoundNode firstInRegion, BoundNode lastInRegion,
34HashSet<Symbol> unassignedVariables, HashSet<PrefixUnaryExpressionSyntax> unassignedVariableAddressOfSyntaxes, out bool? succeeded)
42return badRegion ? new HashSet<Symbol>() : result;
50private HashSet<Symbol> Analyze(ref bool badRegion)
103protected override void ReportUnassigned(Symbol symbol, SyntaxNode node, int slot, bool skipIfUseBeforeDeclaration)
FlowAnalysis\DataFlowsOutWalker.cs (16)
27private DataFlowsOutWalker(CSharpCompilation compilation, Symbol member, BoundNode node, BoundNode firstInRegion, BoundNode lastInRegion, HashSet<Symbol> unassignedVariables, ImmutableArray<ISymbol> dataFlowsIn)
33internal static HashSet<Symbol> Analyze(CSharpCompilation compilation, Symbol member, BoundNode node, BoundNode firstInRegion, BoundNode lastInRegion, HashSet<Symbol> unassignedVariables, ImmutableArray<ISymbol> dataFlowsIn)
46return badRegion ? new HashSet<Symbol>() : result;
54private readonly HashSet<Symbol> _dataFlowsOut = new HashSet<Symbol>();
58private readonly HashSet<Symbol> _assignedInside = new HashSet<Symbol>();
61private HashSet<Symbol> Analyze(ref bool badRegion)
80Symbol variableSymbol = variable.GetSymbol();
91protected override void NoteWrite(Symbol variable, BoundExpression value, bool read, bool isRef)
114private Symbol GetNodeSymbol(BoundNode node)
207Symbol variable = GetNodeSymbol(node);
252protected override void ReportUnassigned(Symbol symbol, SyntaxNode node, int slot, bool skipIfUseBeforeDeclaration)
FlowAnalysis\DefiniteAssignment.cs (44)
59private readonly HashSet<Symbol>? initiallyAssignedVariables;
81private readonly PooledHashSet<Symbol> _writtenVariables = PooledHashSet<Symbol>.GetInstance();
113private readonly PooledDictionary<Symbol, Location> _unsafeAddressTakenVariables = PooledDictionary<Symbol, Location>.GetInstance();
118private readonly PooledHashSet<Symbol> _capturedVariables = PooledHashSet<Symbol>.GetInstance();
120private readonly PooledHashSet<Symbol> _capturedInside = PooledHashSet<Symbol>.GetInstance();
121private readonly PooledHashSet<Symbol> _capturedOutside = PooledHashSet<Symbol>.GetInstance();
168Symbol member,
193Symbol member,
197HashSet<Symbol>? initiallyAssignedVariables = null)
215Symbol member,
219HashSet<Symbol> initiallyAssignedVariables,
234Symbol member,
283protected Symbol GetNonMemberSymbol(int slot)
343var save = CurrentSymbol;
485Symbol associatedPropertyOrEvent = field.AssociatedSymbol;
685foreach (Symbol captured in _capturedVariables)
707private void CheckCaptured(Symbol variable, ParameterSymbol? rangeVariableUnderlyingParameter = null)
710Symbol.IsCaptured(rangeVariableUnderlyingParameter ?? variable, sourceMethod))
721private void NoteCaptured(Symbol variable)
736protected IEnumerable<Symbol> GetCapturedInside() => _capturedInside.ToArray();
737protected IEnumerable<Symbol> GetCapturedOutside() => _capturedOutside.ToArray();
738protected IEnumerable<Symbol> GetCaptured() => _capturedVariables.ToArray();
739protected IEnumerable<Symbol> GetUnsafeAddressTaken() => _unsafeAddressTakenVariables.Keys.ToArray();
744private void NotePrimaryConstructorParameterReadIfNeeded(Symbol symbol)
753Symbol variable,
849protected virtual void NoteWrite(Symbol variable, BoundExpression value, bool read, bool isRef)
1065protected override bool TryGetReceiverAndMember(BoundExpression expr, out BoundExpression receiver, out Symbol member)
1151protected void CheckAssigned(Symbol symbol, SyntaxNode node)
1170private void ReportUnassignedIfNotCapturedInLocalFunction(Symbol symbol, SyntaxNode node, int slot, bool skipIfUseBeforeDeclaration = true)
1187protected virtual void ReportUnassigned(Symbol symbol, SyntaxNode node, int slot, bool skipIfUseBeforeDeclaration)
1256void addDiagnosticForStructThis(Symbol thisParameter, int thisSlot)
1308var associatedSymbol = fieldSymbol.AssociatedSymbol;
1481private Symbol UseNonFieldSymbolUnsafely(BoundExpression expression)
1805Symbol current = CurrentSymbol;
1837Symbol containing = current.ContainingSymbol;
2424var oldSymbol = this.CurrentSymbol;
2542Symbol variable = UseNonFieldSymbolUnsafely(operand);
2654foreach (var symbol in namedType.GetMembersUnordered())
2702Symbol receiver = UseNonFieldSymbolUnsafely(node.ReceiverOpt);
FlowAnalysis\LocalDataFlowPass.cs (9)
36Symbol? member,
48Symbol member,
75protected int VariableSlot(Symbol symbol, int containingSlot = 0)
100protected virtual int GetOrCreateSlot(Symbol symbol, int containingSlot = 0, bool forceSlotEvenIfEmpty = false, bool createIfMissing = true)
161private int DescendThroughTupleRestFields(ref Symbol symbol, int containingSlot, bool forceContainingSlotsToExist)
204protected abstract bool TryGetReceiverAndMember(BoundExpression expr, out BoundExpression? receiver, [NotNullWhen(true)] out Symbol? member);
227if (TryGetReceiverAndMember(node, out BoundExpression? receiver, out Symbol? member))
239protected int MakeMemberSlot(BoundExpression? receiverOpt, Symbol member)
262protected static bool HasInitializer(Symbol field) => field switch
FlowAnalysis\NullableWalker.cs (112)
449Symbol? symbol,
659var alreadyWarnedMembers = PooledHashSet<Symbol>.GetInstance();
660foreach (var member in method.ContainingType.GetMembersUnordered())
704void checkMemberStateOnConstructorExit(MethodSymbol constructor, Symbol member, LocalState state, int thisSlot, Location? exitLocation, ImmutableArray<string> membersWithStateEnforcedByRequiredMembers, bool forcePropertyAnalysis)
723Symbol symbol;
729symbol = (Symbol?)(f.AssociatedSymbol as PropertySymbol) ?? f;
790var info = new CSDiagnosticInfo(errorCode, new object[] { symbol.Kind.Localize(), symbol.Name }, ImmutableArray<Symbol>.Empty, additionalLocations: symbol.Locations);
801foreach (var member in getMembersNeedingDefaultInitialState())
808var memberToInitialize = member;
862ImmutableArray<Symbol> getMembersNeedingDefaultInitialState()
866return ImmutableArray<Symbol>.Empty;
906static ImmutableArray<Symbol> membersToBeInitialized(NamedTypeSymbol containingType, bool includeAllMembers, bool includeCurrentTypeRequiredMembers, bool includeBaseRequiredMembers)
911=> ImmutableArray<Symbol>.Empty,
925var symbolToInitialize = getFieldSymbolToBeInitialized(symbol);
929return OneOrMany<Symbol>.Empty;
944static ImmutableArray<Symbol> getAllTypeAndRequiredMembers(TypeSymbol containingType)
947var baseRequiredMembers = containingType.BaseTypeNoUseSiteDiagnostics?.AllRequiredMembers ?? ImmutableSegmentedDictionary<string, Symbol>.Empty;
954var builder = ArrayBuilder<Symbol>.GetInstance(members.Length + baseRequiredMembers.Count);
978static OneOrMany<Symbol> getAllMembersToBeDefaulted(Symbol requiredMember, bool filterOverridingProperties)
992return OneOrMany<Symbol>.Empty;
1000foreach (var member in property.ContainingType.GetMembers(notNullMemberName))
1010static Symbol getFieldSymbolToBeInitialized(Symbol requiredMember)
1043foreach (var member in method.ContainingType.GetMembers(memberName))
1091void enforceMemberNotNullWhenIfAffected(SyntaxNode? syntaxOpt, bool sense, ImmutableArray<Symbol> members, LocalState state, LocalState otherState)
1093foreach (var member in members)
1110foreach (var member in method.ContainingType.GetMembers(memberName))
1119private void ReportFailedMemberNotNullIfNeeded(SyntaxNode? syntaxOpt, bool sense, Symbol member, LocalState state)
1128private bool FailsMemberNotNullExpectation(Symbol member, LocalState state)
1164foreach (var member in type.GetMembers(memberName))
1175private int GetSlotForMemberPostCondition(Symbol member)
1464internal static VariableState? GetAfterInitializersState(CSharpCompilation compilation, Symbol? symbol, BoundNode constructorBody)
1534Symbol? symbol,
1549Symbol? symbol,
1556ref ImmutableDictionary<Symbol, Symbol>? remappedSymbols)
1565Symbol? symbol,
1628ref ImmutableDictionary<Symbol, Symbol>? remappedSymbols)
1633var symbol = variables.Symbol;
1669private static BoundNode Rewrite(ImmutableDictionary<BoundExpression, (NullabilityInfo, TypeSymbol?)> updatedNullabilities, SnapshotManager? snapshotManager, BoundNode node, ref ImmutableDictionary<Symbol, Symbol>? remappedSymbols)
1671var remappedSymbolsBuilder = ImmutableDictionary.CreateBuilder<Symbol, Symbol>(Symbols.SymbolEqualityComparer.ConsiderEverything, Symbols.SymbolEqualityComparer.ConsiderEverything);
1780Symbol? symbol,
1832Symbol? symbol,
1865private void RecordNullableAnalysisData(Symbol? symbol, bool requiredAnalysis)
1892private void SetUpdatedSymbol(BoundNode node, Symbol originalSymbol, Symbol updatedSymbol)
1915if (lambdaIsExactMatch || Symbol.Equals(originalSymbol, updatedSymbol, TypeCompareKind.ConsiderEverything))
1967var symbol = variable.Symbol;
2000protected override bool TryGetReceiverAndMember(BoundExpression expr, out BoundExpression? receiver, [NotNullWhen(true)] out Symbol? member)
2168var container = method.ContainingSymbol;
2179protected override int GetOrCreateSlot(Symbol symbol, int containingSlot = 0, bool forceSlotEvenIfEmpty = false, bool createIfMissing = true)
2303var containingSymbol = parameterOpt?.ContainingSymbol;
2670private bool IsSlotMember(int slot, Symbol possibleMember)
2682private void InheritNullableStateOfMember(int targetContainerSlot, int valueContainerSlot, Symbol member, bool isDefaultValue, int skipSlot)
2792var symbol = AsMemberOfType(targetType, variable.Symbol);
2799private NullableFlowState GetDefaultState(Symbol symbol)
3234if (Symbol.IsCaptured(variables[slot].Symbol, localFunc))
3253var symbol = variables[variables.RootSlot(slot)].Symbol;
3254if (Symbol.IsCaptured(symbol, localFunc))
3300var oldSymbol = this._symbol;
3302var oldCurrentSymbol = this.CurrentSymbol;
3653private static bool AreCloseEnough(Symbol original, Symbol updated)
4173Symbol? symbol = getTargetMember(containingType, objectInitializer);
4189Action<int, Symbol>? initializationCompletion = null;
4213Action<int, Symbol>? initializationCompletion,
4235Action<int, Symbol>? initializationCompletion)
4239Symbol? symbol = getTargetMember(containingType, (BoundObjectInitializerMember)node.Left);
4251static Symbol? getTargetMember(TypeSymbol containingType, BoundObjectInitializerMember objectInitializer)
4253var symbol = objectInitializer.MemberSymbol;
4264int getOrCreateSlot(int containingSlot, Symbol symbol)
4269Action<int, Symbol>? visitNestedInitializer(int containingSlot, TypeSymbol containingType, Symbol symbol, BoundObjectInitializerExpressionBase initializer, bool delayCompletionForType)
4279Action<int, Symbol>? completeNestedInitializerAnalysis(
4280Symbol symbol, BoundObjectInitializerExpressionBase initializer, int slot, Action<int, TypeSymbol>? nestedCompletion,
4301Action<int, Symbol>? completeNestedInitializerAnalysisAsContinuation(BoundObjectInitializerExpressionBase initializer, Action<int, TypeSymbol>? nestedCompletion)
4303return (int containingSlot, Symbol symbol) =>
4311Action<int, Symbol>? visitMemberAssignment(BoundAssignmentOperator node, int containingSlot, Symbol symbol, bool delayCompletionForType, Func<TypeWithAnnotations, TypeWithState>? conversionCompletion = null)
4344Action<int, Symbol>? visitMemberAssignmentAsContinuation(BoundAssignmentOperator node, Func<TypeWithAnnotations, TypeWithState> conversionCompletion)
4346return (int containingSlot, Symbol symbol) =>
5536foreach (var member in getMembers(expressionType))
5553static IEnumerable<Symbol> getMembers(TypeSymbol type)
5556foreach (var member in type.GetMembers())
5561foreach (var member in baseType.GetMembers())
5566foreach (var member in interfaceType.GetMembers())
6439var implementationMethod = baseType.FindImplementationForInterfaceMember(constructedMethod);
6636private FlowAnalysisAnnotations GetRValueAnnotations(Symbol? symbol)
7246foreach (Symbol member in type.GetMembers(memberName))
8229private static Symbol AsMemberOfType(TypeSymbol? type, Symbol symbol)
8274if (tryAsMemberOfSingleType(containingType, out var result))
8290if (tryAsMemberOfSingleType(containingType, out var result))
8304bool tryAsMemberOfSingleType(NamedTypeSymbol singleType, [NotNullWhen(true)] out Symbol? result)
8311var symbolDef = symbol.OriginalDefinition;
8574int targetSlot = GetNullableOfTValueSlot(containingType, containingSlot, out Symbol? symbol);
10114private FlowAnalysisAnnotations GetObjectInitializerMemberLValueAnnotations(Symbol memberSymbol)
10718var updatedSymbol = VisitMemberAccess(node, node.ReceiverOpt, node.FieldSymbol);
10728var updatedMember = VisitMemberAccess(node, node.ReceiverOpt, property);
10811var updatedSymbol = VisitMemberAccess(node, node.ReceiverOpt, node.EventSymbol);
10816private Symbol VisitMemberAccess(BoundExpression node, BoundExpression? receiverOpt, Symbol member)
10864private SpecialMember? GetNullableOfTMember(Symbol member)
10884private int GetNullableOfTValueSlot(TypeSymbol containingType, int containingSlot, out Symbol? valueProperty, bool forceSlotEvenIfEmpty = false)
12728private sealed class ExpressionAndSymbolEqualityComparer : IEqualityComparer<(BoundNode? expr, Symbol symbol)>
12734public bool Equals((BoundNode? expr, Symbol symbol) x, (BoundNode? expr, Symbol symbol) y)
12745public int GetHashCode((BoundNode? expr, Symbol symbol) obj)
FlowAnalysis\NullableWalker.SnapshotManager.cs (19)
31private readonly ImmutableDictionary<(BoundNode?, Symbol), Symbol> _updatedSymbolsMap;
35private SnapshotManager(ImmutableArray<SharedWalkerState> walkerSharedStates, ImmutableArray<(int position, Snapshot snapshot)> incrementalSnapshots, ImmutableDictionary<(BoundNode?, Symbol), Symbol> updatedSymbolsMap)
74if (_updatedSymbolsMap.TryGetValue((null, lambda), out var updatedDelegate))
82internal bool TryGetUpdatedSymbol(BoundNode node, Symbol symbol, [NotNullWhen(true)] out Symbol? updatedSymbol)
148private readonly ImmutableDictionary<(BoundNode?, Symbol), Symbol>.Builder _updatedSymbolMap = ImmutableDictionary.CreateBuilder<(BoundNode?, Symbol), Symbol>(ExpressionAndSymbolEqualityComparer.Instance, Symbols.SymbolEqualityComparer.ConsiderEverything);
166private readonly PooledDictionary<Symbol, int> _symbolToSlot = PooledDictionary<Symbol, int>.GetInstance();
181internal int EnterNewWalker(Symbol symbol)
220internal void SetUpdatedSymbol(BoundNode node, Symbol originalSymbol, Symbol updatedSymbol)
228internal void RemoveSymbolIfPresent(BoundNode node, Symbol symbol)
233private static (BoundNode?, Symbol) GetKey(BoundNode node, Symbol symbol)
FlowAnalysis\NullableWalker.Variables.cs (13)
38internal readonly Symbol? Symbol;
48internal readonly ImmutableDictionary<Symbol, TypeWithAnnotations> VariableTypes;
50internal VariablesSnapshot(int id, VariablesSnapshot? container, Symbol? symbol, ImmutableArray<KeyValuePair<VariableIdentifier, int>> variableSlot, ImmutableDictionary<Symbol, TypeWithAnnotations> variableTypes)
59internal bool TryGetType(Symbol symbol, out TypeWithAnnotations type)
118internal readonly Symbol? Symbol;
128private readonly PooledDictionary<Symbol, TypeWithAnnotations> _variableTypes = SpecializedSymbolCollections.GetPooledSymbolDictionaryInstance<Symbol, TypeWithAnnotations>();
140internal static Variables Create(Symbol? symbol)
183private Variables(int id, Variables? container, Symbol? symbol)
297internal bool TryGetType(Symbol symbol, out TypeWithAnnotations type)
303internal void SetType(Symbol symbol, TypeWithAnnotations type)
353private Variables GetVariablesContainingSymbol(Symbol symbol)
FlowAnalysis\ReadWriteWalker.cs (25)
22CSharpCompilation compilation, Symbol member, BoundNode node, BoundNode firstInRegion, BoundNode lastInRegion, HashSet<PrefixUnaryExpressionSyntax> unassignedVariableAddressOfSyntaxes,
23out IEnumerable<Symbol> readInside,
24out IEnumerable<Symbol> writtenInside,
25out IEnumerable<Symbol> readOutside,
26out IEnumerable<Symbol> writtenOutside,
27out IEnumerable<Symbol> captured,
28out IEnumerable<Symbol> unsafeAddressTaken,
29out IEnumerable<Symbol> capturedInside,
30out IEnumerable<Symbol> capturedOutside,
40readInside = writtenInside = readOutside = writtenOutside = captured = unsafeAddressTaken = capturedInside = capturedOutside = Enumerable.Empty<Symbol>();
65private readonly HashSet<Symbol> _readInside = new HashSet<Symbol>();
66private readonly HashSet<Symbol> _writtenInside = new HashSet<Symbol>();
67private readonly HashSet<Symbol> _readOutside = new HashSet<Symbol>();
68private readonly HashSet<Symbol> _writtenOutside = new HashSet<Symbol>();
70private ReadWriteWalker(CSharpCompilation compilation, Symbol member, BoundNode node, BoundNode firstInRegion, BoundNode lastInRegion,
78Symbol current = CurrentSymbol;
102Symbol containing = current.ContainingSymbol;
125protected override void NoteRead(Symbol variable, ParameterSymbol rangeVariableUnderlyingParameter = null)
132protected override void NoteWrite(Symbol variable, BoundExpression value, bool read, bool isRef)
170private void NoteReceiverReadOrWritten(BoundFieldAccess expr, HashSet<Symbol> readOrWritten)
178private void NoteExpressionReadOrWritten(BoundExpression receiver, HashSet<Symbol> readOrWritten)
Generated\BoundNodes.xml.Generated.cs (53)
530public BoundDeconstructValuePlaceholder(SyntaxNode syntax, Symbol? variableSymbol, bool isDiscardExpression, TypeSymbol type, bool hasErrors)
540public BoundDeconstructValuePlaceholder(SyntaxNode syntax, Symbol? variableSymbol, bool isDiscardExpression, TypeSymbol type)
551public Symbol? VariableSymbol { get; }
557public BoundDeconstructValuePlaceholder Update(Symbol? variableSymbol, bool isDiscardExpression, TypeSymbol type)
980public BoundBadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray<Symbol?> symbols, ImmutableArray<BoundExpression> childBoundNodes, TypeSymbol? type, bool hasErrors = false)
993public ImmutableArray<Symbol?> Symbols { get; }
999public BoundBadExpression Update(LookupResultKind resultKind, ImmutableArray<Symbol?> symbols, ImmutableArray<BoundExpression> childBoundNodes, TypeSymbol? type)
6075public BoundMethodGroup(SyntaxNode syntax, ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, string name, ImmutableArray<MethodSymbol> methods, Symbol? lookupSymbolOpt, DiagnosticInfo? lookupError, BoundMethodGroupFlags? flags, FunctionTypeSymbol? functionType, BoundExpression? receiverOpt, LookupResultKind resultKind, bool hasErrors = false)
6094public Symbol? LookupSymbolOpt { get; }
6102public BoundMethodGroup Update(ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, string name, ImmutableArray<MethodSymbol> methods, Symbol? lookupSymbolOpt, DiagnosticInfo? lookupError, BoundMethodGroupFlags? flags, FunctionTypeSymbol? functionType, BoundExpression? receiverOpt, LookupResultKind resultKind)
6744public BoundObjectInitializerMember(SyntaxNode syntax, Symbol? memberSymbol, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, bool expanded, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, LookupResultKind resultKind, AccessorKind accessorKind, TypeSymbol receiverType, TypeSymbol type, bool hasErrors = false)
6765public Symbol? MemberSymbol { get; }
6779public BoundObjectInitializerMember Update(Symbol? memberSymbol, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, bool expanded, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, LookupResultKind resultKind, AccessorKind accessorKind, TypeSymbol receiverType, TypeSymbol type)
8095protected BoundObjectPattern(BoundKind kind, SyntaxNode syntax, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8106public Symbol? Variable { get; }
8112public BoundDeclarationPattern(SyntaxNode syntax, BoundTypeExpression declaredType, bool isVar, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8134public BoundDeclarationPattern Update(BoundTypeExpression declaredType, bool isVar, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType, TypeSymbol narrowedType)
8148public BoundRecursivePattern(SyntaxNode syntax, BoundTypeExpression? declaredType, MethodSymbol? deconstructMethod, ImmutableArray<BoundPositionalSubpattern> deconstruction, ImmutableArray<BoundPropertySubpattern> properties, bool isExplicitNotNullTest, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8175public BoundRecursivePattern Update(BoundTypeExpression? declaredType, MethodSymbol? deconstructMethod, ImmutableArray<BoundPositionalSubpattern> deconstruction, ImmutableArray<BoundPropertySubpattern> properties, bool isExplicitNotNullTest, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType, TypeSymbol narrowedType)
8189public BoundListPattern(SyntaxNode syntax, ImmutableArray<BoundPattern> subpatterns, bool hasSlice, BoundExpression? lengthAccess, BoundExpression? indexerAccess, BoundListPatternReceiverPlaceholder? receiverPlaceholder, BoundListPatternIndexPlaceholder? argumentPlaceholder, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8219public BoundListPattern Update(ImmutableArray<BoundPattern> subpatterns, bool hasSlice, BoundExpression? lengthAccess, BoundExpression? indexerAccess, BoundListPatternReceiverPlaceholder? receiverPlaceholder, BoundListPatternIndexPlaceholder? argumentPlaceholder, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType, TypeSymbol narrowedType)
8326public BoundPositionalSubpattern(SyntaxNode syntax, Symbol? symbol, BoundPattern pattern, bool hasErrors = false)
8335public Symbol? Symbol { get; }
8340public BoundPositionalSubpattern Update(Symbol? symbol, BoundPattern pattern)
8384public BoundPropertySubpatternMember(SyntaxNode syntax, BoundPropertySubpatternMember? receiver, Symbol? symbol, TypeSymbol type, bool hasErrors = false)
8396public Symbol? Symbol { get; }
8402public BoundPropertySubpatternMember Update(BoundPropertySubpatternMember? receiver, Symbol? symbol, TypeSymbol type)
8627protected VariablePendingInference(BoundKind kind, SyntaxNode syntax, Symbol variableSymbol, BoundExpression? receiverOpt, bool hasErrors = false)
8638public Symbol VariableSymbol { get; }
8644public OutVariablePendingInference(SyntaxNode syntax, Symbol variableSymbol, BoundExpression? receiverOpt, bool hasErrors = false)
8656public OutVariablePendingInference Update(Symbol variableSymbol, BoundExpression? receiverOpt)
8670public DeconstructionVariablePendingInference(SyntaxNode syntax, Symbol variableSymbol, BoundExpression? receiverOpt, bool hasErrors = false)
8682public DeconstructionVariablePendingInference Update(Symbol variableSymbol, BoundExpression? receiverOpt)
8696public OutDeconstructVarPendingInference(SyntaxNode syntax, Symbol? variableSymbol, bool isDiscardExpression, bool hasErrors)
8703public OutDeconstructVarPendingInference(SyntaxNode syntax, Symbol? variableSymbol, bool isDiscardExpression)
8711public Symbol? VariableSymbol { get; }
8717public OutDeconstructVarPendingInference Update(Symbol? variableSymbol, bool isDiscardExpression)
12256private readonly ImmutableDictionary<Symbol, Symbol>.Builder _remappedSymbols;
12258public NullabilityRewriter(ImmutableDictionary<BoundExpression, (NullabilityInfo Info, TypeSymbol? Type)> updatedNullabilities, NullableWalker.SnapshotManager? snapshotManager, ImmutableDictionary<Symbol, Symbol>.Builder remappedSymbols)
12320Symbol? variableSymbol = GetUpdatedSymbol(node, node.VariableSymbol);
12486ImmutableArray<Symbol?> symbols = GetUpdatedArray(node, node.Symbols);
13930Symbol? lookupSymbolOpt = GetUpdatedSymbol(node, node.LookupSymbolOpt);
14203Symbol? memberSymbol = GetUpdatedSymbol(node, node.MemberSymbol);
14764Symbol? variable = GetUpdatedSymbol(node, node.Variable);
14775Symbol? variable = GetUpdatedSymbol(node, node.Variable);
14787Symbol? variable = GetUpdatedSymbol(node, node.Variable);
14822Symbol? symbol = GetUpdatedSymbol(node, node.Symbol);
14829Symbol? symbol = GetUpdatedSymbol(node, node.Symbol);
14898Symbol variableSymbol = GetUpdatedSymbol(node, node.VariableSymbol);
14916Symbol variableSymbol = GetUpdatedSymbol(node, node.VariableSymbol);
14934Symbol? variableSymbol = GetUpdatedSymbol(node, node.VariableSymbol);
Lowering\ClosureConversion\ExpressionLambdaRewriter.cs (8)
351return new BoundBadExpression(node.Syntax, default(LookupResultKind), ImmutableArray<Symbol>.Empty, ImmutableArray.Create<BoundExpression>(node), ExpressionType);
382return new BoundBadExpression(node.Syntax, 0, ImmutableArray<Symbol>.Empty, ImmutableArray.Create<BoundExpression>(node), ExpressionType);
909private BoundExpression InitializerMemberSetter(Symbol symbol)
924private BoundExpression InitializerMemberGetter(Symbol symbol)
951var sym = ((BoundObjectInitializerMember)a.Left).MemberSymbol;
1091return new BoundBadExpression(node.Syntax, default(LookupResultKind), ImmutableArray<Symbol>.Empty, ImmutableArray.Create<BoundExpression>(node), node.Type);
1098return new BoundBadExpression(node.Syntax, default(LookupResultKind), ImmutableArray<Symbol>.Empty, ImmutableArray.Create<BoundExpression>(node), node.Type);
1130return new BoundBadExpression(node.Syntax, default(LookupResultKind), ImmutableArray<Symbol>.Empty, ImmutableArray.Create<BoundExpression>(node), node.Type);
Lowering\Instrumentation\LocalStateTracingInstrumenter.cs (6)
204private MethodSymbol? GetLocalOrParameterStoreLogger(TypeSymbol variableType, Symbol targetSymbol, bool? refAssignmentSourceIsLocal, SyntaxNode syntax)
388if (!TryGetLocalOrParameterInfo(original.Left, out var targetSymbol, out var targetType, out var targetIndex))
409private bool TryGetLocalOrParameterInfo(BoundNode node, [NotNullWhen(true)] out Symbol? symbol, [NotNullWhen(true)] out TypeSymbol? type, [NotNullWhen(true)] out BoundExpression? indexExpression)
437Symbol targetSymbol,
485private BoundExpression VariableRead(Symbol localOrParameterSymbol)
583if (!TryGetLocalOrParameterInfo(arguments[i], out var targetSymbol, out var targetType, out var targetIndex))
Lowering\LocalRewriter\LocalRewriter_Event.cs (5)
128clearCall = new BoundBadExpression(syntax, LookupResultKind.NotInvocable, ImmutableArray<Symbol?>.Empty, ImmutableArray.Create<BoundExpression>(removeDelegate), ErrorTypeSymbol.UnknownResultType);
170marshalCall = new BoundBadExpression(syntax, LookupResultKind.NotInvocable, ImmutableArray<Symbol?>.Empty, marshalArguments, ErrorTypeSymbol.UnknownResultType);
265getOrCreateCall = new BoundBadExpression(syntax, LookupResultKind.NotInvocable, ImmutableArray<Symbol?>.Empty, ImmutableArray.Create<BoundExpression>(fieldAccess), ErrorTypeSymbol.UnknownResultType);
287return new BoundBadExpression(syntax, LookupResultKind.NotInvocable, ImmutableArray<Symbol?>.Empty, ImmutableArray.Create(getOrCreateCall), ErrorTypeSymbol.UnknownResultType);
333return new BoundBadExpression(node.Syntax, LookupResultKind.NotCreatable, ImmutableArray.Create<Symbol?>(node.Event),
Lowering\LocalRewriter\LocalRewriter_ObjectCreationExpression.cs (4)
217var property = left.MemberSymbol;
389newGuid = new BoundBadExpression(node.Syntax, LookupResultKind.NotCreatable, ImmutableArray<Symbol?>.Empty, ImmutableArray<BoundExpression>.Empty, ErrorTypeSymbol.UnknownResultType);
407callGetTypeFromCLSID = new BoundBadExpression(node.Syntax, LookupResultKind.OverloadResolutionFailure, ImmutableArray<Symbol?>.Empty, ImmutableArray<BoundExpression>.Empty, ErrorTypeSymbol.UnknownResultType);
419rewrittenObjectCreation = new BoundBadExpression(node.Syntax, LookupResultKind.OverloadResolutionFailure, ImmutableArray<Symbol?>.Empty, ImmutableArray<BoundExpression>.Empty, node.Type);
Lowering\StateMachineRewriter\IteratorAndAsyncCaptureWalker.cs (14)
30private readonly OrderedSet<Symbol> _variablesToHoist = new OrderedSet<Symbol>();
34private MultiDictionary<Symbol, SyntaxNode> _lazyDisallowedCaptures;
42private IteratorAndAsyncCaptureWalker(CSharpCompilation compilation, MethodSymbol method, BoundNode node, HashSet<Symbol> initiallyAssignedVariables)
53public static OrderedSet<Symbol> Analyze(CSharpCompilation compilation, MethodSymbol method, BoundNode node, DiagnosticBag diagnostics)
113var variablesToHoist = new OrderedSet<Symbol>();
136private static bool HoistInDebugBuild(Symbol symbol)
209private void CaptureVariable(Symbol variable, SyntaxNode syntax)
215(_lazyDisallowedCaptures ??= new MultiDictionary<Symbol, SyntaxNode>()).Add(variable, syntax);
258protected override void ReportUnassigned(Symbol symbol, SyntaxNode node, int slot, bool skipIfUseBeforeDeclaration)
348private readonly HashSet<Symbol> _localsInScope;
358_localsInScope = new HashSet<Symbol>();
387private void AddVariable(Symbol local)
422private void Capture(Symbol s, SyntaxNode syntax)
Lowering\StateMachineRewriter\StateMachineRewriter.cs (10)
30protected IReadOnlyDictionary<Symbol, CapturedSymbolReplacement>? nonReusableLocalProxies;
33protected IOrderedReadOnlySet<Symbol>? hoistedVariables;
34protected Dictionary<Symbol, CapturedSymbolReplacement>? initialParameters;
86protected abstract BoundStatement GenerateStateMachineCreation(LocalSymbol stateMachineVariable, NamedTypeSymbol frameType, IReadOnlyDictionary<Symbol, CapturedSymbolReplacement> proxies);
114initialParameters = new Dictionary<Symbol, CapturedSymbolReplacement>();
137IEnumerable<Symbol> variablesToHoist,
138out IReadOnlyDictionary<Symbol, CapturedSymbolReplacement> proxies,
142var proxiesBuilder = new Dictionary<Symbol, CapturedSymbolReplacement>();
151foreach (var variable in variablesToHoist)
306protected BoundStatement GenerateParameterStorage(LocalSymbol stateMachineVariable, IReadOnlyDictionary<Symbol, CapturedSymbolReplacement> proxies)
Lowering\SyntheticBoundNodeFactory.cs (9)
233return new BoundBadExpression(Syntax, LookupResultKind.Empty, ImmutableArray<Symbol?>.Empty, ImmutableArray<BoundExpression>.Empty, type, hasErrors: true);
315public Symbol? WellKnownMember(WellKnownMember wm, bool isOptional)
317Symbol? wellKnownMember = Binder.GetWellKnownTypeMember(Compilation, wm, Diagnostics, syntax: Syntax, isOptional: true);
328public Symbol WellKnownMember(WellKnownMember wm)
350public Symbol SpecialMember(SpecialMember sm)
352var result = SpecialMember(sm, isOptional: false);
357public Symbol? SpecialMember(SpecialMember sm, bool isOptional = false)
359Symbol specialMember = Compilation.GetSpecialTypeMember(sm);
789return new BoundBadExpression(Syntax, default(LookupResultKind), ImmutableArray<Symbol?>.Empty, args.AsImmutable(), receiver);
Symbols\AliasSymbol.cs (6)
53private readonly Symbol _containingSymbol;
55protected AliasSymbol(string aliasName, Symbol containingSymbol, ImmutableArray<Location> locations, bool isExtern)
73internal static AliasSymbol CreateCustomDebugInfoAlias(NamespaceOrTypeSymbol targetSymbol, SyntaxToken aliasToken, Symbol containingSymbol, bool isExtern)
206public sealed override Symbol ContainingSymbol
243public override bool Equals(Symbol? obj, TypeCompareKind compareKind)
436internal AliasSymbolFromResolvedTarget(NamespaceOrTypeSymbol target, string aliasName, Symbol containingSymbol, ImmutableArray<Location> locations, bool isExtern)
Symbols\Attributes\AttributeData.cs (6)
215internal void DecodeSecurityAttribute<T>(Symbol targetSymbol, CSharpCompilation compilation, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
290foreach (Symbol foundMember in type.GetMembers(memberName))
339private DeclarativeSecurityAction DecodeSecurityAttributeAction(Symbol targetSymbol, CSharpCompilation compilation, AttributeSyntax? nodeOpt, out bool hasErrors, BindingDiagnosticBag diagnostics)
382private DeclarativeSecurityAction DecodeSecurityAction(TypedConstant typedValue, Symbol targetSymbol, AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics, out bool hasErrors)
653foreach (var member in AttributeClass.GetMembers(memberName))
672internal bool ShouldEmitAttribute(Symbol target, bool isReturnType, bool emittingAssemblyAttributesInNetModule)
Symbols\Compilation_WellKnownMembers.cs (12)
32private Symbol?[]? _lazyWellKnownTypeMembers;
77internal Symbol? GetWellKnownTypeMember(WellKnownMember member)
88var wellKnownTypeMembers = new Symbol[(int)WellKnownMember.Count];
102Symbol? result = null;
245internal static Symbol? GetRuntimeMember(NamedTypeSymbol declaringType, in MemberDescriptor descriptor, SignatureComparer<MethodSymbol, FieldSymbol, PropertySymbol, TypeSymbol, ParameterSymbol> comparer, AssemblySymbol? accessWithinOpt)
251internal static Symbol? GetRuntimeMember(ImmutableArray<Symbol> members, in MemberDescriptor descriptor, SignatureComparer<MethodSymbol, FieldSymbol, PropertySymbol, TypeSymbol, ParameterSymbol> comparer, AssemblySymbol? accessWithinOpt)
257Symbol? result = null;
288foreach (var member in members)
296!(member.DeclaredAccessibility == Accessibility.Public || (accessWithinOpt is object && Symbol.IsSymbolAccessible(member, accessWithinOpt))))
418var wellKnownMember = Binder.GetWellKnownTypeMember(this, arg.Key, useSiteInfo: out _, isOptional: true);
687var member = Binder.GetWellKnownTypeMember(this, attributeCtor,
Symbols\ConstraintsHelper.cs (10)
889this Symbol containingSymbol,
927Symbol containingSymbol,
1029Symbol containingSymbol,
1066if (typeArgument.Type is NamedTypeSymbol { IsInterface: true } iface && SelfOrBaseHasStaticAbstractMember(iface, ref useSiteInfo, out Symbol member))
1093static bool errorIfNotSatisfiesConstructorConstraint(Symbol containingSymbol, TypeParameterSymbol typeParameter, TypeWithAnnotations typeArgument, ArrayBuilder<TypeParameterDiagnosticInfo> diagnosticsBuilder)
1117Symbol containingSymbol,
1140Symbol containingSymbol,
1381private static bool SelfOrBaseHasStaticAbstractMember(NamedTypeSymbol iface, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out Symbol memberWithoutImplementation)
1385foreach (Symbol m in iface.GetMembers())
1396foreach (Symbol m in baseInterface.GetMembers())
Symbols\ExtendedErrorTypeSymbol.cs (11)
25private readonly ImmutableArray<Symbol> _candidateSymbols; // Best guess at what user meant, but was wrong.
52private ExtendedErrorTypeSymbol(NamespaceOrTypeSymbol? containingSymbol, string name, int arity, DiagnosticInfo? errorInfo, bool unreported, bool variableUsedBeforeDeclaration, ImmutableArray<Symbol> candidateSymbols, LookupResultKind resultKind)
69internal ExtendedErrorTypeSymbol(NamespaceOrTypeSymbol? containingSymbol, Symbol guessSymbol, LookupResultKind resultKind, DiagnosticInfo errorInfo, bool unreported = false)
70: this(containingSymbol, ImmutableArray.Create<Symbol>(guessSymbol), resultKind, errorInfo, GetArity(guessSymbol), unreported)
74internal ExtendedErrorTypeSymbol(NamespaceOrTypeSymbol? containingSymbol, ImmutableArray<Symbol> candidateSymbols, LookupResultKind resultKind, DiagnosticInfo errorInfo, int arity, bool unreported = false)
88private static ImmutableArray<Symbol> UnwrapErrorCandidates(ImmutableArray<Symbol> candidateSymbols)
115public override ImmutableArray<Symbol> CandidateSymbols => _candidateSymbols.NullToEmpty();
151public override Symbol? ContainingSymbol
270foreach (Symbol sym in oldError._candidateSymbols)
312private static int GetArity(Symbol symbol)
Symbols\Metadata\PE\PENamedTypeSymbol.cs (37)
53private ImmutableArray<Symbol> _lazyMembersInDeclarationOrder;
59private Dictionary<string, ImmutableArray<Symbol>> _lazyMembersByName;
372Symbol s = _container;
607public override Symbol ContainingSymbol
899public override ImmutableArray<Symbol> GetMembers()
953ImmutableArray<Symbol> staticFields = GetMembers();
1063ImmutableArray<Symbol> members = GetMembers();
1166internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers()
1171internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers(string name)
1176private class DeclarationOrderTypeSymbolComparer : IComparer<Symbol>
1182public int Compare(Symbol x, Symbol y)
1272ArrayBuilder<Symbol> members = null;
1278members = ArrayBuilder<Symbol>.GetInstance();
1327ArrayBuilder<Symbol> nonFieldMembers = ArrayBuilder<Symbol>.GetInstance();
1403Symbol previous = null;
1413Symbol current = s;
1448members = ArrayBuilder<Symbol>.GetInstance();
1449foreach (var member in _lazyMembersInDeclarationOrder)
1459Dictionary<string, ImmutableArray<Symbol>> membersDict = GroupByName(members);
1492internal override ImmutableArray<Symbol> GetSimpleNonTypeMembers(string name)
1496ImmutableArray<Symbol> m;
1499m = ImmutableArray<Symbol>.Empty;
1505public override ImmutableArray<Symbol> GetMembers(string name)
1509ImmutableArray<Symbol> m;
1512m = ImmutableArray<Symbol>.Empty;
1519m = m.Concat(StaticCast<Symbol>.From(t));
1982private PooledDictionary<MethodDefinitionHandle, PEMethodSymbol> CreateMethods(ArrayBuilder<Symbol> members)
2009private void CreateProperties(Dictionary<MethodDefinitionHandle, PEMethodSymbol> methodHandleToSymbol, ArrayBuilder<Symbol> members)
2041ArrayBuilder<Symbol> members)
2086private static Dictionary<string, ImmutableArray<Symbol>> GroupByName(ArrayBuilder<Symbol> symbols)
2440private static int GetIndexOfFirstMember(ImmutableArray<Symbol> members, SymbolKind kind)
2457private static IEnumerable<TSymbol> GetMembers<TSymbol>(ImmutableArray<Symbol> members, SymbolKind kind, int offset = -1)
2458where TSymbol : Symbol
2467var member = members[i];
Symbols\NamedTypeSymbol.cs (29)
29private static readonly ImmutableSegmentedDictionary<string, Symbol> RequiredMembersErrorSentinel = ImmutableSegmentedDictionary<string, Symbol>.Empty.Add("<error sentinel>", null!);
35private ImmutableSegmentedDictionary<string, Symbol> _lazyRequiredMembers = default;
211ImmutableArray<Symbol> candidates = GetSimpleNonTypeMembers(name);
215foreach (var candidate in candidates)
261ImmutableArray<Symbol> instanceCandidates = includeInstance
263: ImmutableArray<Symbol>.Empty;
264ImmutableArray<Symbol> staticCandidates = includeStatic
266: ImmutableArray<Symbol>.Empty;
274foreach (Symbol candidate in instanceCandidates)
282foreach (Symbol candidate in staticCandidates)
303ImmutableArray<Symbol> candidates = GetSimpleNonTypeMembers(WellKnownMemberNames.Indexer);
313foreach (Symbol candidate in candidates)
348foreach (var member in members)
553internal ImmutableSegmentedDictionary<string, Symbol> AllRequiredMembers
561return ImmutableSegmentedDictionary<string, Symbol>.Empty;
575bool success = tryCalculateRequiredMembers(out ImmutableSegmentedDictionary<string, Symbol>.Builder? builder);
578? builder?.ToImmutable() ?? BaseTypeNoUseSiteDiagnostics?.AllRequiredMembers ?? ImmutableSegmentedDictionary<string, Symbol>.Empty
583bool tryCalculateRequiredMembers(out ImmutableSegmentedDictionary<string, Symbol>.Builder? requiredMembersBuilder)
591var baseAllRequiredMembers = BaseTypeNoUseSiteDiagnostics?.AllRequiredMembers ?? ImmutableSegmentedDictionary<string, Symbol>.Empty;
594foreach (var member in GetMembersUnordered())
646public abstract override ImmutableArray<Symbol> GetMembers();
653public abstract override ImmutableArray<Symbol> GetMembers(string name);
662internal virtual ImmutableArray<Symbol> GetSimpleNonTypeMembers(string name)
689internal virtual IEnumerable<Symbol> GetInstanceFieldsAndEvents()
694protected static Func<Symbol, bool> IsInstanceFieldOrEvent = symbol =>
740internal abstract ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers();
750internal abstract ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers(string name);
1436internal override bool GetUnificationUseSiteDiagnosticRecursive(ref DiagnosticInfo result, Symbol owner, ref HashSet<TypeSymbol> checkedTypes)
Symbols\NativeIntegerTypeSymbol.cs (22)
26private ImmutableArray<Symbol> _lazyMembers;
42public override Symbol ContainingSymbol => _underlyingType.ContainingSymbol;
69public override ImmutableArray<Symbol> GetMembers()
77ImmutableArray<Symbol> makeMembers(ImmutableArray<Symbol> underlyingMembers)
79var builder = ArrayBuilder<Symbol>.GetInstance();
80foreach (var underlyingMember in underlyingMembers)
140public override ImmutableArray<Symbol> GetMembers(string name) => GetMembers().WhereAsArray((member, name) => member.Name == name, name);
152internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers() => throw ExceptionUtilities.Unreachable();
154internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers(string name) => throw ExceptionUtilities.Unreachable();
245internal static bool EqualsHelper<TSymbol>(TSymbol symbol, Symbol? other, TypeCompareKind comparison, Func<TSymbol, Symbol> getUnderlyingSymbol)
246where TSymbol : Symbol
265internal static void VerifyEquality(Symbol symbolA, Symbol symbolB)
343public override Symbol ContainingSymbol => _container;
372public override Symbol? AssociatedSymbol => _associatedSymbol;
381public override bool Equals(Symbol? other, TypeCompareKind comparison) => NativeIntegerTypeSymbol.EqualsHelper(this, other, comparison, symbol => symbol.UnderlyingMethod);
417public override Symbol ContainingSymbol => _container;
435public override bool Equals(Symbol? other, TypeCompareKind comparison) => NativeIntegerTypeSymbol.EqualsHelper(this, other, comparison, symbol => symbol._underlyingParameter);
468public override Symbol ContainingSymbol => _container;
484public override bool Equals(Symbol? other, TypeCompareKind comparison) => NativeIntegerTypeSymbol.EqualsHelper(this, other, comparison, symbol => symbol._underlyingProperty);
Symbols\ObsoleteAttributeHelpers.cs (9)
59private static ThreeState GetObsoleteContextState(Symbol symbol, bool forceComplete, Func<Symbol, ThreeState> getStateFromSymbol)
66var associatedSymbol = ((FieldSymbol)symbol).AssociatedSymbol;
98internal static ObsoleteDiagnosticKind GetObsoleteDiagnosticKind(Symbol symbol, Symbol containingMember, bool forceComplete = false)
130static ObsoleteDiagnosticKind getDiagnosticKind(Symbol containingMember, bool forceComplete, Func<Symbol, ThreeState> getStateFromSymbol)
152internal static DiagnosticInfo CreateObsoleteDiagnostic(Symbol symbol, BinderFlags location)
158static DiagnosticInfo createObsoleteDiagnostic(Symbol symbol, BinderFlags location)
Symbols\OverriddenOrHiddenMembersHelpers.cs (68)
84private static OverriddenOrHiddenMembersResult MakeOverriddenOrHiddenMembersWorker(Symbol member)
97Symbol associatedPropertyOrEvent = accessor.AssociatedSymbol;
134ArrayBuilder<Symbol> hiddenBuilder;
135ImmutableArray<Symbol> overriddenMembers;
138ImmutableArray<Symbol> hiddenMembers = hiddenBuilder == null ? ImmutableArray<Symbol>.Empty : hiddenBuilder.ToImmutableAndFree();
142private static void FindOverriddenOrHiddenMembers(Symbol member, NamedTypeSymbol containingType, bool memberIsFromSomeCompilation,
143out ArrayBuilder<Symbol> hiddenBuilder,
144out ImmutableArray<Symbol> overriddenMembers)
146Symbol bestMatch = null;
151Symbol knownOverriddenMember = member switch
180public static Symbol FindFirstHiddenMemberIfAny(Symbol member, bool memberIsFromSomeCompilation)
182ArrayBuilder<Symbol> hiddenBuilder;
186Symbol result = hiddenBuilder?.FirstOrDefault();
249ArrayBuilder<Symbol> hiddenBuilder = null;
253foreach (Symbol hiddenByProperty in hiddenOrOverriddenByProperty.HiddenMembers)
283ImmutableArray<Symbol> overriddenAccessors = ImmutableArray<Symbol>.Empty;
291ImmutableArray<Symbol> hiddenMembers = hiddenBuilder == null ? ImmutableArray<Symbol>.Empty : hiddenBuilder.ToImmutableAndFree();
341ArrayBuilder<Symbol> hiddenBuilder = null;
345foreach (Symbol hiddenByEvent in hiddenOrOverriddenByEvent.HiddenMembers)
373ImmutableArray<Symbol> overriddenAccessors = ImmutableArray<Symbol>.Empty;
383ImmutableArray<Symbol> hiddenMembers = hiddenBuilder == null ? ImmutableArray<Symbol>.Empty : hiddenBuilder.ToImmutableAndFree();
409internal static OverriddenOrHiddenMembersResult MakeInterfaceOverriddenOrHiddenMembers(Symbol member, bool memberIsFromSomeCompilation)
419ArrayBuilder<Symbol> hiddenBuilder = null;
428Symbol currTypeBestMatch;
430ArrayBuilder<Symbol> currTypeHiddenBuilder;
492ImmutableArray<Symbol> overriddenMembers = ImmutableArray<Symbol>.Empty;
496ArrayBuilder<Symbol> hiddenAndRelatedBuilder = null;
497foreach (Symbol hidden in hiddenBuilder)
508ImmutableArray<Symbol> hiddenMembers = hiddenBuilder == null ? ImmutableArray<Symbol>.Empty : hiddenBuilder.ToImmutableAndFree();
533Symbol member,
536Symbol knownOverriddenMember,
538out Symbol currTypeBestMatch,
540out ArrayBuilder<Symbol> hiddenBuilder)
551IEqualityComparer<Symbol> exactMatchComparer = memberIsFromSomeCompilation
555IEqualityComparer<Symbol> fallbackComparer = memberIsFromSomeCompilation
562foreach (Symbol otherMember in currType.GetMembers(member.Name))
674Symbol minCustomModifierMatch = currTypeBestMatch;
676foreach (Symbol otherMember in currType.GetMembers(member.Name))
708Symbol representativeMember,
709out ImmutableArray<Symbol> overriddenMembers,
710ref ArrayBuilder<Symbol> hiddenBuilder)
712overriddenMembers = ImmutableArray<Symbol>.Empty;
723ArrayBuilder<Symbol> overriddenBuilder = ArrayBuilder<Symbol>.GetInstance();
733overriddenMembers = ImmutableArray.Create<Symbol>(representativeMember);
753private static void AddHiddenMemberIfApplicable(ref ArrayBuilder<Symbol> hiddenBuilder, SymbolKind hidingMemberKind, Symbol hiddenMember)
789private static void FindOtherOverriddenMethodsInContainingType(Symbol representativeMember, bool overridingMemberIsFromSomeCompilation, ArrayBuilder<Symbol> overriddenBuilder)
796foreach (Symbol otherMember in representativeMember.ContainingType.GetMembers(representativeMember.Name))
851private static void FindOtherHiddenMembersInContainingType(SymbolKind hidingMemberKind, Symbol representativeMember, ref ArrayBuilder<Symbol> hiddenBuilder)
858IEqualityComparer<Symbol> comparer = MemberSignatureComparer.CSharpCustomModifierOverrideComparer;
859foreach (Symbol otherMember in representativeMember.ContainingType.GetMembers(representativeMember.Name))
871private static bool CanOverrideOrHide(Symbol member)
887private static bool TypeOrReturnTypeHasCustomModifiers(Symbol member)
909private static int CustomModifierCount(Symbol member)
991foreach (Symbol otherMethod in method.ContainingType.GetMembers(method.Name))
1032foreach (Symbol otherMember in currType.GetMembers(method.Name))
1070private static bool IsOverriddenSymbolAccessible(Symbol overridden, NamedTypeSymbol overridingContainingType)
Symbols\Retargeting\RetargetingSymbolTranslator.cs (42)
31private readonly ConcurrentDictionary<Symbol, Symbol> _symbolMap =
32new ConcurrentDictionary<Symbol, Symbol>(concurrencyLevel: 2, capacity: 4);
34private readonly Func<Symbol, RetargetingMethodSymbol> _createRetargetingMethod;
35private readonly Func<Symbol, RetargetingNamespaceSymbol> _createRetargetingNamespace;
36private readonly Func<Symbol, RetargetingTypeParameterSymbol> _createRetargetingTypeParameter;
37private readonly Func<Symbol, RetargetingNamedTypeSymbol> _createRetargetingNamedType;
38private readonly Func<Symbol, FieldSymbol> _createRetargetingField;
39private readonly Func<Symbol, RetargetingPropertySymbol> _createRetargetingProperty;
40private readonly Func<Symbol, RetargetingEventSymbol> _createRetargetingEvent;
42private RetargetingMethodSymbol CreateRetargetingMethod(Symbol symbol)
48private RetargetingNamespaceSymbol CreateRetargetingNamespace(Symbol symbol)
54private RetargetingNamedTypeSymbol CreateRetargetingNamedType(Symbol symbol)
60private FieldSymbol CreateRetargetingField(Symbol symbol)
86private RetargetingPropertySymbol CreateRetargetingProperty(Symbol symbol)
92private RetargetingEventSymbol CreateRetargetingEvent(Symbol symbol)
98private RetargetingTypeParameterSymbol CreateRetargetingTypeParameter(Symbol symbol)
105: CSharpSymbolVisitor<RetargetOptions, Symbol>
118private ConcurrentDictionary<Symbol, Symbol> SymbolMap
162public Symbol Retarget(Symbol symbol)
827public ImmutableArray<Symbol> Retarget(ImmutableArray<Symbol> arr)
1029foreach (var retargetedMember in retargetedType.GetMembers(method.Name))
1095foreach (var retargetedMember in retargetedType.GetMembers(property.Name))
1114foreach (var retargetedMember in retargetedType.GetMembers(@event.Name))
1317public override Symbol VisitModule(ModuleSymbol symbol, RetargetOptions options)
1324public override Symbol VisitNamespace(NamespaceSymbol symbol, RetargetOptions options)
1329public override Symbol VisitNamedType(NamedTypeSymbol symbol, RetargetOptions options)
1334public override Symbol VisitArrayType(ArrayTypeSymbol symbol, RetargetOptions options)
1339public override Symbol VisitPointerType(PointerTypeSymbol symbol, RetargetOptions options)
1344public override Symbol VisitFunctionPointerType(FunctionPointerTypeSymbol symbol, RetargetOptions argument)
1349public override Symbol VisitMethod(MethodSymbol symbol, RetargetOptions options)
1354public override Symbol VisitParameter(ParameterSymbol symbol, RetargetOptions options)
1359public override Symbol VisitField(FieldSymbol symbol, RetargetOptions options)
1364public override Symbol VisitProperty(PropertySymbol symbol, RetargetOptions argument)
1369public override Symbol VisitTypeParameter(TypeParameterSymbol symbol, RetargetOptions options)
1374public override Symbol VisitErrorType(ErrorTypeSymbol symbol, RetargetOptions options)
1379public override Symbol VisitEvent(EventSymbol symbol, RetargetOptions options)
1384public override Symbol VisitDynamicType(DynamicTypeSymbol symbol, RetargetOptions argument)
Symbols\Source\ParameterHelpers.cs (12)
22Symbol owner,
30return MakeParameters<ParameterSyntax, SourceParameterSymbol, Symbol>(
41parameterCreationFunc: (Binder context, Symbol owner, TypeWithAnnotations parameterType,
128where TOwningSymbol : Symbol
379internal static void EnsureNullableAttributeExists(PEModuleBuilder moduleBuilder, Symbol container, ImmutableArray<ParameterSymbol> parameters)
384internal static void EnsureNullableAttributeExists(CSharpCompilation? compilation, Symbol container, ImmutableArray<ParameterSymbol> parameters, BindingDiagnosticBag? diagnostics, bool modifyCompilation)
396private static void EnsureNullableAttributeExists(CSharpCompilation compilation, Symbol container, ImmutableArray<ParameterSymbol> parameters, BindingDiagnosticBag? diagnostics, bool modifyCompilation, PEModuleBuilder? moduleBuilder)
647Symbol? owner,
654Symbol? containingSymbol,
709Symbol owner,
905internal static MethodSymbol FindContainingGenericMethod(Symbol symbol)
907for (Symbol current = symbol; (object)current != null; current = current.ContainingSymbol)
Symbols\Source\SourceMemberContainerSymbol.cs (144)
183private static readonly ObjectPool<PooledDictionary<Symbol, Symbol>> s_duplicateRecordMemberSignatureDictionary =
184PooledDictionary<Symbol, Symbol>.CreatePool(MemberSignatureComparer.RecordAPISignatureComparer);
206private Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>>? _lazyMembersDictionary;
207private Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>>? _lazyEarlyAttributeDecodingMembersDictionary;
213private ImmutableArray<Symbol> _lazyMembersFlattened;
291Symbol containingSymbol = this.ContainingSymbol;
538internal override void ForceComplete(SourceLocation? locationOpt, Predicate<Symbol>? filter, CancellationToken cancellationToken)
632ImmutableArray<Symbol> members = this.GetMembersUnordered();
638foreach (var member in members)
646foreach (var member in members)
719foreach (var member in membersAndInitializers.NonTypeMembers)
763public sealed override Symbol ContainingSymbol
895for (Symbol? container = this.ContainingType; !(container is null); container = container.ContainingType)
1048internal readonly ImmutableArray<Symbol> NonTypeMembers;
1057ImmutableArray<Symbol> nonTypeMembers,
1377private void CheckMemberNameDistinctFromType(Symbol member, BindingDiagnosticBag diagnostics)
1421internal static bool HasAsyncMethodBuilderAttribute(Symbol symbol, [NotNullWhen(true)] out TypeSymbol? builderArgument)
1443internal override ImmutableArray<Symbol> GetMembersUnordered()
1457public override ImmutableArray<Symbol> GetMembers()
1479public sealed override ImmutableArray<Symbol> GetMembers(string name)
1481ImmutableArray<Symbol> members;
1487return ImmutableArray<Symbol>.Empty;
1498internal override ImmutableArray<Symbol> GetSimpleNonTypeMembers(string name)
1505return ImmutableArray<Symbol>.Empty;
1518foreach (var m in this.GetMembers())
1548internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers()
1560internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers(string name)
1562ImmutableArray<Symbol> result;
1563return GetEarlyAttributeDecodingMembersDictionary().TryGetValue(name.AsMemory(), out result) ? result : ImmutableArray<Symbol>.Empty;
1566private Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> GetEarlyAttributeDecodingMembersDictionary()
1570if (Volatile.Read(ref _lazyMembersDictionary) is Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> result)
1580Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName;
1603private static Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> ToNameKeyedDictionary(ImmutableArray<Symbol> symbols)
1607return new Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>>(1, ReadOnlyMemoryOfCharComparer.Instance)
1615return new Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>>(ReadOnlyMemoryOfCharComparer.Instance);
1625foreach (var item in symbols)
1628var dictionary = new Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>>(accumulator.Count, ReadOnlyMemoryOfCharComparer.Instance);
1633dictionary.Add(pair.Key, pair.Value is ArrayBuilder<Symbol> arrayBuilder
1635: ImmutableArray.Create((Symbol)pair.Value));
1679internal void AssertMemberExposure(Symbol member, bool forDiagnostics = false)
1739static bool isMemberInCompleteMemberList(MembersAndInitializers? membersAndInitializers, Symbol member)
1745protected Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> GetMembersByName()
1755private Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> GetMembersByNameSlow()
1777internal override IEnumerable<Symbol> GetInstanceFieldsAndEvents()
1781IEnumerable<Symbol> result = membersAndInitializers.NonTypeMembers.Where(IsInstanceFieldOrEvent);
1920foreach (var member in GetMembersAndInitializers().NonTypeMembers)
1934foreach (var member in GetMembers("Clone"))
1942Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName = GetMembersByName();
1989Symbol? lastSym = GetTypeMembers(name).FirstOrDefault();
1993foreach (var symbol in pair.Value)
2176private void CheckIndexerNameConflicts(BindingDiagnosticBag diagnostics, Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName)
2196foreach (var symbol in members)
2229Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName,
2279foreach (var member in this.GetMembersUnordered())
2300foreach (var dup in GetMembers(tp.Name))
2312foreach (Symbol symbol in this.GetMembersUnordered())
2381foreach (var member in valuesByName)
2416var symbol = field.AssociatedSymbol ?? field;
2438foreach (var member in valuesByName)
2650foreach (var member in GetMembersUnordered())
2667foreach (var member in GetMembersUnordered())
2695foreach (var m in this.GetMembersUnordered())
2739foreach (var m in t.GetMembersUnordered())
2843private Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> MakeAllMembers(BindingDiagnosticBag diagnostics)
2845Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName;
2869Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName,
2874ImmutableArray<Symbol> typesAsSymbols = StaticCast<Symbol>.From(types);
2876ImmutableArray<Symbol> membersForName;
2890public ArrayBuilder<Symbol> NonTypeMembers = ArrayBuilder<Symbol>.GetInstance();
2951public readonly ImmutableArray<Symbol> NonTypeMembers;
2967ImmutableArray<Symbol> nonTypeMembers,
3030private ArrayBuilder<Symbol>? NonTypeMembers;
3139public IReadOnlyCollection<Symbol> GetNonTypeMembers(DeclaredMembersAndInitializers declaredMembers)
3141return NonTypeMembers ?? (IReadOnlyCollection<Symbol>)declaredMembers.NonTypeMembers;
3144public void AddNonTypeMember(Symbol member, DeclaredMembersAndInitializers declaredMembers)
3148NonTypeMembers = ArrayBuilder<Symbol>.GetInstance(declaredMembers.NonTypeMembers.Length + 1);
3155public void SetNonTypeMembers(ArrayBuilder<Symbol> members)
3372ImmutableArray<Symbol> nonTypeMembersToCheck;
3391foreach (var member in nonTypeMembersToCheck)
3418internal ImmutableArray<Symbol> GetMembersToMatchAgainstDeclarationSpan()
3434internal ImmutableArray<Symbol> GetCandidateMembersForLookup(string name)
3442ImmutableArray<Symbol> nonTypeMembersToCheck;
3465ImmutableArray<Symbol> types = GetTypeMembers(name).Cast<NamedTypeSymbol, Symbol>();
3466ArrayBuilder<Symbol>? memberBuilder = null;
3468foreach (var member in nonTypeMembersToCheck)
3477memberBuilder ??= ArrayBuilder<Symbol>.GetInstance(types.Length + 1);
3612ref Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName,
3619var membersBySignature = new Dictionary<Symbol, Symbol>(MemberSignatureComparer.PartialMethodsComparer);
3624foreach (var symbol in membersByName[name])
3631if (!membersBySignature.TryGetValue(symbol, out var prev))
3659foreach (var symbol in membersBySignature.Values)
3696void mergePartialMethods(ref Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName, ReadOnlyMemory<char> name, SourceOrdinaryMethodSymbol currentMethod, SourceOrdinaryMethodSymbol prevMethod, BindingDiagnosticBag diagnostics)
3717void mergePartialProperties(ref Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName, ReadOnlyMemory<char> name, SourcePropertySymbol currentProperty, SourcePropertySymbol prevProperty, BindingDiagnosticBag diagnostics)
3742void mergeAccessors(ref Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName, SourcePropertyAccessorSymbol? currentAccessor, SourcePropertyAccessorSymbol? prevAccessor)
3769private void DuplicateMembersByNameIfCached(ref Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName)
3774membersByName = new Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>>(membersByName, ReadOnlyMemoryOfCharComparer.Instance);
3779private static ImmutableArray<Symbol> FixPartialMethod(ImmutableArray<Symbol> symbols, SourceOrdinaryMethodSymbol part1, SourceOrdinaryMethodSymbol part2)
3801private static void FixPartialProperty(ref Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> membersByName, ReadOnlyMemory<char> name, SourcePropertySymbol part1, SourcePropertySymbol part2)
3829private static ImmutableArray<Symbol> Remove(ImmutableArray<Symbol> symbols, Symbol symbol)
3831var builder = ArrayBuilder<Symbol>.GetInstance();
3832foreach (var s in symbols)
3867foreach (var symbol in GetMembers(accessorName))
3903foreach (var symbol in GetMembers(accessorName))
3931var locationFrom = (Symbol)(getNotSet ? propertySymbol.GetMethod : propertySymbol.SetMethod) ?? propertySymbol;
3940var locationFrom = (Symbol?)(isAdder ? propertySymbol.AddMethod : propertySymbol.RemoveMethod) ?? propertySymbol;
4051private static void CheckInterfaceMembers(ImmutableArray<Symbol> nonTypeMembers, BindingDiagnosticBag diagnostics)
4053foreach (var member in nonTypeMembers)
4059private static void CheckInterfaceMember(Symbol member, BindingDiagnosticBag diagnostics)
4107ArrayBuilder<Symbol> members,
4153var symbol = initializer.FieldOpt.AssociatedSymbol ?? initializer.FieldOpt;
4181var members = ArrayBuilder<Symbol>.GetInstance(membersSoFar.Count + 1);
4201var fieldsByName = PooledDictionary<string, Symbol>.GetInstance();
4203foreach (var member in membersSoFar)
4294void addDeconstruct(SynthesizedPrimaryConstructor ctor, ImmutableArray<Symbol> positionalMembers)
4317if (!memberSignatures.TryGetValue(targetMethod, out Symbol? existingDeconstructMethod))
4365if (!memberSignatures.TryGetValue(targetMethod, out Symbol? existingConstructor))
4392MethodSymbol addPrintMembersMethod(IEnumerable<Symbol> userDefinedMembers)
4414if (!memberSignatures.TryGetValue(targetMethod, out Symbol? existingPrintMembersMethod))
4485if (!memberSignatures.TryGetValue(targetMethod, out Symbol? existingToStringMethod))
4508var objectToString = this.DeclaringCompilation.GetSpecialTypeMember(SpecialMember.System_Object__ToString);
4512foreach (var member in currentBaseType.GetSimpleNonTypeMembers(WellKnownMemberNames.ObjectToString))
4528ImmutableArray<Symbol> addProperties(ImmutableArray<ParameterSymbol> recordParameters)
4530var existingOrAddedMembers = ArrayBuilder<Symbol>.GetInstance(recordParameters.Length);
4610bool checkMemberNotHidden(Symbol symbol, ParameterSymbol param)
4644if (!memberSignatures.TryGetValue(targetMethod, out Symbol? existingHashCodeMethod))
4674if (!memberSignatures.TryGetValue(targetProperty, out Symbol? existingEqualityContractProperty))
4743if (!memberSignatures.TryGetValue(targetMethod, out Symbol? existingEqualsMethod))
4768void reportStaticOrNotOverridableAPIInRecord(Symbol symbol, BindingDiagnosticBag diagnostics)
4809foreach (var member in membersSoFar)
5269private void AddAccessorIfAvailable(ArrayBuilder<Symbol> symbols, MethodSymbol? accessorOpt)
5310foreach (var member in GetMembersUnordered())
5423foreach (var member in this.GetMembersUnordered())
Symbols\Source\SourceMemberContainerSymbol_ImplementationChecks.cs (32)
100foreach (var abstractMember in this.AbstractMembers)
134foreach (var interfaceMember in @interface.GetMembers())
158MultiDictionary<Symbol, Symbol>.ValueSet explicitImpl = this.GetExplicitImplementationForInterfaceMember(interfaceMember);
178var implementingMember = implementingMemberAndDiagnostics.Symbol;
229var info = new CSDiagnosticInfo(ErrorCode.ERR_MixingWinRTEventWithRegular, args, ImmutableArray<Symbol>.Empty, ImmutableArray.Create<Location>(this.GetFirstLocation()));
237var associatedPropertyOrEvent = interfaceMemberKind == SymbolKind.Method ? ((MethodSymbol)interfaceMember).AssociatedSymbol : null;
385private bool ReportAccessorOfInterfacePropertyOrEvent(Symbol interfacePropertyOrEvent)
395Symbol implementingPropertyOrEvent;
399MultiDictionary<Symbol, Symbol>.ValueSet explicitImpl = this.GetExplicitImplementationForInterfaceMember(interfacePropertyOrEvent);
527foreach (var member in this.GetMembersUnordered())
669private void CheckNewModifier(Symbol symbol, bool isNew, BindingDiagnosticBag diagnostics)
701foreach (var hiddenMember in currType.GetMembers(symbol.Name))
741Symbol overridingMember,
778Symbol associatedPropertyOrEvent = null;
867void checkSingleOverriddenMember(Symbol overridingMember, Symbol overriddenMember, BindingDiagnosticBag diagnostics, ref bool suppressAccessors)
924var leastOverriddenMember = overriddenMember.GetLeastOverriddenMember(overriddenMember.ContainingType);
1198private bool IsValidOverrideReturnType(Symbol overridingSymbol, TypeWithAnnotations overridingReturnType, TypeWithAnnotations overriddenReturnType, BindingDiagnosticBag diagnostics)
1519Symbol overriddenMember,
1520Symbol overridingMember)
1551Symbol hidingMember,
1581foreach (var hiddenMember in hiddenMembers)
1630private static bool IsShadowingSynthesizedRecordMember(Symbol hidingMember)
1639private static bool AddHidingAbstractDiagnostic(Symbol hidingMember, Location hidingMemberLocation, Symbol hiddenMember, BindingDiagnosticBag diagnostics, ref bool suppressAccessors)
1674var associatedPropertyOrEvent = ((MethodSymbol)hidingMember).AssociatedSymbol;
1705private static bool OverrideHasCorrectAccessibility(Symbol overridden, Symbol overriding)
1793SynthesizeInterfaceMemberImplementation(SymbolAndDiagnostics implementingMemberAndDiagnostics, Symbol interfaceMember)
1803Symbol implementingMember = implementingMemberAndDiagnostics.Symbol;
Symbols\SubstitutedNamedTypeSymbol.cs (31)
27private static readonly Func<Symbol, NamedTypeSymbol, Symbol> s_symbolAsMemberFunc = SymbolExtensions.SymbolAsMember;
38private readonly Symbol _newContainer;
49private ConcurrentCache<string, ImmutableArray<Symbol>> _lazyMembersByNameCache;
51private ImmutableArray<Symbol> _lazyMembers;
53protected SubstitutedNamedTypeSymbol(Symbol newContainer, TypeMap map, NamedTypeSymbol originalDefinition, NamedTypeSymbol constructedFrom = null, bool unbound = false, TupleExtraData tupleData = null)
122public sealed override Symbol ContainingSymbol
185internal abstract override bool GetUnificationUseSiteDiagnosticRecursive(ref DiagnosticInfo result, Symbol owner, ref HashSet<TypeSymbol> checkedTypes);
232public sealed override ImmutableArray<Symbol> GetMembers()
239var builder = ArrayBuilder<Symbol>.GetInstance();
244foreach (var t in OriginalDefinition.GetMembers())
254foreach (var t in OriginalDefinition.GetMembers())
267private ArrayBuilder<Symbol> AddOrWrapTupleMembersIfNecessary(ArrayBuilder<Symbol> builder)
272var replacedFields = new HashSet<Symbol>(ReferenceEqualityComparer.Instance);
288internal sealed override ImmutableArray<Symbol> GetMembersUnordered()
290var builder = ArrayBuilder<Symbol>.GetInstance();
294foreach (var t in OriginalDefinition.GetMembersUnordered())
304foreach (var t in OriginalDefinition.GetMembersUnordered())
315public sealed override ImmutableArray<Symbol> GetMembers(string name)
317if (_unbound) return StaticCast<Symbol>.From(GetTypeMembers(name));
319ImmutableArray<Symbol> result;
329private ImmutableArray<Symbol> GetMembersWorker(string name)
344var builder = ArrayBuilder<Symbol>.GetInstance(originalMembers.Length);
345foreach (var t in originalMembers)
354void cacheResult(ImmutableArray<Symbol> result)
360(_lazyMembersByNameCache = new ConcurrentCache<string, ImmutableArray<Symbol>>(8));
388internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers()
395internal override ImmutableArray<Symbol> GetEarlyAttributeDecodingMembers(string name)
399var builder = ArrayBuilder<Symbol>.GetInstance();
400foreach (var t in OriginalDefinition.GetEarlyAttributeDecodingMembers(name))
Symbols\Symbol.cs (27)
52internal virtual void ForceComplete(SourceLocation? locationOpt, Predicate<Symbol>? filter, CancellationToken cancellationToken)
109public abstract Symbol ContainingSymbol { get; }
118Symbol container = this.ContainingSymbol;
149for (var container = this.ContainingSymbol; (object)container != null; container = container.ContainingSymbol)
172var container = this.ContainingSymbol;
343var container = this.ContainingSymbol;
363public Symbol OriginalDefinition
371protected virtual Symbol OriginalSymbolDefinition
763public static bool operator ==(Symbol left, Symbol right)
785public static bool operator !=(Symbol left, Symbol right)
808return this.Equals(obj as Symbol, SymbolEqualityComparer.Default.CompareKind);
811public bool Equals(Symbol other)
818return this.Equals(other as Symbol, compareKind);
822public virtual bool Equals(Symbol other, TypeCompareKind compareKind)
833public static bool Equals(Symbol first, Symbol second, TypeCompareKind compareKind)
958internal static void ForceCompleteMemberConditionally(SourceLocation? locationOpt, Predicate<Symbol>? filter, Symbol member, CancellationToken cancellationToken)
1329internal static bool GetUnificationUseSiteDiagnosticRecursive<T>(ref DiagnosticInfo result, ImmutableArray<T> types, Symbol owner, ref HashSet<TypeSymbol> checkedTypes) where T : TypeSymbol
1342internal static bool GetUnificationUseSiteDiagnosticRecursive(ref DiagnosticInfo result, ImmutableArray<TypeWithAnnotations> types, Symbol owner, ref HashSet<TypeSymbol> checkedTypes)
1355internal static bool GetUnificationUseSiteDiagnosticRecursive(ref DiagnosticInfo result, ImmutableArray<CustomModifier> modifiers, Symbol owner, ref HashSet<TypeSymbol> checkedTypes)
1368internal static bool GetUnificationUseSiteDiagnosticRecursive(ref DiagnosticInfo result, ImmutableArray<ParameterSymbol> parameters, Symbol owner, ref HashSet<TypeSymbol> checkedTypes)
1382internal static bool GetUnificationUseSiteDiagnosticRecursive(ref DiagnosticInfo result, ImmutableArray<TypeParameterSymbol> typeParameters, Symbol owner, ref HashSet<TypeSymbol> checkedTypes)
1702internal static bool IsCaptured(Symbol variable, SourceMethodSymbol containingSymbol)
1746for (var currentFunction = variable.ContainingSymbol;
Symbols\SymbolExtensions.cs (56)
24public static bool IsCompilationOutputWinMdObj(this Symbol symbol)
39public static bool IsNestedType([NotNullWhen(true)] this Symbol? symbol)
87public static bool IsNoMoreVisibleThan(this Symbol symbol, TypeSymbol type, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
92public static bool IsNoMoreVisibleThan(this Symbol symbol, TypeWithAnnotations type, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
97internal static void AddUseSiteInfo(this Symbol? symbol, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool addDiagnostics = true)
120public static LocalizableErrorArgument GetKindText(this Symbol symbol)
129internal static NamespaceOrTypeSymbol? ContainingNamespaceOrType(this Symbol symbol)
131var containingSymbol = symbol.ContainingSymbol;
145internal static Symbol? ContainingNonLambdaMember(this Symbol? containingMember)
157internal static ParameterSymbol? EnclosingThisSymbol(this Symbol containingMember)
159Symbol symbol = containingMember;
199public static Symbol ConstructedFrom(this Symbol symbol)
232public static bool IsContainingSymbolOfAllTypeParameters(this Symbol containingSymbol, TypeSymbol type)
241public static bool IsContainingSymbolOfAllTypeParameters(this Symbol containingSymbol, ImmutableArray<TypeSymbol> types)
246private static readonly Func<TypeSymbol, Symbol, bool, bool> s_hasInvalidTypeParameterFunc =
249private static bool HasInvalidTypeParameter(TypeSymbol type, Symbol? containingSymbol)
253var symbol = type.ContainingSymbol;
266public static bool IsTypeOrTypeAlias(this Symbol symbol)
286internal static bool CompilationAllowsUnsafe(this Symbol symbol)
291internal static void CheckUnsafeModifier(this Symbol symbol, DeclarationModifiers modifiers, BindingDiagnosticBag diagnostics)
296internal static void CheckUnsafeModifier(this Symbol symbol, DeclarationModifiers modifiers, Location errorLocation, BindingDiagnosticBag diagnostics)
299internal static void CheckUnsafeModifier(this Symbol symbol, DeclarationModifiers modifiers, Location errorLocation, DiagnosticBag? diagnostics)
313public static bool IsHiddenByCodeAnalysisEmbeddedAttribute(this Symbol symbol)
330public static bool MustCallMethodsDirectly(this Symbol symbol)
343public static int GetArity(this Symbol? symbol)
359internal static CSharpSyntaxNode GetNonNullSyntaxNode(this Symbol? symbol)
367Symbol? containingSymbol = symbol.ContainingSymbol;
384internal static Symbol? EnsureCSharpSymbolOrNull(this ISymbol? symbol, string paramName)
443internal static TypeWithAnnotations GetTypeOrReturnType(this Symbol symbol)
475internal static FlowAnalysisAnnotations GetFlowAnalysisAnnotations(this Symbol? symbol)
487internal static void GetTypeOrReturnType(this Symbol symbol, out RefKind refKind, out TypeWithAnnotations returnType,
538internal static bool IsImplementableInterfaceMember(this Symbol symbol)
543internal static bool RequiresInstanceReceiver(this Symbol symbol)
556private static TISymbol? GetPublicSymbol<TISymbol>(this Symbol? symbol)
563internal static ISymbol? GetPublicSymbol(this Symbol? symbol)
688internal static IEnumerable<ISymbol?> GetPublicSymbols(this IEnumerable<Symbol?> symbols)
693private static ImmutableArray<TISymbol> GetPublicSymbols<TISymbol>(this ImmutableArray<Symbol> symbols)
704internal static ImmutableArray<ISymbol> GetPublicSymbols(this ImmutableArray<Symbol> symbols)
711return GetPublicSymbols<IPropertySymbol>(StaticCast<Symbol>.From(symbols));
716return GetPublicSymbols<ITypeSymbol>(StaticCast<Symbol>.From(symbols));
721return GetPublicSymbols<INamedTypeSymbol>(StaticCast<Symbol>.From(symbols));
726return GetPublicSymbols<ILocalSymbol>(StaticCast<Symbol>.From(symbols));
731return GetPublicSymbols<IEventSymbol>(StaticCast<Symbol>.From(symbols));
736return GetPublicSymbols<ITypeParameterSymbol>(StaticCast<Symbol>.From(symbols));
741return GetPublicSymbols<IParameterSymbol>(StaticCast<Symbol>.From(symbols));
746return GetPublicSymbols<IMethodSymbol>(StaticCast<Symbol>.From(symbols));
751return GetPublicSymbols<IAssemblySymbol>(StaticCast<Symbol>.From(symbols));
756return GetPublicSymbols<IFieldSymbol>(StaticCast<Symbol>.From(symbols));
761return GetPublicSymbols<INamespaceSymbol>(StaticCast<Symbol>.From(symbols));
766where TSymbol : Symbol
772internal static Symbol? GetSymbol(this ISymbol? symbol)
774return symbol.GetSymbol<Symbol>();
825internal static bool IsRequired(this Symbol symbol) => symbol is FieldSymbol { IsRequired: true } or PropertySymbol { IsRequired: true };
830internal static int GetOverloadResolutionPriority(this Symbol symbol)
Symbols\Tuples\TupleTypeSymbol.cs (29)
487internal static Symbol? GetWellKnownMemberInType(NamedTypeSymbol type, WellKnownMember relativeMember, BindingDiagnosticBag diagnostics, SyntaxNode? syntax)
489Symbol? member = GetWellKnownMemberInType(type, relativeMember);
516static Symbol? GetWellKnownMemberInType(NamedTypeSymbol type, WellKnownMember relativeMember)
565public TMember? GetTupleMemberSymbolForUnderlyingMember<TMember>(TMember? underlyingMemberOpt) where TMember : Symbol
570protected ArrayBuilder<Symbol> MakeSynthesizedTupleMembers(ImmutableArray<Symbol> currentMembers, HashSet<Symbol>? replacedFields = null)
577var members = ArrayBuilder<Symbol>.GetInstance(currentMembers.Length);
591foreach (Symbol member in currentMembers)
799static void collectTargetTupleFields(int arity, ImmutableArray<Symbol> members, ArrayBuilder<FieldSymbol?> fieldsForElements)
810static Symbol? getWellKnownMemberInType(ImmutableArray<Symbol> members, WellKnownMember relativeMember)
819static ImmutableArray<Symbol> getOriginalFields(ImmutableArray<Symbol> members)
821var fields = ArrayBuilder<Symbol>.GetInstance();
822foreach (var member in members)
913private SmallDictionary<Symbol, Symbol>? _lazyUnderlyingDefinitionToMemberMap;
1014foreach (var member in tuple.GetMembers())
1045internal SmallDictionary<Symbol, Symbol> UnderlyingDefinitionToMemberMap
1051SmallDictionary<Symbol, Symbol> computeDefinitionToMemberMap()
1053var map = new SmallDictionary<Symbol, Symbol>(ReferenceEqualityComparer.Instance);
1060var member = members[i];
1100public TMember? GetTupleMemberSymbolForUnderlyingMember<TMember>(TMember? underlyingMemberOpt) where TMember : Symbol
1107Symbol underlyingMemberDefinition = underlyingMemberOpt.OriginalDefinition;
1115if (UnderlyingDefinitionToMemberMap.TryGetValue(underlyingMemberDefinition, out Symbol? result))
Symbols\TypeSymbol.cs (131)
42private ImmutableHashSet<Symbol> _lazyAbstractMembers;
60private ConcurrentDictionary<Symbol, SymbolAndDiagnostics> _implementationForInterfaceMemberMap;
62public ConcurrentDictionary<Symbol, SymbolAndDiagnostics> ImplementationForInterfaceMemberMap
73map = new ConcurrentDictionary<Symbol, SymbolAndDiagnostics>(concurrencyLevel: 1, capacity: 1, comparer: SymbolEqualityComparer.ConsiderEverything);
83internal MultiDictionary<Symbol, Symbol> explicitInterfaceImplementationMap;
146protected sealed override Symbol OriginalSymbolDefinition
298public sealed override bool Equals(Symbol other, TypeCompareKind compareKind)
442public Symbol FindImplementationForInterfaceMember(Symbol interfaceMember)
531internal abstract bool GetUnificationUseSiteDiagnosticRecursive(ref DiagnosticInfo result, Symbol owner, ref HashSet<TypeSymbol> checkedTypes);
720internal SymbolAndDiagnostics FindImplementationForInterfaceMemberInNonInterfaceWithDiagnostics(Symbol interfaceMember, bool ignoreImplementationInInterfacesIfResultIsNotReady = false)
771internal Symbol FindImplementationForInterfaceMemberInNonInterface(Symbol interfaceMember, bool ignoreImplementationInInterfacesIfResultIsNotReady = false)
776private SymbolAndDiagnostics ComputeImplementationAndDiagnosticsForInterfaceMember(Symbol interfaceMember, bool ignoreImplementationInInterfaces, out bool implementationInInterfacesMightChangeResult)
779var implementingMember = ComputeImplementationForInterfaceMember(interfaceMember, this, diagnostics, ignoreImplementationInInterfaces, out implementationInInterfacesMightChangeResult);
802private static Symbol ComputeImplementationForInterfaceMember(Symbol interfaceMember, TypeSymbol implementingType, BindingDiagnosticBag diagnostics,
830Symbol implicitImpl = null;
831Symbol closestMismatch = null;
846MultiDictionary<Symbol, Symbol>.ValueSet explicitImpl = currType.GetExplicitImplementationForInterfaceMember(interfaceMember);
878if (IsExplicitlyImplementedViaAccessors(checkPendingExplicitImplementations, interfaceMember, currType, ref useSiteInfo, out Symbol currTypeExplicitImpl))
916Symbol currTypeImplicitImpl;
917Symbol currTypeCloseMismatch;
948Symbol originalImplicitImpl = implicitImpl;
958Symbol defaultImpl = null;
1048private static Symbol FindMostSpecificImplementationInInterfaces(Symbol interfaceMember, TypeSymbol implementingType,
1063Symbol defaultImpl = FindMostSpecificImplementationInBases(interfaceMember,
1065ref useSiteInfo, out Symbol conflict1, out Symbol conflict2);
1101private static Symbol FindMostSpecificImplementation(Symbol interfaceMember, NamedTypeSymbol implementingInterface, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1103MultiDictionary<Symbol, Symbol>.ValueSet implementingMember = FindImplementationInInterface(interfaceMember, implementingInterface);
1120out var _, out var _);
1123Symbol result = implementingMember.Single();
1142private static Symbol FindMostSpecificImplementationInBases(
1143Symbol interfaceMember,
1146out Symbol conflictingImplementation1,
1147out Symbol conflictingImplementation2)
1171Symbol accessorImpl1 = findMostSpecificImplementationInBases(interfaceAccessor1 ?? interfaceAccessor2, allInterfaces, ref useSiteInfo,
1172out Symbol conflictingAccessorImplementation11, out Symbol conflictingAccessorImplementation12);
1202Symbol accessorImpl2 = findMostSpecificImplementationInBases(interfaceAccessor2, allInterfaces, ref useSiteInfo,
1203out Symbol conflictingAccessorImplementation21, out Symbol conflictingAccessorImplementation22);
1233static Symbol findImplementationInInterface(Symbol interfaceMember, Symbol inplementingAccessor1, Symbol implementingAccessor2 = null)
1243MultiDictionary<Symbol, Symbol>.ValueSet implementingMember = FindImplementationInInterface(interfaceMember, implementingInterface);
1254static Symbol findMostSpecificImplementationInBases(
1255Symbol interfaceMember,
1258out Symbol conflictingImplementation1,
1259out Symbol conflictingImplementation2)
1261var implementations = ArrayBuilder<(MultiDictionary<Symbol, Symbol>.ValueSet MethodSet, MultiDictionary<NamedTypeSymbol, NamedTypeSymbol> Bases)>.GetInstance();
1271MultiDictionary<Symbol, Symbol>.ValueSet candidate = FindImplementationInInterface(interfaceMember, interfaceType);
1280(MultiDictionary<Symbol, Symbol>.ValueSet methodSet, MultiDictionary<NamedTypeSymbol, NamedTypeSymbol> bases) = implementations[i];
1281Symbol previous = methodSet.First();
1333Symbol result;
1343MultiDictionary<Symbol, Symbol>.ValueSet methodSet = implementations[0].MethodSet;
1373internal static MultiDictionary<Symbol, Symbol>.ValueSet FindImplementationInInterface(Symbol interfaceMember, NamedTypeSymbol interfaceType)
1387return new MultiDictionary<Symbol, Symbol>.ValueSet(interfaceMember);
1396private static (MethodSymbol interfaceAccessor1, MethodSymbol interfaceAccessor2) GetImplementableAccessors(Symbol interfaceMember)
1457private static bool IsExplicitlyImplementedViaAccessors(bool checkPendingExplicitImplementations, Symbol interfaceMember, TypeSymbol currType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out Symbol implementingMember)
1461Symbol associated1;
1462Symbol associated2;
1494private static bool TryGetExplicitImplementationAssociatedPropertyOrEvent(bool checkPendingExplicitImplementations, MethodSymbol interfaceAccessor, TypeSymbol currType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out Symbol associated)
1500MultiDictionary<Symbol, Symbol>.ValueSet set = currType.GetExplicitImplementationForInterfaceMember(interfaceAccessor);
1503Symbol implementation = set.Single();
1539ref Symbol implicitImpl)
1544Symbol associatedInterfacePropertyOrEvent = interfaceMethod.AssociatedSymbol;
1555Symbol implementingPropertyOrEvent = implementingType.FindImplementationForInterfaceMemberInNonInterface(associatedInterfacePropertyOrEvent,
1621private static void ReportDefaultInterfaceImplementationMatchDiagnostics(Symbol interfaceMember, TypeSymbol implementingType, Symbol implicitImpl, BindingDiagnosticBag diagnostics)
1669private static void ReportImplicitImplementationMatchDiagnostics(Symbol interfaceMember, TypeSymbol implementingType, Symbol implicitImpl, BindingDiagnosticBag diagnostics)
1724foreach (Symbol member in implicitImpl.ContainingType.GetMembers(implicitImpl.Name))
1764internal static void CheckModifierMismatchOnImplementingMember(TypeSymbol implementingType, Symbol implementingMember, Symbol interfaceMember, bool isExplicit, BindingDiagnosticBag diagnostics)
1962static void checkRefStructInterfacesFeatureAvailabilityOnUnscopedRefAttribute(Symbol implementingSymbol, BindingDiagnosticBag diagnostics)
1981private static void ReportImplicitImplementationMismatchDiagnostics(Symbol interfaceMember, TypeSymbol implementingType, Symbol closestMismatch, BindingDiagnosticBag diagnostics)
2053internal static bool HaveInitOnlyMismatch(Symbol one, Symbol other)
2071private static Location GetInterfaceLocation(Symbol interfaceMember, TypeSymbol implementingType)
2130internal static Location GetImplicitImplementationDiagnosticLocation(Symbol interfaceMember, TypeSymbol implementingType, Symbol member)
2160Symbol interfaceMember,
2163out Symbol implicitImpl,
2164out Symbol closeMismatch)
2176foreach (Symbol member in currType.GetMembers(interfaceMember.Name))
2233private static bool IsInterfaceMemberImplementation(Symbol candidateMember, Symbol interfaceMember, bool implementingTypeIsFromSomeCompilation)
2262protected MultiDictionary<Symbol, Symbol>.ValueSet GetExplicitImplementationForInterfaceMember(Symbol interfaceMember)
2278private MultiDictionary<Symbol, Symbol> MakeExplicitInterfaceImplementationMap()
2280var map = new MultiDictionary<Symbol, Symbol>(ExplicitInterfaceImplementationTargetMemberEqualityComparer.Instance);
2281foreach (var member in this.GetMembersUnordered())
2283foreach (var interfaceMember in member.GetExplicitInterfaceImplementations())
2349protected class ExplicitInterfaceImplementationTargetMemberEqualityComparer : IEqualityComparer<Symbol>
2354public bool Equals(Symbol x, Symbol y)
2360public int GetHashCode(Symbol obj)
2373internal ImmutableHashSet<Symbol> AbstractMembers
2385private ImmutableHashSet<Symbol> ComputeAbstractMembers()
2387var abstractMembers = ImmutableHashSet.Create<Symbol>();
2388var overriddenMembers = ImmutableHashSet.Create<Symbol>();
2390foreach (var member in this.GetMembersUnordered())
2397Symbol overriddenMember = null;
2425foreach (var baseAbstractMember in this.BaseTypeNoUseSiteDiagnostics.AbstractMembers)
2466public static bool operator ==(Symbol left, TypeSymbol right)
2470public static bool operator !=(Symbol left, TypeSymbol right)
2474public static bool operator ==(TypeSymbol left, Symbol right)
2478public static bool operator !=(TypeSymbol left, Symbol right)
Symbols\TypeSymbolExtensions.cs (11)
19public Symbol? Symbol;
551private static bool IsNamespaceName(Symbol symbol, string[] names)
673public static bool IsAtLeastAsVisibleAs(this TypeSymbol type, Symbol sym, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
697private static bool IsTypeLessVisibleThan(TypeSymbol type, Symbol sym, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1001internal static bool IsAsRestrictive(this Symbol s1, Symbol sym2, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1010for (Symbol s2 = sym2; s2.Kind != SymbolKind.Namespace; s2 = s2.ContainingSymbol)
1214private static readonly Func<TypeSymbol, Symbol, bool, bool> s_isTypeParameterWithSpecificContainerPredicate =
1740internal static TypeParameterSymbol? FindEnclosingTypeParameter(this Symbol methodOrType, string name)
1777var container = type.ContainingSymbol;
2086Symbol declaringSymbol,