pakrym / jab

C# Source Generator based dependency injection container implementation.
MIT License
1.04k stars 35 forks source link

Generic attributes in .NET 7 #127

Closed Unreal852 closed 1 year ago

Unreal852 commented 1 year ago

Hi, i'm using jab in a .NET 7 project with preview lang version (upgraded from .NET 6) but i can't use generic attributes anymore.

konrad-gora commented 1 year ago

With .NET 7 preview lang version shouldn't be required.

Unreal852 commented 1 year ago

Yes, but it is required by Jab, see the generated Attributes.cs class.

konrad-gora commented 1 year ago

Yeah, but it should be changed for c#11

Unreal852 commented 1 year ago

Yup

notanaverageman commented 1 year ago

I have seen the same issue just now. Targets file checks that the framework is equal to net6.0. It should actually check that it is greater than or equal to.

https://github.com/pakrym/jab/blob/b74fc20f8d5a8aa55ccdd5e762513321960c9abd/src/Jab/build/Jab.targets#L3

konrad-gora commented 1 year ago

Also, these generic attributes are missing type constraints. Like where TImpl: TService. It would give us errors when writing code, not when compiling. And errors would be more clear.