简体   繁体   English

如何将getter和setter添加到PropertyDeclarationSyntax?

[英]How can I add getter and setter to PropertyDeclarationSyntax?

I'm creating a tool which can create properties through Roslyn. 我正在创建一个可以通过Roslyn创建属性的工具。 I would like to add getter and setters to a PropertyDeclarationSyntax . 我想将getter和setter添加到PropertyDeclarationSyntax

How can I do this? 我怎样才能做到这一点?

You need to add an AccessorList , with accessors. 您需要添加一个带有访问器的AccessorList Check out this online tool for the exact syntax tree creation: Roslyn Quoter . 查看此在线工具以创建确切的语法树: Roslyn Quoter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在C#中的getter和setter方法中进行验证? - How can I put validation in the getter and setter methods in C#? 使用C#,如何使用参数访问VB类的默认属性的getter / setter? - Using C#, how can I access the getter/setter of a VB class's default property with parameter? 如果我需要自定义getter / setter,我可以省略字段创建吗? - can I omit field creation if I need custom getter/setter? 我可以在 c# 中为 Realm 自定义 getter 和 setter 吗? - Can I have customize getter and setter for Realm in c#? 我可以为“valuetype”的 getter 和 setter 设置不同的返回类型吗? 特性? - Can I have different return types for getter and setter of "valuetype?" properties? 我该怎么做才能将Getter和Setter方法与ArrayList一起使用 - What can I do to be able to use Getter and Setter meths with ArrayList 如何在C#中调用getter或setter - How do I call a getter or setter in C# 如何向协变接口添加类型不变的设置器? - How can I add a type invariant setter to a covariant interface? 如何为字典编写getter和setter? - How to write a getter and setter for a Dictionary? 您是否可以添加一个约束,即只能使用C#中的public getter和setter将属性添加到属性? - Can you add a constraint that the Attribute can only be added to a property with public getter and setter in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM