Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to .NET 8 #53

Merged
merged 4 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ permissions:
contents: read

env:
DOTNET_VERSION: '7.0'
DOTNET_VERSION: '8.0'

# NOTE: Jobs run in parallel by default.
# https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Import Project="$(MSBuildThisFileDirectory)_ProjectCommons/Common.Directory.Build.props" />

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion _ProjectCommons
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace AppMotor.HttpServer.WebApiSample.Models;
public sealed class TodoItem
{
public long Id { get; set; }
// ReSharper disable once EntityFramework.ModelValidation.UnlimitedStringLength
public string? Name { get; set; }
public bool IsComplete { get; set; }
}
6 changes: 4 additions & 2 deletions src/AppMotor.CliApp/CommandLine/CliParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public CliParam(string name, int positionIndex)
}
}

private Symbol CreateUnderlyingNamedParameter()
[MustUseReturnValue]
private Option<T> CreateUnderlyingNamedParameter()
{
Option<T> option;

Expand All @@ -148,7 +149,8 @@ private Symbol CreateUnderlyingNamedParameter()
return option;
}

private Symbol CreateUnderlyingPositionalParameter()
[MustUseReturnValue]
private Argument<T> CreateUnderlyingPositionalParameter()
{
var argument = new Argument<T>(this.PrimaryName, this.HelpText);

Expand Down
4 changes: 1 addition & 3 deletions src/AppMotor.CliApp/Terminals/ITerminal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ namespace AppMotor.CliApp.Terminals;
/// Instances of this interface may or may not also implement <see cref="ITerminalWindow"/>. You can use an
/// "is"/"as" conversion to check for this and adopt your code accordingly.
/// </remarks>
public interface ITerminal : ITerminalInput, ITerminalOutput
{
}
public interface ITerminal : ITerminalInput, ITerminalOutput;
8 changes: 2 additions & 6 deletions src/AppMotor.Core/DataModel/SensitiveValues/SensitiveValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ namespace AppMotor.Core.DataModel;
/// by accident.
/// </summary>
/// <seealso cref="SensitiveValueMarker"/>
public interface ISensitiveValue
{
}
public interface ISensitiveValue;

/// <summary>
/// A <see cref="TypeMarker"/> alternative to <see cref="ISensitiveValue"/>.
/// </summary>
// ReSharper disable once ClassNeverInstantiated.Global
public sealed class SensitiveValueMarker : TypeMarker
{
}
public sealed class SensitiveValueMarker : TypeMarker;
6 changes: 2 additions & 4 deletions src/AppMotor.Core/DataModel/TypeMarkers/TypeMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ namespace AppMotor.Core.DataModel;

/// <summary>
/// Represents a type marker; that is a way of marking certain .NET <see cref="Type"/>s in a
/// generic way. The main use case here is provide an alternative to marker interfaces when
/// generic way. The main use case here is to provide an alternative to marker interfaces when
/// you can't change the implementation of an existing type you wish to mark. For example,
/// if you can't implement the marker interface <see cref="ISensitiveValue"/>, you can instead
/// mark the type with <see cref="SensitiveValueMarker"/> (via <see cref="TypeMarkerExtensions.MarkWith{TTypeMarker}"/>).
/// </summary>
public abstract class TypeMarker
{
}
public abstract class TypeMarker;
4 changes: 1 addition & 3 deletions src/AppMotor.Core/Events/IEventHandlerRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ namespace AppMotor.Core.Events;
/// A registration for <see cref="Event{TEventHandler}"/>. Dispose this registration
/// to remove/delete the registration.
/// </summary>
public interface IEventHandlerRegistration : IDisposable
{
}
public interface IEventHandlerRegistration : IDisposable;
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ namespace AppMotor.Core.Exceptions;
/// and its variants. Via this interface on can catch all related
/// exceptions in one <c>catch</c> block.
/// </summary>
public interface ICollectionIsReadOnlyException
{
}
public interface ICollectionIsReadOnlyException;
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ namespace AppMotor.Core.Exceptions;
/// Thrown if you try to access properties of an uninitialized struct.
/// </summary>
[PublicAPI]
public class UninitializedStructPropertyException : InvalidOperationException
{
}
public class UninitializedStructPropertyException : InvalidOperationException;
8 changes: 2 additions & 6 deletions src/AppMotor.Core/Logging/SimpleLoggableValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ namespace AppMotor.Core.Logging;
/// and therefor in <see cref="ExtendedExceptionStringExtensions.ToStringExtended"/>.
/// </summary>
/// <seealso cref="SimpleLoggableValueMarker"/>
public interface ISimpleLoggableValue
{
}
public interface ISimpleLoggableValue;

/// <summary>
/// A <see cref="TypeMarker"/> alternative to <see cref="ISimpleLoggableValue"/>.
/// </summary>
// ReSharper disable once ClassNeverInstantiated.Global
public sealed class SimpleLoggableValueMarker : TypeMarker
{
}
public sealed class SimpleLoggableValueMarker : TypeMarker;
4 changes: 1 addition & 3 deletions src/AppMotor.NetStandardCompat/IsExternalInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@ namespace System.Runtime.CompilerServices;
/// </summary>
[UsedImplicitly]
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class IsExternalInit
{
}
public sealed class IsExternalInit;
14 changes: 7 additions & 7 deletions tests/AppMotor.CliApp.Tests/Tests/CliApplicationExecutorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace AppMotor.CliApp.Tests;
/// </summary>
public sealed class CliApplicationExecutorTests
{
private static readonly string[] TEST_ARGS = { "abc", "def" };
private static readonly string[] TEST_ARGS = ["abc", "def"];

[Fact]
public void Test_Sync_Void_NoArgs_NoCancellationToken()
Expand Down Expand Up @@ -403,7 +403,7 @@ async Task Execute(CancellationToken cancellationToken)
called = true;
cancellationToken.IsCancellationRequested.ShouldBe(false);
// ReSharper disable once AccessToDisposedClosure
cts.Cancel();
await cts.CancelAsync();
cancellationToken.IsCancellationRequested.ShouldBe(true); // Validates we actually got the token from "cts"
}

Expand Down Expand Up @@ -433,7 +433,7 @@ async Task Execute(string[] args, CancellationToken cancellationToken)
args.ShouldBe(TEST_ARGS);
cancellationToken.IsCancellationRequested.ShouldBe(false);
// ReSharper disable once AccessToDisposedClosure
cts.Cancel();
await cts.CancelAsync();
cancellationToken.IsCancellationRequested.ShouldBe(true); // Validates we actually got the token from "cts"
}

Expand Down Expand Up @@ -515,7 +515,7 @@ async Task<bool> Execute(CancellationToken cancellationToken)
called = true;
cancellationToken.IsCancellationRequested.ShouldBe(false);
// ReSharper disable once AccessToDisposedClosure
cts.Cancel();
await cts.CancelAsync();
cancellationToken.IsCancellationRequested.ShouldBe(true); // Validates we actually got the token from "cts"
return retVal;
}
Expand Down Expand Up @@ -548,7 +548,7 @@ async Task<bool> Execute(string[] args, CancellationToken cancellationToken)
args.ShouldBe(TEST_ARGS);
cancellationToken.IsCancellationRequested.ShouldBe(false);
// ReSharper disable once AccessToDisposedClosure
cts.Cancel();
await cts.CancelAsync();
cancellationToken.IsCancellationRequested.ShouldBe(true); // Validates we actually got the token from "cts"
return retVal;
}
Expand Down Expand Up @@ -634,7 +634,7 @@ async Task<int> Execute(CancellationToken cancellationToken)
called = true;
cancellationToken.IsCancellationRequested.ShouldBe(false);
// ReSharper disable once AccessToDisposedClosure
cts.Cancel();
await cts.CancelAsync();
cancellationToken.IsCancellationRequested.ShouldBe(true); // Validates we actually got the token from "cts"
return retVal;
}
Expand Down Expand Up @@ -668,7 +668,7 @@ async Task<int> Execute(string[] args, CancellationToken cancellationToken)
args.ShouldBe(TEST_ARGS);
cancellationToken.IsCancellationRequested.ShouldBe(false);
// ReSharper disable once AccessToDisposedClosure
cts.Cancel();
await cts.CancelAsync();
cancellationToken.IsCancellationRequested.ShouldBe(true); // Validates we actually got the token from "cts"
return retVal;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void Execute()
var testApplication = new TestApplication(new CliCommandExecutor(Execute));

// Test
testApplication.AppHelper.Run(new[] { COMMAND_NAME }, expectedExitCode: 0);
testApplication.AppHelper.Run([COMMAND_NAME], expectedExitCode: 0);

// Verify
called.ShouldBe(true);
Expand All @@ -63,7 +63,7 @@ void Execute(CancellationToken cancellationToken)
var testApplication = new TestApplication(new CliCommandExecutor(Execute));

// Test
testApplication.AppHelper.Run(new[] { COMMAND_NAME }, expectedExitCode: 0, cts.Token);
testApplication.AppHelper.Run([COMMAND_NAME], expectedExitCode: 0, cts.Token);

// Verify
called.ShouldBe(true);
Expand All @@ -87,7 +87,7 @@ bool Execute()
var testApplication = new TestApplication(new CliCommandExecutor(Execute));

// Test
testApplication.AppHelper.Run(new[] { COMMAND_NAME }, expectedExitCode: retVal ? 0 : 1);
testApplication.AppHelper.Run([COMMAND_NAME], expectedExitCode: retVal ? 0 : 1);

// Verify
called.ShouldBe(true);
Expand Down Expand Up @@ -117,7 +117,7 @@ bool Execute(CancellationToken cancellationToken)
var testApplication = new TestApplication(new CliCommandExecutor(Execute));

// Test
testApplication.AppHelper.Run(new[] { COMMAND_NAME }, expectedExitCode: retVal ? 0 : 1, cts.Token);
testApplication.AppHelper.Run([COMMAND_NAME], expectedExitCode: retVal ? 0 : 1, cts.Token);

// Verify
called.ShouldBe(true);
Expand All @@ -142,7 +142,7 @@ int Execute()
var testApplication = new TestApplication(new CliCommandExecutor(Execute));

// Test
testApplication.AppHelper.Run(new[] { COMMAND_NAME }, expectedExitCode: retVal);
testApplication.AppHelper.Run([COMMAND_NAME], expectedExitCode: retVal);

// Verify
called.ShouldBe(true);
Expand Down Expand Up @@ -173,7 +173,7 @@ int Execute(CancellationToken cancellationToken)
var testApplication = new TestApplication(new CliCommandExecutor(Execute));

// Test
testApplication.AppHelper.Run(new[] { COMMAND_NAME }, expectedExitCode: retVal, cts.Token);
testApplication.AppHelper.Run([COMMAND_NAME], expectedExitCode: retVal, cts.Token);

// Verify
called.ShouldBe(true);
Expand All @@ -195,7 +195,7 @@ async Task Execute()
var testApplication = new TestApplication(new CliCommandExecutor(Execute));

// Test
testApplication.AppHelper.Run(new[] { COMMAND_NAME }, expectedExitCode: 0);
testApplication.AppHelper.Run([COMMAND_NAME], expectedExitCode: 0);

// Verify
called.ShouldBe(true);
Expand All @@ -217,14 +217,14 @@ async Task Execute(CancellationToken cancellationToken)
called = true;
cancellationToken.IsCancellationRequested.ShouldBe(false);
// ReSharper disable once AccessToDisposedClosure
cts.Cancel();
await cts.CancelAsync();
cancellationToken.IsCancellationRequested.ShouldBe(true); // Validates we actually got the token from "cts"
}

var testApplication = new TestApplication(new CliCommandExecutor(Execute));

// Test
testApplication.AppHelper.Run(new[] { COMMAND_NAME }, expectedExitCode: 0, cts.Token);
testApplication.AppHelper.Run([COMMAND_NAME], expectedExitCode: 0, cts.Token);

// Verify
called.ShouldBe(true);
Expand All @@ -249,7 +249,7 @@ async Task<bool> Execute()
var testApplication = new TestApplication(new CliCommandExecutor(Execute));

// Test
testApplication.AppHelper.Run(new[] { COMMAND_NAME }, expectedExitCode: retVal ? 0 : 1);
testApplication.AppHelper.Run([COMMAND_NAME], expectedExitCode: retVal ? 0 : 1);

// Verify
called.ShouldBe(true);
Expand All @@ -273,15 +273,15 @@ async Task<bool> Execute(CancellationToken cancellationToken)
called = true;
cancellationToken.IsCancellationRequested.ShouldBe(false);
// ReSharper disable once AccessToDisposedClosure
cts.Cancel();
await cts.CancelAsync();
cancellationToken.IsCancellationRequested.ShouldBe(true); // Validates we actually got the token from "cts"
return retVal;
}

var testApplication = new TestApplication(new CliCommandExecutor(Execute));

// Test
testApplication.AppHelper.Run(new[] { COMMAND_NAME }, expectedExitCode: retVal ? 0 : 1, cts.Token);
testApplication.AppHelper.Run([COMMAND_NAME], expectedExitCode: retVal ? 0 : 1, cts.Token);

// Verify
called.ShouldBe(true);
Expand All @@ -307,7 +307,7 @@ async Task<int> Execute()
var testApplication = new TestApplication(new CliCommandExecutor(Execute));

// Test
testApplication.AppHelper.Run(new[] { COMMAND_NAME }, expectedExitCode: retVal);
testApplication.AppHelper.Run([COMMAND_NAME], expectedExitCode: retVal);

// Verify
called.ShouldBe(true);
Expand All @@ -332,15 +332,15 @@ async Task<int> Execute(CancellationToken cancellationToken)
called = true;
cancellationToken.IsCancellationRequested.ShouldBe(false);
// ReSharper disable once AccessToDisposedClosure
cts.Cancel();
await cts.CancelAsync();
cancellationToken.IsCancellationRequested.ShouldBe(true); // Validates we actually got the token from "cts"
return retVal;
}

var testApplication = new TestApplication(new CliCommandExecutor(Execute));

// Test
testApplication.AppHelper.Run(new[] { COMMAND_NAME }, expectedExitCode: retVal, cts.Token);
testApplication.AppHelper.Run([COMMAND_NAME], expectedExitCode: retVal, cts.Token);

// Verify
called.ShouldBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,7 @@ protected override void OnNonColorAnsiEscapeSequence(ReadOnlySpan<char> escapeSe
}
}

private interface IParsedItem
{

}
private interface IParsedItem;

private sealed class ParsedTextItem : IParsedItem, IEquatable<ParsedTextItem>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public void TestNullData()
Should.NotThrow(() => accessor.Clear());

// Enumeration is empty.
accessor.GetEnumerator().MoveNext().ShouldBe(false);
using var enumerator = accessor.GetEnumerator();
enumerator.MoveNext().ShouldBe(false);
}

[Fact]
Expand All @@ -94,7 +95,8 @@ public void TestReadOnlyData()
Should.NotThrow(() => accessor.Clear());

// Enumeration is empty.
accessor.GetEnumerator().MoveNext().ShouldBe(false);
using var enumerator = accessor.GetEnumerator();
enumerator.MoveNext().ShouldBe(false);
}

[Fact]
Expand Down
15 changes: 3 additions & 12 deletions tests/AppMotor.Core.Tests/Tests/Extensions/TypeExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,11 @@ public void Test_Is()
typeof(object).Is(typeof(ITestInterface)).ShouldBe(false);
}

private interface ITestInterface
{
private interface ITestInterface;

}
private class ClassA : ITestInterface;

private class ClassA : ITestInterface
{

}

private class ClassB : ClassA
{

}
private class ClassB : ClassA;

[Theory]
[InlineData("+", UnaryOperators.UnaryPlus)]
Expand Down
Loading