-
Notifications
You must be signed in to change notification settings - Fork 81
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
Setting to disable struct default Constructor generation. #75
Comments
+1 for this but I'd propose an
My idea behind a private constructor would allow for Example[StronglyTypedId(constructor: StronglyTypedIdConstructor.Private)]
partial struct MyStrongString
{
public static bool TryParse(string value, out MyStrongString? result)
{
if (CanParse) // Pseudo-code
{
result = new MyStrongString(value);
return true;
}
result = null;
return false;
}
} |
Sorry for the delay with this 😳. To be honest I got overwhelmed with how to handle the big range of feature requests and options. I think I've found an answer in the big redesign of the library in this PR: The main idea is to make the library much more maintainable while also giving people a mechanism to customise the generated IDs as much as they like. This will make it easy to make changes like this 🙂 |
My proposal is to add a boolean switch on the
[StronglyTypedId]
attribute that would indicate if the generator should generate the default constructor that accepts theBackingType
value.That way someone could provide his own custom constructor that accepts the
BackingType
and allow for further customisation of the finalValue
property.I found myself in need of this actually only on the
string
type so far since I wanted to do some extra work to some ids.If this sounds okay with you I would love to sit and try to implement it myself when I have some time 😸
The text was updated successfully, but these errors were encountered: