Ejemplo n.º 1
0
        public override SyntaxNode VisitGenericName(GenericNameSyntax node)
        {
            if (node.ToString().Contains("Request"))
            {
                Console.WriteLine();
            }

            if (!(node.Parent is MemberAccessExpressionSyntax) || ((MemberAccessExpressionSyntax)node.Parent).Expression == node)
            {
                if (node.GetContainingMethod() == null)
                {
                    return(base.VisitGenericName(node));
                }

                var containingType = node.GetContainingType();
                if (containingType == null || !containingType.Name.StartsWith(enclosingTypeName))
                {
                    return(node);
                }

                var symbol = semanticModel.GetSymbolInfo(node).Symbol;
                if (symbol == null || (new[] { SymbolKind.Field, SymbolKind.Event, SymbolKind.Method, SymbolKind.Property }.Contains(symbol.Kind) && !symbol.ContainingType.Name.StartsWith(enclosingTypeName) && !symbol.IsStatic))
                {
                    return(SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.IdentifierName("_this"), node));
                }
            }
            return(base.VisitGenericName(node));
        }