SteveDunn / Vogen

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

Using c# 11 style attribute eg: [ValueObject<string>] does not trigger some of the code analyzers #389

Closed ThomasSkyldahl closed 1 year ago

ThomasSkyldahl commented 1 year ago

Describe the bug

Hi I have been testing out the library and it's looking very promissing so far but I stumpled upon a bug when using C# 11 style generic attributes it seems like a lot the the build in analyzers do not trigger when using the C# 11 generic attribute:

Steps to reproduce

try out this sample code in your IDE:

[ValueObject(typeof(string))]
public readonly partial struct OldSchoolProductNumber {}

[ValueObject<string>]
public readonly partial struct NewSchoolProductNumber {}

public class Examples
{
     public Examples() 
     {
         _ = new OldSchoolProductNumber(); // VOG010 error seen in editor
         _ = new NewSchoolProductNumber(); // no errror seen in editor
     }
}

The OldSchoolProductNumber shows an error message. The NewSchoolProductNumber does not show an error message

Expected behaviour

I would expect the errors to be seen for both types of ValueObject attribute delerations

ThomasSkyldahl commented 1 year ago

I added a pull request with a fix for the issue see: #390

ThomasSkyldahl commented 1 year ago

@SteveDunn Thanks for the quick merge and the refactor :) closing this bug

SteveDunn commented 1 year ago

Thank you for your contribution! I just tag and pushed a new nuget version, so it should be ready soon.