Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
adamralph committed Dec 17, 2023
1 parent e630900 commit 9044d34
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 2 deletions.
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
}
}
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<!-- workaround for https://github.com/dotnet/roslyn/issues/41640 -->
<NoWarn>EnableGenerateDocumentationFile</NoWarn>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down

0 comments on commit 9044d34

Please sign in to comment.