[英]How to get the containing class of a field symbol with Roslyn?
I'm trying to get the containing class of a field using roslyn. 我正在尝试使用roslyn获取字段的包含类。 I see that I can get the containing namespace using
myfield.ContainingNamespace;
我看到可以使用
myfield.ContainingNamespace;
获得包含名称空间myfield.ContainingNamespace;
, so it must be a way to get the class. ,因此它必须是获取课程的一种方法。
I think it will be easy if I can split the field's symbol using myfield.Split('.');
我认为,如果可以使用
myfield.Split('.');
分割字段的符号,将很容易myfield.Split('.');
and get the class. 然后上课。 But I'm looking for a proper way to do it (Like getting the namespace).
但是我正在寻找一种适当的方法(例如获取名称空间)。
So how I can get the containing class from the field's symbol (without using the semantic model will be great)? 那么,如何从字段的符号中获取包含类(不使用语义模型会更好)吗?
Thank you 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.