GithubHelp home page GithubHelp logo

anthrax3 / vsembed Goto Github PK

View Code? Open in Web Editor NEW

This project forked from slaks/vsembed

0.0 1.0 0.0 5.17 MB

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

C# 99.96% Batchfile 0.04%

vsembed's Introduction

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

vsembed's People

Contributors

slaks avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.