.net 退出时更改变量名称的Resharper Live Template宏

.net 退出时更改变量名称的Resharper Live Template宏,.net,visual-studio,macros,resharper,live-templates,.net,Visual Studio,Macros,Resharper,Live Templates,我想创建一个Resharper Live模板,该模板将所有空格更改为下划线ind我的“事实”Live模板变量$testname$: <Fact()> _ Public Sub $testnames$() ' Arrange $END$ ' Act ' Assert End Sub _ 公共子$testnames$() “安排 $END$ “行动 “断言 端接头 我有这个: [Macro("applyRegex", ShortDescr

我想创建一个Resharper Live模板,该模板将所有空格更改为下划线ind我的“事实”Live模板变量$testname$:

<Fact()> _
Public Sub $testnames$()
    ' Arrange
    $END$

    ' Act

    ' Assert

End Sub
_
公共子$testnames$()
“安排
$END$
“行动
“断言
端接头
我有这个:

    [Macro("applyRegex", ShortDescription = "Run on {#0:variable}", LongDescription = "")]
    class ApplyRegexMacro : IMacro
    {
        public string EvaluateQuickResult(IHotspotContext context, IList<string> arguments)
        {
            return Regex.Replace(arguments[0], " ", "_", RegexOptions.IgnoreCase);
        }

        public HotspotItems GetLookupItems(IHotspotContext context, IList<string> arguments)
        {
            return null;
        }

        public string GetPlaceholder()
        {
            return "placeholder";
        }

        public bool HandleExpansion(IHotspotContext context, IList<string> arguments)
        {
            return false;
        }

        public ParameterInfo[] Parameters
        {
            get
            {
                return new[] { new ParameterInfo(ParameterType.String), new ParameterInfo(ParameterType.String), new ParameterInfo(ParameterType.VariableReference) };           
            }
        }
    }
[宏(“applyRegex”,ShortDescription=“在{0:variable}上运行”,longsdescription=”“)]
类ApplyRegexMacro:IMacro
{
公共字符串EvaluateQuickResult(IHotspotContext上下文,IList参数)
{
返回Regex.Replace(参数[0]、“”、“904;”、RegexOptions.IgnoreCase);
}
公共热点项GetLookupItems(IHotspotContext上下文,IList参数)
{
返回null;
}
公共字符串GetPlaceholder()
{
返回“占位符”;
}
公共布尔句柄扩展(IHotspotContext上下文,IList参数)
{
返回false;
}
公共参数info[]参数
{
得到
{
返回new[]{new ParameterInfo(ParameterType.String)、new ParameterInfo(ParameterType.String)、new ParameterInfo(ParameterType.VariableReference)};
}
}
}
但这只在我按tab键时运行。我希望宏在I选项卡超出$testname$后运行

我希望能够将测试名称写在一行带空格的文本中,然后宏将所有空格变成下划线


这可能吗?

你到底找到解决办法了吗?您是否将宏与给定变量相关联?也有相同的问题。它现在看起来像是一个内置宏,我只是不知道在键入变量名称后如何调用它。你解决问题了吗?如果是,怎么解决?