Resharper Live Template Macro that changes variable name upon exit
I would like to create a Resharper Live Template that changes all spaces to underscores ind my "fact" Live template variable $testname$:
<Fact()> _
Public Sub $testnames$()
' Arrange
$END$
' Act
' Assert
End Sub
I have this:
[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
开发者_StackOverflow {
return new[] { new ParameterInfo(ParameterType.String), new ParameterInfo(ParameterType.String), new ParameterInfo(ParameterType.VariableReference) };
}
}
}
But this only runs when i press tab. I want the macro to run after I tab out of $testname$.
I want to be able to just write the test name in a single line of text with spaces, and then the Macro turns all the spaces into underscores.
Is this possible?
精彩评论