0

I am trying to develop a macro for c# templates, but it simply doesn't work. I have tried reading the whole (incomplete) documentation, or find the source code of a macro to use as an example, but I failed on both.

I am able to build, install and debug the plugin. No errors, and both constructors and methods are called. But when I access the macros inside the templates explorer, nothing shows up there. I have also selected All macros from the options.

Here is my code

MyMacroDefinition.cs

[MacroDefinition("Subeta.Abp.ReSharper", LongDescription = "Long Description", Name = "My Name", Requirement = InstantiationRequirement.Instant, ShortDescription = "Short Description")]
public class MyMacroDefinition : SimpleMacroDefinition
{
    public MyMacroDefinition()
    {

    }
}

MyMacroImplementation.cs

[MacroImplementation(Definition = typeof(MyMacroDefinition), Requirement = InstantiationRequirement.Instant)]
public class MyMacroImplementation : SimpleMacroImplementation
{
    private IMacroParameterValueNew myArgument;

    public MyMacroImplementation([Optional] MacroParameterValueCollection arguments)
    {
        myArgument = arguments.OptionalFirstOrDefault();
    }

    public override string EvaluateQuickResult(IHotspotContext context)
    {
        return myArgument == null ? null : myArgument.GetValue().ToUpperInvariant();
    }
}

Subeta.Abp.ReSharper.nuspec

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>
    <id>Subeta.Abp.ReSharper</id>
    <title>Abp Support</title>
    <version>1.0.2</version>
    <authors>Subeta</authors>
    <owners>Subeta</owners>
    <summary>ReSharper support for ASP.NET Boilerplate framework</summary>
    <description>
      Required desc
    </description>
    <releaseNotes>
    </releaseNotes>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <dependencies>
      <dependency id="Wave" version="[11.0]" />
    </dependencies>
    <tags>aspnetboilerplate abp</tags>
  </metadata>
  <files>
    <file src="bin\Debug\Subeta.Abp.ReSharper.dll" target="DotFiles" />
    <file src="bin\Debug\Subeta.Abp.ReSharper.pdb" target="DotFiles" />
  </files>
</package>

Thanks in advance!

Vitor Durante
  • 950
  • 8
  • 25

1 Answers1

1

Does the plugin get loaded by ReSharper at all? You need to make sure you have "zones" set up. Check this Troubleshooting guide for reasons why it might not have installed correctly.

citizenmatt
  • 18,085
  • 5
  • 55
  • 60
  • The guy who rocks on ReSharper's Github!!! Thank yooou! I found a working and updated extension of Live Templates / macros on github. I spend the day reading it and achieved a few advances, but it didn't work yet. I was able to display my macro in ReSharper's template editing page. I will try your suggestion as well so I can verify what is going on. This is much more complex than I expected, so I need some solid example, such as the repo I found. Thank you!! – Vitor Durante Jan 13 '18 at 03:32