-
Notifications
You must be signed in to change notification settings - Fork 45
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
Disable From method generation #671
Comments
Hi @AthenaAzuraeaX - thanks for the suggestion. This would be quite a big change for Vogen. There are ways to extend the types via static abstracts in interfaces. There's a tutorial here that could be extended and adapted for what you require. |
Hi @SteveDunn I'm aware of static interfaces, but purposely opt to not use them due to downsides and limits. But also there is the fact that Vogen's current From method doesn't support the interface we need. Hence, Vogen adding the From method bypasses all our own logic that we need or want. Hence, the only way for us to use Vogen right now is to add a Validation method to all types that throws an exception. Not a great idea, but since there is no other way to disable the From method, that's what we have to do. That is why I thought it would be nice to disable the From method generation. |
Describe the feature
It is currently possible to disable generation of the TryFrom method. Would it be possible to make it possible to disable generation of the From method, as well? The ctor should remain private. Mostly the reason is because I would like to handle validation myself, while allowing Vogen to generate the code for a Value object.
Currently I have to disable the Validation method by throwing an exception from it to prevent instantiating objects using TestUnit.From.
The reason I really don't want From or TryFrom is because they're static methods, and static methods are difficult to test and use, especially for validation where one might want to inject data into the factories.
The text was updated successfully, but these errors were encountered: