Skip to content

Commit f1deb82

Browse files
committed
Upgrade to .NET 8
1 parent d67d0b7 commit f1deb82

File tree

6 files changed

+28
-18
lines changed

6 files changed

+28
-18
lines changed

CSharpRepl.Tests/CSharpRepl.Tests.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
<PropertyGroup>
44
<EnablePreviewFeatures>true</EnablePreviewFeatures>
55
<LangVersion>preview</LangVersion>
6-
<TargetFramework>net7.0</TargetFramework>
6+
<TargetFramework>net8.0</TargetFramework>
77
<RootNamespace>CSDiscordService.Tests</RootNamespace>
88
</PropertyGroup>
99

1010
<ItemGroup>
1111
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1212
</ItemGroup>
1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.4" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
16-
<PackageReference Include="xunit" Version="2.4.2" />
17-
<PackageReference Include="xunit.runner.reporters" Version="2.4.2" />
18-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
14+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.0" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
16+
<PackageReference Include="xunit" Version="2.6.2" />
17+
<PackageReference Include="xunit.runner.reporters" Version="2.6.2" />
18+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
1919
<PrivateAssets>all</PrivateAssets>
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
2121
</PackageReference>

CSharpRepl.Tests/EvalTests.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,33 @@ public EvalTests(ITestOutputHelper outputHelper)
6969
[InlineData(@"var a = ""thing""; return a;", "thing", "string")]
7070
[InlineData("Math.Pow(1,2)", 1D, "double")]
7171
[InlineData(@"Enumerable.Range(0,1).Select(a=>""@"");", null, null)]
72-
[InlineData("typeof(int)", "System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", "RuntimeType")]
72+
[InlineData("typeof(int)", "System.Int32, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", "RuntimeType")]
7373
[InlineData("Assembly.GetExecutingAssembly()", true, "RuntimeAssembly")]
7474
[InlineData("TimeSpan.FromSeconds(2310293892)", "26739.12:18:12", "TimeSpan")]
7575
[InlineData("float.PositiveInfinity", "Infinity", "float")]
76+
[InlineData("List<int> l = [1, 2, 3]; l", "[1,2,3]", "List<int>")]
7677
public async Task Eval_WellFormattedCodeExecutes(string expr, object expected, string type)
7778
{
7879
var (result, statusCode) = await Execute(expr);
7980
var res = result.ReturnValue as JsonElement?;
8081
object convertedValue;
81-
if (expected is string || expected is null)
82+
if (res.Value.ValueKind == JsonValueKind.Array)
83+
{
84+
convertedValue = res.Value.GetRawText();
85+
}
86+
else if (expected is string || expected is null)
8287
{
8388
convertedValue = res?.GetString();
8489
}
8590
else if (res.Value.ValueKind == JsonValueKind.Object)
8691
{
8792
convertedValue = res.HasValue;
8893
}
94+
else if (result.ReturnTypeName == "RuntimeAssembly")
95+
{
96+
// nothing to do here, value is random for this test
97+
convertedValue = expected;
98+
}
8999
else
90100
{
91101
var value = res.Value.GetRawText();
@@ -186,8 +196,8 @@ public async Task Eval_ConsoleOutputIsCaptured(string expr, string consoleOut, o
186196
[Fact]
187197
public async Task Eval_LoadDLLThatExposesTypeOfADependency()
188198
{
189-
var expr = "#nuget CK.ActivityMonitor\nvar m = new ActivityMonitor();";
190-
var (_, statusCode) = await Execute(expr);
199+
var expr = "#nuget CK.ActivityMonitor\nvar m = new CK.Core.ActivityMonitor();";
200+
var (result, statusCode) = await Execute(expr);
191201

192202
Assert.Equal(HttpStatusCode.OK, statusCode);
193203
}

CSharpRepl/CSharpRepl.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<EnablePreviewFeatures>true</EnablePreviewFeatures>
55
<LangVersion>preview</LangVersion>
6-
<TargetFramework>net7.0</TargetFramework>
6+
<TargetFramework>net8.0</TargetFramework>
77
<OutputType>Exe</OutputType>
88
<UserSecretsId>03629088-8bb9-4faf-8162-debf93066bc4</UserSecretsId>
99
</PropertyGroup>
@@ -14,10 +14,10 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="AngouriMath" Version="1.3.0" />
17-
<PackageReference Include="ICSharpCode.Decompiler" Version="8.0.0.7313-preview4" />
18-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.5.0" />
17+
<PackageReference Include="ICSharpCode.Decompiler" Version="8.2.0.7535" />
18+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.8.0" />
1919
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
20-
<PackageReference Include="NuGet.Resolver" Version="6.5.0" />
20+
<PackageReference Include="NuGet.Resolver" Version="6.8.0" />
2121
<PackageReference Include="Seq.Extensions.Logging" Version="6.1.0" />
2222
</ItemGroup>
2323
<ItemGroup>

CSharpRepl/Eval/NugetDirectiveProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public async Task PreProcess(string directive, ScriptExecutionContext context, A
3232
{
3333
var actionLogger = new NugetLogger(logger);
3434
var nugetDirective = NugetPreProcessorDirective.Parse(directive);
35-
string frameworkName = Assembly.GetEntryAssembly()!.GetCustomAttributes(true)
35+
string frameworkName = typeof(NugetDirectiveProcessor).Assembly.GetCustomAttributes(true)
3636
.OfType<System.Runtime.Versioning.TargetFrameworkAttribute>()
3737
.Select(x => x.FrameworkName)
3838
.FirstOrDefault()!;

CSharpRepl/Infrastructure/JsonFormatters/TypeJsonConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializer
122122

123123
public class AssemblyJsonConverterFactory : JsonConverterFactory
124124
{
125-
public override bool CanConvert(Type typeToConvert) => typeToConvert == Type.GetType("System.RuntimeAssembly");
125+
public override bool CanConvert(Type typeToConvert) => typeToConvert == Type.GetType("System.Reflection.RuntimeAssembly");
126126
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
127127
{
128128
return new RuntimeAssemblyJsonConverter();

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:7.0 as dotnet-build
1+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 as dotnet-build
22
ARG TARGETPLATFORM
33
ARG BUILDPLATFORM
44
WORKDIR /src
@@ -10,7 +10,7 @@ RUN dotnet build --configuration Release --no-restore
1010
#RUN dotnet test --configuration Release CSharpRepl.Tests/CSharpRepl.Tests.csproj --no-build --no-restore
1111
RUN dotnet publish --configuration Release CSharpRepl/CSharpRepl.csproj --no-build --no-restore -o /app
1212

13-
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:7.0
13+
FROM --platform=$TARGETPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0
1414
ARG TARGETPLATFORM
1515
ARG BUILDPLATFORM
1616
WORKDIR /app

0 commit comments

Comments
 (0)