SteveDunn / Vogen

A semi-opinionated library which is a source generator and a code analyser. It Source generates Value Objects
Apache License 2.0
781 stars 45 forks source link

Improve performance and switch to `ForAttributeWithMetadataName` #574

Closed SteveDunn closed 4 months ago

SteveDunn commented 4 months ago

Describe the feature

Follow the incremental generator best practices to improve performance. Also use ForAttributeWithMetadataName instead of checking attributes manually.

Blackclaws commented 4 months ago

This will most likely also solve: https://github.com/SteveDunn/Vogen/issues/575

SteveDunn commented 4 months ago

This is now implemented for finding assembly level config ([VogenDefaults]), but can't currently be used for ValueObjectAttribute as some people derive their own attributes from them, e.g. public class IntVoAttribute : ValueObjectAttribute<int>

In C# 12, this could be aliased with using IntVo = Vogen.ValueObjectAttribute<int>;

The plan is to create an analyser that spots when something is derived, and produces a warning.

SteveDunn commented 4 months ago

Actually, I misread the information re. C# 12 and type aliases: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-12.0/using-alias-types

We've always been able to alias a type. The next major version will be a breaking change as it is better to use a type alias. However, saying that, you can't get all of the benefits of derivation, e.g. specifying constructor parameters.