Skip to content

Commit

Permalink
Upgrade to .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
craigktreasure committed Nov 16, 2023
1 parent a93f99e commit 68ca18f
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ csharp_style_expression_bodied_constructors = when_on_single_line
#prefer expression-bodied members for properties
csharp_style_expression_bodied_properties = when_on_single_line

#IDE0290: Use Primary Constructors
csharp_style_prefer_primary_constructors = false

#Style - expression level options

#prefer out variables to be declared before the method call
Expand Down
1 change: 1 addition & 0 deletions .github/actions/install-tools/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ runs:
dotnet-version: |
6.x
7.x
8.x
- name: Install .NET tools
shell: pwsh
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/workflow_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ jobs:
uses: codecov/codecov-action@v3
with:
name: codecov
directory: __test-results
directory: __artifacts/test-results
fail_ci_if_error: true
verbose: true

- name: Upload output artifact
uses: actions/upload-artifact@v3
with:
name: output_${{ inputs.platform }}
path: __output
path: __artifacts/bin

- name: Upload package artifact
uses: actions/upload-artifact@v3
with:
name: packages_${{ inputs.platform }}
path: __packages
path: __artifacts/package
4 changes: 2 additions & 2 deletions .github/workflows/workflow_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/download-artifact@v3
with:
name: packages_ubuntu
path: __packages
path: __artifacts/package

- name: Push ${{ inputs.package-version }} to NuGet.org
run: nuget push __packages/NuGet/Release/Treasure.Utils.*.nupkg -ApiKey ${{ secrets.NUGET_API_KEY }} -Source https://api.nuget.org/v3/index.json
run: nuget push __artifacts/package/release/Treasure.Utils.*.nupkg -ApiKey ${{ secrets.NUGET_API_KEY }} -Source https://api.nuget.org/v3/index.json
6 changes: 2 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
<PropertyGroup>
<RepoRootPath>$(MSBuildThisFileDirectory)</RepoRootPath>
<SourceRootPath>$(RepoRootPath)src</SourceRootPath>
<CentralBuildOutputPath>$(RepoRootPath)</CentralBuildOutputPath>
<UseArtifactsOutput>true</UseArtifactsOutput>
<ArtifactsPath>$(RepoRootPath)__artifacts</ArtifactsPath>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)\eng\Defaults.props" />

<!-- Import the CentralBuildOutput SDK. -->
<Sdk Name="Treasure.Build.CentralBuildOutput" />

</Project>
2 changes: 1 addition & 1 deletion eng/DotNetAnalyzers.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisLevel>7.0</AnalysisLevel>
<AnalysisLevel>8.0</AnalysisLevel>
</PropertyGroup>

</Project>
10 changes: 9 additions & 1 deletion eng/DotNetDefaults.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- Sets the C# language version:
https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#c-language-version-reference
-->
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>

<!-- Enable implicit usings:
https://docs.microsoft.com/dotnet/core/project-sdk/overview#implicit-using-directives
Expand Down Expand Up @@ -48,4 +48,12 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<!-- Configure test and code coverage output. -->
<BaseTestResultsOutputPath>$(ArtifactsPath)/test-results/</BaseTestResultsOutputPath>
<BaseProjectTestResultsOutputPath>$(BaseTestResultsOutputPath)$(MSBuildProjectName)/</BaseProjectTestResultsOutputPath>
<VSTestResultsDirectory>$(BaseProjectTestResultsOutputPath)</VSTestResultsDirectory>
<CoverletOutput>$(BaseProjectTestResultsOutputPath)</CoverletOutput>
</PropertyGroup>

</Project>
5 changes: 1 addition & 4 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"sdk": {
"version": "7.0.100",
"version": "8.0.100",
"allowPrerelease": false,
"rollForward": "latestFeature"
},
"msbuild-sdks": {
"Treasure.Build.CentralBuildOutput" : "3.0.0"
}
}
4 changes: 4 additions & 0 deletions src/Treasure.Utils.Argument/Argument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public static string NotNullOrEmpty([NotNull] string? value, [CallerArgumentExpr
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string NotNullOrWhiteSpace([NotNull] string? value, [CallerArgumentExpression(nameof(value))] string name = "")
{
#if NET8_0_OR_GREATER
ArgumentException.ThrowIfNullOrWhiteSpace(value, name);
#else
if (value is null)
{
throw new ArgumentNullException(name);
Expand All @@ -84,6 +87,7 @@ public static string NotNullOrWhiteSpace([NotNull] string? value, [CallerArgumen
{
throw new ArgumentException("The value cannot be null, empty, or white-space.", name);
}
#endif

return value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Treasure.Utils.Argument/Treasure.Utils.Argument.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.1</TargetFrameworks>
<RootNamespace>Treasure.Utils</RootNamespace>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion test/Treasure.Utils.Argument.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dotnet run -c Release -f net6.0 --filter "*" --runtimes net6.0 net7.0
// dotnet run -c Release -f net6.0 --filter "*" --runtimes net6.0 net7.0 net8.0

#pragma warning disable IDE0211
#pragma warning disable CA1050
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(TargetFrameworks);net7.0$(PlatformTFMSuffix);net6.0$(PlatformTFMSuffix)</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(TargetFrameworks);net8.0$(PlatformTFMSuffix);net7.0$(PlatformTFMSuffix);net6.0$(PlatformTFMSuffix)</TargetFrameworks>
<RootNamespace>Treasure.Utils.Benchmarks</RootNamespace>
<IsTestProject>false</IsTestProject>

Expand Down
2 changes: 1 addition & 1 deletion test/Treasure.Utils.Argument.Tests/ArgumentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static void Method(string? useMe)
public void NotNull()
{
// Arrange
int[] objectValue = Array.Empty<int>();
int[] objectValue = [];

// Act and assert
Argument.NotNull(objectValue);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(TargetFrameworks);$(DefaultNetStandardTestTFM)</TargetFrameworks>
<RootNamespace>Treasure.Utils.Tests</RootNamespace>
</PropertyGroup>
Expand Down

0 comments on commit 68ca18f

Please sign in to comment.