Skip to content

Commit

Permalink
Update the TFMs (#146)
Browse files Browse the repository at this point in the history
* initial move to net9.0

* Deal with NuGet vulnerabilities

* fix build errors

* fix unit tests
  • Loading branch information
jaredpar committed Jul 25, 2024
1 parent 9d78014 commit 5ccbd34
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 46 deletions.
12 changes: 5 additions & 7 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
FROM mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm
FROM mcr.microsoft.com/devcontainers/dotnet:8.0

RUN wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
sudo dpkg -i packages-microsoft-prod.deb && \
rm packages-microsoft-prod.deb

RUN sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-7.0
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && \
chmod +x dotnet-install.sh && \
./dotnet-install.sh --channel 9.0 --version latest --quality preview --install-dir /usr/share/dotnet && \
rm dotnet-install.sh
8 changes: 4 additions & 4 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
7.0.x
8.0.x
9.0.x
- name: Restore dependencies
run: dotnet restore
Expand All @@ -58,23 +58,23 @@ jobs:

- name: Test Linux
run: >
dotnet test --no-build --framework net7.0
dotnet test --no-build --framework net8.0
--logger "console;verbosity=detailed"
--logger "trx;LogFileName=${{ env.TEST_RESULTS_PATH }}/TestResults-Linux.trx"
-p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=${{ env.TEST_COVERAGE_PATH }}/coverage.linux.xml
if: matrix.os == 'ubuntu-latest'

- name: Test Windows .NET Core
run: >
dotnet test --no-build --framework net7.0
dotnet test --no-build --framework net8.0
--logger "console;verbosity=detailed"
--logger "trx;LogFileName=${{ env.TEST_RESULTS_PATH}}/TestResults-Windows-Core.trx"
-p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=${{ env.TEST_COVERAGE_PATH }}/coverage.windows.core.xml
if: matrix.os == 'windows-latest'

- name: Test Windows .NET Framework
run: >
dotnet test --no-build --framework net7.0
dotnet test --no-build --framework net8.0
--logger "console;verbosity=detailed"
--logger "trx;LogFileName=${{ env.TEST_RESULTS_PATH}}/TestResults-Windows-Framework.trx"
-p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=${{ env.TEST_COVERAGE_PATH }}/coverage.windows.framework.xml
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/Basic.CompilerLog/debug_net7.0/Basic.CompilerLog.dll",
"program": "${workspaceFolder}/artifacts/bin/Basic.CompilerLog/debug_net8.0/Basic.CompilerLog.dll",
"args": ["print", ".\\msbuild.binlog" ],
"cwd": "e:\\temp\\console",
// "cwd": "${workspaceFolder}/src/Basic.CompilerLog",
Expand Down
21 changes: 12 additions & 9 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<_RoslynVersion>4.10.0</_RoslynVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Basic.Reference.Assemblies.Net60" Version="1.6.0" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.5" />
<PackageVersion Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.5" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.0" />
<PackageVersion Include="MessagePack" Version="2.5.129" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.9.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.9.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.9.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Features" Version="4.9.2" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="$(_RoslynVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(_RoslynVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="$(_RoslynVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="$(_RoslynVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Features" Version="$(_RoslynVersion)" />
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="7.0.13" />
<PackageVersion Include="Microsoft.NET.Test.SDK" Version="17.1.0" />
<PackageVersion Include="Microsoft.IO.Redist" Version="6.0.1" />
<PackageVersion Include="Microsoft.NET.Test.SDK" Version="17.10.0" />
<PackageVersion Include="Mono.Options" Version="6.12.0.148" />
<PackageVersion Include="MSBuild.StructuredLogger" Version="2.2.235" />
<PackageVersion Include="MSBuild.StructuredLogger" Version="2.2.243" />
<PackageVersion Include="System.Buffers" Version="4.5.1" />
<PackageVersion Include="System.IO.Compression" Version="4.3.0" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
<PackageVersion Include="xunit" Version="2.9.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="Xunit.Combinatorial" Version="1.6.24" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net472</TargetFrameworks>
<TargetFrameworks>net8.0;net472</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>CS0436</NoWarn>
Expand All @@ -15,7 +15,7 @@
<Compile Include="..\Shared\PathUtil.cs" Link="PathUtil.cs" />
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
<ProjectReference Include="..\Basic.CompilerLog.Util\Basic.CompilerLog.Util.csproj" />
<ProjectReference Include="..\Basic.CompilerLog\Basic.CompilerLog.csproj" Condition="'$(TargetFramework)' == 'net7.0'" />
<ProjectReference Include="..\Basic.CompilerLog\Basic.CompilerLog.csproj" Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageReference Include="Basic.Reference.Assemblies.Net60" />
<PackageReference Include="coverlet.msbuild" >
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -24,7 +24,9 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Features" />
<PackageReference Include="System.Buffers" />
<PackageReference Include="System.Text.Json" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.IO.Redist" Condition="'$(TargetFramework)' == 'net472'" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" >
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
14 changes: 7 additions & 7 deletions src/Basic.CompilerLog.UnitTests/CompilerLogFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public CompilerLogFixture(IMessageSink messageSink)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down Expand Up @@ -140,7 +140,7 @@ partial class Util {
var projectFileContent = """
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -165,7 +165,7 @@ partial class Util {
var projectFileContent = """
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ProduceOnlyReferenceAssembly>true</ProduceOnlyReferenceAssembly>
Expand Down Expand Up @@ -207,7 +207,7 @@ End Module
<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>vbconsole</RootNamespace>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<EmbedAllSources>true</EmbedAllSources>
</PropertyGroup>
</Project>
Expand All @@ -223,7 +223,7 @@ End Module
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EmbedAllSources>true</EmbedAllSources>
Expand Down Expand Up @@ -322,7 +322,7 @@ This is an awesome resource

ClassLib = WithBuild("classlib.complog", void (string scratchPath) =>
{
RunDotnetCommand($"new classlib --name classlib --output . --framework net7.0", scratchPath);
RunDotnetCommand($"new classlib --name classlib --output . --framework net8.0", scratchPath);
var program = """
using System;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -359,7 +359,7 @@ Lazy<LogData> WithBuild(string name, Action<string> action, bool expectDiagnosti
var scratchPath = Path.Combine(ScratchDirecectory, Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(scratchPath);
messageSink.OnDiagnosticMessage($"Starting {name} in {scratchPath}");
RunDotnetCommand("new globaljson --sdk-version 7.0.400", scratchPath);
RunDotnetCommand("new globaljson --sdk-version 8.0.300", scratchPath);
action(scratchPath);
var binlogFilePath = Path.Combine(scratchPath, "msbuild.binlog");
Assert.True(File.Exists(binlogFilePath));
Expand Down
6 changes: 3 additions & 3 deletions src/Basic.CompilerLog.UnitTests/CompilerLogReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public void ProjectSingleTarget()
using var reader = CompilerLogReader.Create(Fixture.ClassLib.Value.CompilerLogPath);
var list = reader.ReadAllCompilationData();
Assert.Single(list);
Assert.NotNull(list.Single(x => x.CompilerCall.TargetFramework == "net7.0"));
Assert.NotNull(list.Single(x => x.CompilerCall.TargetFramework == "net8.0"));
}

[Fact]
Expand All @@ -287,7 +287,7 @@ public void ProjectMultiTarget()
var list = reader.ReadAllCompilationData();
Assert.Equal(2, list.Count);
Assert.NotNull(list.Single(x => x.CompilerCall.TargetFramework == "net6.0"));
Assert.NotNull(list.Single(x => x.CompilerCall.TargetFramework == "net7.0"));
Assert.NotNull(list.Single(x => x.CompilerCall.TargetFramework == "net8.0"));
}

[Fact]
Expand Down Expand Up @@ -346,7 +346,7 @@ public void NoneHostNativePdb()
<PropertyGroup>
<OutputType>Exe</OutputType>
<DebugType>Full</DebugType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
16 changes: 8 additions & 8 deletions src/Basic.CompilerLog.UnitTests/ProgramTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public void ResponseMultiTarget()
var exitCode = RunCompLog($"rsp {Fixture.ClassLibMultiProjectPath}");
Assert.Equal(Constants.ExitSuccess, exitCode);
Assert.True(File.Exists(Path.Combine(RootDirectory, @".complog", "rsp", "classlibmulti-net6.0", "build.rsp")));
Assert.True(File.Exists(Path.Combine(RootDirectory, @".complog", "rsp", "classlibmulti-net7.0", "build.rsp")));
Assert.True(File.Exists(Path.Combine(RootDirectory, @".complog", "rsp", "classlibmulti-net8.0", "build.rsp")));
}

[Fact]
Expand Down Expand Up @@ -410,7 +410,7 @@ public void ResponseInlineMultiTarget()
Assert.Equal(Constants.ExitSuccess, exitCode);
Assert.Contains("Generating response files inline", output);
Assert.True(File.Exists(Path.Combine(dir, "build-net6.0.rsp")));
Assert.True(File.Exists(Path.Combine(dir, "build-net7.0.rsp")));
Assert.True(File.Exists(Path.Combine(dir, "build-net8.0.rsp")));
}

[Fact]
Expand Down Expand Up @@ -694,17 +694,17 @@ public void PrintAll()
{
var (exitCode, output) = RunCompLogEx($"print {Fixture.SolutionBinaryLogPath}");
Assert.Equal(Constants.ExitSuccess, exitCode);
Assert.Contains("console.csproj (net7.0)", output);
Assert.Contains("classlib.csproj (net7.0)", output);
Assert.Contains("console.csproj (net8.0)", output);
Assert.Contains("classlib.csproj (net8.0)", output);
}

[Fact]
public void PrintOne()
{
var (exitCode, output) = RunCompLogEx($"print {Fixture.SolutionBinaryLogPath} -p classlib.csproj");
Assert.Equal(Constants.ExitSuccess, exitCode);
Assert.DoesNotContain("console.csproj (net7.0)", output);
Assert.Contains("classlib.csproj (net7.0)", output);
Assert.DoesNotContain("console.csproj (net8.0)", output);
Assert.Contains("classlib.csproj (net8.0)", output);
}

[Fact]
Expand Down Expand Up @@ -778,9 +778,9 @@ public void PrintKinds()
[Fact]
public void PrintFrameworks()
{
var (exitCode, output) = RunCompLogEx($"print --include {Fixture.ClassLibMultiProjectPath} --framework net7.0");
var (exitCode, output) = RunCompLogEx($"print --include {Fixture.ClassLibMultiProjectPath} --framework net8.0");
Assert.Equal(Constants.ExitSuccess, exitCode);
Assert.Contains("(net7.0)", output);
Assert.Contains("(net8.0)", output);
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions src/Basic.CompilerLog.UnitTests/SolutionFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public SolutionFixture(IMessageSink messageSink)
var binlogDir = Path.Combine(StorageDirectory, "binlogs");
Directory.CreateDirectory(binlogDir);

RunDotnetCommand("new globaljson --sdk-version 7.0.400", StorageDirectory);
RunDotnetCommand("new globaljson --sdk-version 8.0.300", StorageDirectory);
RunDotnetCommand("dotnet new sln -n Solution", StorageDirectory);

var builder = ImmutableArray.CreateBuilder<string>();
Expand Down Expand Up @@ -98,7 +98,7 @@ partial class Util {
var projectFileContent = """
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Basic.CompilerLog.Util/Basic.CompilerLog.Util.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net472;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net472;netstandard2.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DebugType>embedded</DebugType>
Expand All @@ -22,6 +22,7 @@
<PackageReference Include="Microsoft.Extensions.ObjectPool" />
<PackageReference Include="MSBuild.StructuredLogger" />
<PackageReference Include="System.IO.Compression" Condition="'$(TargetFramework)' == 'net472'" />
<PackageReference Include="Microsoft.IO.Redist" Condition="'$(TargetFramework)' == 'net472'" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions src/Basic.CompilerLog.Util/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ internal static string ReadLineOrThrow(this TextReader reader)
throw new InvalidOperationException();
}

#if !NET
internal static void AddRange<T>(this List<T> list, ReadOnlySpan<T> span)
{
foreach (var item in span)
{
list.Add(item);
}
}
#endif

/// <summary>
/// Creates a <see cref="MemoryStream"/> that is a simple wrapper around the array. The intent
Expand Down
3 changes: 2 additions & 1 deletion src/Basic.CompilerLog/Basic.CompilerLog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -33,6 +33,7 @@
<Content Include="..\..\LICENSE" PackagePath="\" />
<PackageReference Include="Mono.Options" />
<ProjectReference Include="..\Basic.CompilerLog.Util\Basic.CompilerLog.Util.csproj" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion src/Scratch/Scratch.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>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -21,6 +21,7 @@
<PackageReference Include="Basic.Reference.Assemblies.Net60" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Features" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>

</Project>

0 comments on commit 5ccbd34

Please sign in to comment.