Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Instance attributes can be converted to underlying type #23

Open
SteveDunn opened this issue Mar 28, 2023 · 2 comments
Open

Ensure Instance attributes can be converted to underlying type #23

SteveDunn opened this issue Mar 28, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@SteveDunn
Copy link
Owner

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 SteveDunn added the enhancement New feature or request label Mar 28, 2023
@SteveDunn
Copy link
Owner Author

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
Copy link
Owner Author

... 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant