Skip to content

Commit

Permalink
Upgrade to .NET 9 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
KubaZ2 authored Nov 29, 2024
1 parent 3b41508 commit 0edcbde
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Restore dependencies
run: dotnet restore
Expand Down
4 changes: 2 additions & 2 deletions Backend/Manager/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
WORKDIR /src

COPY Manager/Manager.csproj Manager/Manager.csproj
Expand All @@ -9,7 +9,7 @@ COPY Manager Manager

RUN dotnet publish Manager/Manager.csproj -c Release -o /app

FROM mcr.microsoft.com/dotnet/aspnet:8.0
FROM mcr.microsoft.com/dotnet/aspnet:9.0
WORKDIR /app

COPY --from=build-env /app .
Expand Down
2 changes: 1 addition & 1 deletion Backend/Manager/Manager.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseAppHost>false</UseAppHost>
Expand Down
4 changes: 2 additions & 2 deletions Backend/Sandbox/Asm/Asm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FSharp.Core" Version="8.0.401" />
<PackageReference Include="FSharp.Core" Version="9.0.100" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseAppHost>false</UseAppHost>
Expand Down
4 changes: 2 additions & 2 deletions Backend/Sandbox/Asm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG DOTNET_SDK_VERSION=8.0
ARG DOTNET_RUNTIME_VERSION=8.0.7
ARG DOTNET_SDK_VERSION=9.0
ARG DOTNET_RUNTIME_VERSION=9.0.0
ARG OS_CODENAME=noble

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:$DOTNET_SDK_VERSION AS build-env
Expand Down
4 changes: 2 additions & 2 deletions Backend/Sandbox/CheckedJit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG DOTNET_RUNTIME_VERSION=8.0.7
ARG DOTNET_RUNTIME_VERSION=9.0.0
ARG OS=ubuntu
ARG OS_VERSION=24.04
ARG OS_CODENAME=noble
Expand All @@ -14,7 +14,7 @@ ARG BUILDARCH
RUN git clone --depth 1 --branch v$DOTNET_RUNTIME_VERSION https://github.com/dotnet/runtime.git .

# Asserts fail when running in pwn.red/jail, so we need to remove them
RUN sed -i 247d src/coreclr/pal/src/misc/cgroup.cpp
RUN sed -i 214d src/coreclr/pal/src/misc/cgroup.cpp
RUN sed -i 666d src/coreclr/pal/src/sync/cs.cpp

RUN if [ $TARGETARCH = $BUILDARCH ]; then \
Expand Down
2 changes: 1 addition & 1 deletion Backend/Sandbox/CheckedJit/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ services:
build:
context: .
dockerfile: Dockerfile
image: ghcr.io/kubaz2/sharp/checked-jit:8.0.7
image: ghcr.io/kubaz2/sharp/checked-jit:9.0.0
4 changes: 2 additions & 2 deletions Backend/Sandbox/Runner/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG DOTNET_SDK_VERSION=8.0
ARG DOTNET_RUNTIME_VERSION=8.0.7
ARG DOTNET_SDK_VERSION=9.0
ARG DOTNET_RUNTIME_VERSION=9.0.0

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:$DOTNET_SDK_VERSION AS build-env
WORKDIR /src
Expand Down
4 changes: 2 additions & 2 deletions Backend/Sandbox/Runner/Runner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FSharp.Core" Version="8.0.401" />
<PackageReference Include="FSharp.Core" Version="9.0.100" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseAppHost>false</UseAppHost>
Expand Down
2 changes: 1 addition & 1 deletion Backend/Sandbox/Shared/Shared.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>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>Sharp.Backend.Sandbox.Shared</AssemblyName>
Expand Down
6 changes: 4 additions & 2 deletions Bot/Sharp/Compilation/CSharpCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class CSharpCompiler : RoslynCompiler
allowUnsafe: true,
nullableContextOptions: NullableContextOptions.Enable);

private static readonly CSharpParseOptions _parseOptions = new(LanguageVersion.Preview);

private static CSharpCompilationOptions GetOptions(SyntaxTree syntaxTree, CompilationOutput? output)
{
if (output.HasValue)
Expand Down Expand Up @@ -53,14 +55,14 @@ private static SyntaxTree CreateGlobalUsingsSyntaxTree(params string[] namespace
stringBuilder.AppendLine();
}

return CSharpSyntaxTree.ParseText(stringBuilder.ToString());
return CSharpSyntaxTree.ParseText(stringBuilder.ToString(), _parseOptions);
}

public override Language Language => Language.CSharp;

protected override Microsoft.CodeAnalysis.Compilation CreateCompilation(string code, CompilationOutput? output)
{
var syntaxTree = CSharpSyntaxTree.ParseText(code);
var syntaxTree = CSharpSyntaxTree.ParseText(code, _parseOptions);

return CSharpCompilation.Create("_", [_globalUsingsSyntaxTree, syntaxTree], _references, GetOptions(syntaxTree, output));
}
Expand Down
8 changes: 4 additions & 4 deletions Bot/Sharp/Compilation/FSharpCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ static FSharpCompiler()
{
FileSystemAutoOpens.FileSystem = _fileSystem = new VirtualFileSystem();

var references = Net80.References.All.Select(r => r.FilePath!).Where(p => p is not "System.Runtime.dll").Select(p => $"-r:{p}");
_baseArguments = [string.Empty, "--targetprofile:netcore", "--noframework", "--nowin32manifest", .. references, $"-r:{typeof(JitGenericAttribute).Assembly.Location}"];
var references = Net90.References.All.Select(r => r.FilePath!).Where(p => p is not "System.Runtime.dll").Select(p => $"-r:{p}");
_baseArguments = [string.Empty, "--targetprofile:netcore", "--noframework", "--nowin32manifest" , "--checknulls", .. references, $"-r:{typeof(JitGenericAttribute).Assembly.Location}"];
}

private const string SourceName = "_.fs";
Expand Down Expand Up @@ -506,7 +506,7 @@ public override string NormalizePathShim(string path)
return base.NormalizePathShim(path);
}

public override Stream OpenFileForReadShim(string filePath, [OptionalArgument] FSharpOption<bool> useMemoryMappedFile, [OptionalArgument] FSharpOption<bool> shouldShadowCopy)
public override Stream OpenFileForReadShim(string filePath, [OptionalArgument] FSharpOption<bool>? useMemoryMappedFile, [OptionalArgument] FSharpOption<bool>? shouldShadowCopy)
{
if (TryGetVirtualPath(filePath.AsMemory(), out var virtualPath))
{
Expand All @@ -519,7 +519,7 @@ public override Stream OpenFileForReadShim(string filePath, [OptionalArgument] F
return base.OpenFileForReadShim(filePath, useMemoryMappedFile, shouldShadowCopy);
}

public override Stream OpenFileForWriteShim(string filePath, [OptionalArgument] FSharpOption<FileMode> fileMode, [OptionalArgument] FSharpOption<FileAccess> fileAccess, [OptionalArgument] FSharpOption<FileShare> fileShare)
public override Stream OpenFileForWriteShim(string filePath, FSharpOption<FileMode>? fileMode, FSharpOption<FileAccess>? fileAccess, FSharpOption<FileShare>? fileShare)
{
if (TryGetVirtualPath(filePath.AsMemory(), out var virtualPath))
{
Expand Down
2 changes: 1 addition & 1 deletion Bot/Sharp/Compilation/RoslynCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Sharp.Compilation;

public abstract class RoslynCompiler : ICompiler
{
protected static readonly MetadataReference[] _references = [.. Net80.References.All, MetadataReference.CreateFromFile(typeof(JitGenericAttribute).Assembly.Location)];
protected static readonly MetadataReference[] _references = [.. Net90.References.All, MetadataReference.CreateFromFile(typeof(JitGenericAttribute).Assembly.Location)];

public abstract Language Language { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Sharp.CompilationResponse;

public abstract record CompilationFormatResult
{
public record Success(EmbedProperties Embed, IEnumerable<MessageComponentProperties>? Components) : CompilationFormatResult;
public record Success(EmbedProperties Embed, IEnumerable<ComponentProperties>? Components) : CompilationFormatResult;

public record Expired : CompilationFormatResult;
}
Expand Down
2 changes: 1 addition & 1 deletion Bot/Sharp/Diagnostics/DiagnosticsFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public DiagnosticsFormatResult.Success FormatDiagnostics(ulong operationId, bool

var fields = CreateDiagnosticsFields(visibleDiagnostics, 1, embedContentLength, out var more);

IEnumerable<MessageComponentProperties>? components;
IEnumerable<ComponentProperties>? components;

if (more)
{
Expand Down
2 changes: 1 addition & 1 deletion Bot/Sharp/Diagnostics/IDiagnosticsFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Sharp.Diagnostics;

public abstract record DiagnosticsFormatResult
{
public record Success(List<EmbedFieldProperties> Fields, IEnumerable<MessageComponentProperties>? Components) : DiagnosticsFormatResult;
public record Success(List<EmbedFieldProperties> Fields, IEnumerable<ComponentProperties>? Components) : DiagnosticsFormatResult;

public record Expired : DiagnosticsFormatResult;
}
Expand Down
4 changes: 2 additions & 2 deletions Bot/Sharp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
WORKDIR /src

COPY Sharp.Runtime/Sharp.Runtime.csproj Sharp.Runtime/Sharp.Runtime.csproj
Expand All @@ -16,7 +16,7 @@ COPY Bot/Sharp Bot/Sharp

RUN dotnet publish Bot/Sharp/Sharp.csproj -c Release -o /app

FROM mcr.microsoft.com/dotnet/sdk:8.0
FROM mcr.microsoft.com/dotnet/sdk:9.0
WORKDIR /app

COPY --from=build-env /app .
Expand Down
25 changes: 12 additions & 13 deletions Bot/Sharp/Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseAppHost>false</UseAppHost>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.9" />
<PackageReference Include="Basic.Reference.Assemblies.Net90" Version="1.7.9" />
<PackageReference Include="ICSharpCode.Decompiler" Version="8.2.0.7535" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.11.0" />
<PackageReference Include="FSharp.Compiler.Service" Version="43.8.401" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="NetCord" Version="1.0.0-alpha.325" />
<PackageReference Include="NetCord.Services" Version="1.0.0-alpha.226" />
<PackageReference Include="NetCord.Hosting" Version="1.0.0-alpha.95" />
<PackageReference Include="NetCord.Hosting.Services" Version="1.0.0-alpha.104" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-3.final " />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.12.0-3.final " />
<PackageReference Include="FSharp.Compiler.Service" Version="43.9.100" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
<PackageReference Include="NetCord" Version="1.0.0-alpha.333" />
<PackageReference Include="NetCord.Services" Version="1.0.0-alpha.333" />
<PackageReference Include="NetCord.Hosting" Version="1.0.0-alpha.333" />
<PackageReference Include="NetCord.Hosting.Services" Version="1.0.0-alpha.333" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Sharp.Runtime/Sharp.Runtime.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>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Sharp</RootNamespace>
Expand Down

0 comments on commit 0edcbde

Please sign in to comment.