Skip to content
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

InvalidOperationException in Vogen 4.0.3 #589

Closed
viceroypenguin opened this issue May 9, 2024 · 3 comments
Closed

InvalidOperationException in Vogen 4.0.3 #589

viceroypenguin opened this issue May 9, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@viceroypenguin
Copy link
Contributor

Describe the bug

If an assembly: attribute with a single params parameter is used with multiple values before the assembly: VogenDefaults attribute in the same file, then the following warning is generated:

warning CS8785: Generator 'ValueObjectGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'InvalidOperationException' with message 'TypedConstant is an array. Use Values property.'.

Products:

  • VS 17.9.6
  • .NET 8.0.204
  • Vogen 4.0.3

Steps to reproduce

In a blank project, use the following code

using Vogen;

[assembly: Test(1, 2, 3, 4)]

[assembly: VogenDefaults(conversions: Conversions.Default | Conversions.LinqToDbValueConverter)]

Console.WriteLine("Test");

[AttributeUsage(AttributeTargets.Assembly)]
public sealed class TestAttribute(params int[] Values) : Attribute;

[ValueObject]
public readonly partial record struct TestId;

Expected behaviour

The [assembly: Test(1, 2, 3, 4)] will have no impact on the VogenDefaults attribute.

NB: switching the order, so that the Test attribute comes after VogenDefaults causes the build to work successfully.

@viceroypenguin viceroypenguin added the bug Something isn't working label May 9, 2024
@viceroypenguin viceroypenguin changed the title InvalidCastException in Vogen 4.0.3 InvalidOperationException in Vogen 4.0.3 May 9, 2024
@SteveDunn
Copy link
Owner

Thanks for the bug and repo - well spotted! I'll get this fixed ASAP

@SteveDunn SteveDunn self-assigned this May 10, 2024
@SteveDunn
Copy link
Owner

Thanks for the bug and repo - well spotted! I'll get this fixed ASAP

Will be in 4.0.4 tomorrow - thanks again!

@viceroypenguin
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants