• Stars
    star
    110
  • Rank 315,317 (Top 7 %)
  • Language
    C#
  • Created about 10 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Embed the Visual Studio editor & theme architecture in your own programs

VSEmbed

VSEmbed lets you embed the Visual Studio editor & theme architecture in your own programs.

better screenshpt screenshot

#Usage Install from NuGet.

To initialize Visual Studio, you need the following code:

VsLoader.LoadLatest();    // Or .Load(new Version(...))
VsServiceProvider.Initialize();
VsMefContainerBuilder.CreateDefault().Build(); // Only needed for editor embedding

The last line can only be JITted after initializing VsLoader (because Build() returns an IComponentModel, which is defined in a VS assembly), so you should put it in a separate method and call that method after setting up VsLoader.

You must create the MEF container using VsMefContainerBuilder; it will use Visual Studio 2015's new version of MEF (where available) to support Roslyn's MEF2 exports.
If you're already using MEF, you can call WithFilteredCatalogs(assemblies) or WithCatalog(types) to add your own assemblies to the MEF container. Note that VsMefContainerBuilder is immutable; these methods return new instances with the new catalogs added.

#Using Roslyn After loading Dev14, you can set the ContentType of an ITextBuffer to C# or VisualBasic to activate the Roslyn editors. However, you will also need to link the ITextBuffer to a Roslyn Workspace to activate the language services. In addition, the workspace must have an IWorkCoordinatorRegistrationService registered to run diagnostics in the background.

To do all this, use my EditorWorkspace class, and call CreateDocument() to create a new document linked to a text buffer, or OpenDocument() to link an existing document (which is already in the Workspace) to a text buffer. You can also inherit this class to provide additional behavior. You should also set ActiveDocumentId to the document ID for the document being edited in the current text view, for quicker live error checking.

To add references to framework assemblies, call CreateFrameworkReference(), which will locate the XML doc comment files for full IntelliSense.

If you create a Roslyn-powered buffer and do not link it to a workspace, I have a buffer listener which will create a simple workspace with a few references for you.

#Caveats

  • The end-user must have a version (2012+) of Visual Studio (including Express editions) installed for this to run.
  • The Roslyn editor services will only work if VS2015 Preview (or later builds) is installed.
  • To make it support older Dev14 CTPs, use Reflection to call MefHostService if MefV1HostServices does not exist, and re-add the older XmlDocumentationProvider code that was replaced in this commit.
  • If Visual Studio 2012 assemblies are in the GAC, other versions will not load properly.
  • Code snippets are not implemented.
  • Peek does not work.
  • To make Peek work, implement & export IPeekResultPresenter & IPeekResultPresentation, and create a WpfTextViewHost in Create(). Note that peek only operates on file paths.
  • Rename with preview does not work.
  • To make this work, implement IVsPreviewChangesService and add it to the ServiceProvider.

License

MIT

More Repositories

1

Silon

Logic Gates and Adders in pure CSS
HTML
327
star
2

Styliner

Turns CSS stylesheets into inline style="" attributes for HTML emails
HTML
125
star
3

Ref12

Sends F12 in Visual Studio to the new .Net Reference Source Browser
C#
73
star
4

Minimatch

A C# glob matcher, ported from Javascript
C#
54
star
5

Rebracer

Saves editor formatting settings as part of each solution.
C#
44
star
6

ExcelExporter

Simple, easy-to-use .Net Excel exporting
C#
43
star
7

Qx

A set of LINQ-like extensions to Q for working with arrays of promises.
JavaScript
31
star
8

Root-VSIX

Installs VSIX packages to custom RootSuffixes for Visual Studio
C#
21
star
9

csrf-crypto

Connect middleware for session-less CSRF protection using cryptography
JavaScript
13
star
10

CSS-Gallery

An interactive, data-bound photo gallery in pure CSS
CSS
12
star
11

ConfOxide

Fast, DRY, strongly-typed configuration system for C# projects
C#
11
star
12

DroidMaster

A one-stop solution for bulk Android automation & scripting
C#
6
star
13

jqPresentation

PowerPoint-style slideshows in HTML and jQuery
JavaScript
6
star
14

jsDelegate

C#-style multicast delegates in Javascript
JavaScript
3
star
15

Managed.AndroidDebugBridge

Fork of https://madb.codeplex.com
C#
3
star
16

NetPresenter

Presents slideshows or other content, synchronized across multiple monitors or computers.
C#
3
star
17

Styliner-less

Adds LESS support to Styliner
JavaScript
3
star
18

vs-nodesense

Abandoned Node.js IntelliSense for Visual Studio 2012+
JavaScript
3
star
19

PageOptions

Stores Knockout viewmodels in cookies or URL, with history support
JavaScript
2
star
20

jsObject

Powerful Javascript OOP
JavaScript
2
star
21

OOMath

Building math from scratch in C#
C#
2
star
22

Progression

Allows business logic to report progress without coupling to the UI
C#
2
star
23

logup-emitter

A lightweight log emitter used by library packages to emit log entries to an optional logup-hub in the host application.
JavaScript
2
star
24

configdir-loader

Loads environment-specific configuration files into a config object
JavaScript
1
star
25

ScriptLESS-UI

A complex web app UI without any Javascript
1
star
26

LibraryBrowser

C#
1
star
27

shutdown-sequence

Invokes a series of asynchronous shutdown handlers for composable applications.
JavaScript
1
star
28

Glisten

Displays lists from Trello or Google Calendar in poster-screen format
JavaScript
1
star
29

net.slaks.parallelProcessor

Interview question
Java
1
star
30

SLaks.net

Homepage for http://slaks.net
1
star
31

Mvc.ClientRoutes

ASP.Net Routing Framework for Javascript
1
star
32

Ternion

Triangle matching game
JavaScript
1
star
33

logup-hub

A central hub that receives log messages from all logup-emitters in an application.
JavaScript
1
star