Skip to content

Commit

Permalink
target .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
adamralph committed Dec 21, 2023
1 parent f208efa commit 4966447
Show file tree
Hide file tree
Showing 30 changed files with 4,809 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: mcr.microsoft.com/dotnet/sdk:7.0
- image: mcr.microsoft.com/dotnet/sdk:8.0
steps:
- checkout
- run:
Expand Down
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
container:
image: mcr.microsoft.com/dotnet/sdk:7.0
image: mcr.microsoft.com/dotnet/sdk:8.0
build_task:
build_script: ./build
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-7.0
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-8.0

RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install lts/* && npm install -g cspell 2>&1"
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
dotnet-version: |
6.0.417
7.0.404
8.0.100
- uses: actions/[email protected]
with:
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/[email protected]
with:
dotnet-version: 7.0.404
dotnet-version: 8.0.100
- uses: actions/[email protected]
- run: dotnet build --configuration Release --nologo
- name: push
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
build:
image: mcr.microsoft.com/dotnet/sdk:7.0
image: mcr.microsoft.com/dotnet/sdk:8.0
script: ./build
3 changes: 1 addition & 2 deletions Bullseye/Bullseye.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>https://github.com/adamralph/bullseye/blob/main/CHANGELOG.md</PackageReleaseNotes>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="MinVer" Version="5.0.0-beta.1" PrivateAssets="All" />
</ItemGroup>

Expand Down
4 changes: 4 additions & 0 deletions Bullseye/Internal/ArgsParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public static (IReadOnlyList<string> Targets, Options Options, IReadOnlyList<str
showHelp: nonHelpArgs.Count != args.Count);
}

#if NET8_0_OR_GREATER
private static bool IsTarget(string arg) => !arg.StartsWith('-');
#else
private static bool IsTarget(string arg) => !arg.StartsWith("-", StringComparison.Ordinal);
#endif

private static bool IsNotTarget(string arg) => !IsTarget(arg);
}
Expand Down
10 changes: 10 additions & 0 deletions Bullseye/Internal/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@

namespace Bullseye.Internal
{
#if NET8_0_OR_GREATER
public class Target(string name, string description, IEnumerable<string> dependencies)
{
public string Name { get; } = name;

public string Description { get; } = description;

public IReadOnlyCollection<string> Dependencies { get; } = dependencies.ToList();
#else
public class Target
{
public Target(string name, string description, IEnumerable<string> dependencies)
Expand All @@ -19,6 +28,7 @@ public Target(string name, string description, IEnumerable<string> dependencies)
public string Description { get; }

public IReadOnlyCollection<string> Dependencies { get; }
#endif

public virtual Task RunAsync(bool dryRun, bool parallel, Output output, Func<Exception, bool> messageOnly, IReadOnlyCollection<Target> dependencyPath) => output.Succeeded(this, dependencyPath, TimeSpan.Zero);

Expand Down
4 changes: 4 additions & 0 deletions Bullseye/Internal/TargetCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ private void CheckForMissingDependencies()
{
_ = (missingDependencies.TryGetValue(dependency, out var set)
? set
#if NET8_0_OR_GREATER
: missingDependencies[dependency] = [])
#else
: missingDependencies[dependency] = new SortedSet<string>())
#endif
.Add(target.Name);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Bullseye/Internal/TargetCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ private static IEnumerable<string> Expand(this TargetCollection targets, IEnumer
continue;
}

yield return matches.Any() ? matches[0].Name : name;
yield return matches.Count != 0 ? matches[0].Name : name;
}

if (ambiguousNames.Any())
if (ambiguousNames.Count != 0)
{
throw new InvalidUsageException($"Ambiguous target{(ambiguousNames.Count > 1 ? "s" : "")}: {ambiguousNames.Spaced()}");
}
Expand Down
4 changes: 4 additions & 0 deletions Bullseye/Palette.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ namespace Bullseye
/// </summary>
public class Palette
{
#if NET8_0_OR_GREATER
private static readonly int[] numbers = [0, 30, 31, 32, 33, 34, 35, 36, 37, 90, 91, 92, 93, 94, 95, 96, 97,];
#else
private static readonly int[] numbers = { 0, 30, 31, 32, 33, 34, 35, 36, 37, 90, 91, 92, 93, 94, 95, 96, 97, };
#endif

/// <summary>
/// Constructs an instance of <see cref="Palette"/>.
Expand Down
4 changes: 4 additions & 0 deletions Bullseye/Targets.Instance.Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ namespace Bullseye
/// </summary>
public partial class Targets
{
#if NET8_0_OR_GREATER
private static readonly List<string> defaultList = [];
#else
private static readonly List<string> defaultList = new();
#endif
private static readonly Func<Exception, bool> defaultMessageOnly = _ => false;

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions Bullseye/Targets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ namespace Bullseye
/// </summary>
public partial class Targets
{
#if NET8_0_OR_GREATER
private readonly TargetCollection targetCollection = [];
#else
private readonly TargetCollection targetCollection = new();
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<RollForward>major</RollForward>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<RollForward>major</RollForward>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<RollForward>major</RollForward>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion BullseyeSmokeTester/BullseyeSmokeTester.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<RollForward>major</RollForward>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion BullseyeTests/BullseyeTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<RollForward>major</RollForward>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions BullseyeTests/OutputTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public static async Task DefaultHost()
#if NET7_0
var expectedPath = "../../../output.default.host.net7.0.txt";
#endif
#if NET8_0
var expectedPath = "../../../output.default.host.net8.0.txt";
#endif

await AssertFile.Contains(expectedPath, output.ToString().Replace(Environment.NewLine, "\r\n", StringComparison.Ordinal));
}
Expand Down Expand Up @@ -66,6 +69,9 @@ public static async Task AllHosts(Host host)
#if NET7_0
var expectedPath = $"../../../output.all.hosts.{host}.net7.0.txt";
#endif
#if NET8_0
var expectedPath = $"../../../output.all.hosts.{host}.net8.0.txt";
#endif

await AssertFile.Contains(expectedPath, output.ToString().Replace(Environment.NewLine, "\r\n", StringComparison.Ordinal));
}
Expand Down
Loading

0 comments on commit 4966447

Please sign in to comment.