Exemple #1
0
        public static CallDescriptor Create(int depth, InvocationExpressionSyntax invocationExpressionSyntax, SemanticModel semanticModel)
        {
            var methodSymbol = semanticModel.GetSymbolInfo(invocationExpressionSyntax).Symbol as IMethodSymbol;

            if (methodSymbol == null)
            {
                // methodSymbol is null when the invocationExpressionSyntax is "nameof(...)"
                return(null);
            }

            var callDescriptor = new CallDescriptor();

            callDescriptor.Initialize(depth, invocationExpressionSyntax, methodSymbol, semanticModel);
            return(callDescriptor);
        }
Exemple #2
0
        public static CallDescriptor Create(int depth, MemberAccessExpressionSyntax memberAccessExpressionSyntax, SemanticModel semanticModel)
        {
            var symbolInfo = semanticModel.GetSymbolInfo(memberAccessExpressionSyntax);

            if (symbolInfo.Symbol == null)
            {
                return(null);
            }

            var symbolKind = symbolInfo.Symbol.Kind;

            if (symbolKind != SymbolKind.Property)
            {
                return(null);
            }

            var propertySymbol = symbolInfo.Symbol as IPropertySymbol;

            var callDescriptor = new CallDescriptor();

            callDescriptor.Initialize(depth, memberAccessExpressionSyntax, propertySymbol, semanticModel);
            return(callDescriptor);
        }
Exemple #3
0
        public static CallDescriptor Create(int depth, MemberDeclarationSyntax memberDeclarationSyntax, SemanticModel semanticModel)
        {
            var isMethod   = false;
            var isProperty = false;

            switch (memberDeclarationSyntax.Kind())
            {
            case Microsoft.CodeAnalysis.CSharp.SyntaxKind.MethodDeclaration:
                isMethod = true;
                break;

            case Microsoft.CodeAnalysis.CSharp.SyntaxKind.PropertyDeclaration:
                isProperty = true;
                break;

            default:
                return(null);
            }

            var callDescriptor = new CallDescriptor();

            callDescriptor.Initialize(depth, memberDeclarationSyntax, semanticModel, isMethod, isProperty);
            return(callDescriptor);
        }