andrewlock / StronglyTypedId

A Rosyln-powered generator for strongly-typed IDs
MIT License
1.5k stars 78 forks source link

Add StronglyTypedId<T> generic attribute for C# 11+ #129

Closed kzu closed 4 months ago

kzu commented 5 months ago

Now that C# (11+) supports generic attributes, it would be nice to be able to annotate a type with the generic version to specify the backing type:

[StronglyTypedId<int>]
public partial struct UserId { }
andrewlock commented 5 months ago

Thanks for the suggestion, but unfortunately this won't work with the new design. The backing type isn't an unconstrained type, it's one of a specific enum values, or a string. This was discussed further in #102.

kzu commented 5 months ago

Hm, it's kinda losing its original simplicity-focused approach.