Skip to content

Commit

Permalink
Update dependencies and framework to .NET 8 along with related code r…
Browse files Browse the repository at this point in the history
…efinements.
  • Loading branch information
fgimian committed Nov 29, 2023
1 parent 57a3aec commit e30481c
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 399 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ dotnet_diagnostic.SA1504.severity = none
dotnet_diagnostic.SA1515.severity = none
dotnet_diagnostic.SA1516.severity = none

# Disable checking of square bracket spacing due to incompatibility with .NET 8.
# See https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3687
dotnet_diagnostic.SA1010.severity = none

# --------------------------------------------------------------------------------------------------
# Sonar
# --------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -303,6 +307,10 @@ csharp_style_prefer_local_over_anonymous_function = false
# Do not force short-hand object initialisers in tests so properties may be set in the Act stage.
dotnet_diagnostic.IDE0017.severity = none

# Disable checking for ConfigureAwait calls in tests as this may cause parallelization issues.
# See https://xunit.net/xunit.analyzers/rules/xUnit1030
dotnet_diagnostic.MA0004.severity = none

# Disable documentation requirements for unit tests.
dotnet_diagnostic.SA0001.severity = none
dotnet_diagnostic.SA1600.severity = none
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Setup Just
uses: extractions/setup-just@v1
Expand Down
2 changes: 1 addition & 1 deletion TotalMixVC.iss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#define AppRepoIssuesURL AppRepoURL + "/issues"
#define AppRepoReleasesURL AppRepoURL + "/releases"
#define AppIconPath "src\TotalMixVC\Icons\TotalMixVC.ico"
#define AppPublishPath "src\TotalMixVC\bin\" + AppBuildConfiguration + "\net7.0-windows\win-x64\publish"
#define AppPublishPath "src\TotalMixVC\bin\" + AppBuildConfiguration + "\net8.0-windows\win-x64\publish"
#define AppExeName "TotalMixVC.exe"
#define AppVersion GetStringFileInfo(AddBackslash(AppPublishPath) + AppExeName, "ProductVersion")

Expand Down
54 changes: 22 additions & 32 deletions src/TotalMixVC.Tests/TaskExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public async Task TimeoutAfter_Completes_DoesNotThrowException_Async()
bool completed = false;
Func<Task> task = async () =>
{
await Task.Delay(1).ConfigureAwait(false);
await Task.Delay(1);
completed = true;
};

// Act
await Task.Run(task).TimeoutAfter(1000).ConfigureAwait(false);
await Task.Run(task).TimeoutAfter(1000);

// Assert
Assert.True(completed);
Expand All @@ -35,15 +35,15 @@ public async Task TimeoutAfter_TimesOut_ThrowsException_Async()
bool completed = false;
Func<Task> task = async () =>
{
await Task.Delay(1000).ConfigureAwait(false);
await Task.Delay(1000);
completed = true;
};

// Act
Func<Task> timeoutTask = () => Task.Run(task).TimeoutAfter(1);

// Assert
await Assert.ThrowsAsync<TimeoutException>(timeoutTask).ConfigureAwait(false);
await Assert.ThrowsAsync<TimeoutException>(timeoutTask);
Assert.False(completed);
}

Expand All @@ -56,28 +56,23 @@ public async Task TimeoutAfter_Cancellation_ThrowsException_Async()
bool completed = false;
Func<Task> task = async () =>
{
await Task.Delay(1000).ConfigureAwait(false);
await Task.Delay(1000);
completed = true;
};

// Act
Task cancelTask = Task.Run(async () =>
{
await Task.Delay(100).ConfigureAwait(false);
cancellationTokenSource.Cancel();
await Task.Delay(100);
await cancellationTokenSource.CancelAsync();
});

// Assert
await Assert
.ThrowsAsync<OperationCanceledException>(
async () =>
await Task.Run(task)
.TimeoutAfter(1000, cancellationTokenSource)
.ConfigureAwait(false)
)
.ConfigureAwait(false);
await Assert.ThrowsAsync<OperationCanceledException>(
async () => await Task.Run(task).TimeoutAfter(1000, cancellationTokenSource)
);
Assert.False(completed);
await cancelTask.ConfigureAwait(false);
await cancelTask;
}

[Fact]
Expand All @@ -87,13 +82,13 @@ public async Task TimeoutAfter_CompletesWithReturn_ReturnsValue_Async()
bool completed = false;
Func<Task<string>> task = async () =>
{
await Task.Delay(1).ConfigureAwait(false);
await Task.Delay(1);
completed = true;
return "Hello";
};

// Act
string result = await Task.Run(task).TimeoutAfter(1000).ConfigureAwait(false);
string result = await Task.Run(task).TimeoutAfter(1000);

// Assert
Assert.True(completed);
Expand All @@ -107,7 +102,7 @@ public async Task TimeoutAfter_TimesOutWithReturn_ThrowsException_Async()
bool completed = false;
Func<Task<string>> task = async () =>
{
await Task.Delay(1000).ConfigureAwait(false);
await Task.Delay(1000);
completed = true;
return "Hello";
};
Expand All @@ -116,7 +111,7 @@ public async Task TimeoutAfter_TimesOutWithReturn_ThrowsException_Async()
Func<Task<string>> timeoutTask = () => Task.Run(task).TimeoutAfter(1);

// Assert
await Assert.ThrowsAsync<TimeoutException>(timeoutTask).ConfigureAwait(false);
await Assert.ThrowsAsync<TimeoutException>(timeoutTask);
Assert.False(completed);
}

Expand All @@ -129,28 +124,23 @@ public async Task TimeoutAfter_CancellationWithReturn_ThrowsException_Async()
bool completed = false;
Func<Task<string>> task = async () =>
{
await Task.Delay(1000).ConfigureAwait(false);
await Task.Delay(1000);
completed = true;
return "Hello";
};

// Act
Task cancelTask = Task.Run(async () =>
{
await Task.Delay(100).ConfigureAwait(false);
cancellationTokenSource.Cancel();
await Task.Delay(100);
await cancellationTokenSource.CancelAsync();
});

// Assert
await Assert
.ThrowsAsync<OperationCanceledException>(
async () =>
await Task.Run(task)
.TimeoutAfter(1000, cancellationTokenSource)
.ConfigureAwait(false)
)
.ConfigureAwait(false);
await Assert.ThrowsAsync<OperationCanceledException>(
async () => await Task.Run(task).TimeoutAfter(1000, cancellationTokenSource)
);
Assert.False(completed);
await cancelTask.ConfigureAwait(false);
await cancelTask;
}
}
22 changes: 11 additions & 11 deletions src/TotalMixVC.Tests/TotalMixVC.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand All @@ -12,22 +12,22 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="NSubstitute" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.16">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="XunitXml.TestLogger" Version="3.0.78" />
<PackageReference Include="XunitXml.TestLogger" Version="3.1.17" />
</ItemGroup>

<ItemGroup>
Expand All @@ -39,23 +39,23 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.61">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.113">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.6.40">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Roslynator.Analyzers" Version="4.3.0">
<PackageReference Include="Roslynator.Analyzers" Version="4.6.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Roslynator.Formatting.Analyzers" Version="4.3.0">
<PackageReference Include="Roslynator.Formatting.Analyzers" Version="4.6.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.4.0.72892">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.14.0.81108">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit e30481c

Please sign in to comment.