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

Improve compatibility in complex cross-targeting scenarios. #8

Merged
merged 2 commits into from
Oct 21, 2022

Conversation

Chryssie
Copy link
Contributor

@Chryssie Chryssie commented Oct 19, 2022

This allows for a dll compiled against netstandard2.0 with this as a depedency to be consumed from another dll compiled against net6.0 (or greater) without requiring the netstandard2.0 dll to multitarget netstandard2.0 and net6.0.

This is achieved by the removal of the conditional remove of the output dlls in the package, instead opting for conditional exclusion of most of the codebase except for three [assembly: TypeForwardedTo()] declarations which allow the compiler and runtimes to swap out the type decalrations here for the real ones in net6.0.

This allows for a dll compiled against netstandard2.0 with this as a depedency to be consumed from another dll compiled against net6.0 (or greater) without requiring the netstandard2.0 dll to multitarget netstandard2.0 and net6.0.

This is achieved by the removal of the conditional remove of the output dlls in the package, instead opting for conditional exclusion of most of the codebase except for three [assembly: TypeForwardedTo()] declarations which allow the compiler and runtimes to swap out the type decalrations here for the real ones in net6.0.
@OlegRa OlegRa self-assigned this Oct 19, 2022
@OlegRa OlegRa added the enhancement New feature or request label Oct 19, 2022
@OlegRa
Copy link
Owner

OlegRa commented Oct 20, 2022

@Chryssie thanks a lot for this PR and your help. I've spent some time trying to understand/reproduce the original problem with transitive dependency and now I know the root cause better. Proposed changes solve this problem, but I have some ideas to improve it. We have two options:

  1. I can merge your PR as-is and apply my changes in a separate commit. This way is simple and straightforward but I want to try another approach.
  2. You will enable the Allow edits from maintainers option for this PR and I'll add my changes to the existing PR. it will make Git history clearer.

Please, tell me which option works better for you and I'll process with the next step.

@OlegRa OlegRa mentioned this pull request Oct 20, 2022
3 tasks
@Chryssie
Copy link
Contributor Author

@OlegRa I've enabled edits by maintainers so you should be able to make your changes now.

…impler:

- Generate reference-only assemblies and place these assemblies into the `ref` folder in NuGet package
- Include/exclude files from TFM-specific builds using project file instead of conditional compilation
- Revet back .NET 6.0 TFM `lib` folder empty placeholder for preventing unused assembly copy
@OlegRa OlegRa merged commit ed1af48 into OlegRa:master Oct 21, 2022
Repository owner deleted a comment from allcontributors bot Oct 26, 2022
Repository owner deleted a comment from allcontributors bot Oct 26, 2022
@OlegRa
Copy link
Owner

OlegRa commented Oct 26, 2022

@all-contributors please add @Chryssie for code.

@allcontributors
Copy link
Contributor

@OlegRa

I've put up a pull request to add @Chryssie! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants