Intellenum
Intellenum copied to clipboard
Ensure Instance attributes can be converted to underlying type
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
Same for declaring a float but setting ints
[Intellenum(typeof(record.@struct.@float.@decimal))]
[Instance("Item1", 1)]
[Instance("Item2", 2)]
public partial class @event2
{
}
... 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