Code Monkey home page Code Monkey logo

editorutils's Introduction

Editor Utilities Library

This is a utility library to be used with VSIX projects. It abstracts away many of the problem areas of the Visual Studio API into simple to use types.

This project is available as a set of NuGet packages. Which one to choose depends on which version of Visual Studio you are targetting

  • EditorUtils: VS 2010 and above
  • EditorUtils2012: VS 2012 and above
  • EditorUtils2013: VS 2013 and above

If you don't target VS 2010 then use EditorUtils2012 instead of EditorUtils. This avoids some tooling issues in the Visual Studio build around missing references

AppVeyor: Build status

Features

EditorUtils is a collection of abstractions for building VSIX projects. It is broken down into the following feature areas

Tagging

Syntax highlighting, brace completion, intra text adornments, etc ... are all features provided by the ITagger interface. The interface is simple enough but the rules and scenarios around this interface are complex and largely undocumented. EditorUtils abstracts away much of this complexity by providing a much simpler interface IBasicTaggerSource.

Async Tagging

All ITagger implementations are driven through the UI thread of Visual Studio. Any delay in tagger implementations is felt immediately by the user. Simple taggers can afford to be synchronous but more complex taggers must be asynchronous in order to keep the UI responsive. EditorUtils provides the IAsyncTaggerSource<TData, TTag>to abstract away all of the complexities of async tagging.

class MyAsyncTaggerSource : IAsyncTaggerSource<string, TextMarkerTag> { ... } 

MyAsyncTaggerSource myAsyncTaggerSource = new MyAsyncTaggerSource();
ITagger<TextMarkerTag> tagger = EditorUtilsFactory.CreateAsyncTaggerRaw(myAsyncTaggerSource);

Editor Hosting

At its core the Visual Studio editor is just a WPF control that is completely independent of Visual Studio itself. The ability to host this control outside of Visual Studio is critical to thorough testing of VSIX plugins. EditorUtils makes this extremely easy to do with the EditorHost feature.

var editorHost = new EditorHost();
var textView = editorHost.CreateTextView(); 

editorutils's People

Contributors

chaitanyagurrapu avatar jaredpar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

editorutils's Issues

CreatePkgDef ReflectionTypeLoadException when implementing IBasicTaggerSource

I have a VS extension I'm playing around with. In it I have a class that implements ITag. But I want to change it to implement IBasicTaggerSource<T> from EditorUtils. But when I do, the build blows up even though I implemented all of the members.

public sealed class LinkTaggerSource : IBasicTaggerSource<ClassificationTag> {...}

You can see that it says get_TextSnapshot is missing, but I see the property right there just fine. You can see the method in the IL.

178

1> Code Analysis Complete -- 0 error(s), 0 warning(s)
1> Creating intermediate PkgDef file.
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.targets(761,5): error : CreatePkgDef : error : ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.targets(761,5): error : at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.targets(761,5): error : at System.Reflection.RuntimeModule.GetTypes()
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.targets(761,5): error : at System.Reflection.Assembly.GetTypes()
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.targets(761,5): error : at Microsoft.VisualStudio.Tools.CreatePkgDef.ProcessAssembly(String fileName, Hive hive, PkgDefContext context, Boolean register, RegistrationMode mode) in f:\dd\VSSDK\VSIntegration\Tools\src\CreatePkgDef\CreatePkgDef.cs:line 260
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.targets(761,5): error : at Microsoft.VisualStudio.Tools.CreatePkgDef.DoCreatePkgDef(InputArguments inputArguments) in f:\dd\VSSDK\VSIntegration\Tools\src\CreatePkgDef\CreatePkgDef.cs:line 164
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.targets(761,5): error : at Microsoft.VisualStudio.Tools.CreatePkgDef.Main(String[] arguments) in f:\dd\VSSDK\VSIntegration\Tools\src\CreatePkgDef\CreatePkgDef.cs:line 85
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.targets(761,5): error : Method 'get_TextSnapshot' in type 'Haack.UI.Adornments.LinkTagger.LinkTaggerSource' from assembly 'Haack.Experiment, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.targets(761,5): error :

Any thoughts?

EditorUtils.psm1 not loaded during install

I installed the EditorUtils package and noticed the following error.

Import-Module : The specified module 'C:\dev\VisualStudio\packages\EditorUtils.1.4.0.0\tools\EditorUtils.psm1' was not loaded because no valid module file was found in any module directory.
At C:\dev\VisualStudio\packages\EditorUtils.1.4.0.0\tools\Init.ps1:7 char:1

  • Import-Module -force (Join-Path $toolsPath "EditorUtils.psm1")
  • - CategoryInfo          : ResourceUnavailable: (C:\dev\VisualSt...ditorUtils.psm1:String) [Import-Module], FileNotFoundException
    - FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
    

Need to rethink the setup for testing

The design of EditorUtils NuGet packaging and testing strategy is 5+ years old. It was done at a time when I had less understanding of binding redirects, assembly resolution and the GAC. As a result I missed a couple of important scenarios but was constantly saved by the fact that all of the editor assemblies were in the GAC. Now that VS 2017 is out and have removed all of the GAC entries these flaws are showing now and causing me to rethink the setup.

The testing strategy was designed around the idea that a developer could:

  • Add a reference to EditorUtils VS version X
  • Use binding redirects to test against VS version X, X +1, etc ...

This meant at build time you could control the VS version to test against by simply changing the binding redirects. In general it would essentially work like the following:

  • EditorUtils compiled against 10.0.0.0
  • Test directory has editor assemblies version 10.0.0.0
  • Binding redirect moves 10.0.0.0 -> 14.0.0.0
  • At runtime
    • None of the editor assemblies in test directory match due to the redirect.
    • The assemblies do exist in the GAC and win

That runtime behavior really falls apart in VS 2017 because there is no GAC. It's making me question the overall strategy here.

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.