Question

I need to provide scripting capabilities within my application, allowing customers to extend its functionality using our object model. I was hoping to offer some kind of integrated C#/VB.Net editor with intellisense, but after looking at products like AvalonEdit and ScintillaNet, they don't appear to provide true code-completion, just an API where you can provide your own list of items to appear in the popup autocomplete list.

I was therefore wondering if Roslyn provided any such features? From the tutorials and examples I've come across, it appears that Roslyn is really just a compiler service.

As a last resort the customers could use something like VS Express but an integrated editor is obviously a bit nicer.

(I also came across Visual Studio Tools for Applications, which sounded promising; however the online resources are several years old, and documentation/tutorials are non-existent, so I've drawn a blank with this one).

Was it helpful?

Solution

I'm ceretainly not an expert in this area. But since you haven't received any other replies, I'll take a shot.

I think the short answer is "yes".

Looking at the code in AvalonEdit and SharpDevelop, it appears that code completion is one of the most difficult parts. Essentially, you have to write a compiler (or a parser, anyway) to figure out what items should be on the completion list. It appears that Roslyn provides tools for constructing the completion list. In older versions, these tools were tied to the VS editor, but I have seen statements saying that they are independent in the latest release. If so, these tools will be very useful in implementing code completion.

I haven't really looked into the details at all, but I intend to, since I have some of the same goals as you, and Roslyn looks like it will be helpful (based on what I know so far, which is not very much).

OTHER TIPS

You made a very interesting claim that "after looking at products like AvalonEdit, SharpDevelop and ScintillaNet, they don't seem to provide true code-completion intellisense". SharpDevelop is a complete IDE, and why don't you find "true" code completion Intellisense? You will have to provide some evidence, or that statement is invalid.

What you want to achieve can only be achieved with two important pieces of components,

  • A language parser, with which you can get context and elements for code completion. That is what Roslyn offers, but Roslyn is not yet mature enough to parse all existing C# syntax. SharpDevelop (as well as MonoDevelop) uses NRefactory, which serves the same goal.

  • A UI element that supports syntax highlighting. This can be achieved by AvalonEdit, or ScintillaNet based on the UI framework you choose.

Visual Studio Shell might provide you some assistance, as @Mystere Man pointed out. But personally I don't know much about it.

I tried really hard to use one of those built in components, but ended up implementing one myself. After a day exploring RichTextBox api, you can comfortably build this support. Just play with PreviewKeyDown/Up, make sure a batch of work play with the undo support and such.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top