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

Upgrade dotnet-please to .NET 8 #94

Merged
merged 2 commits into from
Jun 3, 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/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 @@
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 All @@ -65,7 +65,7 @@
{
using var scope = ServiceProvider.CreateScope();
var parser = BuildCommandLineParser();
var cursorVisible = !Console.IsOutputRedirected && Console.CursorVisible;

Check warning on line 68 in DotNetPlease/App.cs

View workflow job for this annotation

GitHub Actions / build / build

This call site is reachable on all platforms. 'Console.CursorVisible.get' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
if (!Console.IsOutputRedirected)
{
Console.CursorVisible = false;
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 @@
[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 All @@ -62,7 +62,7 @@
projectFileName =>
{
var projectDirectory = Path.GetDirectoryName(projectFileName)!;
var projectDirectoryParent = Directory.GetParent(projectDirectory).FullName!;

Check warning on line 65 in DotNetPlease/Commands/ChangeNamespace.cs

View workflow job for this annotation

GitHub Actions / build / build

Dereference of a possibly null reference.
var projectName = GetProjectNameFromFileName(projectFileName);
var newProjectName = ChangeFileNameWithNamespace(projectName, command.OldNamespace, command.NewNamespace);
var newProjectFileName = newProjectName + Path.GetExtension(projectFileName);
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 @@
[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 Expand Up @@ -101,7 +101,7 @@
foreach (var projectInfo in source.Where(p => projectsToInclude.Contains(p.ProjectFileName)))
{
var projectRelativePath = Path.GetRelativePath(
Path.GetDirectoryName(context.SolutionFileName),

Check warning on line 104 in DotNetPlease/Commands/ExpandReferences.cs

View workflow job for this annotation

GitHub Actions / build / build

Possible null reference argument for parameter 'relativeTo' in 'string Path.GetRelativePath(string relativeTo, string path)'.
projectInfo.ProjectFileName);

Reporter.Success($"Add project {projectRelativePath}");
Expand Down Expand Up @@ -140,7 +140,7 @@
foreach (var projectRef in project.AllEvaluatedItems.Where(i => i.ItemType == "ProjectReference"))
{
IncludeProjectWithDependencies(
Path.GetFullPath(projectRef.EvaluatedInclude, Path.GetDirectoryName(projectFileName)));

Check warning on line 143 in DotNetPlease/Commands/ExpandReferences.cs

View workflow job for this annotation

GitHub Actions / build / build

Possible null reference argument for parameter 'basePath' in 'string Path.GetFullPath(string path, string basePath)'.
}
}
}
Expand Down Expand Up @@ -296,7 +296,7 @@
{
public Command Command { get; }

public Context(Command command)

Check warning on line 299 in DotNetPlease/Commands/ExpandReferences.cs

View workflow job for this annotation

GitHub Actions / build / build

Non-nullable property 'SolutionFileName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
{
Command = 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
Loading