visual studio 2015 - Using Roslyn for VS2015 Custom Editor -


i'm building visual studio 2015 custom editor (not code editor extension, totally custom wpf control) edit .cs files. i'm uncertain of right approach use .net compilation sdk here.

so far i've tried:

  • getting workspace->soltuion->projects , finding open file using file path passed editor factory. of course if document isn't part of solution nothing.
  • parsing raw source pulling data text buffer , spinning own isolated syntax tree.

none of i'm doing feels clean @ all. there more direct way access compiler apis editor's document?

i might interpreting question wrong i'll take shot. sounds you're trying find roslyn document given text buffer.

there's whole set of extension methods make easier bridge gap between roslyn , visual studio objects.

see: microsoft.codeanalysis.text.extensions

they're not shipped microsoft.codeanalysis nuget package though, you'll have install them via:

install-package microsoft.codeanalysis.editorfeatures.text -version 1.0.0

given itextsnapshot or itextbuffer these methods allow map them original roslyn documents (if exist).

for more info: https://joshvarty.wordpress.com/2015/07/06/lrn-quick-tip-bridging-visual-studio-and-roslyn/


Comments