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

Multi-target Annotations against .NET Standard 1.0 #1192

Merged
merged 1 commit into from Oct 3, 2022

Conversation

bkoelman
Copy link
Member

@bkoelman bkoelman commented Sep 28, 2022

Adds netstandard1.0 as a TFM to the JsonApiDotNetCore.Annotations NuGet package. This enables consumers to share their models project with .NET Framework code.

The types in the NetStandard target don't actually work with JsonApiDotNetCore. This is provided solely for convenience so that consumers don't need to use conditional defines that are based on the target framework.

Internally, we use project-level conditionals to include/exclude source files per target framework, based on their file name:

  • *.shared.cs: Included for both targets
  • *.netstandard.cs: Only included for netstandard1.0 (added as None for .NET 6 so it shows up in the IDE)
  • *.cs: Only included for .NET 6

This approach avoids the use of #if ... #else ... #endif in our source files, which is problematic for Resharper CleanupCode.

Closes #1190.

QUALITY CHECKLIST

@bkoelman bkoelman marked this pull request as ready for review September 28, 2022 01:48
@bkoelman
Copy link
Member Author

/cc @bjornharrtell we discussed this a while ago

@codecov
Copy link

codecov bot commented Sep 28, 2022

Codecov Report

Merging #1192 (70c053a) into master (79d918a) will not change coverage.
The diff coverage is n/a.

❗ Current head 70c053a differs from pull request most recent head 70c06b9. Consider uploading reports for the commit 70c06b9 to get more accurate results

@@           Coverage Diff           @@
##           master    #1192   +/-   ##
=======================================
  Coverage   92.59%   92.59%           
=======================================
  Files         242      242           
  Lines        7706     7706           
=======================================
  Hits         7135     7135           
  Misses        571      571           
Impacted Files Coverage Δ
.../Resources/Annotations/ResourceAttribute.shared.cs 100.00% <ø> (ø)
...urces/Annotations/ResourceLinksAttribute.shared.cs 100.00% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link

@ThomasBarnekow ThomasBarnekow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. It covers all the attributes that I have used in my code (Resource, NoResource, Attr, HasMany, and HasOne).

@bkoelman
Copy link
Member Author

bkoelman commented Oct 3, 2022

@ThomasBarnekow Thanks!

@bkoelman bkoelman merged commit ea3ab72 into master Oct 3, 2022
@bkoelman bkoelman deleted the multi-target-annotations branch October 3, 2022 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

JsonApiDotNetCore.Annotation for netstandard2.0
3 participants