Skip to content

Upgrade to NET8#114

Merged
oliverbock merged 23 commits intoJavascriptNet:masterfrom
bwinsley:net8-2
Dec 19, 2025
Merged

Upgrade to NET8#114
oliverbock merged 23 commits intoJavascriptNet:masterfrom
bwinsley:net8-2

Conversation

@bwinsley
Copy link
Copy Markdown
Collaborator

Original PR was merged into master without squashing. @oliverbock and I attempted a squash and force push which somehow broke the git history. Master has since been restored so I am redoing this PR which we will squash and rebase.

===========================================

This pull request modernizes the project by upgrading it from .NET Framework 4.7.2 to .NET 8, updating build configurations, and improving memory management for managed JavaScript function wrappers. It also revises documentation and sample code to reflect these changes, ensuring compatibility with current development tools and practices.

.NET 8 Migration and Build System Updates:

  • Migrated Fiddling.csproj and JavaScript.Net.vcxproj to .NET 8 SDK-style projects, removed legacy .NET Framework settings, and updated platform/toolset requirements for C++/CLI to use CLRSupport=NetCore. [1] [2]
  • Updated solution file JavaScript.Net.sln for Visual Studio 2022/2019 and removed references to older Visual Studio versions.
  • Removed obsolete configuration file app.config and legacy assembly references, as .NET 8 includes most system assemblies by default. [1] [2]

Changes to method of tracking and garbage collecting JavascriptExternals

  • Passing GCHandle to unmanaged c++ code would cause issues in NET8 and accessing methods on it such as GCHandle.Target would throw System.AccessViolationException.
  • The solution was to use the method GCHandle.ToIntPtr to obtain a pointer which we can pass to unmanaged code

Memory Management Enhancements:

  • Added a dedicated wrapper (JavascriptFunctionWrapper and WrappedJavascriptFunction) for managed JavaScript function objects, enabling proper cleanup of V8 handles and managed references when the context is disposed. Updated construction and disposal logic in both header and implementation files. [1] [2] [3] [4]
  • Readded memory management code into Program.cs in Fidding.csproj [1] [2] [3]
  • This change mimics that of Reduce memory inefficiencies and leaks #95
  • See performance improvement below

Before: image
After: image

This upgrade brings the project up to date with current .NET and Visual Studio standards, improves reliability and maintainability, and provides clearer guidance for users and contributors.

@oliverbock oliverbock merged commit 1231fcd into JavascriptNet:master Dec 19, 2025
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.

3 participants