Intellenum icon indicating copy to clipboard operation
Intellenum copied to clipboard

Ensure Instance attributes can be converted to underlying type

Open SteveDunn opened this issue 2 years ago • 2 comments

Describe the feature

e.g. had this mistake when converting the tests:

namespace Intellenum.Tests.Types;

[Intellenum(typeof(int))]
[Instance("Points", "Points")]
[Instance("Percentage", "Percentage")]
public partial class ScoreType
{
}

This just resulted in a meaningless compilation error: Intellenum.Tests.Types_ScoreType.g.cs(135,10): error CS0150: A constant value is expected

SteveDunn avatar Mar 28 '23 06:03 SteveDunn

Same for declaring a float but setting ints

    [Intellenum(typeof(record.@struct.@float.@decimal))]
    [Instance("Item1", 1)]
    [Instance("Item2", 2)]
    public partial class @event2
    {
    }

SteveDunn avatar Mar 28 '23 06:03 SteveDunn

... also, Instance attributes/methods should check the type, e.g.

    [Intellenum(typeof(record.@struct.@float.@decimal))]
    [Instance("Item1", 1f)]
    [Instance("Item2", 2f)]
    public partial class @event2
    {
    }

@decimal (it's convoluted as it's from the 'escaped types' tests) is not a decimal, so should be checked in the Instance attributes/method

SteveDunn avatar Mar 28 '23 06:03 SteveDunn