我已经创建了非常简单的 Visual Studio 插件,也就是 JP Booodhoo 的这篇文章。
http://codebetter.com/jpboodhoo/2007/09/04/macro-to-aid-bdd-test-naming-style/
插件在调试中工作,所以如果我在插件解决方案中按 F5,然后打开一个解决方案,插件就会显示在工具中。但是,它在不调试时不显示。即在我部署了插件之后,关闭并重新打开我的解决方案。
我错过了什么吗?
部署方面,我按照本文的部署步骤,部署到C:\Users[你的用户名]\Documents\Visual Studio 2012\Addins
public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false;
if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if(commandName == "KinghamExtensions.Connect.KinghamExtensions")
{
var selection = (TextSelection)(_applicationObject.ActiveDocument.Selection);
selection.SelectLine();
if (selection.Text == "") return;
var prefix = "public void ";
var index = selection.Text.IndexOf(prefix);
prefix = selection.Text.Substring(0, index) + prefix;
var description = selection.Text.Replace(prefix, String.Empty);
selection.Text = prefix + description.Replace(" ", "_").Replace("'", "_");
selection.LineDown();
selection.EndOfLine();
handled = true;
}
}
}
正如我所说,代码在调试中从 vs 运行插件时有效,但未显示在工具菜单中。
此外,它不会像 Git Extensions 插件那样显示在键盘选项中,这意味着我无法分配键绑定。
有什么想法吗?