How to add custom syntax annotation to SyntaxNode?

本小妞迷上赌 提交于 2019-12-08 04:00:26

问题


In previous version of Roslyn I could add custom data to SyntaxNode with using class derived from SyntaxAnnotation. But now SyntaxAnnotation is sealed and I can use SyntaxAnnotation only with to strings: kind and data. It is not enough for me. I want to build custom CFG from AST and make bidirectional links between CFG and AST nodes.

How I can do that?


回答1:


SyntaxAnnotation is sealed because your tree may be serialized, and we need to be able to serialize and deserialize the annotations. If you want to store more info, then store the strings you use for annotations as a key to a dictionary containing the state.



来源:https://stackoverflow.com/questions/27260603/how-to-add-custom-syntax-annotation-to-syntaxnode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!