标签: visual-studio-extensions

测试visual studio扩展

是否有另一种方法来测试VS 2010扩展项目?现在我必须旋转VS 2010的新实例并等待.这需要几分钟时间,并且很想知道是否有其他方法可以快速完成.

visual-studio-2010 visual-studio visual-studio-extensions

6
推荐指数
1
解决办法
1166
查看次数

Visual Studio插件可以跳转到测试类

我想知道是否有一个插件允许我直接跳转到当前类的测试(或者如果它不存在则创建它).

我想这应该基于以下惯例:测试项目被命名为正在测试的项目+"test",测试类被命名为类似测试者+"测试".

像这样的功能对于包含许多文件和文件夹的项目非常有用,在这里滚动解决方案资源管理器来查找相关的测试项目可能非常烦人.

tdd unit-testing visual-studio visual-studio-extensions

6
推荐指数
1
解决办法
812
查看次数

如何使用Visual Studio Extension从当前解决方案中收集类型?

我创建了Visual Studio 2012 Package(使用VS2012 SDK).此扩展(如果安装在客户端的IDE环境中)应该具有从开发人员正在处理的当前打开的解决方案中收集所有特定类型的功能.Visual Studio Designer for ASP.NET MVC Application Project中嵌入了类似的功能,其中开发人员实现模型/控制器类,构建项目,然后能够在Scaffolding UI(Designer的下拉列表)中访问此类型.相应的功能也可用于WPF,WinForms视觉设计师等.

假设我的扩展必须从当前解决方案中收集所有类型,这些解决方案实现了ISerializable接口.步骤如下:开发人员创建特定的类,重建包含项目/解决方案,然后执行扩展UI提供的某些操作,从而涉及执行ISerializable类型收集.

我试图用反射实现收集操作:

List<Type> types = AppDomain.CurrentDomain.GetAssemblies().ToList()
                  .SelectMany(s => s.GetTypes())
                  .Where(p => typeof(ISerializable).IsAssignableFrom(p) && !p.IsAbstract).ToList();
Run Code Online (Sandbox Code Playgroud)

但是上面的代码会导致System.Reflection.ReflectionTypeLoadException抛出异常:

System.Reflection.ReflectionTypeLoadException was unhandled by user code
  HResult=-2146232830
  Message=Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
  Source=mscorlib
  StackTrace:
       at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
       at System.Reflection.RuntimeModule.GetTypes()
       at System.Reflection.Assembly.GetTypes()
(...)  
LoaderException: [System.Exception{System.TypeLoadException}]
{"Could not find Windows Runtime type   'Windows.System.ProcessorArchitecture'.":"Windows.System.ProcessorArchitecture"}
(...)
Run Code Online (Sandbox Code Playgroud)

如何正确实施从当前构建的解决方案中收集特定类型的操作?

c# vspackage vsix visual-studio-extensions visual-studio-2012

6
推荐指数
1
解决办法
1476
查看次数

在Visual Studio扩展中,获取调试器停止的函数的行范围

我有一个Visual Studio扩展,它挂钩到调试事件.当调试器在一行代码处停止时,我的IDebugEventCallback2回调被调用,我可以找到调试器已经停止的文件名和行号IDebugThread2::EnumFrameInfo.

我想知道当前函数跨越的源代码行的范围.

我希望可以从调试器接口获取我需要的信息 - 调试器必须知道函数的行范围.如果那是不可能的,我会接受任何其他方法.在理想的世界中,解决方案可以在没有项目系统的情况下工作 - 包括我自己在内的许多人使用Visual Studio作为独立的调试器而不使用项目系统.(另外,我不能依赖Roslyn - 它需要在现有版本的Visual Studio中工作.)

编辑:FileCodeModel只要文件是项目的一部分,Carlos的使用方法效果很好.我仍然想知道是否有一种不需要项目系统的方法.

extensibility visual-studio vs-extensibility vsix visual-studio-extensions

6
推荐指数
1
解决办法
396
查看次数

在扩展中编写Visual Studio设置不会保留

在我为Visual Studio 2015编写的扩展中,我希望更改选项卡大小和缩进大小,因为在工作中我们有不同的设置,就像我正在开发开源项目(公司历史记录在我们的C期间).我在命令类中编写了以下代码:

private const string CollectionPath = @"Text Editor\CSharp";
private void MenuItemCallback(object sender, EventArgs e)
{
  var settingsManager = new ShellSettingsManager(ServiceProvider);
  var settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
  var tabSize = settingsStore.GetInt32(CollectionPath, "Tab Size", -1);
  var indentSize = settingsStore.GetInt32(CollectionPath, "Indent Size", -1);
  if (tabSize != -1 && indentSize != -1)
  {
    settingsStore.SetInt32(CollectionPath, "Tab Size", 2);
    settingsStore.SetInt32(CollectionPath, "Indent Size", 2);
  }
}
Run Code Online (Sandbox Code Playgroud)

在实验配置单元中进行测试时,当您单步执行该方法时,它会更改它,但是当您打开"选项"对话框时,它将保持原始值.再次调试时,值保持原始值.

我忘记了什么或做错了什么?

c# visual-studio visual-studio-extensions visual-studio-2015

6
推荐指数
1
解决办法
262
查看次数

如何确定EnvDTE.Project对象是否代表C/C++项目?

我有一个Project实例,我不明白如何找出项目类型/语言.具体来说,我需要检查一个C/C++项目.

文档似乎缺乏.

以前,另一个人在我的开源VS扩展中添加了以下一些魔法,它在VS2013-2015中有效:

private static bool isVisualCppProject(object project)
{
    Type projectObjectType = project.GetType();
    var projectInterface = projectObjectType.GetInterface("Microsoft.VisualStudio.VCProjectEngine.VCProject");
    return projectInterface != null;
}

   ...

isVisualCppProject(project.Object);
Run Code Online (Sandbox Code Playgroud)

但它不再适用于VS 2017 RC.而且我很乐意摆脱这种运行时反射魔法和un-typed objectdynamic不是Project- 因为这个代码已经变得不可维护了.

c# visual-studio visual-studio-extensions visual-studio-package

6
推荐指数
1
解决办法
603
查看次数

VS Extension:TextPoint.GreaterThan/LessThan对于大文件来说非常慢

我正在开发一个VS扩展,需要知道文本光标当前位于哪个类成员(方法,属性等).它还需要父母的意识(例如,类,嵌套类等).它需要知道成员或类的类型,名称和行号.当我说"类型"时我的意思是"方法"或"属性"不一定是".NET类型".

目前我在这里使用此代码:

public static class CodeElementHelper
{
    public static CodeElement[] GetCodeElementAtCursor(DTE2 dte)
    {
        try
        {
            var cursorTextPoint = GetCursorTextPoint(dte);

            if (cursorTextPoint != null)
            {
                var activeDocument = dte.ActiveDocument;
                var projectItem = activeDocument.ProjectItem;
                var codeElements = projectItem.FileCodeModel.CodeElements;
                return GetCodeElementAtTextPoint(codeElements, cursorTextPoint).ToArray();
            }
        }
        catch (Exception ex)
        {
            Debug.WriteLine("[DBG][EXC] - " + ex.Message + " " + ex.StackTrace);
        }

        return null;
    }

    private static TextPoint GetCursorTextPoint(DTE2 dte)
    {
        var cursorTextPoint = default(TextPoint);

        try
        {
            var objTextDocument = (TextDocument)dte.ActiveDocument.Object();
            cursorTextPoint = objTextDocument.Selection.ActivePoint;
        }
        catch …
Run Code Online (Sandbox Code Playgroud)

c# visual-studio envdte vsix visual-studio-extensions

6
推荐指数
1
解决办法
159
查看次数

重置Visual Studio的实验实例

我正在尝试为Visual Studio开发扩展,并且正在阅读一些文章。

VS扩展开发的一个关键点是重置我遇到问题的Visual Studio实验实例。

例如,这里写道我应该使用以下命令来重置它(在Microsoft docs中也建议使用):

CreateExpInstance /Reset /VSInstance=12.0 /RootSuffix=Exp
Run Code Online (Sandbox Code Playgroud)

我运行命令行并导航到CreateExpInstance位置并运行此命令(我尝试使用各种版本:12.0、14.0等)。

但是,我不断收到这样的答复:

Visual Studio实验实例目录C:\ Users \ Mi \ AppData \ Local \ Microsoft \ VisualStudio \ 10.0Exp不存在。CreateExpInstance:警告:Visual Studio目录C:\ Users \ Mi \ AppData \ Local \ Microsoft \ VisualStudio \ 10.0不存在。创建目录C:\ Users \ Mi \ AppData \ Local \ Microsoft \ VisualStudio \ 10.0Exp \ Extensions。按任意键继续 。。。

此外,执行此操作会在我的%localappdata%/Microsoft/VisualStudio目录中继续创建新的实验实例

我究竟做错了什么?为什么我的实例没有重置?也许这应该是这样?

.net c# vb.net visual-studio visual-studio-extensions

6
推荐指数
2
解决办法
702
查看次数

如何使扩展适应Visual Studio 2019?

我读到适应VS 2019的扩展非常容易-https: //devblogs.microsoft.com/visualstudio/visual-studio-extensions-and-version-ranges-demystified/#

但是,如果我从帖子中执行所有操作,则会出错:

无法安装,因为没有以下链接:Microsoft.VisualStudio.Component.CoreEditor。

该帖子的作者在修改其扩展名时显示的行完全相同:

<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" />
Run Code Online (Sandbox Code Playgroud)

因此,看来这个先决条件对他来说不是问题。

我更新的extension.vsixmanifest是:

<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011">
  <Metadata>
    <Identity Id="PowerQuerySDK.Microsoft.30831070-f420-4649-a031-6f679996b182" Version="1.0.0.20" Language="en-US" Publisher="Microsoft" />
    <DisplayName>Power Query SDK</DisplayName>
    <Description xml:space="preserve">A Power Query language service for Visual Studio</Description>
    <License>Microsoft Power Query SDK - Pre-Release or Evaluation Use Terms.rtf</License>
    <Icon>dataconnector_128.png</Icon>
    <PreviewImage>EATIcon.ico</PreviewImage>
  </Metadata>
  <Installation>
    <InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[14.0,17.0)" />
    <InstallationTarget Version="[14.0,17.0)" Id="Microsoft.VisualStudio.Pro" />
    <InstallationTarget Version="[14.0,17.0)" Id="Microsoft.VisualStudio.Enterprise" />
  </Installation>
  <Dependencies>
    <Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" Version="[4.5,)" />
  </Dependencies>
  <Assets>
    <Asset Type="Microsoft.VisualStudio.ProjectTemplate" Path="ProjectTemplates" />
    <Asset …
Run Code Online (Sandbox Code Playgroud)

visual-studio-extensions

6
推荐指数
1
解决办法
1402
查看次数

How to get terminal window inside Visual Studio 2017 / 2019?

I was just reading this article - https://devblogs.microsoft.com/dotnet/visual-studio-2019-net-productivity-2/ and noticed in one of the GIF image, she is showing a terminal window inside VS editor itself. It looks like a fully fledged powershell window. How can we get that? Here is a screenshot.

在此处输入图片说明

terminal visual-studio-extensions visual-studio-2017 visual-studio-2019

6
推荐指数
2
解决办法
8306
查看次数