How to write a Visual Studio extension for a template or markup language that supports embedded code snippets
Asked Answered
T

2

15

Is it possible to write an extension for Visual Studio 2010 that provides syntax highlighting, intellisense, outlining, etc for a custom template or markup language supporting embedded code snippets, similar to the tooling for Razor in ASP .NET MVC 3? Can this be done without using private APIs, without access to Microsoft-internal documentation and, most importantly, without having to reimplement syntax highlighting, intellisense, etc. for the embedded programming language (i.e. C# or VB)?

The SDK documentation seems to suggest that the Visual Studio editor supports embedded languages via projection buffers, but it doesn't really give any details or examples. Some of the "legacy interop interfaces used for the editor and language services" in Microsoft.VisualStudio.TextManager.Interop also seem to be relevant, e.g. IVsTextBufferCoordinator, but the documentation doesn't say much about how all these pieces fit together.

Provided that projection buffers actually do what I hope, where can I hook into the editor to replace a normal text buffer with a projection buffer?

Does maybe anyone have more information on the APIs relevant for supporting embedded languages or could point me into the right direction?

Thermosphere answered 1/5, 2011 at 15:10 Comment(2)
I'm also looking for pointers to do this. Did you ever find any resources on this?Hobble
No, and I eventually gave up on my project due to the sorry state of the relevant SDK documentation (and SDK functionality?).Thermosphere
A
2

You should take a look at https://github.com/SparkViewEngine/SparkSense as an example. It was built for the spark view engine to provide intellisense for VS 2010.

"SparkSense is a plugin for Visual Studio 2010 that enables various tooling support and productivity features when using Spark as a View Engine for various MVC frameworks including ASP.NET MVC"

Aigneis answered 1/5, 2011 at 17:7 Comment(1)
Thanks for the pointer. However, it seems that SparkSense implements its own limited kind of "intellisense" for the embedded code snippets. I think Robert calls it "type completion". It doesn't reuse the Visual Studio C# language service and it's not the full intellisense as e.g. available in Razor pages.Thermosphere
S
0

you can write your own editor extension, see this article : http://www.devx.com/VS_2010/Article/45058

And to understand how it works : http://msdn.microsoft.com/en-us/library/dd885240(v=VS.100).aspx

Do research about "Managed Extensibility Framework (MEF) "

You can download an exemple for the Ook langage here

Stocky answered 1/5, 2011 at 16:51 Comment(1)
I'm well aware of the available SDK documentation and my question actually contains a link to the same MSDN page you've linked.Thermosphere

© 2022 - 2024 — McMap. All rights reserved.