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

Replace .NET 7 target with .NET 8 rc1 #153

Merged
merged 9 commits into from
Sep 19, 2023
Merged

Replace .NET 7 target with .NET 8 rc1 #153

merged 9 commits into from
Sep 19, 2023

Conversation

jasongin
Copy link
Member

@jasongin jasongin commented Sep 17, 2023

Fixes #116

I am replacing the .NET 7 target with .NET 8. Version 7 is not an LTS release, while 6 and 8 are, so it makes sense to support .NET versions 472, 6, and 8 for the near future.

.NET 8 is now RC1 status which has a go-live license. Merging this change will require .NET 8 RC1 SDK to develop/build the node-api-dotnet project, but NOT to develop applications that use it. (Any of .NET 472, 6, 7, or 8 runtimes should still work.) Of course, we'll update from RC1 to the released .NET 8 version when it's available in a couple months.

This update required more work than just replacing 7 with 8 in a few places:

  • The code for loading .NET HostFxr is updated to allow a prerelease version (at least for now).
  • .NET 8 disables dynamic code generation when compiling with PublishAot=true property. For most applications it makes sense to have the managed code behave the same as the Native AOT compiled app. But node-api-dotnet depends on Reflection.Emit in its managed host (not in its native host). To work around that I added a special aot target, with separate output path, that is built and published when packaging (and for tests).
  • The source generator assemblies are in a "collectible" assembly load context in .NET 7 and 8, which is incompatible with the default behavior of Expression.Lambda(). I had previously used a workaround for .NET 7 (to reload the generator assemblies as non-collectible) but that doesn't work anymore on .NET 8. This change includes code to explicitly create the lambda delegate types in a collectible context, which resolves the issue. It is a lot more code but is a better solution since now the source-generator can be properly unloaded (and reloaded to pick up changes).
  • The VSTestNoBuild behavior changed a bit in the .NET 8 SDK, so I had to update the logic that is used to conditionally skip the dependency builds during the tests.
  • The .NET 8 SDK added more analyzer rules checked by dotnet format. So there are small updates in several places to resolve those.

Additionally, I noticed the .NET 6 targeted tests were mistakenly using the .NET 7 or 8 runtime. The build and host logic is updated to fix the issue.

@jasongin
Copy link
Member Author

jasongin commented Sep 18, 2023

There's an issue with the source-generator on Max & Linux that causes many of the tests to fail. I know a workaround, but it will be somewhat complicated to implement.

Copy link
Member

@vmoroz vmoroz left a comment

Choose a reason for hiding this comment

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

LGTM

@jasongin jasongin merged commit c141ce3 into main Sep 19, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.NET 8 Support
2 participants