Roslyn 中的 VisitClassDeclaration 节点.Identifier
如何找到源文件中声明所在的行号?
How can I find what line number in the source file the declaration was found on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
免责声明:我在 Microsoft 的 Roslyn 团队工作。
您可以使用
ISyntaxTree.GetLineSpan()
方法转换为行号。例如,给定一个ISymbol
“符号”,您可以通过以下方式获取第一个定义的起始位置:从标题来看,您似乎是从
SyntaxNode
开始的,因此您可以直接使用Span
属性。Disclaimer: I work for Microsoft on the Roslyn team.
You can use the
ISyntaxTree.GetLineSpan()
method to convert to a line number. For example, given anISymbol
"symbol", you can get the start location of the first definition with:From the title, it looks like you're starting with a
SyntaxNode
, so you can just use theSpan
property directly.