-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Add support for generic attributes to StronglyTypedIdAttribute #577
Conversation
Can you rebase your branch? Also, I changed the way attributes are defined. It's now in the Meziantou.Framework.StronglyTypedId.Annotations project. You should be able to use |
Generic attributes are a csharp 11/.net 7 feature. Do you still want to gate it behind .net8? |
Use the minimum supported version. If it's .net 7, use NET_7_0_OR_GREATER. |
I haven't worked with multi-targeted libs before so correct me if I'm wrong on the following. Wrapping the attribute definition in Line 9 in 3f7bd16
Lines 40 to 46 in 3f7bd16
+ const string NetCoreVersion =
+ #if NET7_0
+ "7.0.14"
+ #elif NET8_0
+ "8.0.0"
+ #else
+ "6.0.12"
+ #endif
+ ;
var compilation = await CreateCompilation(sourceText,
[
- new NuGetReference("Microsoft.NETCore.App.Ref", "6.0.12", "ref/"),
+ new NuGetReference("Microsoft.NETCore.App.Ref", NetCoreVersion, "ref/"), |
Seems ok. I wonder if you can only reference the .NET 8 package in the test or if you need to use |
Only referencing .net8 produces
I suppose that error could be suppressed via I've rebased the branch. Let me know what you think. |
This PR adds support for generic attributes to StronglyTypedIdAttribute.
[StronglyTypedId<int>]
I wasn't sure what the best way to conditionally add a generic version of the attribute. This approach adds an MSBuild file that defines a preprocessor constant to check if the project supports generic attributes.