Get semantic model from a classifier VSIX

被刻印的时光 ゝ 提交于 2019-12-10 09:44:02

问题


As R# is not supporting the Roslyn Early Preview C# 6.0 features, the code looks very dull...

I would like to colorize the code using a classifier VSIX. Is it possible to get the semantic model from the Roslyn Language Service for the current document?


回答1:


You need to add a reference to Microsoft.CodeAnalysis.EditorFeatures.Text.dll, then use the following code.

var doc = point.Snapshot.GetOpenDocumentInCurrentContextWithChanges();
var model = await doc.GetSemanticModelAsync();

This requires the Microsoft.CodeAnalysis.EditorFeatures.Text NuGet package (.NET 4.6 required)



来源:https://stackoverflow.com/questions/23869722/get-semantic-model-from-a-classifier-vsix

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