1

I'm trying to make extension for VS, but I don't have enough knowledge about it's structures. (Well, actually I started searching for building extension about 4hrs ago)

By the way, I want to get type information from caret position such as "Go to definition".

For example)

using System;

...

private IServiceProvider ServiceProvider { get; }

In this case, if you move your caret to IServiceProvider and execute "Go to definition" command, it will navigate and shows a code of System.IServiceProvider.

My question is "How to get type information from caret"?
I can read line text where caret located and get "IServiceProvider" text by substring lines by space.

textView.GetCaretPos(out int line, out int column);
textView.GetBuffer(out IVsTextLines lines);
lines.GetLengthOfLine(line, out int lineLength);
lines.GetLineText(line, 0, line, lineLength, out string lineText);

Is anyone can guide me how to get type information from caret position?

Thanks for your interest.

SlaneR
  • 684
  • 5
  • 19
  • See https://stackoverflow.com/questions/37469869/get-roslyn-syntaxtoken-from-visual-studio-text-selection-caret-position – Sergey Vlasov Oct 14 '18 at 01:33
  • @SergeyVlasov well, I installed Roslyn SDK but there's no Microsoft.CodeAnalysis or something. I found Microsoft.VisualStudio.CodeAnalysis but class name was different :/ is there any reference I can access to? – SlaneR Oct 14 '18 at 11:21
  • Personally I reference Microsoft.CodeAnalysis.dll that comes with Visual Studio. Like "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\ManagedLanguages\VBCSharp\LanguageServices\Microsoft.CodeAnalysis.dll" or "c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies\Microsoft.CodeAnalysis.dll". – Sergey Vlasov Oct 15 '18 at 17:28

0 Answers0