Skip to content

Commit

Permalink
Add net 8 target (#43)
Browse files Browse the repository at this point in the history
* Add .Net8 runtime

* Use net8 target framework

* Update System.Text.Json

* Set MyJsonSerializerContext.Default explicitly
  • Loading branch information
trejjam authored Nov 15, 2023
1 parent 2298d5a commit 5c56f22
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 23 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ jobs:
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
steps:
- name: Setup .Net 7.0.x
- name: Setup .Net
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: |
7.0.x
8.0.x
- uses: actions/checkout@v4
- name: Restore
run: dotnet restore --nologo
Expand All @@ -32,10 +34,10 @@ jobs:
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
steps:
- uses: actions/checkout@v4
- name: Setup .Net 7.0.x
- name: Setup .Net 8.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'
- name: Restore
run: dotnet restore --nologo
- name: .Net Format
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/nightly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ jobs:
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
steps:
- name: Setup .Net 7.0.x
- name: Setup .Net
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: |
7.0.x
8.0.x
- uses: actions/checkout@v4
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ jobs:
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
steps:
- name: Setup .Net 7.0.x
- name: Setup .Net
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: |
7.0.x
8.0.x
- uses: actions/checkout@v4
- name: Restore
run: dotnet restore --nologo
Expand All @@ -32,10 +34,10 @@ jobs:
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
steps:
- uses: actions/checkout@v4
- name: Setup .Net 7.0.x
- name: Setup .Net 8.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'
- name: Restore
run: dotnet restore --nologo
- name: .Net Format
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ jobs:
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
steps:
- name: Setup .Net 7.0.x
- name: Setup .Net
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: |
7.0.x
8.0.x
- uses: actions/checkout@v4
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public partial class MyJsonSerializerContext : JsonSerializerContext
// register generated converters to options
UsePolymorphicConverters(s_defaultOptions.Converters);
UseEnumConverters(s_defaultOptions.Converters);

#if NET8_0_OR_GREATER
Default = new MyJsonSerializerContext(new System.Text.Json.JsonSerializerOptions(s_defaultOptions));
#endif
}
}
```
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ProjectName>Aviationexam.GeneratedJsonConverters.SourceGenerator.Target.Tests</ProjectName>
<IsPackable>false</IsPackable>
Expand All @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="System.Text.Json" Version="7.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ProjectName>Aviationexam.GeneratedJsonConverters.SourceGenerator.Target</ProjectName>
<IsPackable>false</IsPackable>
Expand All @@ -25,8 +25,12 @@
<ProjectReference Include="..\Aviationexam.GeneratedJsonConverters.SourceGenerator\Aviationexam.GeneratedJsonConverters.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="$(TargetFramework) == 'net7.0'">
<PackageReference Include="System.Text.Json" Version="7.0.3" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework) == 'net8.0'">
<PackageReference Include="System.Text.Json" Version="8.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
using Aviationexam.GeneratedJsonConverters.SourceGenerator.Target.ContractWithCustomDelimiter;
using System.Collections.Generic;
using System.Text.Json.Serialization;
#if NET8_0_OR_GREATER
using System.Text.Json;
#endif

namespace Aviationexam.GeneratedJsonConverters.SourceGenerator.Target;

Expand Down Expand Up @@ -31,5 +34,9 @@ static MyJsonSerializerContext()
{
UsePolymorphicConverters(s_defaultOptions.Converters);
UseEnumConverters(s_defaultOptions.Converters);

#if NET8_0_OR_GREATER
Default = new MyJsonSerializerContext(new JsonSerializerOptions(s_defaultOptions));
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ProjectName>Aviationexam.GeneratedJsonConverters.SourceGenerator.Tests</ProjectName>
<IsPackable>false</IsPackable>
Expand All @@ -17,7 +17,7 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.7.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="7.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="Verify.XUnit" Version="22.4.1" />
<PackageReference Include="Verify.SourceGenerators" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.6.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ProjectName>Aviationexam.GeneratedJsonConverters.SourceGenerator</ProjectName>
<IsRoslynComponent>true</IsRoslynComponent>
Expand Down Expand Up @@ -31,7 +31,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="7.0.3" PrivateAssets="all" />
<PackageReference Include="System.Text.Json" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" PrivateAssets="all" />
<PackageReference Include="H.Generators.Extensions" Version="1.20.0" PrivateAssets="all" GeneratePathProperty="true" />
<PackageReference Include="PolySharp" Version="1.13.2" PrivateAssets="all" />
Expand Down

0 comments on commit 5c56f22

Please sign in to comment.