Skip to content

Commit

Permalink
Merge pull request #94 from ztanczos/please_upgrade_net8
Browse files Browse the repository at this point in the history
Upgrade dotnet-please to .NET 8
  • Loading branch information
ztanczos authored Jun 3, 2024
2 parents 17c8f57 + 37be7cb commit 953b30d
Show file tree
Hide file tree
Showing 21 changed files with 125 additions and 305 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore --locked-mode
Expand Down
14 changes: 7 additions & 7 deletions DotNetPlease.Tests/DotNetPlease.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>DotNetPlease</RootNamespace>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Xunit.Combinatorial" Version="1.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.3.0">
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="Xunit.Combinatorial" Version="1.6.24" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
16 changes: 8 additions & 8 deletions DotNetPlease.Tests/TestUtils/PathEquivalencyStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ namespace DotNetPlease.TestUtils
{
public class PathEquivalencyStep : IEquivalencyStep
{
public bool CanHandle(IEquivalencyValidationContext context, IEquivalencyAssertionOptions config)
public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context, IEquivalencyValidator nestedValidator)
{
return (context.Subject is null || context.Subject is string)
&& (context.Expectation is null || context.Expectation is string);
}

public bool Handle(IEquivalencyValidationContext context, IEquivalencyValidator parent, IEquivalencyAssertionOptions config)
{
return FileSystemHelper.PathComparer.Equals((string)context.Subject, (string)context.Expectation);
if ((comparands.Subject is null || comparands.Subject is not string)
|| (comparands.Expectation is null || comparands.Expectation is not string))
{
return EquivalencyResult.ContinueWithNext;
}
return FileSystemHelper.PathComparer.Equals((string)comparands.Subject, (string)comparands.Expectation) ? EquivalencyResult.AssertionCompleted : EquivalencyResult.ContinueWithNext;
}
}

Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal App(Func<IServiceCollection, IServiceCollection>? overrideServices)
private void ConfigureServices(IServiceCollection services)
{
services
.AddMediatR(typeof(Program).Assembly)
.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly))
.AddTransient<CommandHandlerDependencies>()
.AddSingleton<IConsole, SystemConsole>();
services.TryAddSingleton<IReporter, SystemConsoleReporter>();
Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/AddToPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public CommandHandler(CommandHandlerDependencies dependencies) : base(dependenci
{
}

protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
var path = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User) ?? "";
var paths = path.Split(Path.PathSeparator).Select(p => p.Trim()).ToHashSet(FileSystemHelper.PathComparer);
Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/ChangeNamespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class Command : IRequest
[UsedImplicitly]
public class CommandHandler : CommandHandlerBase<Command>
{
protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
Reporter.Info($"Changing namespace \"{command.OldNamespace}\" to \"{command.NewNamespace}\"");

Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/CleanupProjectFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class Command : IRequest
[UsedImplicitly]
public class CommandHandler : CommandHandlerBase<Command>
{
protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
Reporter.Info($"Cleaning up project files");

Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/ConsolidatePackages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class Command : IRequest
[UsedImplicitly]
public class CommandHandler : CommandHandlerBase<Command>
{
protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
if (!string.IsNullOrWhiteSpace(command.Version) && string.IsNullOrWhiteSpace(command.PackageName))
{
Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/EvaluateProjectProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Command : IRequest
[UsedImplicitly]
public class CommandHandler : CommandHandlerBase<Command>
{
protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
Reporter.Info("Evaluating project properties");

Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/ExpandReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class Command : IRequest
[UsedImplicitly]
public class CommandHandler : CommandHandlerBase<Command>
{
protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
var context = CreateContext(command);

Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/FindStrayProjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Command : IRequest
[UsedImplicitly]
public class CommandHandler : CommandHandlerBase<Command>
{
protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
Reporter.Info($"Searching for stray projects");

Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/FixProjectReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Command : IRequest
[UsedImplicitly]
public class CommandHandler : CommandHandlerBase<Command>
{
protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
Reporter.Info($"Fixing project references");

Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/Internal/MoveProjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ProjectMoveItem(string oldProjectFileName, string newProjectFileName)
[UsedImplicitly]
public class CommandHandler : CommandHandlerBase<Command>
{
protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
var projects = Workspace.LoadProjects();
var context = new Context(command, projects);
Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/MoveProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Command : IRequest
[UsedImplicitly]
public class CommandHandler : CommandHandlerBase<Command>
{
protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
Reporter.Info($"Moving/renaming project \"{command.ProjectName}\" to \"{command.NewProjectName}\"");

Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/PullPackageVersions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class Command : IRequest
[UsedImplicitly]
public class CommandHandler : CommandHandlerBase<Command>
{
protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
Reporter.Info($"Pulling package versions from project files");

Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/RemoveFromPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public CommandHandler(CommandHandlerDependencies dependencies) : base(dependenci
{
}

protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
var path = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User) ?? "";
var paths = path.Split(Path.PathSeparator).Select(p => p.Trim()).ToHashSet(PathComparer);
Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/RemoveJunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Command : IRequest
[UsedImplicitly]
public class CommandHandler : CommandHandlerBase<Command>
{
protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
var context = new Context(command, Workspace.SolutionFileName);

Expand Down
2 changes: 1 addition & 1 deletion DotNetPlease/Commands/RestorePackageVersions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Command : IRequest

public class CommandHandler : CommandHandlerBase<Command>
{
protected override Task Handle(Command command, CancellationToken cancellationToken)
public override Task Handle(Command command, CancellationToken cancellationToken)
{
Reporter.Info($"Restoring package versions");

Expand Down
23 changes: 11 additions & 12 deletions DotNetPlease/DotNetPlease.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<Configurations>Debug;Release</Configurations>
<PackageId>MorganStanley.DotNetPlease</PackageId>
Expand All @@ -24,21 +24,20 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="MediatR" Version="8.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Build" Version="16.11.0" />
<PackageReference Include="Microsoft.Build.Framework" Version="16.11.0" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.11.0" />
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.Build" Version="17.10.4" />
<PackageReference Include="Microsoft.Build.Framework" Version="17.10.4" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.10.4" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="6.0.0" />
<PackageReference Include="MinVer" Version="4.3.0">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
<PackageReference Include="MinVer" Version="5.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NuGet.Versioning" Version="6.5.0" />
<PackageReference Include="System.Collections.Immutable" Version="6.0.0" />
<PackageReference Include="NuGet.Versioning" Version="6.10.0" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7" />
<PackageReference Include="System.Console" Version="4.3.1" />
</ItemGroup>
Expand Down
6 changes: 5 additions & 1 deletion DotNetPlease/Internal/CommandHandlerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@

using DotNetPlease.Services.Reporting.Abstractions;
using MediatR;
using System.Threading;
using System.Threading.Tasks;

namespace DotNetPlease.Internal
{
public abstract class CommandHandlerBase<TCommand> : AsyncRequestHandler<TCommand> where TCommand : IRequest
public abstract class CommandHandlerBase<TCommand> : IRequestHandler<TCommand> where TCommand : IRequest
{
protected IReporter Reporter { get; }
protected IMediator Mediator { get; }
Expand All @@ -27,5 +29,7 @@ protected CommandHandlerBase(CommandHandlerDependencies dependencies)
Mediator = dependencies.Mediator;
Workspace = dependencies.Workspace;
}

public abstract Task Handle(TCommand request, CancellationToken cancellationToken);
}
}
Loading

0 comments on commit 953b30d

Please sign in to comment.