views:

58

answers:

1

Ok, before I begin I realize that there is a lot of documentation on this subject but I have thus far failed to get even basic colourization working for VS2010.

My goal is to simply get to a point where I can open a document and everything is coloured red, from here I can implement the relevant parsing logic.

Here's what I have tried/found:

1) Downloaded all the relevent SDK's and such- Found the ook sample (http://code.msdn.microsoft.com/ookLanguage) - didn't build, didn't work.

2) Knowing almost nothing about MEF read through "Implementing a Language Service By Using the Managed Package Framework" - http://msdn.microsoft.com/en-us/library/bb166533(v=VS.100).aspx

This was pretty much a copy and paste of all the basic stuff here, and also updating some references which were out of date with the sample see: http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a310fe67-afd2-4592-b295-3fc86fec7996

Now, I have got to a point where when running the package MEF appears to have hooked up correctly (I know this because with the debugger open I can see that the packages initialize and FDoIdle methods are being hit).

When I open a file of the extension I have registered with the ProvideLanguageExtensionAttribute everything dies as if in an endless loop, yet no debug symbols hit (though they are loaded).

Looking at the ook sample and the MEF examples they seem to be totally different approaches to the same problem. In the ook sample there are notions of Clasifications and Completion controllers which aren't mentioned in the MEF example. Also, they don't seem to create a Package or Language service, so I have no idea how it should work?

With the MEF example, my assumption is that I need to hook into the "IScanner.ScanTokenAndProvideInfoAboutIt" to provide syntax highlighting? Which would be fine if I could ever hit this method.

So my first question I guess is which approach should I be taking here? Or do they both somehow tie together?

My second questions is, where can I find a basic fully working project that implements bog standard basic syntax highlighting and intellisense or VS2010?

Thirdly, in the MEF example when I created a Package there were a bunch of test projects created for me. I appears that the integration tests launch the VS2010 test rig somehow, but the test fails. It would be good to write my service with tests but I have no idea what/how I can test each interaction so any references to testing Language services would be helpful.

Finally, please throw any resource/book links my way that I may find useful.

Cheers, Chris.

N.B. Sorry I realize this is part question part rant, but I have never been so confused.

+1  A: 

First, the package example is not using MEF. Essentially everyplace that you mention MEF in your question is not actually MEF, but the managed package framework (MPF), also colloquially called the managed language service (MLS). You'd know if your extension was using MEF by two things: the vsixmanifest lists your assembly as containing a MEF component, and you see [Export] and [Import] attributes in the code.

The easiest way to do this is to use MEF. Since you have the SDK installed, you also have a template for an editor classifier project (under C# (or VB)->Extensibility->Editor classifier in the New Project dialog). You can certainly do this with a language service/colorizer/package, but there will be significantly more code than the equivalent classifier.

The Ook solution is the sample for this and should work; if it doesn't build/work, then can you send me email (noahric at microsoft) with what errors you are seeing so I can email the owner of that sample?

In general, you should also read my answer for the question on "How can I write a plugin for VS2010 using MEF?". That has links to other resources that should help.

Noah Richards
Thanks for the update, I'll drop you an email with the issues I am facing with the ook! solution. I also noticed that I do NOT have the Editor classifier project template available under the Extensibility tab, which makes me wonder if I have either incorrectly installed the SDK or have an earlier version running on my machine.
Owen
Incidentally Noah, you have forced me to read up on MEF and its pretty interesting stuff. I really didn't understand it as anything more than an IoC container until I dug a little deeper. I now understand how VS could take advantage of this. Maybe it as worth me reading a little more before posting/ranting here :-).
Owen
Ok, so I got to the bottom of why I couldn't build the Ook! sample - I had only the beta SDK installed. Additionlly, I couldn't start the sample with the VS test shell as the debug properties specifying to run the VS were missing but I added these, and all is well. Thanks for your help.
Owen
Excellent, glad to hear it worked out :)
Noah Richards

related questions