I need my package to get initialized when VS starts, without having to trigger it by invoking the Command I implemented in it.
I try those, but that does not work.
[ProvideAutoLoad(UIContextGuids80.SolutionExists)]
[ProvideAutoLoad(VSConstants.UICONTEXT.NoSolution_string)]
[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExists_string)]
[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionHasMultipleProjects_string)]
[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionHasSingleProject_string)]
public sealed class VSIXProject1Package : AsyncPackage
<
My package is loaded, but the InitializeAsync method won't be called until I click on my command (command1) in the tools menu.
Related
When I edit a method of a class that existed when I launched the jupyter notebook (adding a print statement or something), the new code will be executed. But when I add a new method to the class, I need to relaunch the jupyter notebook to use it. Otherwise, it says that the method is not defined. It does not matter if I execute the import statement another time.
So apparently the interface (i.e. defined methods) stays cached and only the content is reloaded. How can I reload everything?
I have installed the project in development mode and I use %autoreload 2 in the notebook.
Is there a way to place a Breakpoint on a class, so that whenever control reaches any field, property or method of that class, execution breaks?
Just place the breakpoint at the Constructor of the class, or at a specific method.
I'm using Visual Studio 2013 with Resharper 8.1 installed and I'm all about finding shortcuts for regular tasks. One such task that I do regularly is add new constructor dependencies to MVC Controllers. So for example, I might have the following:
public class MyController : Controller {
private readonly ICustomerManager _customerManager;
public MyController(ICustomerManager customerManager) {
_customerManager = customerManager;
}
Now I want to add in an IOrderManager, so I have 3 different lines to adapt: I have to add a private variable to store it, add a parameter to the constructor, and add a line inside the constructor to set the private variable.
I'd love to be able to write a macro/template/snippet that would allow me to enter "IOrderManager" and have it add all the code for me. Is there any way I can do this in VS2013 or Resharper?
The easiest thing is to add the field manually, then Alt+Enter and let ReSharper initialise the field from the constructor. It will add the parameter, and initialise the field with it.
I'm trying to develop a VS extension using the Visual Adornment project template.
The extension is working on the experimental instance of VS (it simply adds a text layer on the editor window), but now I'm trying to add 2 features, with no luck:
Help/About entry for the extension
Settings page for some basic configurations
So I started to study some other extension to understand how they do that, taking as example this from Phil Haack Encourage.
No way I can get it to work. I created a class that inherits from Microsoft.VisualStudio.Shell.Package and I've decorated it with all the needed attribute to have the Help/About entry, without any success.
[PackageRegistration(UseManagedResourcesOnly = true)]
[ComVisible(true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
[Guid("665d2c8c-0d47-42b6-ae34-e1db4ac2ed0f")]
public sealed class MyPackage : Package
{
public MyPackage()
{
Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
}
protected override void Initialize()
{
base.Initialize();
Debug.WriteLine("Initialize MyPackage");
}
}
Not only the package is not registering, but the debug lines are not written at all, I cannot even step in with the debugger.
I took a look around the web, and any article I found sounds like this one, even following any single step, my package is not registering itself BUT, and it is the strange thing, the viewport adornment it's working as expected...
UPDATE:
I can add some details: it seems that during the build the .pkgdef file is not created at all in the debug folder, and it's not added to the VSIX file (if I open it with 7zip there's no .pkgdef)
No way I can get it to work. I created a class that inherits from Microsoft.VisualStudio.Shell.Package and I've decorated it with all the needed attribute to have the Help/About entry, without any success.
I didn't understand that part quite. You're supposed to use Visual Studio "project template" for "Visual Studio packages". That will create all the stuff necessary to build VSIX file. Start with that, if you already haven't.
By default, Visual Studio extensions(>=2013) don't load automatically. This took me few hours of debugging, but you're supposed to decorate your package with an attribute if you'd like to load when Visual Studio starts up. Alternatively, there's an option to load your VSPackage once a solution is loaded.
This is a peek of my package definition:
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
[Guid(Guids.GuidMyStudioPackageString)]
[ProvideAutoLoad(UIContextGuids.NoSolution)]
[ProvideMenuResource("Menus.ctmenu", 1)]
public sealed class MyPackage : CommonPackage
Notice the [ProvideAutoLoad(...)] option. It says that load the package once visual studio starts.
When using Visual Studio it is easy to extract an interface from a class that I have written myself. I right click on the class and select 'Refactor' then select 'Extract Interface'.
Let's assume for a second that I wanted to create a ConfigurationManager wrapper and write some tests around it. A quick way to do that would be to extract an interface from ConfigurationManager by right clicking it, then 'Go To Definition' and then from inside the class select 'Refactor' then select 'Extract Interface'. Then I would simply create my wrapper class, inherit from my newly created interface, and then implement it and I have a great starting point for my wrapper class.
However, extracting an interface from any .NET system classes is not possible, probably because it's just meta data about the classes and not the classes themselves (or I am doing it wrong).
Is there an easy way to do what I am trying to accomplish? I want to ensure I am not wasting time typing what I don't need to be typing.
Thanks
The problem is not so much to extract the interface - you could also do this 'by hand'
But you have no way to tell the CLR that the System-defined Configuration manager implements this interface since this (meta-)information is stored in the framework assembly which you cannot modify.
EDIT:
To ease the 'extraction by hand' you can click with the right button on the type and select "Go to Definition". Visual Studio creates a class definition (without implementation) from the metadata. You can then use copy and paste into a new file. Anyway you'll still have to do some modifications by hand
Replace the class keyword by interface
remove all non-public methods/properties
remove the public and override access modifiers (they are invalid in an interface definition)
This can be done easily using search&replace. You'll even get the documentation strings with this approach.