-
Notifications
You must be signed in to change notification settings - Fork 46
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
Exception is thrown if type is placed in the Validation
namespace
#669
Comments
The code producing the bug seems to be the following: public static ValueObjectOrError<MyValueObject> TryFrom(System.String value)
{
if (value is null)
{
return new ValueObjectOrError<MyValueObject>(Validation.Invalid("The value provided was null"));
}
var validation = MyValueObject.Validate(value);
if (validation != Vogen.Validation.Ok)
{
return new ValueObjectOrError<MyValueObject>(validation);
}
return new ValueObjectOrError<MyValueObject>(new MyValueObject(value));
} Instead of |
Hi, thanks for the feedback @nZeus and @TipluSebastian . I'm just building a fix for this and will release a new version later today. |
I think the bigger problem here is that Vogen relies on using directives. If anything conflicts with names in the Vogen namespace, than the generator will generate incorrect code. It would be best for the generator to use the full names of the types and not add the use Vogen directive at the top of the generated files. |
That is a very good point! The next release won't have these in. |
Fixed in 5.0.2 |
Describe the bug
This worked well before v5.0.0
Place your type inside the
Validation
folder:This error is thrown from the generated class:
error CS0234: The type or namespace name 'Invalid' does not exist in the namespace
Xxx.Validation' (are you missing an assembly reference?)`I think it is related to this piece of code:
Vogen/src/Vogen/GenerateCodeForTryFrom.cs
Line 105 in dedb1f9
Kind regards,
Ilia
Steps to reproduce
^
Expected behaviour
^
The text was updated successfully, but these errors were encountered: