예제 #1
0
        public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax node)
        {
            // Not the correct way of getting rid of compiler generated getter/setter
            if (node.AttributeLists.Any(attrList =>
                attrList.Attributes.Any(attr =>
                    attr.Name.ToFullString().Contains("CompilerGeneratedAttribute")))||
                node.Identifier.ToFullString().StartsWith("get_") ||
                node.Identifier.ToFullString().StartsWith("set_") ||
                node.Identifier.ToFullString().StartsWith("add_")||
                node.Identifier.ToFullString().StartsWith("remove_"))
            {
                return null;
            }

            return base.VisitMethodDeclaration(
                node.Update(
                    node.AttributeLists,
                    SyntaxFactory.TokenList(),
                    UpdateReturnType(node.ReturnType),
                    node.ExplicitInterfaceSpecifier,
                    node.Identifier,
                    UpdateTypeParameterList(node.TypeParameterList),
                    UpdateParameterList(node.ParameterList),
                    node.ConstraintClauses,
                    UpdateMethodBody(node.Body, node.ReturnType, node.ParameterList),
                    node.SemicolonToken
                ));
        }