From 9044d34bdbca40b4d68164846b8bf768c5a3ca73 Mon Sep 17 00:00:00 2001 From: Adam Ralph Date: Sun, 17 Dec 2023 23:55:13 +0000 Subject: [PATCH] wip --- Bullseye/Internal/ArgsParser.cs | 4 ++++ Bullseye/Internal/Target.cs | 10 ++++++++++ Bullseye/Internal/TargetCollection.cs | 4 ++++ Bullseye/Internal/TargetCollectionExtensions.cs | 4 ++-- Bullseye/Palette.cs | 4 ++++ Bullseye/Targets.Instance.Run.cs | 4 ++++ Bullseye/Targets.cs | 4 ++++ Directory.Build.props | 2 ++ 8 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Bullseye/Internal/ArgsParser.cs b/Bullseye/Internal/ArgsParser.cs index 23ca9898..b2f7cc04 100644 --- a/Bullseye/Internal/ArgsParser.cs +++ b/Bullseye/Internal/ArgsParser.cs @@ -40,7 +40,11 @@ public static (IReadOnlyList Targets, Options Options, IReadOnlyList !arg.StartsWith('-'); +#else private static bool IsTarget(string arg) => !arg.StartsWith("-", StringComparison.Ordinal); +#endif private static bool IsNotTarget(string arg) => !IsTarget(arg); } diff --git a/Bullseye/Internal/Target.cs b/Bullseye/Internal/Target.cs index bdc2fe37..57f601dd 100644 --- a/Bullseye/Internal/Target.cs +++ b/Bullseye/Internal/Target.cs @@ -5,6 +5,15 @@ namespace Bullseye.Internal { +#if NET8_0_OR_GREATER + public class Target(string name, string description, IEnumerable dependencies) + { + public string Name { get; } = name; + + public string Description { get; } = description; + + public IReadOnlyCollection Dependencies { get; } = dependencies.ToList(); +#else public class Target { public Target(string name, string description, IEnumerable dependencies) @@ -19,6 +28,7 @@ public Target(string name, string description, IEnumerable dependencies) public string Description { get; } public IReadOnlyCollection Dependencies { get; } +#endif public virtual Task RunAsync(bool dryRun, bool parallel, Output output, Func messageOnly, IReadOnlyCollection dependencyPath) => output.Succeeded(this, dependencyPath, TimeSpan.Zero); diff --git a/Bullseye/Internal/TargetCollection.cs b/Bullseye/Internal/TargetCollection.cs index f1ffdf27..9aa62fd0 100644 --- a/Bullseye/Internal/TargetCollection.cs +++ b/Bullseye/Internal/TargetCollection.cs @@ -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()) +#endif .Add(target.Name); } } diff --git a/Bullseye/Internal/TargetCollectionExtensions.cs b/Bullseye/Internal/TargetCollectionExtensions.cs index 836ddca7..ff823ddc 100644 --- a/Bullseye/Internal/TargetCollectionExtensions.cs +++ b/Bullseye/Internal/TargetCollectionExtensions.cs @@ -247,10 +247,10 @@ private static IEnumerable 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()}"); } diff --git a/Bullseye/Palette.cs b/Bullseye/Palette.cs index 1b83a4b0..6d0646b4 100644 --- a/Bullseye/Palette.cs +++ b/Bullseye/Palette.cs @@ -8,7 +8,11 @@ namespace Bullseye /// 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 /// /// Constructs an instance of . diff --git a/Bullseye/Targets.Instance.Run.cs b/Bullseye/Targets.Instance.Run.cs index 74c8c3fe..f74b2e7d 100644 --- a/Bullseye/Targets.Instance.Run.cs +++ b/Bullseye/Targets.Instance.Run.cs @@ -13,7 +13,11 @@ namespace Bullseye /// public partial class Targets { +#if NET8_0_OR_GREATER + private static readonly List defaultList = []; +#else private static readonly List defaultList = new(); +#endif private static readonly Func defaultMessageOnly = _ => false; /// diff --git a/Bullseye/Targets.cs b/Bullseye/Targets.cs index 47ae5594..b8787dac 100644 --- a/Bullseye/Targets.cs +++ b/Bullseye/Targets.cs @@ -7,6 +7,10 @@ namespace Bullseye /// public partial class Targets { +#if NET8_0_OR_GREATER + private readonly TargetCollection targetCollection = []; +#else private readonly TargetCollection targetCollection = new(); +#endif } } diff --git a/Directory.Build.props b/Directory.Build.props index a5b456d1..a69a8f36 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,6 +6,8 @@ true true true + + EnableGenerateDocumentationFile enable