Skip to content

Commit

Permalink
Update packages, drop support for .NET Core 3, add .NET 8 (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkl authored Nov 2, 2023
1 parent af6b674 commit 108540c
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 105 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install .NET SDKs
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-quality: 'preview'
dotnet-version: |
3.x
6.x
7.x
8.x
- name: Build Solution
run: dotnet build "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/build.binlog"
Expand All @@ -60,12 +61,15 @@ jobs:
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 Core 3.1)
run: dotnet test ${{ env.CommonTestArguments }} ${{ matrix.TestArguments}} --framework netcoreapp3.1 "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/test-netcoreapp3.1.binlog"

- name: Run Unit Tests (.NET 6)
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 7)
run: dotnet test ${{ env.CommonTestArguments }} ${{ matrix.TestArguments}} --framework net7.0 "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/test-net7.0.binlog"

- name: Run Unit Tests (.NET 8)
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: Code Coverage Report
if: ${{ matrix.name == 'Linux' }}
uses: irongut/[email protected]
Expand All @@ -83,15 +87,15 @@ jobs:
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY

- name: Upload Test Results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: test-results-${{ matrix.name }}
path: '**/TestResults/*.trx'
if-no-files-found: error

- name: Upload Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: ${{ env.ArtifactsDirectoryName }}-${{ matrix.name }}
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/Official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,22 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install .NET SDKs
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-quality: 'preview'
dotnet-version: |
3.x
6.x
7.x
8.x
- name: Build Solution
run: dotnet build "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}\build.binlog"

- name: Upload Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: ${{ env.ArtifactsDirectoryName }}
Expand Down
12 changes: 5 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<XunitRunnerVisualStudioVersion>2.5.3</XunitRunnerVisualStudioVersion>
<XunitRunnerVisualStudioVersion Condition="'$(TargetFramework)' == 'netcoreapp3.1'">2.4.5</XunitRunnerVisualStudioVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="Moq" Version="4.20.69" />
<PackageVersion Include="Shouldly" Version="4.2.1" />
<PackageVersion Include="xunit" Version="2.5.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />
<PackageVersion Include="xunit" Version="2.6.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>
<ItemGroup>
<GlobalPackageReference Include="Microsoft.Build.Artifacts" Version="6.0.6" />
<GlobalPackageReference Include="Microsoft.Build.Artifacts" Version="6.1.2" />
<GlobalPackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" Condition="'$(EnablePublicApiAnalyzers)' == 'true'" />
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" />
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<GlobalPackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" Condition="'$(EnablePublicApiAnalyzers)' == 'true'" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)build\stylecop.json" Visible="false" />
<Compile Include="$(MSBuildThisFileDirectory)src\GlobalSuppressions.cs" Condition="'$(UsingMicrosoftNoTargetsSdk)' != 'true'" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0;net7.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Shouldly" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="coverlet.collector" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EnvironmentAbstractions.TestHelpers\EnvironmentAbstractions.TestHelpers.csproj" />
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;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0;net7.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ public void GetEnvironmentVariablesWrapperContainsKeyReturnsSameValueAsGetEnviro
}
}

[Fact]
public void GetEnvironmentVariablesWrapperCountSameAsGetEnvironmentVariables()
{
GetEnvironmentVariablesWrapper actual = new GetEnvironmentVariablesWrapper();

IDictionary expected = Environment.GetEnvironmentVariables();

actual.ToDictionary(i => i.Key, i => i.Value).ShouldBe(expected.Cast<DictionaryEntry>().ToDictionary(i => (string)i.Key, i => (string)i.Value!));

actual.Count.ShouldBe(expected.Count);
}

[Fact]
public void GetEnvironmentVariablesWrapperEnumerateSeveralTimes()
{
Expand Down Expand Up @@ -112,7 +100,7 @@ public void GetEnvironmentVariablesWrapperTryGetValueReturnsSameValueAsGetEnviro

foreach (KeyValuePair<string, string> environmentVariable in Environment.GetEnvironmentVariables().Cast<DictionaryEntry>().Select(i => new KeyValuePair<string, string>((string)i.Key, (string)i.Value!)))
{
wrapper.TryGetValue(environmentVariable.Key, out string actual).ShouldBeTrue();
wrapper.TryGetValue(environmentVariable.Key, out string actual).ShouldBeTrue($"{environmentVariable.Key} should exist");

actual.ShouldBe(environmentVariable.Value);
}
Expand Down
3 changes: 1 addition & 2 deletions src/EnvironmentAbstractions/EnvironmentAbstractions.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net7.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>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RootNamespace>System</RootNamespace>
<EnablePublicApiAnalyzers>true</EnablePublicApiAnalyzers>
<NoWarn Condition="'$(TargetFramework)' == 'net5.0'">$(NoWarn);NETSDK1138</NoWarn>
</PropertyGroup>
<ItemGroup>
<InternalsVisibleTo Include="EnvironmentAbstractions.UnitTests" />
Expand Down
126 changes: 63 additions & 63 deletions src/EnvironmentAbstractions/IEnvironmentProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,102 +7,102 @@ namespace System
/// <summary>
/// Provides information about, and means to manipulate, the current environment and platform.
/// </summary>
public interface IEnvironmentProvider : IEnvironmentVariableProvider
{
/// <inheritdoc cref="Environment.CommandLine" />
string CommandLine { get; }
public interface IEnvironmentProvider : IEnvironmentVariableProvider
{
/// <inheritdoc cref="Environment.CommandLine" />
string CommandLine { get; }

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

/// <inheritdoc cref="Environment.CurrentManagedThreadId" />
int CurrentManagedThreadId { get; }
/// <inheritdoc cref="Environment.CurrentManagedThreadId" />
int CurrentManagedThreadId { get; }

/// <inheritdoc cref="Environment.ExitCode" />
int ExitCode { get; }
/// <inheritdoc cref="Environment.ExitCode" />
int ExitCode { get; }

/// <inheritdoc cref="Environment.HasShutdownStarted" />
bool HasShutdownStarted { get; }
/// <inheritdoc cref="Environment.HasShutdownStarted" />
bool HasShutdownStarted { get; }

/// <inheritdoc cref="Environment.Is64BitOperatingSystem" />
bool Is64BitOperatingSystem { get; }
/// <inheritdoc cref="Environment.Is64BitOperatingSystem" />
bool Is64BitOperatingSystem { get; }

/// <inheritdoc cref="Environment.Is64BitProcess" />
bool Is64BitProcess { get; }
/// <inheritdoc cref="Environment.Is64BitProcess" />
bool Is64BitProcess { get; }

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

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

/// <inheritdoc cref="Environment.OSVersion" />
OperatingSystem OSVersion { get; }
/// <inheritdoc cref="Environment.OSVersion" />
OperatingSystem OSVersion { get; }

#if NET5_0_OR_GREATER
/// <inheritdoc cref="Environment.ProcessId" />
int ProcessId { get; }
/// <inheritdoc cref="Environment.ProcessId" />
int ProcessId { get; }
#endif

/// <inheritdoc cref="Environment.ProcessorCount" />
int ProcessorCount { get; }
/// <inheritdoc cref="Environment.ProcessorCount" />
int ProcessorCount { get; }

#if NET6_0_OR_GREATER
/// <inheritdoc cref="Environment.ProcessPath" />
string? ProcessPath { get; }
/// <inheritdoc cref="Environment.ProcessPath" />
string? ProcessPath { get; }
#endif

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

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

/// <inheritdoc cref="Environment.SystemPageSize" />
int SystemPageSize { get; }
/// <inheritdoc cref="Environment.SystemPageSize" />
int SystemPageSize { get; }

/// <inheritdoc cref="Environment.TickCount" />
int TickCount { get; }
/// <inheritdoc cref="Environment.TickCount" />
int TickCount { get; }

#if NETCOREAPP3_1_OR_GREATER
/// <inheritdoc cref="Environment.TickCount64" />
long TickCount64 { get; }
/// <inheritdoc cref="Environment.TickCount64" />
long TickCount64 { get; }
#endif

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

/// <inheritdoc cref="Environment.UserInteractive" />
bool UserInteractive { get; }
/// <inheritdoc cref="Environment.UserInteractive" />
bool UserInteractive { get; }

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

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

/// <inheritdoc cref="Environment.WorkingSet" />
long WorkingSet { get; }
/// <inheritdoc cref="Environment.WorkingSet" />
long WorkingSet { get; }

/// <inheritdoc cref="Environment.Exit(int)" />
void Exit(int exitCode);
/// <inheritdoc cref="Environment.Exit(int)" />
void Exit(int exitCode);

/// <inheritdoc cref="Environment.FailFast(string?)" />
void FailFast(string? message);
/// <inheritdoc cref="Environment.FailFast(string?)" />
void FailFast(string? message);

/// <inheritdoc cref="Environment.FailFast(string?, Exception?)" />
void FailFast(string? message, Exception? exception);
/// <inheritdoc cref="Environment.FailFast(string?, Exception?)" />
void FailFast(string? message, Exception? exception);

/// <inheritdoc cref="Environment.GetCommandLineArgs" />
string[] GetCommandLineArgs();
/// <inheritdoc cref="Environment.GetCommandLineArgs" />
string[] GetCommandLineArgs();

/// <inheritdoc cref="Environment.GetFolderPath(Environment.SpecialFolder)" />
string GetFolderPath(Environment.SpecialFolder folder);
/// <inheritdoc cref="Environment.GetFolderPath(Environment.SpecialFolder)" />
string GetFolderPath(Environment.SpecialFolder folder);

/// <inheritdoc cref="System.Environment.GetFolderPath(Environment.SpecialFolder, Environment.SpecialFolderOption)" />
string GetFolderPath(Environment.SpecialFolder folder, Environment.SpecialFolderOption option);
/// <inheritdoc cref="System.Environment.GetFolderPath(Environment.SpecialFolder, Environment.SpecialFolderOption)" />
string GetFolderPath(Environment.SpecialFolder folder, Environment.SpecialFolderOption option);

/// <inheritdoc cref="Environment.GetLogicalDrives" />
string[] GetLogicalDrives();
}
/// <inheritdoc cref="Environment.GetLogicalDrives" />
string[] GetLogicalDrives();
}
}
2 changes: 1 addition & 1 deletion src/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1309:FieldNamesMustNotBeginWithUnderscore", Justification = "Reviewed.")]
[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:PrefixLocalCallsWithThis", Justification = "Reviewed.")]
[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:PrefixLocalCallsWithThis", Justification = "Reviewed.")]
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "2.1",
"version": "3.0",
"assemblyVersion": "1.0",
"versionHeightOffset": -1,
"nugetPackageVersion": {
Expand Down

0 comments on commit 108540c

Please sign in to comment.