Deploying very simple macro Follow
Hi,
I need to create new template macro that would change CamelCase names to names separated with underscore.
Like this:
ThisIsCamelCase --> this_is_camel_case.
This is the code I wrote:
namespace ResharperExt
{
[MacroDefinition("Pascal case to db table column")]
public class PascalCaseToDbTableColumnMacroDefinition : SimpleMacroDefinition
{
}
}
namespace ResharperExt
{
[MacroImplementation(Definition = typeof(PascalCaseToDbTableColumnMacroDefinition))]
public class PascalCaseToDbTableColumnMacro : SimpleMacroImplementation
{
private readonly IMacroParameterValueNew myArgument;
public PascalCaseToDbTableColumnMacro([Optional] MacroParameterValueCollection arguments) {
myArgument = arguments.OptionalFirstOrDefault();
}
public override string EvaluateQuickResult(IHotspotContext context)
{
if (myArgument == null) return null;
string argValue = myArgument.GetValue();
StringBuilder result = new StringBuilder();
foreach (char ch in argValue)
{
if (Char.IsUpper(ch))
{
if (result.Length > 0)
result.Append('_');
result.Append(Char.ToLower(ch));
}
else
result.Append(ch);
}
return result.ToString();
}
}
}
This compiles successfully after adding jetbrains sdk package as reference. This is where my problems started. I tried to copy plugin dll to multiple folders but nothing happened.
After that I found this: https://www.jetbrains.com/help/resharper/sdk/Extensions/Tools.html
I'm not sure is this really a way to implement this mega turbo tiny simple resharper macro. Another build of resharper, nuget packages, waves, zones?!
My question is: do I really need to do all this in order to make this extremely simple macro work? Or there is a simpler way?
Thanks.
Please sign in to leave a comment.