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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ parameters:
# Matrix with target platforms.
# x86 versions are not supported by Native AOT.
# linux-arm64 must be added after we learn how to set up the cross-compilation environment.
# Use net7.0 as the latest stable version except for osx-arm64 which is only supported in net8.0.
# Use net8.0 as the latest stable version.
- name: buildMatrix
type: object
default:
- Name: win_x64
VMImage: windows-latest
TargetRuntime: win-x64
DotNetVersion: 7.0.x
DotNetMoniker: net7.0
DotNetVersion: 8.0.x
DotNetMoniker: net8.0
UseGlobalJson: true
- Name: win_arm64
VMImage: windows-latest
TargetRuntime: win-arm64
DotNetVersion: 7.0.x
DotNetMoniker: net7.0
DotNetVersion: 8.0.x
DotNetMoniker: net8.0
UseGlobalJson: true
- Name: osx_x64
VMImage: macos-latest
TargetRuntime: osx-x64
DotNetVersion: 7.0.x
DotNetMoniker: net7.0
DotNetVersion: 8.0.x
DotNetMoniker: net8.0
UseGlobalJson: true
- Name: osx_arm64
VMImage: macos-latest
Expand All @@ -47,8 +47,8 @@ parameters:
- Name: linux_x64
VMImage: ubuntu-latest
TargetRuntime: linux-x64
DotNetVersion: 7.0.x
DotNetMoniker: net7.0
DotNetVersion: 8.0.x
DotNetMoniker: net8.0
UseGlobalJson: true

jobs:
Expand Down Expand Up @@ -126,8 +126,8 @@ jobs:
variables:
VMImage: windows-latest
TargetRuntime: win-x64
DotNetVersion: 7.0.x
DotNetMoniker: net7.0
DotNetVersion: 8.0.x
DotNetMoniker: net8.0
UseGlobalJson: true
TargetRuntimeList:

Expand Down
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

# ThrowIf* APIs are not available in .NET Framework
dotnet_diagnostic.CA1510.severity = none
dotnet_diagnostic.CA1513.severity = none

# License header
file_header_template = Copyright (c) Microsoft Corporation.\nLicensed under the MIT License.

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:
with:
dotnet-version: 6.0.x

- name: Setup .NET 7
- name: Setup .NET 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
Expand Down Expand Up @@ -83,15 +83,15 @@ jobs:
--logger trx
--results-directory "out/test/dotnet6-node${{ matrix.node-version }}-${{ matrix.configuration }}"

- name: Test .NET 7
- name: Test .NET 8
if: steps.pack.conclusion == 'success' && !cancelled()
env:
TRACE_NODE_API_HOST: 1
run: >
dotnet test -f net7.0
dotnet test -f net8.0
--configuration ${{ matrix.configuration }}
--logger trx
--results-directory "out/test/dotnet7-node${{ matrix.node-version }}-${{ matrix.configuration }}"
--results-directory "out/test/dotnet8-node${{ matrix.node-version }}-${{ matrix.configuration }}"

- name: Upload test logs
if: always() # Update artifacts regardless if code succeeded, failed, or cancelled
Expand Down
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"recommendations": [
"ms-dotnettools.csharp",
"formulahendry.dotnet-test-explorer"
"ms-dotnettools.csharp"
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
// We try to limit the length of code lines to 100 columns.
"editor.rulers": [
100,
]
],
"dotnet.preferRuntimeFromSDK": true
}
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"-c",
"Release",
"-f",
"net7.0",
"net8.0",
"--",
"--filter",
"*.NonAot.*"
Expand All @@ -68,7 +68,7 @@
"-c",
"Release",
"-f",
"net7.0",
"net8.0",
"--",
"--filter",
"*.Aot.*"
Expand Down
19 changes: 17 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project>
<PropertyGroup>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and ! $([MSBuild]::IsOsPlatform('Windows')) ">net7.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and $([MSBuild]::IsOsPlatform('Windows')) ">net7.0;net6.0;net472</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and ! $([MSBuild]::IsOsPlatform('Windows')) ">net8.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and $([MSBuild]::IsOsPlatform('Windows')) ">net8.0;net6.0;net472</TargetFrameworks>
<TargetFrameworks Condition=" '$(PublishAot)' == 'true' ">net8.0</TargetFrameworks>
<LangVersion>10</LangVersion>
<Nullable>enable</Nullable>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
Expand All @@ -16,6 +17,20 @@

<!-- Display each test case and passed/failed status when using `dotnet test`. -->
<VSTestLogger Condition="'$(VSTestLogger)' == ''">console%3Bverbosity=normal</VSTestLogger>

<!-- Suppress warnings about using a preview version of .NET. -->
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>

<PropertyGroup Condition=" '$(PublishAot)' == 'true' ">
<!-- Modify the build output paths when publishing for AOT. This enables separately compiling
AOT and non-AOT flavors of the same project, which is necessary because .NET 8 blocks
dynamic code generation even in the managed assembly if AOT is enabled at compile time. -->
<OutputPath>$(BaseOutputPath)bin/$(Configuration)/$(MSBuildProjectName)/aot/</OutputPath>
<BaseIntermediateOutputPath>$(BaseIntermediateOutputPath)aot/</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<StripSymbols>true</StripSymbols>
</PropertyGroup>

<PropertyGroup Label="Nuget metadata">
Expand Down
6 changes: 3 additions & 3 deletions Docs/node-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ For a minimal example of this scenario, see
AOT compiled modules load more quickly and _do not have any runtime dependency .NET_. However,
.NET Native AOT has some limitations, so you should understand the implications before starting
on this path. Some of the considerations include:
- .NET 7 SDK or later is required at build time. (Not at run time.)
- .NET 8 SDK or later is required at build time. (Not at run time.)
- AOT binaries are much larger: at least 4-10 MB depending on the platform.
- AOT code can only call other native code. That may include other .NET Native AOT assemblies,
but NOT any managed .NET assemblies, because the .NET runtime is not loaded.
- No dynamic loading, reflection, or runtime code-generation is possible.
- Some .NET APIs and libraries are not compatible with AOT.
For more details, see https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/

To configure a .NET Node API module project for AOT, make sure the target framework is .NET 7 or
To configure a .NET Node API module project for AOT, make sure the target framework is .NET 8 or
later, and add the publishing properties to the project file:
```xml
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<PublishAot>true</PublishAot>
<PublishNodeModule>true</PublishNodeModule>
```
Expand Down
6 changes: 3 additions & 3 deletions README-DEV.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# node-api-dotnet Development Notes

### Requirements for Development
- [.NET 7 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/7.0)
- [.NET 8 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
- _and_ [.NET 6 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
- _and_ [.NET 4.7.2 developer pack](https://dotnet.microsoft.com/en-us/download/dotnet-framework/net472)
(Windows only)
- [Node.js](https://nodejs.org/) version 16 or later

While `node-api-dotnet` supports .NET 6 or .NET Framework 4 at runtime, .NET 7 or later SDK is
While `node-api-dotnet` supports .NET 6 or .NET Framework 4 at runtime, .NET 8 or later SDK is
required for building the AOT components.

## Build
Expand Down Expand Up @@ -40,7 +40,7 @@ use the same target framework version._

Use `--framework` to specify a target framework, or `--filter` to run a subset of test cases:
```bash
dotnet test --framework net7.0 --filter "DisplayName~aot"
dotnet test --framework net8.0 --filter "DisplayName~aot"
```

The list of test cases is automatically derived from the set of `.js` files under the
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ For details, see [Using .NET Generics in JavaScript](./docs/generics.md).
## Getting Started
#### Requirements
- .NET 6 or later
- .NET 7 or later is required for AOT support.
- .NET 8 or later is required for AOT support.
- .NET Framework 4.7.2 or later is supported at runtime,
but .NET 6 SDK is still required for building.
- Node.js v16 or later
Expand Down
5 changes: 3 additions & 2 deletions bench/NodeApi.Bench.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and ! $([MSBuild]::IsOsPlatform('Windows')) ">net7.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and $([MSBuild]::IsOsPlatform('Windows')) ">net7.0;net472</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and ! $([MSBuild]::IsOsPlatform('Windows')) ">net8.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' and $([MSBuild]::IsOsPlatform('Windows')) ">net8.0;net472</TargetFrameworks>
<OutputType>exe</OutputType>
<RootNamespace>Microsoft.JavaScript.NodeApi.Bench</RootNamespace>
<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>
<NoWarn>MSB3270</NoWarn><!-- Processor architecture mismatch bewteen "MSIL" and ... -->
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/aot-module/aot-module.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishAot>true</PublishAot>
Expand Down
2 changes: 1 addition & 1 deletion examples/hermes-engine/hermes-engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion examples/winui-fluid/winui-fluid.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows10.0.22000.0</TargetFramework>
<TargetFramework>net8.0-windows10.0.22000.0</TargetFramework>
<TargetPlatformMinVersion>10.0.22000.0</TargetPlatformMinVersion>
<OutputType>WinExe</OutputType><!-- TODO: Change back to WinExe -->
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.302",
"version": "8.0.100-rc.1",
"rollForward": "latestPatch"
}
}
8 changes: 2 additions & 6 deletions src/NodeApi.DotNetHost/JSInterfaceMarshaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ internal class JSInterfaceMarshaller

public JSInterfaceMarshaller()
{
string assemblyName = typeof(JSInterface).FullName +
"_" + Environment.CurrentManagedThreadId;
_assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(
new AssemblyName(assemblyName), AssemblyBuilderAccess.Run);
_moduleBuilder =
_assemblyBuilder.DefineDynamicModule(typeof(JSInterface).Name);
_assemblyBuilder = JSMarshaller.CreateAssemblyBuilder(typeof(JSInterfaceMarshaller));
_moduleBuilder = _assemblyBuilder.DefineDynamicModule(typeof(JSInterfaceMarshaller).Name);
}

/// <summary>
Expand Down
Loading