Skip to content

Commit

Permalink
Merge pull request #204 from davidwengier/UpdateToNet9
Browse files Browse the repository at this point in the history
Upgrade to .NET 9.0
  • Loading branch information
davidwengier authored Dec 29, 2024
2 parents 2fbfe22 + 3f23292 commit 884e6db
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 56 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Install workload
run: dotnet workload install wasm-tools
Expand All @@ -31,7 +31,7 @@ jobs:
run: dotnet build Trains.NET.sln -p:CI=true -c Release -bl

- name: Upload binary log
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: binlog
path: msbuild.binlog
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Install workload
run: dotnet workload install wasm-tools
Expand All @@ -99,6 +99,6 @@ jobs:
uses: crazy-max/[email protected]
with:
target_branch: gh-pages
build_dir: src/BlazingTrains/bin/Release/net8.0/publish/wwwroot
build_dir: src/BlazingTrains/bin/Release/net9.0/publish/wwwroot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Install workload
run: dotnet workload install wasm-tools
Expand All @@ -30,7 +30,7 @@ jobs:
run: dotnet build Trains.NET.sln -p:CI=true -c Release -bl

- name: Upload binary log
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: binlog
path: msbuild.binlog
Expand Down
39 changes: 20 additions & 19 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.5" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.10.0-3.final" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.10.0-3.final" />
<PackageVersion Include="Microsoft.Net.Compilers.Toolset" Version="4.10.0-3.final" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.62-alpha" />
<PackageVersion Include="Silk.NET.Input" Version="2.21.0" />
<PackageVersion Include="Silk.NET.OpenGL" Version="2.21.0" />
<PackageVersion Include="Silk.NET.Windowing" Version="2.21.0" />
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.4" />
<PackageVersion Include="SkiaSharp" Version="3.0.0-preview.3.1" />
<PackageVersion Include="SkiaSharp.Views.Blazor" Version="3.0.0-preview.3.1" />
<PackageVersion Include="SkiaSharp.Views.WindowsForms" Version="3.0.0-preview.3.1" />
<PackageVersion Include="SkiaSharp.Views.WPF" Version="3.0.0-preview.3.1" />
<PackageVersion Include="Svg.SourceGenerator.Skia" Version="0.5.18" />
<PackageVersion Include="xunit" Version="2.8.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.0" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.112" />
<PackageVersion Include="Silk.NET.Input" Version="2.22.0" />
<PackageVersion Include="Silk.NET.OpenGL" Version="2.22.0" />
<PackageVersion Include="Silk.NET.Windowing" Version="2.22.0" />
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.6" />
<PackageVersion Include="SkiaSharp" Version="3.118.0-preview.2.3" />
<PackageVersion Include="SkiaSharp.Views.Blazor" Version="3.118.0-preview.2.3" />
<PackageVersion Include="SkiaSharp.Views.WindowsForms" Version="3.118.0-preview.2.3" />
<PackageVersion Include="SkiaSharp.Views.WPF" Version="3.118.0-preview.2.3" />
<PackageVersion Include="Svg.SourceGenerator.Skia" Version="2.0.0.4" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />

<PackageVersion Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>
</Project>
6 changes: 0 additions & 6 deletions build/Packages.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" />

<!-- Latest C# compiler -->
<PackageReference Include="Microsoft.Net.Compilers.Toolset">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

<!-- Nerdbank GitVersioning -->
<PackageReference Include="Nerdbank.GitVersioning">
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion src/BlazingTrains/BlazingTrains.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PublishIISAssets>true</PublishIISAssets>
Expand Down
3 changes: 2 additions & 1 deletion src/SilkTrains/SilkTrains.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -11,6 +11,7 @@
<PackageReference Include="Silk.NET.OpenGL" />
<PackageReference Include="Silk.NET.Windowing" />
<PackageReference Include="SixLabors.ImageSharp" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Trains.NET.Engine\Trains.NET.Engine.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/Trains.Emoji/Trains.Emoji.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<NoWarn>$(NoWarn);CS1591;CA1062</NoWarn>
</PropertyGroup>

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

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<NoWarn>$(NoWarn);CS1591;CA1707;CA1052;CA1062;CA1063;CA1816</NoWarn>
</PropertyGroup>

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

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
21 changes: 10 additions & 11 deletions src/Trains.NET.SourceGenerator/DISourceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@
namespace Trains.NET.SourceGenerator;

[Generator]
public class DISourceGenerator : ISourceGenerator
public class DISourceGenerator : IIncrementalGenerator
{
public void Initialize(GeneratorInitializationContext context)
public void Initialize(IncrementalGeneratorInitializationContext context)
{
context.RegisterSourceOutput(context.CompilationProvider, DoStuff);
}

public void Execute(GeneratorExecutionContext context)
private void DoStuff(SourceProductionContext context, Compilation compilation)
{
Compilation? compilation = context.Compilation;

string sourceBuilder = Generate(context, compilation);
context.AddSource("ServiceLocator.cs", SourceText.From(sourceBuilder, Encoding.UTF8));
}

public static string Generate(GeneratorExecutionContext context, Compilation compilation)
public static string Generate(SourceProductionContext context, Compilation compilation)
{
string stub = @"
// <auto-generated />
Expand Down Expand Up @@ -188,7 +187,7 @@ private static string GetVariableName(Service service, List<Service> fields)
return typeName;
}

private static void Generate(GeneratorExecutionContext context, INamedTypeSymbol typeToCreate, Compilation compilation, List<Service> services, Service? parent, KnownTypes knownTypes)
private static void Generate(SourceProductionContext context, INamedTypeSymbol typeToCreate, Compilation compilation, List<Service> services, Service? parent, KnownTypes knownTypes)
{
// System.Diagnostics.Debugger.Launch();
typeToCreate = (INamedTypeSymbol)typeToCreate.WithNullableAnnotation(default);
Expand Down Expand Up @@ -270,7 +269,7 @@ private static void Generate(GeneratorExecutionContext context, INamedTypeSymbol
}
}

private static bool CheckForCycle(GeneratorExecutionContext context, List<Service> services, INamedTypeSymbol typeToCreate)
private static bool CheckForCycle(SourceProductionContext context, List<Service> services, INamedTypeSymbol typeToCreate)
{
foreach (var service in services)
{
Expand All @@ -288,19 +287,19 @@ private static bool CheckForCycle(GeneratorExecutionContext context, List<Servic
return false;
}

private static INamedTypeSymbol? FindImplementation(GeneratorExecutionContext context, Compilation compilation, KnownTypes knownTypes, ITypeSymbol typeToFind)
private static INamedTypeSymbol? FindImplementation(SourceProductionContext context, Compilation compilation, KnownTypes knownTypes, ITypeSymbol typeToFind)
{
return FindImplementations(context, compilation, knownTypes, typeToFind).FirstOrDefault();
}

private static IOrderedEnumerable<INamedTypeSymbol> FindImplementations(GeneratorExecutionContext context, Compilation compilation, KnownTypes knownTypes, ITypeSymbol typeToFind)
private static IOrderedEnumerable<INamedTypeSymbol> FindImplementations(SourceProductionContext context, Compilation compilation, KnownTypes knownTypes, ITypeSymbol typeToFind)
{
return FindImplementations(context, typeToFind, compilation).OrderBy(t => (int)(t.GetAttributes().FirstOrDefault(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, knownTypes.OrderAttribute))?.ConstructorArguments[0].Value ?? 0));
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "<Pending>")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "<Pending>")]
private static IEnumerable<INamedTypeSymbol> FindImplementations(GeneratorExecutionContext context, ITypeSymbol typeToFind, Compilation compilation)
private static IEnumerable<INamedTypeSymbol> FindImplementations(SourceProductionContext context, ITypeSymbol typeToFind, Compilation compilation)
{
foreach (INamespaceSymbol? ns in compilation.GlobalNamespace.GetNamespaceMembers())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>

<ItemGroup>
<ProjectCapability Include="RoslynComponent" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Trains/Trains.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net9.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<PlatformTarget>x64</PlatformTarget>
<NoWarn>$(NoWarn);MSB3245;CS1591;CA1062</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion src/WinTrains/WinTrains.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net9.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<NoWarn>$(NoWarn);CS1587;CS1591;CA1062</NoWarn>
<ApplicationIcon>RedTrain.ico</ApplicationIcon>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>

<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);CA2000</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion tests/Trains.NET.Tests/Trains.NET.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>

<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);CA2000</NoWarn>
Expand Down

0 comments on commit 884e6db

Please sign in to comment.