Migrate Macro From R#8

Hi,

I have some Problems to migrate my R#8 macro to R#9, 10.

So i have a macro, which creates a random number. I need this functionality in R#9,10 too.

I found this page https://confluence.jetbrains.com/pages/viewpage.action?pageId=50503757 , which describes, how to migrate. But how I can install this macro locally?

Is there any example project?

Thanks in advance.

Here my code:

    [MacroDefinition("ASErrMainNumber",
        LongDescription = "Generiert aus einer erzeugten GUID eine eindeutige Fehlernummer.",
        ShortDescription = "ASErrMainNumber")]
    public class ASErrMainNumberDefinition : IMacroDefinition
    {
        public string GetPlaceholder(IDocument document, IEnumerable<IMacroParameterValue> parameters)
        {
            return "A";
        }
        //public ParameterInfo[] Parameters { get; private set; }

        public ParameterInfo[] Parameters
        {
            get { return new ParameterInfo[0]; }
        }
    }

    [MacroImplementation(Definition = typeof(ASErrMainNumberDefinition))]
    public class ASErrMainNumberImplementation : SimpleMacroImplementation
    {

        public override string EvaluateQuickResult(IHotspotContext context)
        {
            var value = Guid.NewGuid().ToString();

            short[] powers = new short[8];
            int checksum = 0;

            for (int i = 0; i < 8; i++)
            {
                powers[i] = (short)Math.Pow(2, i);
            }

            int length = value.Length;
            short character;
            bool flag;
            for (int i = 0; i < length; i++)
            {
                character = Convert.ToInt16(value[i]);
                for (int j = powers.Length - 1; j >= 0; j--)
                {
                    flag = ((checksum & 32768) == 32768) ^ ((character & powers[j]) == powers[j]);
                    checksum = (checksum & 32767) * 2;
                    if (flag)
                    {
                        checksum = checksum ^ 0x8005;
                    }
                }
            }
            return checksum.ToString();
        }
    }

 

Thanks in advance.

 

Please sign in to leave a comment.