Skip to content

Commit

Permalink
Add .NET 8 support (#80)
Browse files Browse the repository at this point in the history
This change adds .NET 8 support.

#do release
  • Loading branch information
craigktreasure authored Nov 18, 2023
1 parent d3864d0 commit 4a734a6
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 11 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
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>
2 changes: 1 addition & 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
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.100",
"version": "8.0.100",
"allowPrerelease": false,
"rollForward": "latestFeature"
},
Expand Down
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
6 changes: 5 additions & 1 deletion test/Treasure.Utils.Argument.Benchmarks/Combine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[CmdletBinding()]
Param (
[string[]] $TFMs = @('net6.0', 'net6.0-windows', 'net7.0', 'net7.0-windows'),
[string[]] $TFMs = @('net6.0', 'net6.0-windows', 'net7.0', 'net7.0-windows', 'net8.0', 'net8.0-windows'),
[string[]] $Columns = @( 'Runtime', 'TFM', 'LibraryTfm', 'Method', 'Mean', 'Error', 'StdDev', 'Code Size'),
[string] $ArtifactInputRoot = (Join-Path $PSScriptRoot '..' '..' '__benchmarks'),
[string] $ResultOutputPath = (Join-Path $PSScriptRoot '..' '..' '__benchmarks' 'results.md'),
Expand Down Expand Up @@ -44,6 +44,10 @@ function GetLibraryTfmName ($tfm) {
return 'net7.0'
}

if ($tfm -eq 'net8.0') {
return 'net8.0'
}

if ($tfm.Contains('-')) {
return 'netstandard2.1'
}
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,6 +1,6 @@
// .\Run.ps1
// or
// dotnet run -c Release -f [net6.0 net7.0] --filter "*"
// dotnet run -c Release -f [net6.0 net7.0 net8.0] --filter "*"

#pragma warning disable CA1050
#pragma warning disable CA1812
Expand Down
2 changes: 1 addition & 1 deletion test/Treasure.Utils.Argument.Benchmarks/Run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[CmdletBinding()]
Param (
[string[]] $TFMs = @('net6.0', 'net6.0-windows', 'net7.0', 'net7.0-windows'),
[string[]] $TFMs = @('net6.0', 'net6.0-windows', 'net7.0', 'net7.0-windows', 'net8.0', 'net8.0-windows'),
[string] $ArtifactOutputRoot = (Join-Path $PSScriptRoot '..' '..' '__benchmarks'),
[string] $ResultOutputPath = (Join-Path $PSScriptRoot '..' '..' '__benchmarks' 'results.md')
)
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 4a734a6

Please sign in to comment.