Skip to content

Commit

Permalink
Add support for .NET 9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkl committed Sep 9, 2024
1 parent 24293e7 commit 0931e8d
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 116 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,35 @@ jobs:
with:
fetch-depth: 0

- name: Install .NET SDKs
- name: Install .NET 6.x and 8.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
8.x
- name: Install .NET 9.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
dotnet-quality: 'preview'

- name: Build Solution
run: dotnet build "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/build.binlog"

- name: Run Unit Tests (.NET Framework)
if: ${{ matrix.name == 'Windows' }}
run: dotnet test ${{ env.CommonTestArguments }} ${{ matrix.TestArguments}} --framework net472 "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/test-net472.binlog"

- name: Run Unit Tests (.NET 6)
- name: Run Unit Tests (.NET 6.0)
run: dotnet test ${{ env.CommonTestArguments }} ${{ matrix.TestArguments}} --framework net6.0 "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/test-net6.0.binlog"

- name: Run Unit Tests (.NET 8)
- name: Run Unit Tests (.NET 8.0)
run: dotnet test ${{ env.CommonTestArguments }} ${{ matrix.TestArguments}} --framework net8.0 "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/test-net8.0.binlog"

- name: Run Unit Tests (.NET 9.0)
run: dotnet test ${{ env.CommonTestArguments }} ${{ matrix.TestArguments}} --framework net9.0 "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/test-net9.0.binlog"

- name: Code Coverage Report
if: ${{ matrix.name == 'Linux' }}
uses: irongut/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- name: Install .NET SDKs
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.x
dotnet-version: 9.x
dotnet-quality: 'preview'

- name: Build Solution
run: dotnet build "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}\build.binlog"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0;net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net8.0;net9.0</TargetFrameworks>
<Description>Provides implementations of IEnvironmentVariableProvider so that unit tests can mock calls that retrieve environment variable.</Description>
<PackageTags>Environment Variable Abstraction env var test helper</PackageTags>
<ArtifactsPath>$(BaseArtifactsPath)\$(MSBuildProjectName)\</ArtifactsPath>
Expand Down
16 changes: 16 additions & 0 deletions src/EnvironmentAbstractions.TestHelpers/MockEnvironmentProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ public MockEnvironmentProvider(bool useExistingEnvironmentValues = true, bool ad
if (useExistingEnvironmentValues)
{
CommandLine = Environment.CommandLine;
#if NET9_0_OR_GREATER
CpuUsage = Environment.CpuUsage;
#endif
CurrentDirectory = Environment.CurrentDirectory;
CurrentManagedThreadId = Environment.CurrentManagedThreadId;
ExitCode = Environment.ExitCode;
HasShutdownStarted = Environment.HasShutdownStarted;
Is64BitOperatingSystem = Environment.Is64BitOperatingSystem;
Is64BitProcess = Environment.Is64BitProcess;
#if NET9_0_OR_GREATER
IsPrivilegedProcess = Environment.IsPrivilegedProcess;
#endif
MachineName = Environment.MachineName;
NewLine = Environment.NewLine;
OSVersion = Environment.OSVersion;
Expand Down Expand Up @@ -88,6 +94,11 @@ public MockEnvironmentProvider(bool useExistingEnvironmentValues = true, bool ad
/// <inheritdoc />
public string CommandLine { get; set; }

#if NET9_0_OR_GREATER
/// <inheritdoc />
public Environment.ProcessCpuUsage CpuUsage { get; set; }
#endif

/// <inheritdoc />
public string CurrentDirectory { get; set; }

Expand All @@ -106,6 +117,11 @@ public MockEnvironmentProvider(bool useExistingEnvironmentValues = true, bool ad
/// <inheritdoc />
public bool Is64BitProcess { get; set; }

#if NET9_0_OR_GREATER
/// <inheritdoc />
public bool IsPrivilegedProcess { get; }
#endif

/// <inheritdoc />
public string MachineName { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#nullable enable
EnvironmentAbstractions.TestHelpers.MockEnvironmentVariableProvider
EnvironmentAbstractions.TestHelpers.MockEnvironmentVariableProvider.Add(string! name, string? value) -> void
EnvironmentAbstractions.TestHelpers.MockEnvironmentVariableProvider.ExpandEnvironmentVariables(string! name) -> string?
EnvironmentAbstractions.TestHelpers.MockEnvironmentVariableProvider.GetEnvironmentVariable(string! name) -> string?
EnvironmentAbstractions.TestHelpers.MockEnvironmentVariableProvider.GetEnvironmentVariable(string! name, System.EnvironmentVariableTarget target) -> string?
EnvironmentAbstractions.TestHelpers.MockEnvironmentVariableProvider.GetEnvironmentVariables() -> System.Collections.Generic.IReadOnlyDictionary<string!, string!>!
EnvironmentAbstractions.TestHelpers.MockEnvironmentVariableProvider.GetEnvironmentVariables(System.EnvironmentVariableTarget target) -> System.Collections.Generic.IReadOnlyDictionary<string!, string!>!
EnvironmentAbstractions.TestHelpers.MockEnvironmentVariableProvider.MockEnvironmentVariableProvider(bool addExistingEnvironmentVariables = false) -> void
EnvironmentAbstractions.TestHelpers.MockEnvironmentVariableProvider.SetEnvironmentVariable(string! name, string? value) -> void
EnvironmentAbstractions.TestHelpers.MockEnvironmentVariableProvider.SetEnvironmentVariable(string! name, string? value, System.EnvironmentVariableTarget target) -> void
EnvironmentAbstractions.TestHelpers.MockEnvironmentVariableProvider.this[string! name].get -> string?
EnvironmentAbstractions.TestHelpers.MockEnvironmentVariableProvider.this[string! name].set -> void
System.MockEnvironmentProvider
System.MockEnvironmentProvider.CommandLine.get -> string!
System.MockEnvironmentProvider.CommandLine.set -> void
System.MockEnvironmentProvider.CpuUsage.get -> System.Environment.ProcessCpuUsage
System.MockEnvironmentProvider.CpuUsage.set -> void
System.MockEnvironmentProvider.CurrentDirectory.get -> string!
System.MockEnvironmentProvider.CurrentDirectory.set -> void
System.MockEnvironmentProvider.CurrentManagedThreadId.get -> int
System.MockEnvironmentProvider.CurrentManagedThreadId.set -> void
System.MockEnvironmentProvider.Exit(int exitCode) -> void
System.MockEnvironmentProvider.ExitCode.get -> int
System.MockEnvironmentProvider.ExitCode.set -> void
System.MockEnvironmentProvider.FailFast(string? message) -> void
System.MockEnvironmentProvider.FailFast(string? message, System.Exception? exception) -> void
System.MockEnvironmentProvider.GetCommandLineArgs() -> string![]!
System.MockEnvironmentProvider.GetFolderPath(System.Environment.SpecialFolder folder) -> string!
System.MockEnvironmentProvider.GetFolderPath(System.Environment.SpecialFolder folder, System.Environment.SpecialFolderOption option) -> string!
System.MockEnvironmentProvider.GetLogicalDrives() -> string![]!
System.MockEnvironmentProvider.HasShutdownStarted.get -> bool
System.MockEnvironmentProvider.HasShutdownStarted.set -> void
System.MockEnvironmentProvider.Is64BitOperatingSystem.get -> bool
System.MockEnvironmentProvider.Is64BitOperatingSystem.set -> void
System.MockEnvironmentProvider.Is64BitProcess.get -> bool
System.MockEnvironmentProvider.Is64BitProcess.set -> void
System.MockEnvironmentProvider.IsPrivilegedProcess.get -> bool
System.MockEnvironmentProvider.MachineName.get -> string!
System.MockEnvironmentProvider.MachineName.set -> void
System.MockEnvironmentProvider.MockEnvironmentProvider(bool useExistingEnvironmentValues = true, bool addExistingEnvironmentVariables = false) -> void
System.MockEnvironmentProvider.NewLine.get -> string!
System.MockEnvironmentProvider.NewLine.set -> void
System.MockEnvironmentProvider.OSVersion.get -> System.OperatingSystem!
System.MockEnvironmentProvider.OSVersion.set -> void
System.MockEnvironmentProvider.ProcessId.get -> int
System.MockEnvironmentProvider.ProcessId.set -> void
System.MockEnvironmentProvider.ProcessorCount.get -> int
System.MockEnvironmentProvider.ProcessorCount.set -> void
System.MockEnvironmentProvider.ProcessPath.get -> string?
System.MockEnvironmentProvider.ProcessPath.set -> void
System.MockEnvironmentProvider.SetCommandLineArgs(string![]! args) -> void
System.MockEnvironmentProvider.SetFolderPath(System.Environment.SpecialFolder folder, string! path) -> void
System.MockEnvironmentProvider.SetLogicalDrives(string![]! drives) -> void
System.MockEnvironmentProvider.StackTrace.get -> string!
System.MockEnvironmentProvider.StackTrace.set -> void
System.MockEnvironmentProvider.SystemDirectory.get -> string!
System.MockEnvironmentProvider.SystemDirectory.set -> void
System.MockEnvironmentProvider.SystemPageSize.get -> int
System.MockEnvironmentProvider.SystemPageSize.set -> void
System.MockEnvironmentProvider.TickCount.get -> int
System.MockEnvironmentProvider.TickCount.set -> void
System.MockEnvironmentProvider.TickCount64.get -> long
System.MockEnvironmentProvider.TickCount64.set -> void
System.MockEnvironmentProvider.UserDomainName.get -> string!
System.MockEnvironmentProvider.UserDomainName.set -> void
System.MockEnvironmentProvider.UserInteractive.get -> bool
System.MockEnvironmentProvider.UserInteractive.set -> void
System.MockEnvironmentProvider.UserName.get -> string!
System.MockEnvironmentProvider.UserName.set -> void
System.MockEnvironmentProvider.Version.get -> System.Version!
System.MockEnvironmentProvider.Version.set -> void
System.MockEnvironmentProvider.WorkingSet.get -> long
System.MockEnvironmentProvider.WorkingSet.set -> void
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0;net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/EnvironmentAbstractions/EnvironmentAbstractions.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net8.0;net9.0</TargetFrameworks>
<Description>Provides an abstraction for retrieving environment variable so that these calls can be made to be more testable.</Description>
<PackageTags>Environment Variable Abstraction env var</PackageTags>
<ArtifactsPath>$(BaseArtifactsPath)\$(MSBuildProjectName)\</ArtifactsPath>
Expand Down
10 changes: 10 additions & 0 deletions src/EnvironmentAbstractions/IEnvironmentProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public interface IEnvironmentProvider : IEnvironmentVariableProvider
/// <inheritdoc cref="Environment.CommandLine" />
string CommandLine { get; }

#if NET9_0_OR_GREATER
/// <inheritdoc cref="Environment.CpuUsage" />
Environment.ProcessCpuUsage CpuUsage { get; }
#endif

/// <inheritdoc cref="Environment.CurrentDirectory" />
string CurrentDirectory { get; set; }

Expand All @@ -30,6 +35,11 @@ public interface IEnvironmentProvider : IEnvironmentVariableProvider
/// <inheritdoc cref="Environment.Is64BitProcess" />
bool Is64BitProcess { get; }

#if NET9_0_OR_GREATER
/// <inheritdoc cref="Environment.IsPrivilegedProcess" />
bool IsPrivilegedProcess { get; }
#endif

/// <inheritdoc cref="Environment.MachineName" />
string MachineName { get; }

Expand Down
18 changes: 0 additions & 18 deletions src/EnvironmentAbstractions/PublicAPI/net5.0/PublicAPI.Shipped.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#nullable enable
static System.SystemEnvironmentProvider.Instance.get -> System.IEnvironmentProvider!
static System.SystemEnvironmentVariableProvider.Instance.get -> System.IEnvironmentVariableProvider!
System.IEnvironmentProvider
System.IEnvironmentProvider.CommandLine.get -> string!
System.IEnvironmentProvider.CpuUsage.get -> System.Environment.ProcessCpuUsage
System.IEnvironmentProvider.CurrentDirectory.get -> string!
System.IEnvironmentProvider.CurrentDirectory.set -> void
System.IEnvironmentProvider.CurrentManagedThreadId.get -> int
Expand All @@ -16,11 +18,13 @@ System.IEnvironmentProvider.GetLogicalDrives() -> string![]!
System.IEnvironmentProvider.HasShutdownStarted.get -> bool
System.IEnvironmentProvider.Is64BitOperatingSystem.get -> bool
System.IEnvironmentProvider.Is64BitProcess.get -> bool
System.IEnvironmentProvider.IsPrivilegedProcess.get -> bool
System.IEnvironmentProvider.MachineName.get -> string!
System.IEnvironmentProvider.NewLine.get -> string!
System.IEnvironmentProvider.OSVersion.get -> System.OperatingSystem!
System.IEnvironmentProvider.ProcessId.get -> int
System.IEnvironmentProvider.ProcessorCount.get -> int
System.IEnvironmentProvider.ProcessPath.get -> string?
System.IEnvironmentProvider.StackTrace.get -> string!
System.IEnvironmentProvider.SystemDirectory.get -> string!
System.IEnvironmentProvider.SystemPageSize.get -> int
Expand All @@ -31,8 +35,17 @@ System.IEnvironmentProvider.UserInteractive.get -> bool
System.IEnvironmentProvider.UserName.get -> string!
System.IEnvironmentProvider.Version.get -> System.Version!
System.IEnvironmentProvider.WorkingSet.get -> long
System.IEnvironmentVariableProvider
System.IEnvironmentVariableProvider.ExpandEnvironmentVariables(string! name) -> string?
System.IEnvironmentVariableProvider.GetEnvironmentVariable(string! name) -> string?
System.IEnvironmentVariableProvider.GetEnvironmentVariable(string! name, System.EnvironmentVariableTarget target) -> string?
System.IEnvironmentVariableProvider.GetEnvironmentVariables() -> System.Collections.Generic.IReadOnlyDictionary<string!, string!>!
System.IEnvironmentVariableProvider.GetEnvironmentVariables(System.EnvironmentVariableTarget target) -> System.Collections.Generic.IReadOnlyDictionary<string!, string!>!
System.IEnvironmentVariableProvider.SetEnvironmentVariable(string! name, string? value) -> void
System.IEnvironmentVariableProvider.SetEnvironmentVariable(string! name, string? value, System.EnvironmentVariableTarget target) -> void
System.SystemEnvironmentProvider
System.SystemEnvironmentProvider.CommandLine.get -> string!
System.SystemEnvironmentProvider.CpuUsage.get -> System.Environment.ProcessCpuUsage
System.SystemEnvironmentProvider.CurrentDirectory.get -> string!
System.SystemEnvironmentProvider.CurrentDirectory.set -> void
System.SystemEnvironmentProvider.CurrentManagedThreadId.get -> int
Expand All @@ -53,11 +66,13 @@ System.SystemEnvironmentProvider.GetLogicalDrives() -> string![]!
System.SystemEnvironmentProvider.HasShutdownStarted.get -> bool
System.SystemEnvironmentProvider.Is64BitOperatingSystem.get -> bool
System.SystemEnvironmentProvider.Is64BitProcess.get -> bool
System.SystemEnvironmentProvider.IsPrivilegedProcess.get -> bool
System.SystemEnvironmentProvider.MachineName.get -> string!
System.SystemEnvironmentProvider.NewLine.get -> string!
System.SystemEnvironmentProvider.OSVersion.get -> System.OperatingSystem!
System.SystemEnvironmentProvider.ProcessId.get -> int
System.SystemEnvironmentProvider.ProcessorCount.get -> int
System.SystemEnvironmentProvider.ProcessPath.get -> string?
System.SystemEnvironmentProvider.SetEnvironmentVariable(string! name, string? value) -> void
System.SystemEnvironmentProvider.SetEnvironmentVariable(string! name, string? value, System.EnvironmentVariableTarget target) -> void
System.SystemEnvironmentProvider.StackTrace.get -> string!
Expand All @@ -71,3 +86,11 @@ System.SystemEnvironmentProvider.UserInteractive.get -> bool
System.SystemEnvironmentProvider.UserName.get -> string!
System.SystemEnvironmentProvider.Version.get -> System.Version!
System.SystemEnvironmentProvider.WorkingSet.get -> long
System.SystemEnvironmentVariableProvider
System.SystemEnvironmentVariableProvider.ExpandEnvironmentVariables(string! name) -> string?
System.SystemEnvironmentVariableProvider.GetEnvironmentVariable(string! name) -> string?
System.SystemEnvironmentVariableProvider.GetEnvironmentVariable(string! name, System.EnvironmentVariableTarget target) -> string?
System.SystemEnvironmentVariableProvider.GetEnvironmentVariables() -> System.Collections.Generic.IReadOnlyDictionary<string!, string!>!
System.SystemEnvironmentVariableProvider.GetEnvironmentVariables(System.EnvironmentVariableTarget target) -> System.Collections.Generic.IReadOnlyDictionary<string!, string!>!
System.SystemEnvironmentVariableProvider.SetEnvironmentVariable(string! name, string? value) -> void
System.SystemEnvironmentVariableProvider.SetEnvironmentVariable(string! name, string? value, System.EnvironmentVariableTarget target) -> void
Loading

0 comments on commit 0931e8d

Please sign in to comment.