2128 lines
96 KiB
C#
2128 lines
96 KiB
C#
using System;
|
|||
|
|
using System.Collections.Immutable;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Threading;
|
||
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
||
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
||
|
|
using Microsoft.CodeAnalysis.Text;
|
||
|
|
using Roslyn.Utilities;
|
||
|
|
|
||
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
||
|
|
|
||
|
|
internal class SyntaxTreeSemanticModel : PublicSemanticModel
|
||
|
|
{
|
||
|
|
private readonly CSharpCompilation _compilation;
|
||
|
|
|
||
|
|
private readonly SyntaxTree _syntaxTree;
|
||
|
|
|
||
|
|
private ImmutableDictionary<CSharpSyntaxNode, MemberSemanticModel> _memberModels = ImmutableDictionary<CSharpSyntaxNode, MemberSemanticModel>.Empty;
|
||
|
|
|
||
|
|
private readonly BinderFactory _binderFactory;
|
||
|
|
|
||
|
|
private Func<CSharpSyntaxNode, MemberSemanticModel> _createMemberModelFunction;
|
||
|
|
|
||
|
|
private readonly bool _ignoresAccessibility;
|
||
|
|
|
||
|
|
private ScriptLocalScopeBinder.Labels _globalStatementLabels;
|
||
|
|
|
||
|
|
private static readonly Func<CSharpSyntaxNode, bool> s_isMemberDeclarationFunction = IsMemberDeclaration;
|
||
|
|
|
||
|
|
public override CSharpCompilation Compilation => _compilation;
|
||
|
|
|
||
|
|
internal override CSharpSyntaxNode Root => (CSharpSyntaxNode)(object)_syntaxTree.GetRoot(default(CancellationToken));
|
||
|
|
|
||
|
|
public override SyntaxTree SyntaxTree => _syntaxTree;
|
||
|
|
|
||
|
|
public override bool IgnoresAccessibility => _ignoresAccessibility;
|
||
|
|
|
||
|
|
public override bool IsSpeculativeSemanticModel => false;
|
||
|
|
|
||
|
|
public override int OriginalPositionForSpeculation => 0;
|
||
|
|
|
||
|
|
public override CSharpSemanticModel ParentModel => null;
|
||
|
|
|
||
|
|
internal ImmutableDictionary<CSharpSyntaxNode, MemberSemanticModel> TestOnlyMemberModels => _memberModels;
|
||
|
|
|
||
|
|
private bool IsRegularCSharp => (int)SyntaxTree.Options.Kind == 0;
|
||
|
|
|
||
|
|
internal SyntaxTreeSemanticModel(CSharpCompilation compilation, SyntaxTree syntaxTree, bool ignoreAccessibility = false)
|
||
|
|
{
|
||
|
|
_compilation = compilation;
|
||
|
|
_syntaxTree = syntaxTree;
|
||
|
|
_ignoresAccessibility = ignoreAccessibility;
|
||
|
|
_binderFactory = compilation.GetBinderFactory(SyntaxTree, ignoreAccessibility);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal SyntaxTreeSemanticModel(CSharpCompilation parentCompilation, SyntaxTree parentSyntaxTree, SyntaxTree speculatedSyntaxTree, bool ignoreAccessibility)
|
||
|
|
{
|
||
|
|
_compilation = parentCompilation;
|
||
|
|
_syntaxTree = speculatedSyntaxTree;
|
||
|
|
_binderFactory = _compilation.GetBinderFactory(parentSyntaxTree, ignoreAccessibility);
|
||
|
|
_ignoresAccessibility = ignoreAccessibility;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void VerifySpanForGetDiagnostics(TextSpan? span)
|
||
|
|
{
|
||
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if (span.HasValue)
|
||
|
|
{
|
||
|
|
TextSpan fullSpan = ((SyntaxNode)Root).FullSpan;
|
||
|
|
if (!((TextSpan)(ref fullSpan)).Contains(span.Value))
|
||
|
|
{
|
||
|
|
throw new ArgumentException("span");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ImmutableArray<Diagnostic> GetSyntaxDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
VerifySpanForGetDiagnostics(span);
|
||
|
|
return Compilation.GetDiagnosticsForSyntaxTree((CompilationStage)0, SyntaxTree, span, includeEarlierStages: false, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ImmutableArray<Diagnostic> GetDeclarationDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
VerifySpanForGetDiagnostics(span);
|
||
|
|
return Compilation.GetDiagnosticsForSyntaxTree((CompilationStage)1, SyntaxTree, span, includeEarlierStages: false, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ImmutableArray<Diagnostic> GetMethodBodyDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
VerifySpanForGetDiagnostics(span);
|
||
|
|
return Compilation.GetDiagnosticsForSyntaxTree((CompilationStage)2, SyntaxTree, span, includeEarlierStages: false, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ImmutableArray<Diagnostic> GetDiagnostics(TextSpan? span = null, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
VerifySpanForGetDiagnostics(span);
|
||
|
|
return Compilation.GetDiagnosticsForSyntaxTree((CompilationStage)2, SyntaxTree, span, includeEarlierStages: true, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override Binder GetEnclosingBinderInternal(int position)
|
||
|
|
{
|
||
|
|
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
SyntaxToken val = Root.FindTokenIncludingCrefAndNameAttributes(position);
|
||
|
|
if (position == 0 && position != ((SyntaxToken)(ref val)).SpanStart)
|
||
|
|
{
|
||
|
|
return _binderFactory.GetBinder((SyntaxNode)(object)Root, position).WithAdditionalFlags(GetSemanticModelBinderFlags());
|
||
|
|
}
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel(position);
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
return memberModel.GetEnclosingBinder(position);
|
||
|
|
}
|
||
|
|
return _binderFactory.GetBinder((SyntaxNode)(object)(CSharpSyntaxNode)(object)((SyntaxToken)(ref val)).Parent, position).WithAdditionalFlags(GetSemanticModelBinderFlags());
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override IOperation GetOperationWorker(CSharpSyntaxNode node, CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
return ((node is ConstructorDeclarationSyntax constructorDeclarationSyntax) ? ((constructorDeclarationSyntax.HasAnyBody() || constructorDeclarationSyntax.Initializer != null) ? GetOrAddModel(node) : null) : ((node is BaseMethodDeclarationSyntax declaration) ? (declaration.HasAnyBody() ? GetOrAddModel(node) : null) : ((node is AccessorDeclarationSyntax accessorDeclarationSyntax) ? ((accessorDeclarationSyntax.Body != null || accessorDeclarationSyntax.ExpressionBody != null) ? GetOrAddModel(node) : null) : ((!(node is TypeDeclarationSyntax { ParameterList: not null, PrimaryConstructorBaseTypeIfClass: not null } typeDeclarationSyntax) || (object)TryGetSynthesizedPrimaryConstructor(typeDeclarationSyntax) == null) ? GetMemberModel((SyntaxNode)(object)node) : GetOrAddModel(typeDeclarationSyntax)))))?.GetOperationWorker(node, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SymbolInfo GetSymbolInfoWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
CSharpSemanticModel.ValidateSymbolInfoOptions(options);
|
||
|
|
node = SyntaxFactory.GetStandaloneNode(node);
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel((SyntaxNode)(object)node);
|
||
|
|
SymbolInfo result;
|
||
|
|
XmlNameAttributeSyntax syntax;
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
result = memberModel.GetSymbolInfoWorker(node, options, cancellationToken);
|
||
|
|
if (((SymbolInfo)(ref result)).Symbol == null && (int)((SymbolInfo)(ref result)).CandidateReason == 0 && node is ExpressionSyntax && SyntaxFacts.IsInNamespaceOrTypeContext((ExpressionSyntax)node))
|
||
|
|
{
|
||
|
|
Binder enclosingBinder = GetEnclosingBinder(GetAdjustedNodePosition((SyntaxNode)(object)node));
|
||
|
|
if (enclosingBinder != null)
|
||
|
|
{
|
||
|
|
enclosingBinder = new LocalScopeBinder(enclosingBinder);
|
||
|
|
BoundExpression boundExpression = enclosingBinder.BindExpression((ExpressionSyntax)node, BindingDiagnosticBag.Discarded);
|
||
|
|
SymbolInfo symbolInfoForNode = GetSymbolInfoForNode(options, boundExpression, boundExpression, null, null);
|
||
|
|
if (((SymbolInfo)(ref symbolInfoForNode)).Symbol != null)
|
||
|
|
{
|
||
|
|
((SymbolInfo)(ref result))._002Ector(ImmutableArray.Create<ISymbol>(((SymbolInfo)(ref symbolInfoForNode)).Symbol), (CandidateReason)1);
|
||
|
|
}
|
||
|
|
else if (!((SymbolInfo)(ref symbolInfoForNode)).CandidateSymbols.IsEmpty)
|
||
|
|
{
|
||
|
|
((SymbolInfo)(ref result))._002Ector(((SymbolInfo)(ref symbolInfoForNode)).CandidateSymbols, (CandidateReason)1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (node.Parent.Kind() == SyntaxKind.XmlNameAttribute && (syntax = (XmlNameAttributeSyntax)node.Parent).Identifier == node)
|
||
|
|
{
|
||
|
|
result = SymbolInfo.None;
|
||
|
|
Binder enclosingBinder2 = GetEnclosingBinder(GetAdjustedNodePosition((SyntaxNode)(object)node));
|
||
|
|
if (enclosingBinder2 != null)
|
||
|
|
{
|
||
|
|
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = CompoundUseSiteInfo<AssemblySymbol>.Discarded;
|
||
|
|
ImmutableArray<Symbol> symbols = enclosingBinder2.BindXmlNameAttribute(syntax, ref useSiteInfo);
|
||
|
|
result = (SymbolInfo)(symbols.Length switch
|
||
|
|
{
|
||
|
|
0 => SymbolInfo.None,
|
||
|
|
1 => SymbolInfoFactory.Create(symbols, LookupResultKind.Viable, isDynamic: false),
|
||
|
|
_ => SymbolInfoFactory.Create(symbols, LookupResultKind.Ambiguous, isDynamic: false),
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (node is CrefSyntax crefSyntax)
|
||
|
|
{
|
||
|
|
int adjustedNodePosition = GetAdjustedNodePosition((SyntaxNode)(object)crefSyntax);
|
||
|
|
result = GetCrefSymbolInfo(adjustedNodePosition, crefSyntax, options, CSharpSemanticModel.HasParameterList(crefSyntax));
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
Symbol semanticInfoSymbolInNonMemberContext = GetSemanticInfoSymbolInNonMemberContext(node, (options & SymbolInfoOptions.PreserveAliases) != 0);
|
||
|
|
result = (((object)semanticInfoSymbolInNonMemberContext != null) ? CSharpSemanticModel.GetSymbolInfoForSymbol(semanticInfoSymbolInNonMemberContext, options) : SymbolInfo.None);
|
||
|
|
}
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override SymbolInfo GetCollectionInitializerSymbolInfoWorker(InitializerExpressionSyntax collectionInitializer, ExpressionSyntax node, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return GetMemberModel((SyntaxNode)(object)collectionInitializer)?.GetCollectionInitializerSymbolInfoWorker(collectionInitializer, node, cancellationToken) ?? SymbolInfo.None;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override CSharpTypeInfo GetTypeInfoWorker(CSharpSyntaxNode node, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
node = SyntaxFactory.GetStandaloneNode(node);
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel((SyntaxNode)(object)node);
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
return memberModel.GetTypeInfoWorker(node, cancellationToken);
|
||
|
|
}
|
||
|
|
Symbol semanticInfoSymbolInNonMemberContext = GetSemanticInfoSymbolInNonMemberContext(node, bindVarAsAliasFirst: false);
|
||
|
|
if ((object)semanticInfoSymbolInNonMemberContext == null)
|
||
|
|
{
|
||
|
|
return CSharpTypeInfo.None;
|
||
|
|
}
|
||
|
|
return CSharpSemanticModel.GetTypeInfoForSymbol(semanticInfoSymbolInNonMemberContext);
|
||
|
|
}
|
||
|
|
|
||
|
|
private Symbol GetSemanticInfoSymbolInNonMemberContext(CSharpSyntaxNode node, bool bindVarAsAliasFirst)
|
||
|
|
{
|
||
|
|
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0096: Invalid comparison between Unknown and I4
|
||
|
|
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
Binder enclosingBinder = GetEnclosingBinder(GetAdjustedNodePosition((SyntaxNode)(object)node));
|
||
|
|
if (enclosingBinder != null && node is TypeSyntax typeSyntax)
|
||
|
|
{
|
||
|
|
ConsList<TypeSymbol> basesBeingResolved = GetBasesBeingResolved(typeSyntax);
|
||
|
|
if (SyntaxFacts.IsNamespaceAliasQualifier(typeSyntax))
|
||
|
|
{
|
||
|
|
return enclosingBinder.BindNamespaceAliasSymbol(node as IdentifierNameSyntax, BindingDiagnosticBag.Discarded);
|
||
|
|
}
|
||
|
|
if (SyntaxFacts.IsInTypeOnlyContext(typeSyntax))
|
||
|
|
{
|
||
|
|
if (!typeSyntax.IsVar)
|
||
|
|
{
|
||
|
|
return enclosingBinder.BindTypeOrAlias(typeSyntax, BindingDiagnosticBag.Discarded, basesBeingResolved).Symbol;
|
||
|
|
}
|
||
|
|
Symbol symbol = (bindVarAsAliasFirst ? enclosingBinder.BindTypeOrAlias(typeSyntax, BindingDiagnosticBag.Discarded, basesBeingResolved).Symbol : null);
|
||
|
|
if (((object)symbol == null || (int)symbol.Kind == 4) && ((SyntaxNode)(object)typeSyntax).ModifyingScopedOrRefTypeOrSelf().Parent is VariableDeclarationSyntax variableDeclarationSyntax && variableDeclarationSyntax.Variables.Any())
|
||
|
|
{
|
||
|
|
FieldSymbol declaredFieldSymbol = GetDeclaredFieldSymbol(variableDeclarationSyntax.Variables.First());
|
||
|
|
if ((object)declaredFieldSymbol != null)
|
||
|
|
{
|
||
|
|
symbol = declaredFieldSymbol.Type;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return symbol ?? enclosingBinder.BindTypeOrAlias(typeSyntax, BindingDiagnosticBag.Discarded, basesBeingResolved).Symbol;
|
||
|
|
}
|
||
|
|
return enclosingBinder.BindNamespaceOrTypeOrAliasSymbol(typeSyntax, BindingDiagnosticBag.Discarded, basesBeingResolved, basesBeingResolved != null).Symbol;
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override ImmutableArray<Symbol> GetMemberGroupWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
node = SyntaxFactory.GetStandaloneNode(node);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetMemberGroupWorker(node, options, cancellationToken) ?? ImmutableArray<Symbol>.Empty;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override ImmutableArray<IPropertySymbol> GetIndexerGroupWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
node = SyntaxFactory.GetStandaloneNode(node);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetIndexerGroupWorker(node, options, cancellationToken) ?? ImmutableArray<IPropertySymbol>.Empty;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override Optional<object> GetConstantValueWorker(CSharpSyntaxNode node, CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
node = SyntaxFactory.GetStandaloneNode(node);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetConstantValueWorker(node, cancellationToken) ?? default(Optional<object>);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override QueryClauseInfo GetQueryClauseInfo(QueryClauseSyntax node, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(node);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetQueryClauseInfo(node, cancellationToken) ?? default(QueryClauseInfo);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override SymbolInfo GetSymbolInfo(SelectOrGroupClauseSyntax node, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
CheckSyntaxNode(node);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetSymbolInfo(node, cancellationToken) ?? SymbolInfo.None;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override TypeInfo GetTypeInfo(SelectOrGroupClauseSyntax node, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
CheckSyntaxNode(node);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetTypeInfo(node, cancellationToken) ?? ((TypeInfo)CSharpTypeInfo.None);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IPropertySymbol GetDeclaredSymbol(AnonymousObjectMemberDeclaratorSyntax declaratorSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declaratorSyntax);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)declaratorSyntax)?.GetDeclaredSymbol(declaratorSyntax, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override INamedTypeSymbol GetDeclaredSymbol(AnonymousObjectCreationExpressionSyntax declaratorSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declaratorSyntax);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)declaratorSyntax)?.GetDeclaredSymbol(declaratorSyntax, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override INamedTypeSymbol GetDeclaredSymbol(TupleExpressionSyntax declaratorSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declaratorSyntax);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)declaratorSyntax)?.GetDeclaredSymbol(declaratorSyntax, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ISymbol GetDeclaredSymbol(ArgumentSyntax declaratorSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declaratorSyntax);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)declaratorSyntax)?.GetDeclaredSymbol(declaratorSyntax, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IRangeVariableSymbol GetDeclaredSymbol(QueryClauseSyntax node, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(node);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetDeclaredSymbol(node, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IRangeVariableSymbol GetDeclaredSymbol(JoinIntoClauseSyntax node, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(node);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetDeclaredSymbol(node, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IRangeVariableSymbol GetDeclaredSymbol(QueryContinuationSyntax node, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(node);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetDeclaredSymbol(node, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override SymbolInfo GetSymbolInfo(OrderingSyntax node, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
CheckSyntaxNode(node);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetSymbolInfo(node, cancellationToken) ?? SymbolInfo.None;
|
||
|
|
}
|
||
|
|
|
||
|
|
private ConsList<TypeSymbol> GetBasesBeingResolved(TypeSyntax expression)
|
||
|
|
{
|
||
|
|
while (expression != null && expression.Parent != null)
|
||
|
|
{
|
||
|
|
CSharpSyntaxNode parent = expression.Parent;
|
||
|
|
if (parent is BaseTypeSyntax baseTypeSyntax && parent.Parent != null && parent.Parent.Kind() == SyntaxKind.BaseList && baseTypeSyntax.Type == expression)
|
||
|
|
{
|
||
|
|
BaseTypeDeclarationSyntax declarationSyntax = (BaseTypeDeclarationSyntax)parent.Parent.Parent;
|
||
|
|
INamedTypeSymbol declaredSymbol = GetDeclaredSymbol(declarationSyntax);
|
||
|
|
return ConsListExtensions.Prepend<TypeSymbol>(ConsList<TypeSymbol>.Empty, (TypeSymbol)declaredSymbol.GetSymbol().OriginalDefinition);
|
||
|
|
}
|
||
|
|
expression = expression.Parent as TypeSyntax;
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override Conversion ClassifyConversion(ExpressionSyntax expression, ITypeSymbol destination, bool isExplicitInSource = false)
|
||
|
|
{
|
||
|
|
TypeSymbol destination2 = destination.EnsureCSharpSymbolOrNull("destination");
|
||
|
|
if (expression.Kind() == SyntaxKind.DeclarationExpression)
|
||
|
|
{
|
||
|
|
return Conversion.NoConversion;
|
||
|
|
}
|
||
|
|
if (isExplicitInSource)
|
||
|
|
{
|
||
|
|
return ClassifyConversionForCast(expression, destination2);
|
||
|
|
}
|
||
|
|
CheckSyntaxNode(expression);
|
||
|
|
if (destination == null)
|
||
|
|
{
|
||
|
|
throw new ArgumentNullException("destination");
|
||
|
|
}
|
||
|
|
return GetMemberModel((SyntaxNode)(object)expression)?.ClassifyConversion(expression, destination) ?? Conversion.NoConversion;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override Conversion ClassifyConversionForCast(ExpressionSyntax expression, TypeSymbol destination)
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(expression);
|
||
|
|
if ((object)destination == null)
|
||
|
|
{
|
||
|
|
throw new ArgumentNullException("destination");
|
||
|
|
}
|
||
|
|
return GetMemberModel((SyntaxNode)(object)expression)?.ClassifyConversionForCast(expression, destination) ?? Conversion.NoConversion;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal sealed override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, TypeSyntax type, SpeculativeBindingOption bindingOption, out PublicSemanticModel speculativeModel)
|
||
|
|
{
|
||
|
|
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
position = CheckAndAdjustPosition(position);
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel(position);
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
return memberModel.TryGetSpeculativeSemanticModelCore(parentModel, position, type, bindingOption, out speculativeModel);
|
||
|
|
}
|
||
|
|
Binder speculativeBinder = GetSpeculativeBinder(position, type, bindingOption);
|
||
|
|
if (speculativeBinder != null)
|
||
|
|
{
|
||
|
|
speculativeModel = SpeculativeSyntaxTreeSemanticModel.Create(parentModel, type, speculativeBinder, position, bindingOption);
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
speculativeModel = null;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, CrefSyntax crefSyntax, out PublicSemanticModel speculativeModel)
|
||
|
|
{
|
||
|
|
position = CheckAndAdjustPosition(position);
|
||
|
|
Binder enclosingBinder = GetEnclosingBinder(position);
|
||
|
|
if (enclosingBinder != null && enclosingBinder.InCref)
|
||
|
|
{
|
||
|
|
speculativeModel = SpeculativeSyntaxTreeSemanticModel.Create(parentModel, crefSyntax, enclosingBinder, position);
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
speculativeModel = null;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal sealed override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, StatementSyntax statement, out PublicSemanticModel speculativeModel)
|
||
|
|
{
|
||
|
|
position = CheckAndAdjustPosition(position);
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel(position);
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
return memberModel.TryGetSpeculativeSemanticModelCore(parentModel, position, statement, out speculativeModel);
|
||
|
|
}
|
||
|
|
speculativeModel = null;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal sealed override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, BaseMethodDeclarationSyntax method, out PublicSemanticModel speculativeModel)
|
||
|
|
{
|
||
|
|
position = CheckAndAdjustPosition(position);
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel(position);
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
return memberModel.TryGetSpeculativeSemanticModelForMethodBodyCore(parentModel, position, method, out speculativeModel);
|
||
|
|
}
|
||
|
|
speculativeModel = null;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal sealed override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out PublicSemanticModel speculativeModel)
|
||
|
|
{
|
||
|
|
position = CheckAndAdjustPosition(position);
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel(position);
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
return memberModel.TryGetSpeculativeSemanticModelForMethodBodyCore(parentModel, position, accessor, out speculativeModel);
|
||
|
|
}
|
||
|
|
speculativeModel = null;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal sealed override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, EqualsValueClauseSyntax initializer, out PublicSemanticModel speculativeModel)
|
||
|
|
{
|
||
|
|
position = CheckAndAdjustPosition(position);
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel(position);
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
return memberModel.TryGetSpeculativeSemanticModelCore(parentModel, position, initializer, out speculativeModel);
|
||
|
|
}
|
||
|
|
speculativeModel = null;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, ArrowExpressionClauseSyntax expressionBody, out PublicSemanticModel speculativeModel)
|
||
|
|
{
|
||
|
|
position = CheckAndAdjustPosition(position);
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel(position);
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
return memberModel.TryGetSpeculativeSemanticModelCore(parentModel, position, expressionBody, out speculativeModel);
|
||
|
|
}
|
||
|
|
speculativeModel = null;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal sealed override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, ConstructorInitializerSyntax constructorInitializer, out PublicSemanticModel speculativeModel)
|
||
|
|
{
|
||
|
|
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
position = CheckAndAdjustPosition(position);
|
||
|
|
SyntaxToken val = Root.FindToken(position);
|
||
|
|
if (((SyntaxToken)(ref val)).Parent.AncestorsAndSelf(true).OfType<ConstructorInitializerSyntax>().FirstOrDefault() != null)
|
||
|
|
{
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel(position);
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
return memberModel.TryGetSpeculativeSemanticModelCore(parentModel, position, constructorInitializer, out speculativeModel);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
speculativeModel = null;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal sealed override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, PrimaryConstructorBaseTypeSyntax constructorInitializer, out PublicSemanticModel speculativeModel)
|
||
|
|
{
|
||
|
|
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
position = CheckAndAdjustPosition(position);
|
||
|
|
SyntaxToken val = Root.FindToken(position);
|
||
|
|
PrimaryConstructorBaseTypeSyntax primaryConstructorBaseTypeSyntax = ((SyntaxToken)(ref val)).Parent.AncestorsAndSelf(true).OfType<PrimaryConstructorBaseTypeSyntax>().FirstOrDefault();
|
||
|
|
if (primaryConstructorBaseTypeSyntax != null)
|
||
|
|
{
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel((SyntaxNode)(object)primaryConstructorBaseTypeSyntax);
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
return memberModel.TryGetSpeculativeSemanticModelCore(parentModel, position, constructorInitializer, out speculativeModel);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
speculativeModel = null;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override BoundExpression GetSpeculativelyBoundExpression(int position, ExpressionSyntax expression, SpeculativeBindingOption bindingOption, out Binder binder, out ImmutableArray<Symbol> crefSymbols)
|
||
|
|
{
|
||
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if (expression == null)
|
||
|
|
{
|
||
|
|
throw new ArgumentNullException("expression");
|
||
|
|
}
|
||
|
|
if ((int)bindingOption == 0)
|
||
|
|
{
|
||
|
|
position = CheckAndAdjustPosition(position);
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel(position);
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
return memberModel.GetSpeculativelyBoundExpression(position, expression, bindingOption, out binder, out crefSymbols);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return GetSpeculativelyBoundExpressionWithoutNullability(position, expression, bindingOption, out binder, out crefSymbols);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal PublicSemanticModel CreateSpeculativeAttributeSemanticModel(int position, AttributeSyntax attribute, Binder binder, AliasSymbol aliasOpt, NamedTypeSymbol attributeType)
|
||
|
|
{
|
||
|
|
return AttributeSemanticModel.CreateSpeculative(this, attribute, attributeType, aliasOpt, binder, (IsNullableAnalysisEnabledAtSpeculativePosition(position, (SyntaxNode)(object)attribute) ? GetMemberModel(position) : null)?.GetRemappedSymbols(), position);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal bool IsNullableAnalysisEnabledAtSpeculativePosition(int position, SyntaxNode speculativeSyntax)
|
||
|
|
{
|
||
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
return ((CSharpSyntaxTree)(object)speculativeSyntax.SyntaxTree).IsNullableAnalysisEnabled(speculativeSyntax.Span) ?? Compilation.IsNullableAnalysisEnabledIn((CSharpSyntaxTree)(object)SyntaxTree, new TextSpan(position, 0));
|
||
|
|
}
|
||
|
|
|
||
|
|
private MemberSemanticModel GetMemberModel(int position)
|
||
|
|
{
|
||
|
|
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
SyntaxToken val = Root.FindTokenIncludingCrefAndNameAttributes(position);
|
||
|
|
CSharpSyntaxNode node = (CSharpSyntaxNode)(object)((SyntaxToken)(ref val)).Parent;
|
||
|
|
CSharpSyntaxNode memberDeclaration = GetMemberDeclaration((SyntaxNode)(object)node);
|
||
|
|
bool flag = false;
|
||
|
|
if (memberDeclaration != null)
|
||
|
|
{
|
||
|
|
switch (memberDeclaration.Kind())
|
||
|
|
{
|
||
|
|
case SyntaxKind.GetAccessorDeclaration:
|
||
|
|
case SyntaxKind.SetAccessorDeclaration:
|
||
|
|
case SyntaxKind.AddAccessorDeclaration:
|
||
|
|
case SyntaxKind.RemoveAccessorDeclaration:
|
||
|
|
case SyntaxKind.InitAccessorDeclaration:
|
||
|
|
flag = !LookupPosition.IsInBody(position, (AccessorDeclarationSyntax)memberDeclaration);
|
||
|
|
break;
|
||
|
|
case SyntaxKind.ConstructorDeclaration:
|
||
|
|
{
|
||
|
|
ConstructorDeclarationSyntax constructorDeclarationSyntax = (ConstructorDeclarationSyntax)memberDeclaration;
|
||
|
|
flag = !LookupPosition.IsInConstructorParameterScope(position, constructorDeclarationSyntax) && !LookupPosition.IsInParameterList(position, constructorDeclarationSyntax);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
case SyntaxKind.ClassDeclaration:
|
||
|
|
case SyntaxKind.RecordDeclaration:
|
||
|
|
{
|
||
|
|
TypeDeclarationSyntax typeDeclarationSyntax = (TypeDeclarationSyntax)memberDeclaration;
|
||
|
|
if (typeDeclarationSyntax.ParameterList == null)
|
||
|
|
{
|
||
|
|
flag = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
ArgumentListSyntax argumentListSyntax = typeDeclarationSyntax.PrimaryConstructorBaseTypeIfClass?.ArgumentList;
|
||
|
|
flag = argumentListSyntax == null || !LookupPosition.IsBetweenTokens(position, argumentListSyntax.OpenParenToken, argumentListSyntax.CloseParenToken);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
case SyntaxKind.MethodDeclaration:
|
||
|
|
case SyntaxKind.OperatorDeclaration:
|
||
|
|
case SyntaxKind.ConversionOperatorDeclaration:
|
||
|
|
case SyntaxKind.DestructorDeclaration:
|
||
|
|
{
|
||
|
|
BaseMethodDeclarationSyntax baseMethodDeclarationSyntax = (BaseMethodDeclarationSyntax)memberDeclaration;
|
||
|
|
flag = !LookupPosition.IsInBody(position, baseMethodDeclarationSyntax) && !LookupPosition.IsInParameterList(position, baseMethodDeclarationSyntax);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (!flag)
|
||
|
|
{
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node);
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override MemberSemanticModel GetMemberModel(SyntaxNode node)
|
||
|
|
{
|
||
|
|
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0339: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if (IsInDocumentationComment(node))
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
CSharpSyntaxNode cSharpSyntaxNode = GetMemberDeclaration(node) ?? (node as CompilationUnitSyntax);
|
||
|
|
if (cSharpSyntaxNode != null)
|
||
|
|
{
|
||
|
|
TextSpan span = node.Span;
|
||
|
|
BaseMethodDeclarationSyntax baseMethodDeclarationSyntax;
|
||
|
|
TextSpan fullSpan;
|
||
|
|
ConstructorDeclarationSyntax constructorDeclarationSyntax;
|
||
|
|
DestructorDeclarationSyntax destructorDeclarationSyntax;
|
||
|
|
AccessorDeclarationSyntax accessorDeclarationSyntax;
|
||
|
|
switch (cSharpSyntaxNode.Kind())
|
||
|
|
{
|
||
|
|
case SyntaxKind.MethodDeclaration:
|
||
|
|
case SyntaxKind.OperatorDeclaration:
|
||
|
|
case SyntaxKind.ConversionOperatorDeclaration:
|
||
|
|
{
|
||
|
|
baseMethodDeclarationSyntax = (BaseMethodDeclarationSyntax)cSharpSyntaxNode;
|
||
|
|
ArrowExpressionClauseSyntax? expressionBodySyntax = baseMethodDeclarationSyntax.GetExpressionBodySyntax();
|
||
|
|
if (expressionBodySyntax != null)
|
||
|
|
{
|
||
|
|
fullSpan = ((SyntaxNode)expressionBodySyntax).FullSpan;
|
||
|
|
if (((TextSpan)(ref fullSpan)).Contains(span))
|
||
|
|
{
|
||
|
|
goto IL_0145;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
BlockSyntax? body2 = baseMethodDeclarationSyntax.Body;
|
||
|
|
if (body2 != null)
|
||
|
|
{
|
||
|
|
fullSpan = ((SyntaxNode)body2).FullSpan;
|
||
|
|
if (((TextSpan)(ref fullSpan)).Contains(span))
|
||
|
|
{
|
||
|
|
goto IL_0145;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
case SyntaxKind.ConstructorDeclaration:
|
||
|
|
{
|
||
|
|
constructorDeclarationSyntax = (ConstructorDeclarationSyntax)cSharpSyntaxNode;
|
||
|
|
ArrowExpressionClauseSyntax expressionBodySyntax2 = constructorDeclarationSyntax.GetExpressionBodySyntax();
|
||
|
|
ConstructorInitializerSyntax? initializer = constructorDeclarationSyntax.Initializer;
|
||
|
|
if (initializer != null)
|
||
|
|
{
|
||
|
|
fullSpan = ((SyntaxNode)initializer).FullSpan;
|
||
|
|
if (((TextSpan)(ref fullSpan)).Contains(span))
|
||
|
|
{
|
||
|
|
goto IL_01b5;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (expressionBodySyntax2 != null)
|
||
|
|
{
|
||
|
|
fullSpan = ((SyntaxNode)expressionBodySyntax2).FullSpan;
|
||
|
|
if (((TextSpan)(ref fullSpan)).Contains(span))
|
||
|
|
{
|
||
|
|
goto IL_01b5;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
BlockSyntax? body3 = constructorDeclarationSyntax.Body;
|
||
|
|
if (body3 != null)
|
||
|
|
{
|
||
|
|
fullSpan = ((SyntaxNode)body3).FullSpan;
|
||
|
|
if (((TextSpan)(ref fullSpan)).Contains(span))
|
||
|
|
{
|
||
|
|
goto IL_01b5;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
case SyntaxKind.ClassDeclaration:
|
||
|
|
case SyntaxKind.RecordDeclaration:
|
||
|
|
{
|
||
|
|
TypeDeclarationSyntax typeDeclarationSyntax = (TypeDeclarationSyntax)cSharpSyntaxNode;
|
||
|
|
if (typeDeclarationSyntax.ParameterList != null)
|
||
|
|
{
|
||
|
|
PrimaryConstructorBaseTypeSyntax primaryConstructorBaseTypeIfClass = typeDeclarationSyntax.PrimaryConstructorBaseTypeIfClass;
|
||
|
|
if (primaryConstructorBaseTypeIfClass != null)
|
||
|
|
{
|
||
|
|
if ((object)node != primaryConstructorBaseTypeIfClass)
|
||
|
|
{
|
||
|
|
fullSpan = ((SyntaxNode)primaryConstructorBaseTypeIfClass.ArgumentList).FullSpan;
|
||
|
|
if (!((TextSpan)(ref fullSpan)).Contains(span))
|
||
|
|
{
|
||
|
|
goto IL_01f9;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return GetOrAddModel(cSharpSyntaxNode);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
goto IL_01f9;
|
||
|
|
}
|
||
|
|
case SyntaxKind.DestructorDeclaration:
|
||
|
|
{
|
||
|
|
destructorDeclarationSyntax = (DestructorDeclarationSyntax)cSharpSyntaxNode;
|
||
|
|
ArrowExpressionClauseSyntax? expressionBodySyntax3 = destructorDeclarationSyntax.GetExpressionBodySyntax();
|
||
|
|
if (expressionBodySyntax3 != null)
|
||
|
|
{
|
||
|
|
fullSpan = ((SyntaxNode)expressionBodySyntax3).FullSpan;
|
||
|
|
if (((TextSpan)(ref fullSpan)).Contains(span))
|
||
|
|
{
|
||
|
|
goto IL_024b;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
BlockSyntax? body4 = destructorDeclarationSyntax.Body;
|
||
|
|
if (body4 != null)
|
||
|
|
{
|
||
|
|
fullSpan = ((SyntaxNode)body4).FullSpan;
|
||
|
|
if (((TextSpan)(ref fullSpan)).Contains(span))
|
||
|
|
{
|
||
|
|
goto IL_024b;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
case SyntaxKind.GetAccessorDeclaration:
|
||
|
|
case SyntaxKind.SetAccessorDeclaration:
|
||
|
|
case SyntaxKind.AddAccessorDeclaration:
|
||
|
|
case SyntaxKind.RemoveAccessorDeclaration:
|
||
|
|
case SyntaxKind.InitAccessorDeclaration:
|
||
|
|
{
|
||
|
|
accessorDeclarationSyntax = (AccessorDeclarationSyntax)cSharpSyntaxNode;
|
||
|
|
ArrowExpressionClauseSyntax? expressionBody = accessorDeclarationSyntax.ExpressionBody;
|
||
|
|
if (expressionBody != null)
|
||
|
|
{
|
||
|
|
fullSpan = ((SyntaxNode)expressionBody).FullSpan;
|
||
|
|
if (((TextSpan)(ref fullSpan)).Contains(span))
|
||
|
|
{
|
||
|
|
goto IL_029c;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
BlockSyntax? body = accessorDeclarationSyntax.Body;
|
||
|
|
if (body != null)
|
||
|
|
{
|
||
|
|
fullSpan = ((SyntaxNode)body).FullSpan;
|
||
|
|
if (((TextSpan)(ref fullSpan)).Contains(span))
|
||
|
|
{
|
||
|
|
goto IL_029c;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
case SyntaxKind.IndexerDeclaration:
|
||
|
|
{
|
||
|
|
IndexerDeclarationSyntax indexerDeclarationSyntax = (IndexerDeclarationSyntax)cSharpSyntaxNode;
|
||
|
|
return GetOrAddModelIfContains(indexerDeclarationSyntax.ExpressionBody, span);
|
||
|
|
}
|
||
|
|
case SyntaxKind.FieldDeclaration:
|
||
|
|
case SyntaxKind.EventFieldDeclaration:
|
||
|
|
{
|
||
|
|
Enumerator<VariableDeclaratorSyntax> enumerator = ((BaseFieldDeclarationSyntax)cSharpSyntaxNode).Declaration.Variables.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
VariableDeclaratorSyntax current = enumerator.Current;
|
||
|
|
MemberSemanticModel orAddModelIfContains = GetOrAddModelIfContains(current.Initializer, span);
|
||
|
|
if (orAddModelIfContains != null)
|
||
|
|
{
|
||
|
|
return orAddModelIfContains;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
case SyntaxKind.EnumMemberDeclaration:
|
||
|
|
{
|
||
|
|
EnumMemberDeclarationSyntax enumMemberDeclarationSyntax = (EnumMemberDeclarationSyntax)cSharpSyntaxNode;
|
||
|
|
if (enumMemberDeclarationSyntax.EqualsValue == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return GetOrAddModelIfContains(enumMemberDeclarationSyntax.EqualsValue, span);
|
||
|
|
}
|
||
|
|
case SyntaxKind.PropertyDeclaration:
|
||
|
|
{
|
||
|
|
PropertyDeclarationSyntax propertyDeclarationSyntax = (PropertyDeclarationSyntax)cSharpSyntaxNode;
|
||
|
|
return GetOrAddModelIfContains(propertyDeclarationSyntax.Initializer, span) ?? GetOrAddModelIfContains(propertyDeclarationSyntax.ExpressionBody, span);
|
||
|
|
}
|
||
|
|
case SyntaxKind.GlobalStatement:
|
||
|
|
if (SyntaxFacts.IsSimpleProgramTopLevelStatement((GlobalStatementSyntax)cSharpSyntaxNode))
|
||
|
|
{
|
||
|
|
return GetOrAddModel((CompilationUnitSyntax)cSharpSyntaxNode.Parent);
|
||
|
|
}
|
||
|
|
return GetOrAddModel(cSharpSyntaxNode);
|
||
|
|
case SyntaxKind.CompilationUnit:
|
||
|
|
if ((object)SynthesizedSimpleProgramEntryPointSymbol.GetSimpleProgramEntryPoint(Compilation, (CompilationUnitSyntax)cSharpSyntaxNode, fallbackToMainEntryPoint: false) != null)
|
||
|
|
{
|
||
|
|
return GetOrAddModel(cSharpSyntaxNode);
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case SyntaxKind.Attribute:
|
||
|
|
return GetOrAddModelForAttribute((AttributeSyntax)cSharpSyntaxNode);
|
||
|
|
case SyntaxKind.Parameter:
|
||
|
|
{
|
||
|
|
if ((object)node != cSharpSyntaxNode)
|
||
|
|
{
|
||
|
|
return GetOrAddModelForParameter((ParameterSyntax)cSharpSyntaxNode, span);
|
||
|
|
}
|
||
|
|
return GetMemberModel((SyntaxNode)(object)cSharpSyntaxNode.Parent);
|
||
|
|
}
|
||
|
|
IL_024b:
|
||
|
|
return GetOrAddModel(destructorDeclarationSyntax);
|
||
|
|
IL_029c:
|
||
|
|
return GetOrAddModel(accessorDeclarationSyntax);
|
||
|
|
IL_01b5:
|
||
|
|
return GetOrAddModel(constructorDeclarationSyntax);
|
||
|
|
IL_0145:
|
||
|
|
return GetOrAddModel(baseMethodDeclarationSyntax);
|
||
|
|
IL_01f9:
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
private MemberSemanticModel GetOrAddModelForAttribute(AttributeSyntax attribute)
|
||
|
|
{
|
||
|
|
MemberSemanticModel memberSemanticModel = ((attribute.Parent != null) ? GetMemberModel((SyntaxNode)(object)attribute.Parent) : null);
|
||
|
|
if (memberSemanticModel == null)
|
||
|
|
{
|
||
|
|
return GetOrAddModel(attribute);
|
||
|
|
}
|
||
|
|
return ImmutableInterlocked.GetOrAdd(ref _memberModels, attribute, (CSharpSyntaxNode node, (Binder binder, MemberSemanticModel model) binderAndModel) => CreateModelForAttribute(binderAndModel.binder, (AttributeSyntax)node, binderAndModel.model), (memberSemanticModel.GetEnclosingBinder(((SyntaxNode)attribute).SpanStart), memberSemanticModel));
|
||
|
|
}
|
||
|
|
|
||
|
|
private static bool IsInDocumentationComment(SyntaxNode node)
|
||
|
|
{
|
||
|
|
for (SyntaxNode val = node; val != null; val = val.Parent)
|
||
|
|
{
|
||
|
|
if (SyntaxFacts.IsDocumentationCommentTrivia(val.Kind()))
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
private MemberSemanticModel GetOrAddModelForParameter(ParameterSyntax paramDecl, TextSpan span)
|
||
|
|
{
|
||
|
|
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
EqualsValueClauseSyntax equalsValueClauseSyntax = paramDecl.Default;
|
||
|
|
MemberSemanticModel memberSemanticModel = ((paramDecl.Parent != null) ? GetMemberModel((SyntaxNode)(object)paramDecl.Parent) : null);
|
||
|
|
if (memberSemanticModel == null)
|
||
|
|
{
|
||
|
|
return GetOrAddModelIfContains(equalsValueClauseSyntax, span);
|
||
|
|
}
|
||
|
|
if (equalsValueClauseSyntax != null)
|
||
|
|
{
|
||
|
|
TextSpan fullSpan = ((SyntaxNode)equalsValueClauseSyntax).FullSpan;
|
||
|
|
if (((TextSpan)(ref fullSpan)).Contains(span))
|
||
|
|
{
|
||
|
|
ParameterSymbol symbol = ((ISymbol?)(object)memberSemanticModel.GetDeclaredSymbol(paramDecl)).GetSymbol<ParameterSymbol>();
|
||
|
|
if ((object)symbol != null)
|
||
|
|
{
|
||
|
|
return ImmutableInterlocked.GetOrAdd(ref _memberModels, equalsValueClauseSyntax, (CSharpSyntaxNode equalsValue, (CSharpCompilation compilation, ParameterSyntax paramDecl, ParameterSymbol parameterSymbol, MemberSemanticModel containing) tuple) => InitializerSemanticModel.Create(this, tuple.paramDecl, tuple.parameterSymbol, tuple.containing.GetEnclosingBinder(((SyntaxNode)tuple.paramDecl).SpanStart).CreateBinderForParameterDefaultValue(tuple.parameterSymbol, (EqualsValueClauseSyntax)equalsValue), tuple.containing.GetRemappedSymbols()), (Compilation, paramDecl, symbol, memberSemanticModel));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return memberSemanticModel;
|
||
|
|
}
|
||
|
|
|
||
|
|
private static CSharpSyntaxNode GetMemberDeclaration(SyntaxNode node)
|
||
|
|
{
|
||
|
|
return node.FirstAncestorOrSelf<CSharpSyntaxNode>(s_isMemberDeclarationFunction, true);
|
||
|
|
}
|
||
|
|
|
||
|
|
private MemberSemanticModel GetOrAddModelIfContains(CSharpSyntaxNode node, TextSpan span)
|
||
|
|
{
|
||
|
|
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if (node != null)
|
||
|
|
{
|
||
|
|
TextSpan fullSpan = ((SyntaxNode)node).FullSpan;
|
||
|
|
if (((TextSpan)(ref fullSpan)).Contains(span))
|
||
|
|
{
|
||
|
|
return GetOrAddModel(node);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
private MemberSemanticModel GetOrAddModel(CSharpSyntaxNode node)
|
||
|
|
{
|
||
|
|
Func<CSharpSyntaxNode, MemberSemanticModel> createMemberModelFunction = CreateMemberModel;
|
||
|
|
return GetOrAddModel(node, createMemberModelFunction);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal MemberSemanticModel GetOrAddModel(CSharpSyntaxNode node, Func<CSharpSyntaxNode, MemberSemanticModel> createMemberModelFunction)
|
||
|
|
{
|
||
|
|
return ImmutableInterlocked.GetOrAdd(ref _memberModels, node, createMemberModelFunction);
|
||
|
|
}
|
||
|
|
|
||
|
|
private MemberSemanticModel CreateMemberModel(CSharpSyntaxNode node)
|
||
|
|
{
|
||
|
|
switch (node.Kind())
|
||
|
|
{
|
||
|
|
case SyntaxKind.CompilationUnit:
|
||
|
|
return createMethodBodySemanticModel(node, SynthesizedSimpleProgramEntryPointSymbol.GetSimpleProgramEntryPoint(Compilation, (CompilationUnitSyntax)node, fallbackToMainEntryPoint: false));
|
||
|
|
case SyntaxKind.MethodDeclaration:
|
||
|
|
case SyntaxKind.OperatorDeclaration:
|
||
|
|
case SyntaxKind.ConversionOperatorDeclaration:
|
||
|
|
case SyntaxKind.ConstructorDeclaration:
|
||
|
|
case SyntaxKind.DestructorDeclaration:
|
||
|
|
{
|
||
|
|
MemberDeclarationSyntax memberDeclarationSyntax = (MemberDeclarationSyntax)node;
|
||
|
|
SourceMemberMethodSymbol symbol3 = GetDeclaredSymbol(memberDeclarationSyntax).GetSymbol<SourceMemberMethodSymbol>();
|
||
|
|
return createMethodBodySemanticModel(memberDeclarationSyntax, symbol3);
|
||
|
|
}
|
||
|
|
case SyntaxKind.ClassDeclaration:
|
||
|
|
case SyntaxKind.RecordDeclaration:
|
||
|
|
{
|
||
|
|
SynthesizedPrimaryConstructor synthesizedPrimaryConstructor = TryGetSynthesizedPrimaryConstructor((TypeDeclarationSyntax)node);
|
||
|
|
if ((object)synthesizedPrimaryConstructor == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return createMethodBodySemanticModel(node, synthesizedPrimaryConstructor);
|
||
|
|
}
|
||
|
|
case SyntaxKind.GetAccessorDeclaration:
|
||
|
|
case SyntaxKind.SetAccessorDeclaration:
|
||
|
|
case SyntaxKind.AddAccessorDeclaration:
|
||
|
|
case SyntaxKind.RemoveAccessorDeclaration:
|
||
|
|
case SyntaxKind.InitAccessorDeclaration:
|
||
|
|
{
|
||
|
|
AccessorDeclarationSyntax accessorDeclarationSyntax = (AccessorDeclarationSyntax)node;
|
||
|
|
SourceMemberMethodSymbol symbol4 = ((ISymbol?)(object)GetDeclaredSymbol(accessorDeclarationSyntax)).GetSymbol<SourceMemberMethodSymbol>();
|
||
|
|
return createMethodBodySemanticModel(accessorDeclarationSyntax, symbol4);
|
||
|
|
}
|
||
|
|
case SyntaxKind.Block:
|
||
|
|
ExceptionUtilities.UnexpectedValue((object)node.Parent);
|
||
|
|
break;
|
||
|
|
case SyntaxKind.EqualsValueClause:
|
||
|
|
switch (node.Parent.Kind())
|
||
|
|
{
|
||
|
|
case SyntaxKind.VariableDeclarator:
|
||
|
|
{
|
||
|
|
VariableDeclaratorSyntax variableDeclaratorSyntax = (VariableDeclaratorSyntax)node.Parent;
|
||
|
|
FieldSymbol declaredFieldSymbol = GetDeclaredFieldSymbol(variableDeclaratorSyntax);
|
||
|
|
return InitializerSemanticModel.Create(this, variableDeclaratorSyntax, declaredFieldSymbol, GetFieldOrPropertyInitializerBinder(declaredFieldSymbol, defaultOuter(), variableDeclaratorSyntax.Initializer));
|
||
|
|
}
|
||
|
|
case SyntaxKind.PropertyDeclaration:
|
||
|
|
{
|
||
|
|
PropertyDeclarationSyntax propertyDeclarationSyntax = (PropertyDeclarationSyntax)node.Parent;
|
||
|
|
SourcePropertySymbol symbol2 = ((ISymbol?)(object)GetDeclaredSymbol(propertyDeclarationSyntax)).GetSymbol<SourcePropertySymbol>();
|
||
|
|
return InitializerSemanticModel.Create(this, propertyDeclarationSyntax, symbol2, GetFieldOrPropertyInitializerBinder(symbol2.BackingField, defaultOuter(), propertyDeclarationSyntax.Initializer));
|
||
|
|
}
|
||
|
|
case SyntaxKind.Parameter:
|
||
|
|
{
|
||
|
|
ParameterSyntax parameterSyntax = (ParameterSyntax)node.Parent;
|
||
|
|
ParameterSymbol declaredNonLambdaParameterSymbol = GetDeclaredNonLambdaParameterSymbol(parameterSyntax);
|
||
|
|
if ((object)declaredNonLambdaParameterSymbol == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return InitializerSemanticModel.Create(this, parameterSyntax, declaredNonLambdaParameterSymbol, defaultOuter().CreateBinderForParameterDefaultValue(declaredNonLambdaParameterSymbol, (EqualsValueClauseSyntax)node), null);
|
||
|
|
}
|
||
|
|
case SyntaxKind.EnumMemberDeclaration:
|
||
|
|
{
|
||
|
|
EnumMemberDeclarationSyntax enumMemberDeclarationSyntax = (EnumMemberDeclarationSyntax)node.Parent;
|
||
|
|
FieldSymbol symbol = ((ISymbol?)(object)GetDeclaredSymbol(enumMemberDeclarationSyntax)).GetSymbol<FieldSymbol>();
|
||
|
|
if ((object)symbol == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return InitializerSemanticModel.Create(this, enumMemberDeclarationSyntax, symbol, GetFieldOrPropertyInitializerBinder(symbol, defaultOuter(), enumMemberDeclarationSyntax.EqualsValue));
|
||
|
|
}
|
||
|
|
default:
|
||
|
|
throw ExceptionUtilities.UnexpectedValue((object)node.Parent.Kind());
|
||
|
|
}
|
||
|
|
case SyntaxKind.ArrowExpressionClause:
|
||
|
|
{
|
||
|
|
SourceMemberMethodSymbol sourceMemberMethodSymbol = null;
|
||
|
|
ArrowExpressionClauseSyntax arrowExpressionClauseSyntax = (ArrowExpressionClauseSyntax)node;
|
||
|
|
if (node.Parent is BasePropertyDeclarationSyntax)
|
||
|
|
{
|
||
|
|
sourceMemberMethodSymbol = ((ISymbol?)(object)GetDeclaredSymbol(arrowExpressionClauseSyntax)).GetSymbol<SourceMemberMethodSymbol>();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
ExceptionUtilities.UnexpectedValue((object)node.Parent);
|
||
|
|
}
|
||
|
|
ExecutableCodeBinder executableCodeBinder = sourceMemberMethodSymbol?.TryGetBodyBinder(_binderFactory, ((SemanticModel)this).IgnoresAccessibility);
|
||
|
|
if (executableCodeBinder == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return MethodBodySemanticModel.Create(this, sourceMemberMethodSymbol, new MethodBodySemanticModel.InitialState(arrowExpressionClauseSyntax, null, executableCodeBinder));
|
||
|
|
}
|
||
|
|
case SyntaxKind.GlobalStatement:
|
||
|
|
{
|
||
|
|
CSharpSyntaxNode parent = node.Parent;
|
||
|
|
if (parent.Kind() == SyntaxKind.CompilationUnit && !IsRegularCSharp && (object)_compilation.ScriptClass != null)
|
||
|
|
{
|
||
|
|
SynthesizedInteractiveInitializerMethod scriptInitializer = _compilation.ScriptClass.GetScriptInitializer();
|
||
|
|
if ((object)scriptInitializer == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
if (_globalStatementLabels == null)
|
||
|
|
{
|
||
|
|
Interlocked.CompareExchange(ref _globalStatementLabels, new ScriptLocalScopeBinder.Labels(scriptInitializer, (CompilationUnitSyntax)parent), null);
|
||
|
|
}
|
||
|
|
return MethodBodySemanticModel.Create(this, scriptInitializer, new MethodBodySemanticModel.InitialState(node, null, new ExecutableCodeBinder((SyntaxNode)(object)node, scriptInitializer, new ScriptLocalScopeBinder(_globalStatementLabels, defaultOuter()))));
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
case SyntaxKind.Attribute:
|
||
|
|
return CreateModelForAttribute(defaultOuter(), (AttributeSyntax)node, null);
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
MemberSemanticModel createMethodBodySemanticModel(CSharpSyntaxNode memberDecl, SourceMemberMethodSymbol sourceMemberMethodSymbol2)
|
||
|
|
{
|
||
|
|
ExecutableCodeBinder executableCodeBinder2 = sourceMemberMethodSymbol2?.TryGetBodyBinder(_binderFactory, ((SemanticModel)this).IgnoresAccessibility);
|
||
|
|
if (executableCodeBinder2 == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return MethodBodySemanticModel.Create(this, sourceMemberMethodSymbol2, new MethodBodySemanticModel.InitialState(memberDecl, null, executableCodeBinder2));
|
||
|
|
}
|
||
|
|
Binder defaultOuter()
|
||
|
|
{
|
||
|
|
return _binderFactory.GetBinder((SyntaxNode)(object)node).WithAdditionalFlags(((SemanticModel)this).IgnoresAccessibility ? BinderFlags.IgnoreAccessibility : BinderFlags.None);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private SynthesizedPrimaryConstructor TryGetSynthesizedPrimaryConstructor(TypeDeclarationSyntax node)
|
||
|
|
{
|
||
|
|
return CSharpSemanticModel.TryGetSynthesizedPrimaryConstructor(node, GetDeclaredType(node));
|
||
|
|
}
|
||
|
|
|
||
|
|
private FieldSymbol GetDeclaredFieldSymbol(VariableDeclaratorSyntax variableDecl)
|
||
|
|
{
|
||
|
|
ISymbol declaredSymbol = GetDeclaredSymbol(variableDecl);
|
||
|
|
if (declaredSymbol != null)
|
||
|
|
{
|
||
|
|
switch (variableDecl.Parent.Parent.Kind())
|
||
|
|
{
|
||
|
|
case SyntaxKind.FieldDeclaration:
|
||
|
|
return declaredSymbol.GetSymbol<FieldSymbol>();
|
||
|
|
case SyntaxKind.EventFieldDeclaration:
|
||
|
|
return declaredSymbol.GetSymbol<EventSymbol>().AssociatedField;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
private Binder GetFieldOrPropertyInitializerBinder(FieldSymbol symbol, Binder outer, EqualsValueClauseSyntax initializer)
|
||
|
|
{
|
||
|
|
outer = outer.GetFieldInitializerBinder(symbol, !IsRegularCSharp && symbol.ContainingType.IsScriptClass);
|
||
|
|
if (initializer != null)
|
||
|
|
{
|
||
|
|
outer = new ExecutableCodeBinder((SyntaxNode)(object)initializer, symbol, outer);
|
||
|
|
}
|
||
|
|
return outer;
|
||
|
|
}
|
||
|
|
|
||
|
|
private static bool IsMemberDeclaration(CSharpSyntaxNode node)
|
||
|
|
{
|
||
|
|
if (!(node is MemberDeclarationSyntax) && !(node is AccessorDeclarationSyntax) && node.Kind() != SyntaxKind.Attribute)
|
||
|
|
{
|
||
|
|
return node.Kind() == SyntaxKind.Parameter;
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override INamespaceSymbol GetDeclaredSymbol(NamespaceDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
return GetDeclaredNamespace(declarationSyntax).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
public override INamespaceSymbol GetDeclaredSymbol(FileScopedNamespaceDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
return GetDeclaredNamespace(declarationSyntax).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
private NamespaceSymbol GetDeclaredNamespace(BaseNamespaceDeclarationSyntax declarationSyntax)
|
||
|
|
{
|
||
|
|
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
NamespaceOrTypeSymbol container = ((declarationSyntax.Parent.Kind() != SyntaxKind.CompilationUnit) ? GetDeclaredNamespaceOrType(declarationSyntax.Parent) : _compilation.Assembly.GlobalNamespace);
|
||
|
|
NamespaceSymbol declaredNamespace = GetDeclaredNamespace(container, ((SyntaxNode)declarationSyntax).Span, declarationSyntax.Name);
|
||
|
|
return _compilation.GetCompilationNamespace(declaredNamespace);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override INamedTypeSymbol GetDeclaredSymbol(BaseTypeDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
return GetDeclaredType(declarationSyntax).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
public override INamedTypeSymbol GetDeclaredSymbol(DelegateDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
return GetDeclaredType(declarationSyntax).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
private NamedTypeSymbol GetDeclaredType(BaseTypeDeclarationSyntax declarationSyntax)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
SyntaxToken identifier = declarationSyntax.Identifier;
|
||
|
|
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
|
||
|
|
return GetDeclaredNamedType(declarationSyntax, valueText);
|
||
|
|
}
|
||
|
|
|
||
|
|
private NamedTypeSymbol GetDeclaredType(DelegateDeclarationSyntax declarationSyntax)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
SyntaxToken identifier = declarationSyntax.Identifier;
|
||
|
|
string valueText = ((SyntaxToken)(ref identifier)).ValueText;
|
||
|
|
return GetDeclaredNamedType(declarationSyntax, valueText);
|
||
|
|
}
|
||
|
|
|
||
|
|
private NamedTypeSymbol GetDeclaredNamedType(CSharpSyntaxNode declarationSyntax, string name)
|
||
|
|
{
|
||
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
NamespaceOrTypeSymbol declaredTypeMemberContainer = GetDeclaredTypeMemberContainer(declarationSyntax);
|
||
|
|
return GetDeclaredMember(declaredTypeMemberContainer, ((SyntaxNode)declarationSyntax).Span, isKnownToBeANamespace: false, name) as NamedTypeSymbol;
|
||
|
|
}
|
||
|
|
|
||
|
|
private NamespaceOrTypeSymbol GetDeclaredNamespaceOrType(CSharpSyntaxNode declarationSyntax)
|
||
|
|
{
|
||
|
|
if (declarationSyntax is BaseNamespaceDeclarationSyntax declarationSyntax2)
|
||
|
|
{
|
||
|
|
return GetDeclaredNamespace(declarationSyntax2);
|
||
|
|
}
|
||
|
|
if (declarationSyntax is BaseTypeDeclarationSyntax declarationSyntax3)
|
||
|
|
{
|
||
|
|
return GetDeclaredType(declarationSyntax3);
|
||
|
|
}
|
||
|
|
if (declarationSyntax is DelegateDeclarationSyntax declarationSyntax4)
|
||
|
|
{
|
||
|
|
return GetDeclaredType(declarationSyntax4);
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ISymbol GetDeclaredSymbol(MemberDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
switch (declarationSyntax.Kind())
|
||
|
|
{
|
||
|
|
case SyntaxKind.GlobalStatement:
|
||
|
|
return null;
|
||
|
|
case SyntaxKind.IncompleteMember:
|
||
|
|
return null;
|
||
|
|
case SyntaxKind.FieldDeclaration:
|
||
|
|
case SyntaxKind.EventFieldDeclaration:
|
||
|
|
return null;
|
||
|
|
default:
|
||
|
|
return (GetDeclaredNamespaceOrType(declarationSyntax) ?? GetDeclaredMemberSymbol(declarationSyntax)).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IMethodSymbol GetDeclaredSymbol(CompilationUnitSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
return SynthesizedSimpleProgramEntryPointSymbol.GetSimpleProgramEntryPoint(Compilation, declarationSyntax, fallbackToMainEntryPoint: false).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ISymbol GetDeclaredSymbol(LocalFunctionStatementSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)declarationSyntax)?.GetDeclaredSymbol(declarationSyntax, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IFieldSymbol GetDeclaredSymbol(EnumMemberDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
return ((FieldSymbol)GetDeclaredMemberSymbol(declarationSyntax)).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IMethodSymbol GetDeclaredSymbol(BaseMethodDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
return ((MethodSymbol)GetDeclaredMemberSymbol(declarationSyntax)).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ISymbol GetDeclaredSymbol(BasePropertyDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
return GetDeclaredMemberSymbol(declarationSyntax).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IPropertySymbol GetDeclaredSymbol(PropertyDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
return ((PropertySymbol)GetDeclaredMemberSymbol(declarationSyntax)).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IPropertySymbol GetDeclaredSymbol(IndexerDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
return ((PropertySymbol)GetDeclaredMemberSymbol(declarationSyntax)).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IEventSymbol GetDeclaredSymbol(EventDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
return ((EventSymbol)GetDeclaredMemberSymbol(declarationSyntax)).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IMethodSymbol GetDeclaredSymbol(AccessorDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
if (declarationSyntax.Kind() == SyntaxKind.UnknownAccessorDeclaration)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
CSharpSyntaxNode parent = declarationSyntax.Parent.Parent;
|
||
|
|
SyntaxKind syntaxKind = parent.Kind();
|
||
|
|
if (syntaxKind == SyntaxKind.EventFieldDeclaration || syntaxKind - 8892 <= (SyntaxKind)2)
|
||
|
|
{
|
||
|
|
NamespaceOrTypeSymbol declaredTypeMemberContainer = GetDeclaredTypeMemberContainer(parent);
|
||
|
|
return (GetDeclaredMember(declaredTypeMemberContainer, ((SyntaxNode)declarationSyntax).Span, isKnownToBeANamespace: false) as MethodSymbol).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
throw ExceptionUtilities.UnexpectedValue((object)parent.Kind());
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IMethodSymbol GetDeclaredSymbol(ArrowExpressionClauseSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
CSharpSyntaxNode parent = declarationSyntax.Parent;
|
||
|
|
SyntaxKind syntaxKind = parent.Kind();
|
||
|
|
if (syntaxKind == SyntaxKind.PropertyDeclaration || syntaxKind == SyntaxKind.IndexerDeclaration)
|
||
|
|
{
|
||
|
|
NamespaceOrTypeSymbol declaredTypeMemberContainer = GetDeclaredTypeMemberContainer(parent);
|
||
|
|
return (GetDeclaredMember(declaredTypeMemberContainer, ((SyntaxNode)declarationSyntax).Span, isKnownToBeANamespace: false) as MethodSymbol).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
ExceptionUtilities.UnexpectedValue((object)parent.Kind());
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
private string GetDeclarationName(CSharpSyntaxNode declaration)
|
||
|
|
{
|
||
|
|
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
SyntaxToken identifier;
|
||
|
|
switch (declaration.Kind())
|
||
|
|
{
|
||
|
|
case SyntaxKind.MethodDeclaration:
|
||
|
|
{
|
||
|
|
MethodDeclarationSyntax methodDeclarationSyntax = (MethodDeclarationSyntax)declaration;
|
||
|
|
ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier2 = methodDeclarationSyntax.ExplicitInterfaceSpecifier;
|
||
|
|
identifier = methodDeclarationSyntax.Identifier;
|
||
|
|
return GetDeclarationName(declaration, explicitInterfaceSpecifier2, ((SyntaxToken)(ref identifier)).ValueText);
|
||
|
|
}
|
||
|
|
case SyntaxKind.PropertyDeclaration:
|
||
|
|
{
|
||
|
|
PropertyDeclarationSyntax propertyDeclarationSyntax = (PropertyDeclarationSyntax)declaration;
|
||
|
|
ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier = propertyDeclarationSyntax.ExplicitInterfaceSpecifier;
|
||
|
|
identifier = propertyDeclarationSyntax.Identifier;
|
||
|
|
return GetDeclarationName(declaration, explicitInterfaceSpecifier, ((SyntaxToken)(ref identifier)).ValueText);
|
||
|
|
}
|
||
|
|
case SyntaxKind.IndexerDeclaration:
|
||
|
|
{
|
||
|
|
IndexerDeclarationSyntax indexerDeclarationSyntax = (IndexerDeclarationSyntax)declaration;
|
||
|
|
return GetDeclarationName(declaration, indexerDeclarationSyntax.ExplicitInterfaceSpecifier, "this[]");
|
||
|
|
}
|
||
|
|
case SyntaxKind.EventDeclaration:
|
||
|
|
{
|
||
|
|
EventDeclarationSyntax eventDeclarationSyntax = (EventDeclarationSyntax)declaration;
|
||
|
|
ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifier3 = eventDeclarationSyntax.ExplicitInterfaceSpecifier;
|
||
|
|
identifier = eventDeclarationSyntax.Identifier;
|
||
|
|
return GetDeclarationName(declaration, explicitInterfaceSpecifier3, ((SyntaxToken)(ref identifier)).ValueText);
|
||
|
|
}
|
||
|
|
case SyntaxKind.DelegateDeclaration:
|
||
|
|
identifier = ((DelegateDeclarationSyntax)declaration).Identifier;
|
||
|
|
return ((SyntaxToken)(ref identifier)).ValueText;
|
||
|
|
case SyntaxKind.ClassDeclaration:
|
||
|
|
case SyntaxKind.StructDeclaration:
|
||
|
|
case SyntaxKind.InterfaceDeclaration:
|
||
|
|
case SyntaxKind.EnumDeclaration:
|
||
|
|
case SyntaxKind.RecordDeclaration:
|
||
|
|
case SyntaxKind.RecordStructDeclaration:
|
||
|
|
identifier = ((BaseTypeDeclarationSyntax)declaration).Identifier;
|
||
|
|
return ((SyntaxToken)(ref identifier)).ValueText;
|
||
|
|
case SyntaxKind.VariableDeclarator:
|
||
|
|
identifier = ((VariableDeclaratorSyntax)declaration).Identifier;
|
||
|
|
return ((SyntaxToken)(ref identifier)).ValueText;
|
||
|
|
case SyntaxKind.EnumMemberDeclaration:
|
||
|
|
identifier = ((EnumMemberDeclarationSyntax)declaration).Identifier;
|
||
|
|
return ((SyntaxToken)(ref identifier)).ValueText;
|
||
|
|
case SyntaxKind.DestructorDeclaration:
|
||
|
|
return "Finalize";
|
||
|
|
case SyntaxKind.ConstructorDeclaration:
|
||
|
|
if (((ConstructorDeclarationSyntax)declaration).Modifiers.Any(SyntaxKind.StaticKeyword))
|
||
|
|
{
|
||
|
|
return ".cctor";
|
||
|
|
}
|
||
|
|
return ".ctor";
|
||
|
|
case SyntaxKind.OperatorDeclaration:
|
||
|
|
{
|
||
|
|
OperatorDeclarationSyntax operatorDeclarationSyntax = (OperatorDeclarationSyntax)declaration;
|
||
|
|
return GetDeclarationName(declaration, operatorDeclarationSyntax.ExplicitInterfaceSpecifier, OperatorFacts.OperatorNameFromDeclaration(operatorDeclarationSyntax));
|
||
|
|
}
|
||
|
|
case SyntaxKind.ConversionOperatorDeclaration:
|
||
|
|
{
|
||
|
|
ConversionOperatorDeclarationSyntax conversionOperatorDeclarationSyntax = (ConversionOperatorDeclarationSyntax)declaration;
|
||
|
|
return GetDeclarationName(declaration, conversionOperatorDeclarationSyntax.ExplicitInterfaceSpecifier, OperatorFacts.OperatorNameFromDeclaration(conversionOperatorDeclarationSyntax));
|
||
|
|
}
|
||
|
|
case SyntaxKind.FieldDeclaration:
|
||
|
|
case SyntaxKind.EventFieldDeclaration:
|
||
|
|
throw new ArgumentException(CSharpResources.InvalidGetDeclarationNameMultipleDeclarators);
|
||
|
|
case SyntaxKind.IncompleteMember:
|
||
|
|
return null;
|
||
|
|
default:
|
||
|
|
throw ExceptionUtilities.UnexpectedValue((object)declaration.Kind());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private string GetDeclarationName(CSharpSyntaxNode declaration, ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifierOpt, string memberName)
|
||
|
|
{
|
||
|
|
if (explicitInterfaceSpecifierOpt == null)
|
||
|
|
{
|
||
|
|
return memberName;
|
||
|
|
}
|
||
|
|
return ExplicitInterfaceHelpers.GetMemberName(_binderFactory.GetBinder((SyntaxNode)(object)declaration), explicitInterfaceSpecifierOpt, memberName);
|
||
|
|
}
|
||
|
|
|
||
|
|
private NamespaceSymbol GetDeclaredNamespace(NamespaceOrTypeSymbol container, TextSpan declarationSpan, NameSyntax name)
|
||
|
|
{
|
||
|
|
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
switch (name.Kind())
|
||
|
|
{
|
||
|
|
case SyntaxKind.IdentifierName:
|
||
|
|
case SyntaxKind.GenericName:
|
||
|
|
{
|
||
|
|
SyntaxToken identifier = ((SimpleNameSyntax)name).Identifier;
|
||
|
|
return (NamespaceSymbol)GetDeclaredMember(container, declarationSpan, isKnownToBeANamespace: true, ((SyntaxToken)(ref identifier)).ValueText);
|
||
|
|
}
|
||
|
|
case SyntaxKind.QualifiedName:
|
||
|
|
{
|
||
|
|
QualifiedNameSyntax qualifiedNameSyntax = (QualifiedNameSyntax)name;
|
||
|
|
NamespaceOrTypeSymbol declaredNamespace = GetDeclaredNamespace(container, declarationSpan, qualifiedNameSyntax.Left);
|
||
|
|
return GetDeclaredNamespace(declaredNamespace, declarationSpan, qualifiedNameSyntax.Right);
|
||
|
|
}
|
||
|
|
case SyntaxKind.AliasQualifiedName:
|
||
|
|
{
|
||
|
|
AliasQualifiedNameSyntax aliasQualifiedNameSyntax = (AliasQualifiedNameSyntax)name;
|
||
|
|
return GetDeclaredNamespace(container, declarationSpan, aliasQualifiedNameSyntax.Name);
|
||
|
|
}
|
||
|
|
default:
|
||
|
|
throw ExceptionUtilities.UnexpectedValue((object)name.Kind());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private Symbol GetDeclaredMember(NamespaceOrTypeSymbol container, TextSpan declarationSpan, bool isKnownToBeANamespace, string name = null)
|
||
|
|
{
|
||
|
|
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00cd: Invalid comparison between Unknown and I4
|
||
|
|
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
if ((object)container == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
ImmutableArray<Symbol> immutableArray = ((name != null) ? container.GetMembers(name) : container.GetMembersUnordered());
|
||
|
|
if (isKnownToBeANamespace)
|
||
|
|
{
|
||
|
|
ImmutableArray<Symbol> immutableArray2 = ImmutableArrayExtensions.WhereAsArray<Symbol>(immutableArray, (Func<Symbol, bool>)((Symbol symbol3) => symbol3 is NamespaceSymbol));
|
||
|
|
if (name != null && immutableArray2.Length == 1 && immutableArray2[0] is NamespaceSymbol result)
|
||
|
|
{
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
Symbol symbol = null;
|
||
|
|
ImmutableArray<Symbol>.Enumerator enumerator = immutableArray.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
Symbol current = enumerator.Current;
|
||
|
|
if (current is ImplicitNamedTypeSymbol { IsImplicitClass: not false } implicitNamedTypeSymbol)
|
||
|
|
{
|
||
|
|
Symbol declaredMember = GetDeclaredMember(implicitNamedTypeSymbol, declarationSpan, isKnownToBeANamespace, name);
|
||
|
|
if ((object)declaredMember != null)
|
||
|
|
{
|
||
|
|
return declaredMember;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (current.HasLocationContainedWithin(SyntaxTree, declarationSpan, out var wasZeroWidthMatch))
|
||
|
|
{
|
||
|
|
if (!wasZeroWidthMatch)
|
||
|
|
{
|
||
|
|
return current;
|
||
|
|
}
|
||
|
|
symbol = current;
|
||
|
|
}
|
||
|
|
MethodSymbol methodSymbol = (((int)current.Kind == 9) ? ((MethodSymbol)current).PartialImplementationPart : null);
|
||
|
|
if ((object)methodSymbol != null)
|
||
|
|
{
|
||
|
|
Location firstLocation = methodSymbol.GetFirstLocation();
|
||
|
|
if (firstLocation.IsInSource && firstLocation.SourceTree == SyntaxTree && ((TextSpan)(ref declarationSpan)).Contains(firstLocation.SourceSpan))
|
||
|
|
{
|
||
|
|
return methodSymbol;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
Symbol symbol2 = symbol;
|
||
|
|
if ((object)symbol2 == null)
|
||
|
|
{
|
||
|
|
if (name == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
symbol2 = GetDeclaredMember(container, declarationSpan, isKnownToBeANamespace);
|
||
|
|
}
|
||
|
|
return symbol2;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ISymbol GetDeclaredSymbol(VariableDeclaratorSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
BaseFieldDeclarationSyntax baseFieldDeclarationSyntax = ((declarationSyntax.Parent == null) ? null : (declarationSyntax.Parent.Parent as BaseFieldDeclarationSyntax));
|
||
|
|
if (baseFieldDeclarationSyntax != null)
|
||
|
|
{
|
||
|
|
NamespaceOrTypeSymbol declaredTypeMemberContainer = GetDeclaredTypeMemberContainer(baseFieldDeclarationSyntax);
|
||
|
|
TextSpan span = ((SyntaxNode)declarationSyntax).Span;
|
||
|
|
SyntaxToken identifier = declarationSyntax.Identifier;
|
||
|
|
return GetDeclaredMember(declaredTypeMemberContainer, span, isKnownToBeANamespace: false, ((SyntaxToken)(ref identifier)).ValueText).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
return GetMemberModel((SyntaxNode)(object)declarationSyntax)?.GetDeclaredSymbol(declarationSyntax, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ISymbol GetDeclaredSymbol(SingleVariableDesignationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
ISymbol val = GetMemberModel((SyntaxNode)(object)declarationSyntax)?.GetDeclaredSymbol(declarationSyntax, cancellationToken);
|
||
|
|
if (val != null)
|
||
|
|
{
|
||
|
|
return val;
|
||
|
|
}
|
||
|
|
return (ISymbol)(object)GetEnclosingBinder(((SyntaxNode)declarationSyntax).Position)?.LookupDeclaredField(declarationSyntax).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override LocalSymbol GetAdjustedLocalSymbol(SourceLocalSymbol originalSymbol)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
SyntaxToken identifierToken = originalSymbol.IdentifierToken;
|
||
|
|
int spanStart = ((SyntaxToken)(ref identifierToken)).SpanStart;
|
||
|
|
return GetMemberModel(spanStart)?.GetAdjustedLocalSymbol(originalSymbol) ?? originalSymbol;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ILabelSymbol GetDeclaredSymbol(LabeledStatementSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)declarationSyntax)?.GetDeclaredSymbol(declarationSyntax, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ILabelSymbol GetDeclaredSymbol(SwitchLabelSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
return GetMemberModel((SyntaxNode)(object)declarationSyntax)?.GetDeclaredSymbol(declarationSyntax, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IAliasSymbol GetDeclaredSymbol(UsingDirectiveSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
if (declarationSyntax.Alias == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
for (Binder binder = _binderFactory.GetInNamespaceBinder(declarationSyntax.Parent); binder != null; binder = binder.Next)
|
||
|
|
{
|
||
|
|
ImmutableArray<AliasAndUsingDirective> usingAliases = binder.UsingAliases;
|
||
|
|
if (!usingAliases.IsDefault)
|
||
|
|
{
|
||
|
|
ImmutableArray<AliasAndUsingDirective>.Enumerator enumerator = usingAliases.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
AliasAndUsingDirective current = enumerator.Current;
|
||
|
|
if (current.Alias.GetFirstLocation().SourceSpan == ((SyntaxNode)declarationSyntax.Alias.Name).Span)
|
||
|
|
{
|
||
|
|
return current.Alias.GetPublicSymbol();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IAliasSymbol GetDeclaredSymbol(ExternAliasDirectiveSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
for (Binder binder = _binderFactory.GetInNamespaceBinder(declarationSyntax.Parent); binder != null; binder = binder.Next)
|
||
|
|
{
|
||
|
|
ImmutableArray<AliasAndExternAliasDirective> externAliases = binder.ExternAliases;
|
||
|
|
if (!externAliases.IsDefault)
|
||
|
|
{
|
||
|
|
ImmutableArray<AliasAndExternAliasDirective>.Enumerator enumerator = externAliases.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
AliasAndExternAliasDirective current = enumerator.Current;
|
||
|
|
TextSpan sourceSpan = current.Alias.GetFirstLocation().SourceSpan;
|
||
|
|
SyntaxToken identifier = declarationSyntax.Identifier;
|
||
|
|
if (sourceSpan == ((SyntaxToken)(ref identifier)).Span)
|
||
|
|
{
|
||
|
|
return current.Alias.GetPublicSymbol();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override ImmutableArray<ISymbol> GetDeclaredSymbols(BaseFieldDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
ArrayBuilder<ISymbol> val = new ArrayBuilder<ISymbol>();
|
||
|
|
Enumerator<VariableDeclaratorSyntax> enumerator = declarationSyntax.Declaration.Variables.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
VariableDeclaratorSyntax current = enumerator.Current;
|
||
|
|
ISymbol declaredSymbol = GetDeclaredSymbol(current, cancellationToken);
|
||
|
|
if (declaredSymbol != null)
|
||
|
|
{
|
||
|
|
val.Add(declaredSymbol);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return val.ToImmutableAndFree();
|
||
|
|
}
|
||
|
|
|
||
|
|
private ParameterSymbol GetMethodParameterSymbol(ParameterSyntax parameter, CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
if (!(parameter.Parent is ParameterListSyntax parameterListSyntax))
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
if (!(parameterListSyntax.Parent is MemberDeclarationSyntax memberDeclarationSyntax))
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
MethodSymbol methodSymbol;
|
||
|
|
if (memberDeclarationSyntax is TypeDeclarationSyntax typeDeclarationSyntax && typeDeclarationSyntax.ParameterList == parameterListSyntax)
|
||
|
|
{
|
||
|
|
methodSymbol = TryGetSynthesizedPrimaryConstructor(typeDeclarationSyntax);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
ISymbol declaredSymbol = GetDeclaredSymbol(memberDeclarationSyntax, cancellationToken);
|
||
|
|
methodSymbol = ((IMethodSymbol?)(object)((declaredSymbol is IMethodSymbol) ? declaredSymbol : null)).GetSymbol();
|
||
|
|
}
|
||
|
|
if ((object)methodSymbol == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
object obj = GetParameterSymbol(methodSymbol.Parameters, parameter, cancellationToken);
|
||
|
|
if (obj == null)
|
||
|
|
{
|
||
|
|
if ((object)methodSymbol.PartialDefinitionPart != null)
|
||
|
|
{
|
||
|
|
return GetParameterSymbol(methodSymbol.PartialDefinitionPart.Parameters, parameter, cancellationToken);
|
||
|
|
}
|
||
|
|
obj = null;
|
||
|
|
}
|
||
|
|
return (ParameterSymbol)obj;
|
||
|
|
}
|
||
|
|
|
||
|
|
private ParameterSymbol GetIndexerParameterSymbol(ParameterSyntax parameter, CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
if (!(parameter.Parent is BracketedParameterListSyntax bracketedParameterListSyntax))
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
if (!(bracketedParameterListSyntax.Parent is MemberDeclarationSyntax declarationSyntax))
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
ISymbol declaredSymbol = GetDeclaredSymbol(declarationSyntax, cancellationToken);
|
||
|
|
PropertySymbol symbol = ((IPropertySymbol?)(object)((declaredSymbol is IPropertySymbol) ? declaredSymbol : null)).GetSymbol();
|
||
|
|
if ((object)symbol == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return GetParameterSymbol(symbol.Parameters, parameter, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
private ParameterSymbol GetDelegateParameterSymbol(ParameterSyntax parameter, CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
if (!(parameter.Parent is ParameterListSyntax parameterListSyntax))
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
if (!(parameterListSyntax.Parent is DelegateDeclarationSyntax declarationSyntax))
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
NamedTypeSymbol symbol = GetDeclaredSymbol(declarationSyntax, cancellationToken).GetSymbol();
|
||
|
|
if ((object)symbol == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
MethodSymbol delegateInvokeMethod = symbol.DelegateInvokeMethod;
|
||
|
|
if ((object)delegateInvokeMethod == null || delegateInvokeMethod.HasUseSiteError)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return GetParameterSymbol(delegateInvokeMethod.Parameters, parameter, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override IParameterSymbol GetDeclaredSymbol(ParameterSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel((SyntaxNode)(object)declarationSyntax);
|
||
|
|
if (memberModel != null)
|
||
|
|
{
|
||
|
|
return memberModel.GetDeclaredSymbol(declarationSyntax, cancellationToken);
|
||
|
|
}
|
||
|
|
return GetDeclaredNonLambdaParameterSymbol(declarationSyntax, cancellationToken).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
|
||
|
|
private ParameterSymbol GetDeclaredNonLambdaParameterSymbol(ParameterSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
return GetMethodParameterSymbol(declarationSyntax, cancellationToken) ?? GetIndexerParameterSymbol(declarationSyntax, cancellationToken) ?? GetDelegateParameterSymbol(declarationSyntax, cancellationToken);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ITypeParameterSymbol GetDeclaredSymbol(TypeParameterSyntax typeParameter, CancellationToken cancellationToken = default(CancellationToken))
|
||
|
|
{
|
||
|
|
if (typeParameter == null)
|
||
|
|
{
|
||
|
|
throw new ArgumentNullException("typeParameter");
|
||
|
|
}
|
||
|
|
if (!IsInTree((SyntaxNode)(object)typeParameter))
|
||
|
|
{
|
||
|
|
throw new ArgumentException("typeParameter not within tree");
|
||
|
|
}
|
||
|
|
if (typeParameter.Parent is TypeParameterListSyntax typeParameterListSyntax)
|
||
|
|
{
|
||
|
|
ISymbol val = null;
|
||
|
|
CSharpSyntaxNode parent = typeParameterListSyntax.Parent;
|
||
|
|
if (!(parent is MemberDeclarationSyntax declarationSyntax))
|
||
|
|
{
|
||
|
|
if (!(parent is LocalFunctionStatementSyntax declarationSyntax2))
|
||
|
|
{
|
||
|
|
throw ExceptionUtilities.UnexpectedValue((object)typeParameter.Parent.Kind());
|
||
|
|
}
|
||
|
|
val = GetDeclaredSymbol(declarationSyntax2, cancellationToken);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
val = GetDeclaredSymbol(declarationSyntax, cancellationToken);
|
||
|
|
}
|
||
|
|
Symbol symbol = val.GetSymbol();
|
||
|
|
if (symbol is NamedTypeSymbol namedTypeSymbol)
|
||
|
|
{
|
||
|
|
return GetTypeParameterSymbol(namedTypeSymbol.TypeParameters, typeParameter).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
if (symbol is MethodSymbol methodSymbol)
|
||
|
|
{
|
||
|
|
return (GetTypeParameterSymbol(methodSymbol.TypeParameters, typeParameter) ?? (((object)methodSymbol.PartialDefinitionPart == null) ? null : GetTypeParameterSymbol(methodSymbol.PartialDefinitionPart.TypeParameters, typeParameter))).GetPublicSymbol();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
private TypeParameterSymbol GetTypeParameterSymbol(ImmutableArray<TypeParameterSymbol> parameters, TypeParameterSyntax parameter)
|
||
|
|
{
|
||
|
|
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
ImmutableArray<TypeParameterSymbol>.Enumerator enumerator = parameters.GetEnumerator();
|
||
|
|
while (enumerator.MoveNext())
|
||
|
|
{
|
||
|
|
TypeParameterSymbol current = enumerator.Current;
|
||
|
|
ImmutableArray<Location>.Enumerator enumerator2 = current.Locations.GetEnumerator();
|
||
|
|
while (enumerator2.MoveNext())
|
||
|
|
{
|
||
|
|
Location current2 = enumerator2.Current;
|
||
|
|
if (current2.SourceTree == SyntaxTree)
|
||
|
|
{
|
||
|
|
TextSpan span = ((SyntaxNode)parameter).Span;
|
||
|
|
if (((TextSpan)(ref span)).Contains(current2.SourceSpan))
|
||
|
|
{
|
||
|
|
return current;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ControlFlowAnalysis AnalyzeControlFlow(StatementSyntax firstStatement, StatementSyntax lastStatement)
|
||
|
|
{
|
||
|
|
ValidateStatementRange(firstStatement, lastStatement);
|
||
|
|
return (ControlFlowAnalysis)(object)new CSharpControlFlowAnalysis(RegionAnalysisContext(firstStatement, lastStatement));
|
||
|
|
}
|
||
|
|
|
||
|
|
private void ValidateStatementRange(StatementSyntax firstStatement, StatementSyntax lastStatement)
|
||
|
|
{
|
||
|
|
if (firstStatement == null)
|
||
|
|
{
|
||
|
|
throw new ArgumentNullException("firstStatement");
|
||
|
|
}
|
||
|
|
if (lastStatement == null)
|
||
|
|
{
|
||
|
|
throw new ArgumentNullException("lastStatement");
|
||
|
|
}
|
||
|
|
if (!IsInTree((SyntaxNode)(object)firstStatement))
|
||
|
|
{
|
||
|
|
throw new ArgumentException("statements not within tree");
|
||
|
|
}
|
||
|
|
bool num = firstStatement.Parent is GlobalStatementSyntax;
|
||
|
|
if (num && (!(lastStatement.Parent is GlobalStatementSyntax) || firstStatement.Parent.Parent != lastStatement.Parent.Parent))
|
||
|
|
{
|
||
|
|
throw new ArgumentException("global statements not within the same compilation unit");
|
||
|
|
}
|
||
|
|
if (!num && (firstStatement.Parent == null || firstStatement.Parent != lastStatement.Parent))
|
||
|
|
{
|
||
|
|
throw new ArgumentException("statements not within the same statement list");
|
||
|
|
}
|
||
|
|
if (((SyntaxNode)firstStatement).SpanStart > ((SyntaxNode)lastStatement).SpanStart)
|
||
|
|
{
|
||
|
|
throw new ArgumentException("first statement does not precede last statement");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override DataFlowAnalysis AnalyzeDataFlow(ExpressionSyntax expression)
|
||
|
|
{
|
||
|
|
if (expression == null)
|
||
|
|
{
|
||
|
|
throw new ArgumentNullException("expression");
|
||
|
|
}
|
||
|
|
if (!IsInTree((SyntaxNode)(object)expression))
|
||
|
|
{
|
||
|
|
throw new ArgumentException("expression not within tree");
|
||
|
|
}
|
||
|
|
return (DataFlowAnalysis)(object)new CSharpDataFlowAnalysis(RegionAnalysisContext(expression));
|
||
|
|
}
|
||
|
|
|
||
|
|
public override DataFlowAnalysis AnalyzeDataFlow(ConstructorInitializerSyntax constructorInitializer)
|
||
|
|
{
|
||
|
|
if (constructorInitializer == null)
|
||
|
|
{
|
||
|
|
throw new ArgumentNullException("constructorInitializer");
|
||
|
|
}
|
||
|
|
if (!IsInTree((SyntaxNode)(object)constructorInitializer))
|
||
|
|
{
|
||
|
|
throw new ArgumentException("node not within tree");
|
||
|
|
}
|
||
|
|
return (DataFlowAnalysis)(object)new CSharpDataFlowAnalysis(RegionAnalysisContext(constructorInitializer));
|
||
|
|
}
|
||
|
|
|
||
|
|
public override DataFlowAnalysis AnalyzeDataFlow(PrimaryConstructorBaseTypeSyntax primaryConstructorBaseType)
|
||
|
|
{
|
||
|
|
if (primaryConstructorBaseType == null)
|
||
|
|
{
|
||
|
|
throw new ArgumentNullException("primaryConstructorBaseType");
|
||
|
|
}
|
||
|
|
if (!IsInTree((SyntaxNode)(object)primaryConstructorBaseType))
|
||
|
|
{
|
||
|
|
throw new ArgumentException("node not within tree");
|
||
|
|
}
|
||
|
|
return (DataFlowAnalysis)(object)new CSharpDataFlowAnalysis(RegionAnalysisContext(primaryConstructorBaseType));
|
||
|
|
}
|
||
|
|
|
||
|
|
public override DataFlowAnalysis AnalyzeDataFlow(StatementSyntax firstStatement, StatementSyntax lastStatement)
|
||
|
|
{
|
||
|
|
ValidateStatementRange(firstStatement, lastStatement);
|
||
|
|
return (DataFlowAnalysis)(object)new CSharpDataFlowAnalysis(RegionAnalysisContext(firstStatement, lastStatement));
|
||
|
|
}
|
||
|
|
|
||
|
|
private static BoundNode GetBoundRoot(MemberSemanticModel memberModel, out Symbol member)
|
||
|
|
{
|
||
|
|
member = memberModel.MemberSymbol;
|
||
|
|
return memberModel.GetBoundRoot();
|
||
|
|
}
|
||
|
|
|
||
|
|
private NamespaceOrTypeSymbol GetDeclaredTypeMemberContainer(CSharpSyntaxNode memberDeclaration)
|
||
|
|
{
|
||
|
|
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
SyntaxKind syntaxKind;
|
||
|
|
if (memberDeclaration.Parent.Kind() == SyntaxKind.CompilationUnit)
|
||
|
|
{
|
||
|
|
syntaxKind = memberDeclaration.Kind();
|
||
|
|
if ((syntaxKind == SyntaxKind.NamespaceDeclaration || syntaxKind == SyntaxKind.FileScopedNamespaceDeclaration) ? true : false)
|
||
|
|
{
|
||
|
|
return _compilation.Assembly.GlobalNamespace;
|
||
|
|
}
|
||
|
|
if ((int)SyntaxTree.Options.Kind != 0)
|
||
|
|
{
|
||
|
|
return Compilation.ScriptClass;
|
||
|
|
}
|
||
|
|
if (SyntaxFacts.IsTypeDeclaration(memberDeclaration.Kind()))
|
||
|
|
{
|
||
|
|
return _compilation.Assembly.GlobalNamespace;
|
||
|
|
}
|
||
|
|
return _compilation.Assembly.GlobalNamespace.ImplicitType;
|
||
|
|
}
|
||
|
|
NamespaceOrTypeSymbol declaredNamespaceOrType = GetDeclaredNamespaceOrType(memberDeclaration.Parent);
|
||
|
|
if (!declaredNamespaceOrType.IsNamespace)
|
||
|
|
{
|
||
|
|
return declaredNamespaceOrType;
|
||
|
|
}
|
||
|
|
syntaxKind = memberDeclaration.Kind();
|
||
|
|
bool flag = ((syntaxKind == SyntaxKind.NamespaceDeclaration || syntaxKind == SyntaxKind.FileScopedNamespaceDeclaration) ? true : false);
|
||
|
|
if (flag || SyntaxFacts.IsTypeDeclaration(memberDeclaration.Kind()))
|
||
|
|
{
|
||
|
|
return declaredNamespaceOrType;
|
||
|
|
}
|
||
|
|
return ((NamespaceSymbol)declaredNamespaceOrType).ImplicitType;
|
||
|
|
}
|
||
|
|
|
||
|
|
private Symbol GetDeclaredMemberSymbol(CSharpSyntaxNode declarationSyntax)
|
||
|
|
{
|
||
|
|
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
CheckSyntaxNode(declarationSyntax);
|
||
|
|
NamespaceOrTypeSymbol declaredTypeMemberContainer = GetDeclaredTypeMemberContainer(declarationSyntax);
|
||
|
|
string declarationName = GetDeclarationName(declarationSyntax);
|
||
|
|
return GetDeclaredMember(declaredTypeMemberContainer, ((SyntaxNode)declarationSyntax).Span, isKnownToBeANamespace: false, declarationName);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override AwaitExpressionInfo GetAwaitExpressionInfo(AwaitExpressionSyntax node)
|
||
|
|
{
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetAwaitExpressionInfo(node) ?? default(AwaitExpressionInfo);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ForEachStatementInfo GetForEachStatementInfo(ForEachStatementSyntax node)
|
||
|
|
{
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetForEachStatementInfo(node) ?? default(ForEachStatementInfo);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override ForEachStatementInfo GetForEachStatementInfo(CommonForEachStatementSyntax node)
|
||
|
|
{
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetForEachStatementInfo(node) ?? default(ForEachStatementInfo);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override DeconstructionInfo GetDeconstructionInfo(AssignmentExpressionSyntax node)
|
||
|
|
{
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetDeconstructionInfo(node) ?? default(DeconstructionInfo);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override DeconstructionInfo GetDeconstructionInfo(ForEachVariableStatementSyntax node)
|
||
|
|
{
|
||
|
|
return GetMemberModel((SyntaxNode)(object)node)?.GetDeconstructionInfo(node) ?? default(DeconstructionInfo);
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override Symbol RemapSymbolIfNecessaryCore(Symbol symbol)
|
||
|
|
{
|
||
|
|
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
Location val = symbol.TryGetFirstLocation();
|
||
|
|
if (val == null)
|
||
|
|
{
|
||
|
|
return symbol;
|
||
|
|
}
|
||
|
|
if (val.SourceTree != SyntaxTree)
|
||
|
|
{
|
||
|
|
return symbol;
|
||
|
|
}
|
||
|
|
TextSpan sourceSpan = val.SourceSpan;
|
||
|
|
int position = CheckAndAdjustPosition(((TextSpan)(ref sourceSpan)).Start);
|
||
|
|
return GetMemberModel(position)?.RemapSymbolIfNecessaryCore(symbol) ?? symbol;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override Func<SyntaxNode, bool> GetSyntaxNodesToAnalyzeFilter(SyntaxNode declaredNode, ISymbol declaredSymbol)
|
||
|
|
{
|
||
|
|
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_00c8: Expected I4, but got Unknown
|
||
|
|
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0214: Invalid comparison between Unknown and I4
|
||
|
|
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01a8: Invalid comparison between Unknown and I4
|
||
|
|
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0162: Invalid comparison between Unknown and I4
|
||
|
|
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_01ae: Invalid comparison between Unknown and I4
|
||
|
|
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0168: Invalid comparison between Unknown and I4
|
||
|
|
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
CompilationUnitSyntax compilationUnitSyntax = declaredNode as CompilationUnitSyntax;
|
||
|
|
if (compilationUnitSyntax == null)
|
||
|
|
{
|
||
|
|
TypeDeclarationSyntax typeDeclarationSyntax = declaredNode as TypeDeclarationSyntax;
|
||
|
|
if (typeDeclarationSyntax == null)
|
||
|
|
{
|
||
|
|
PrimaryConstructorBaseTypeSyntax primaryConstructorBaseTypeSyntax = declaredNode as PrimaryConstructorBaseTypeSyntax;
|
||
|
|
if (primaryConstructorBaseTypeSyntax != null)
|
||
|
|
{
|
||
|
|
CSharpSyntaxNode parent = primaryConstructorBaseTypeSyntax.Parent;
|
||
|
|
if (parent is BaseListSyntax && parent.Parent is TypeDeclarationSyntax typeDeclarationSyntax2 && (object)typeDeclarationSyntax2.PrimaryConstructorBaseTypeIfClass == declaredNode)
|
||
|
|
{
|
||
|
|
SynthesizedPrimaryConstructor synthesizedPrimaryConstructor = TryGetSynthesizedPrimaryConstructor(typeDeclarationSyntax2);
|
||
|
|
if ((object)synthesizedPrimaryConstructor != null && (object)declaredSymbol.GetSymbol() == synthesizedPrimaryConstructor)
|
||
|
|
{
|
||
|
|
return (SyntaxNode node) => (object)node != primaryConstructorBaseTypeSyntax.Type;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (declaredNode is ParameterSyntax parameterSyntax && (int)declaredSymbol.Kind == 15 && parameterSyntax.Parent?.Parent is RecordDeclarationSyntax recordDeclarationSyntax && recordDeclarationSyntax.ParameterList == parameterSyntax.Parent)
|
||
|
|
{
|
||
|
|
return (SyntaxNode node) => false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if ((object)TryGetSynthesizedPrimaryConstructor(typeDeclarationSyntax) != null)
|
||
|
|
{
|
||
|
|
SyntaxKind syntaxKind = typeDeclarationSyntax.Kind();
|
||
|
|
if ((syntaxKind == SyntaxKind.ClassDeclaration || syntaxKind == SyntaxKind.RecordDeclaration) ? true : false)
|
||
|
|
{
|
||
|
|
SymbolKind kind = declaredSymbol.Kind;
|
||
|
|
if ((int)kind == 9)
|
||
|
|
{
|
||
|
|
return delegate(SyntaxNode node)
|
||
|
|
{
|
||
|
|
if ((object)node.Parent == typeDeclarationSyntax)
|
||
|
|
{
|
||
|
|
if ((object)node != typeDeclarationSyntax.ParameterList)
|
||
|
|
{
|
||
|
|
return (object)node == typeDeclarationSyntax.BaseList;
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
if (node.Parent is BaseListSyntax)
|
||
|
|
{
|
||
|
|
return (object)node == typeDeclarationSyntax.PrimaryConstructorBaseTypeIfClass;
|
||
|
|
}
|
||
|
|
return !(node.Parent is PrimaryConstructorBaseTypeSyntax primaryConstructorBaseTypeSyntax2) || primaryConstructorBaseTypeSyntax2 != typeDeclarationSyntax.PrimaryConstructorBaseTypeIfClass || (object)node == primaryConstructorBaseTypeSyntax2.ArgumentList;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
if ((int)kind == 11)
|
||
|
|
{
|
||
|
|
return (SyntaxNode node) => (object)node != typeDeclarationSyntax.ParameterList && (node.Kind() != SyntaxKind.ArgumentList || (object)node != typeDeclarationSyntax.PrimaryConstructorBaseTypeIfClass?.ArgumentList);
|
||
|
|
}
|
||
|
|
ExceptionUtilities.UnexpectedValue((object)declaredSymbol.Kind);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
SymbolKind kind = declaredSymbol.Kind;
|
||
|
|
if ((int)kind == 9)
|
||
|
|
{
|
||
|
|
return (SyntaxNode node) => (object)node.Parent != typeDeclarationSyntax || (object)node == typeDeclarationSyntax.ParameterList;
|
||
|
|
}
|
||
|
|
if ((int)kind == 11)
|
||
|
|
{
|
||
|
|
return (SyntaxNode node) => (object)node != typeDeclarationSyntax.ParameterList;
|
||
|
|
}
|
||
|
|
ExceptionUtilities.UnexpectedValue((object)declaredSymbol.Kind);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if ((object)SynthesizedSimpleProgramEntryPointSymbol.GetSimpleProgramEntryPoint(Compilation, compilationUnitSyntax, fallbackToMainEntryPoint: false) != null)
|
||
|
|
{
|
||
|
|
SymbolKind kind = declaredSymbol.Kind;
|
||
|
|
switch (kind - 9)
|
||
|
|
{
|
||
|
|
case 3:
|
||
|
|
return (SyntaxNode node) => node.Kind() != SyntaxKind.GlobalStatement || (object)node.Parent != compilationUnitSyntax;
|
||
|
|
case 0:
|
||
|
|
return (SyntaxNode node) => (object)node.Parent != compilationUnitSyntax || node.Kind() == SyntaxKind.GlobalStatement;
|
||
|
|
case 2:
|
||
|
|
return (SyntaxNode node) => false;
|
||
|
|
}
|
||
|
|
ExceptionUtilities.UnexpectedValue((object)declaredSymbol.Kind);
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal override bool ShouldSkipSyntaxNodeAnalysis(SyntaxNode node, ISymbol containingSymbol)
|
||
|
|
{
|
||
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||
|
|
//IL_0008: Invalid comparison between Unknown and I4
|
||
|
|
if ((int)containingSymbol.Kind == 9)
|
||
|
|
{
|
||
|
|
if (node is TypeDeclarationSyntax)
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
if (node is CompilationUnitSyntax)
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
private RegionAnalysisContext RegionAnalysisContext(ExpressionSyntax expression)
|
||
|
|
{
|
||
|
|
while (expression.Kind() == SyntaxKind.ParenthesizedExpression)
|
||
|
|
{
|
||
|
|
expression = ((ParenthesizedExpressionSyntax)expression).Expression;
|
||
|
|
}
|
||
|
|
return RegionAnalysisContext((CSharpSyntaxNode)expression);
|
||
|
|
}
|
||
|
|
|
||
|
|
private RegionAnalysisContext RegionAnalysisContext(CSharpSyntaxNode expression)
|
||
|
|
{
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel((SyntaxNode)(object)expression);
|
||
|
|
if (memberModel == null)
|
||
|
|
{
|
||
|
|
BoundBadStatement boundBadStatement = new BoundBadStatement((SyntaxNode)(object)expression, ImmutableArray<BoundNode>.Empty, hasErrors: true);
|
||
|
|
return new RegionAnalysisContext(Compilation, null, boundBadStatement, boundBadStatement, boundBadStatement);
|
||
|
|
}
|
||
|
|
Symbol member;
|
||
|
|
BoundNode boundRoot = GetBoundRoot(memberModel, out member);
|
||
|
|
BoundNode upperBoundNode = memberModel.GetUpperBoundNode(expression, promoteToBindable: true);
|
||
|
|
BoundNode lastInRegion = upperBoundNode;
|
||
|
|
return new RegionAnalysisContext(Compilation, member, boundRoot, upperBoundNode, lastInRegion);
|
||
|
|
}
|
||
|
|
|
||
|
|
private RegionAnalysisContext RegionAnalysisContext(StatementSyntax firstStatement, StatementSyntax lastStatement)
|
||
|
|
{
|
||
|
|
MemberSemanticModel memberModel = GetMemberModel((SyntaxNode)(object)firstStatement);
|
||
|
|
if (memberModel == null)
|
||
|
|
{
|
||
|
|
BoundBadStatement boundBadStatement = new BoundBadStatement((SyntaxNode)(object)firstStatement, ImmutableArray<BoundNode>.Empty, hasErrors: true);
|
||
|
|
return new RegionAnalysisContext(Compilation, null, boundBadStatement, boundBadStatement, boundBadStatement);
|
||
|
|
}
|
||
|
|
Symbol member;
|
||
|
|
BoundNode boundRoot = GetBoundRoot(memberModel, out member);
|
||
|
|
BoundNode upperBoundNode = memberModel.GetUpperBoundNode(firstStatement, promoteToBindable: true);
|
||
|
|
BoundNode upperBoundNode2 = memberModel.GetUpperBoundNode(lastStatement, promoteToBindable: true);
|
||
|
|
return new RegionAnalysisContext(Compilation, member, boundRoot, upperBoundNode, upperBoundNode2);
|
||
|
|
}
|
||
|
|
}
|