Closed nZeus closed 2 months ago
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 Validation.Invalid("The value provided was null")
it should be Vogen.Validation.Invalid("The value provided was null")
.
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.
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: https://github.com/SteveDunn/Vogen/blob/dedb1f964983449109f3e264c7ca6f88a1a7e19a/src/Vogen/GenerateCodeForTryFrom.cs#L105
Kind regards, Ilia
Steps to reproduce
^
Expected behaviour
^