C# expression body syntax in Grasshopper Plugin class getters

I know that this is small beer, and it’s mostly my OCD but…

when I create a new plugin I am compelled (by the power of Patty) to edit this:

namespace WingCutters
{
    public class WingCuttersInfo : GH_AssemblyInfo
    {
        public override string Name
        {
            get
            {
                return "WingCutters";
            }
        }
        public override Bitmap Icon
        {
            get
            {
                //Return a 24x24 pixel bitmap to represent this GHA library.
                return null;
            }
        }
        public override string Description
        {
            get
            {
                //Return a short string describing the purpose of this GHA library.
                return "";
            }
        }
        public override Guid Id
        {
            get
            {
                return new Guid("89b9ca79-7ccc-41f3-972f-768283efb797");
            }
        }

        public override string AuthorName
        {
            get
            {
                //Return a string identifying you or your company.
                return "John";
            }
        }
        public override string AuthorContact
        {
            get
            {
                //Return a string representing your preferred contact details.
                return "";
            }
        }
    }
}

into this:

namespace WingCutters
{
    public class WingCuttersInfo : GH_AssemblyInfo
    {
        public override string Name => "WingCutters";
        public override Bitmap Icon => null;
        public override string Description => "Creates wing cutout and trim and flaps volume and trim to speed things up";
        public override Guid Id => new Guid("89b9ca79-7ccc-41f3-972f-768283efb797");
        public override string AuthorName => "John";
        public override string AuthorContact => "";
    }
}

uh, just because.

Could you change future plugin code generaters to use the expression body syntax? Where it makes sense.

The component ComponentGuid and Icon are also candidates for this.

I think the => syntax wasn’t yet available back when that plugin wizard was made. When we make a new one for GH2 we’ll definitely use the latest language syntax available on the oldest supported version of Visual Studio.

Could anyone explain to me why would the former code be better than the latter? Sure seems like the latter is shorter and cleaner. Kinda Pythonic :wink:

I don’t think that it was available at the time the Developer Studio Extension?/Plugin?/Whatever was written. Essentially McNeel wrote an extension for Developer Studio that writes the initial code for your project. It was written for the current state of the C# language.

The language has moved on and has had some syntactic sugar added. The original get/set properties were syntactic sugar but the new stuff is even sweeter :wink: It’s such an improvement over Java and C++.

As David said, they have to make sure that the changes are compatible with whatever the earliest version of Developer Studio they decide to support when they come to make the changes.

The dev studio version probably wont matter as it’s the language version that decides what compiles. I have created and edited projects in dev studio 2015. It doesn’t offer the option to convert between full method body and expression syntax but there are no intellisense warnings or compile issues.

So, hopefully, there will be no show stoppers and we can just have it. But let’s see.

Ah, so the latter code is the newer one?
It does look better at least from my (python-biased) perspective.

I am on a mission to create Python-only plugin for Rhino and I have an issue creating the AssemblyInfo attributes. Perhaps after they implement this change I’ll succeed as well :wink: