4

I want to develop support in Visual Studio for a particular language. MPF language services and MEF editor extensions seem to have an awful lot of overlap, and I have not been able to get a clear answer on which one I should be using.

I am only interested in developing this language support in Visual Studio 2012 and later. I am working in C# and wish to use managed APIs only.

The MSDN documentation states that syntax highlighting should be done with a language service. But then when you go to the documentation there, there's a note that arguably is suggesting to use MEF. But when you read the MEF documentation, it doesn't really specify that it is designed to handle full-file syntax highlighting; the wording makes me feel like it is intended for interspersed highlight adornments.

On the contrary to this, however, the Ook! sample demonstrates what I believe is full-file syntax highlighting, though with a sample of that scale, it's not very clear if it is actually suggesting that it should be used that way.

MPF language services seems to have support for adding a filter to the Save As dialog. I haven't seen anything like this for a language that is only supported through MEF, but I might have missed it. I haven't found any indication that either of them support adding a file type filter to the Open dialog. This suggests to me that MEF editor extensions are not intended to implement full scale language extensions so much as they are intended to extend existing ones.

Any thoughts, please?

EDIT:

Some questions that I'm hoping you can answer directly:

  1. Is the MEF editor extension point for highlighting intended for full-file syntax highlighting implementation, or is it intended for interspersed adornments only?

  2. If I have a FileType and a ContentType registered for MEF Export, what additional steps are necessary (or is it even possible?) to cause an associated file filter to show up in the various file dialogs?

  3. Are MEF editor extension points intended to replace and potentially eventually deprecate MPF language services?

leppie
  • 115,091
  • 17
  • 196
  • 297
Kelsie
  • 1,000
  • 1
  • 9
  • 21
  • If at all possible, maybe you could document this adventure somewhere for others to reference and use... – Daniel A.A. Pelsmaeker Apr 18 '13 at 18:54
  • Please review the way I asked the following question for an example of questions that can be answered directly: http://stackoverflow.com/questions/15263761/supporting-user-specified-file-extensions-in-custom-visual-studio-language-servi – Sam Harwell Apr 18 '13 at 19:01
  • Any MS API seems to be intentionally painful. I am in the same boat. – leppie Apr 19 '13 at 04:38

1 Answers1

2

For full-featured support, you won't be able to get away with using only one thing. However, what you end up with will likely be a combination of implementing MEF interfaces and implementing some of Visual Studio's core COM interfaces. You don't need to use the MPF Language Services package at all.

I think your question is more broad than you intended, which is making it difficult for me to write a complete answer.

Edit: For the new questions.

  1. You can use an implementation of IClassifier for full-file syntax highlighting. All of my newer Visual Studio-based IDEs use this exclusively.

  2. You need to export a ContentTypeDefinition, but not necessarily a file type. I just posted a blog article describing the steps I take to register file types and extensions:

    File types and extensions in Visual Studio 2012

  3. Maybe? More importantly, there are things that it's better at and other things that it simply can't do right now, so you pick a balance for best overall productivity.

Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
  • In the comment above where you linked to your own question, I believe you are using MPF to register a package. See [ http://msdn.microsoft.com/en-us/library/bb166544.aspx ]. – Kelsie Apr 19 '13 at 04:26
  • Sure, but I didn't use the `Microsoft.VisualStudio.Package.LanguageService` assembly. – Sam Harwell Apr 19 '13 at 13:43
  • @Kelsie I posted a blog article for question 2. – Sam Harwell Apr 19 '13 at 15:37
  • @SamHarwell Would using MPF in combination with MEF cause any problems? I'd like to use MEF where possible, and the MPF classes seem to reduce the effort for the other features quite considerably. – Botz3000 Feb 09 '17 at 07:36