C# Roslyn получить Properties у поля

Нужно получить Properties у поля и его свойство Classification, прикреплю скриншот для наглядности введите сюда описание изображения

Код

  public class PropertyDeclarationRewriter : CSharpSyntaxRewriter
    {
        private readonly List<Microsoft.CodeAnalysis.Document> Project_Files;
        private readonly SemanticModel _semanticModel;
        public PropertyDeclarationRewriter(List<Microsoft.CodeAnalysis.Document> Project_Files, SemanticModel semanticModel)
        {
            this.Project_Files = Project_Files;
            _semanticModel = semanticModel;
        }

        public override SyntaxNode VisitPropertyDeclaration(PropertyDeclarationSyntax node)
        {
            var propertyType = node.Type.ToString();
            var propertyToken = node.Identifier.Value;
            if (propertyType == "DbSet<ChatDb>")
            {
                if (node is PropertyDeclarationSyntax property)
                {
                }
                if (node.Type is GenericNameSyntax generic)
                {
                    if(generic.Identifier is SyntaxToken syntaxToken)
                    {
                        var rr = syntaxToken;
                    }
                    var nameType = generic.Identifier.ValueText;
                    foreach (var arguments in generic.TypeArgumentList.Arguments)
                    {

                    }
                }
            }
            Hellper hellper = new Hellper();
            var newTypeName = RandomName.NewName(propertyType);
            var existBaseClass = hellper.Search_Object(Project_Files, newTypeName, Class: true);
            if (existBaseClass)
            {
                var newType = SyntaxFactory.ParseTypeName(newTypeName).WithTriviaFrom(node.Type);
                node = node.WithType(newType);
            }
            string newName = RandomName.NewName(node.Identifier.ValueText);
            node = node.WithIdentifier(SyntaxFactory.Identifier(node.Identifier.LeadingTrivia, newName, node.Identifier.TrailingTrivia));
            return node;
        }
    }

В

 if (node is PropertyDeclarationSyntax property)
                    {
                    }

Получаю не то что нужно.


Ответы (0 шт):