diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 0eecf4ad..49564826 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -14,6 +14,7 @@
true$(MSBuildThisFileDirectory)\..\resources\spectre.snk00240000048000009400000006020000002400005253413100040000010001006146d3789d31477cf4a3b508dcf772ff9ccad8613f6bd6b17b9c4a960a7a7b551ecd22e4f4119ced70ee8bbdf3ca0a117c99fd6248c16255ea9033110c2233d42e74e81bf4f3f7eb09bfe8b53ad399d957514f427171a86f5fe9fe0014be121d571c80c4a0cfc3531bdbf5a2900d936d93f2c94171b9134f7644a1ac3612a0d0
+ true
diff --git a/src/Extensions/Spectre.Console.ImageSharp/CanvasImageExtensions.cs b/src/Extensions/Spectre.Console.ImageSharp/CanvasImageExtensions.cs
index 88724357..9402c9f4 100644
--- a/src/Extensions/Spectre.Console.ImageSharp/CanvasImageExtensions.cs
+++ b/src/Extensions/Spectre.Console.ImageSharp/CanvasImageExtensions.cs
@@ -16,10 +16,7 @@ public static class CanvasImageExtensions
/// The same instance so that multiple calls can be chained.
public static CanvasImage MaxWidth(this CanvasImage image, int? maxWidth)
{
- if (image is null)
- {
- throw new ArgumentNullException(nameof(image));
- }
+ ArgumentNullException.ThrowIfNull(image);
image.MaxWidth = maxWidth;
return image;
@@ -32,10 +29,7 @@ public static class CanvasImageExtensions
/// The same instance so that multiple calls can be chained.
public static CanvasImage NoMaxWidth(this CanvasImage image)
{
- if (image is null)
- {
- throw new ArgumentNullException(nameof(image));
- }
+ ArgumentNullException.ThrowIfNull(image);
image.MaxWidth = null;
return image;
@@ -50,10 +44,7 @@ public static class CanvasImageExtensions
[Obsolete("Not used anymore. Will be removed in future update.")]
public static CanvasImage PixelWidth(this CanvasImage image, int width)
{
- if (image is null)
- {
- throw new ArgumentNullException(nameof(image));
- }
+ ArgumentNullException.ThrowIfNull(image);
image.PixelWidth = width;
return image;
@@ -67,15 +58,9 @@ public static class CanvasImageExtensions
/// The same instance so that multiple calls can be chained.
public static CanvasImage Mutate(this CanvasImage image, Action action)
{
- if (image is null)
- {
- throw new ArgumentNullException(nameof(image));
- }
+ ArgumentNullException.ThrowIfNull(image);
- if (action is null)
- {
- throw new ArgumentNullException(nameof(action));
- }
+ ArgumentNullException.ThrowIfNull(action);
image.Image.Mutate(action);
return image;
@@ -88,10 +73,7 @@ public static class CanvasImageExtensions
/// The same instance so that multiple calls can be chained.
public static CanvasImage BicubicResampler(this CanvasImage image)
{
- if (image is null)
- {
- throw new ArgumentNullException(nameof(image));
- }
+ ArgumentNullException.ThrowIfNull(image);
image.Resampler = KnownResamplers.Bicubic;
return image;
@@ -106,10 +88,7 @@ public static class CanvasImageExtensions
/// The same instance so that multiple calls can be chained.
public static CanvasImage BilinearResampler(this CanvasImage image)
{
- if (image is null)
- {
- throw new ArgumentNullException(nameof(image));
- }
+ ArgumentNullException.ThrowIfNull(image);
image.Resampler = KnownResamplers.Triangle;
return image;
@@ -124,10 +103,7 @@ public static class CanvasImageExtensions
/// The same instance so that multiple calls can be chained.
public static CanvasImage NearestNeighborResampler(this CanvasImage image)
{
- if (image is null)
- {
- throw new ArgumentNullException(nameof(image));
- }
+ ArgumentNullException.ThrowIfNull(image);
image.Resampler = KnownResamplers.NearestNeighbor;
return image;
diff --git a/src/Extensions/Spectre.Console.Json/JsonTextExtensions.cs b/src/Extensions/Spectre.Console.Json/JsonTextExtensions.cs
index 634d72ac..2a371fa5 100644
--- a/src/Extensions/Spectre.Console.Json/JsonTextExtensions.cs
+++ b/src/Extensions/Spectre.Console.Json/JsonTextExtensions.cs
@@ -13,10 +13,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText BracesStyle(this JsonText text, Style? style)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.BracesStyle = style;
return text;
@@ -30,10 +27,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText BracketStyle(this JsonText text, Style? style)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.BracketsStyle = style;
return text;
@@ -47,10 +41,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText MemberStyle(this JsonText text, Style? style)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.MemberStyle = style;
return text;
@@ -64,10 +55,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText ColonStyle(this JsonText text, Style? style)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.ColonStyle = style;
return text;
@@ -81,10 +69,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText CommaStyle(this JsonText text, Style? style)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.CommaStyle = style;
return text;
@@ -98,10 +83,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText StringStyle(this JsonText text, Style? style)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.StringStyle = style;
return text;
@@ -115,10 +97,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText NumberStyle(this JsonText text, Style? style)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.NumberStyle = style;
return text;
@@ -132,10 +111,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText BooleanStyle(this JsonText text, Style? style)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.BooleanStyle = style;
return text;
@@ -149,10 +125,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText NullStyle(this JsonText text, Style? style)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.NullStyle = style;
return text;
@@ -166,10 +139,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText BracesColor(this JsonText text, Color color)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.BracesStyle = new Style(color);
return text;
@@ -183,10 +153,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText BracketColor(this JsonText text, Color color)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.BracketsStyle = new Style(color);
return text;
@@ -200,10 +167,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText MemberColor(this JsonText text, Color color)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.MemberStyle = new Style(color);
return text;
@@ -217,10 +181,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText ColonColor(this JsonText text, Color color)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.ColonStyle = new Style(color);
return text;
@@ -234,10 +195,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText CommaColor(this JsonText text, Color color)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.CommaStyle = new Style(color);
return text;
@@ -251,10 +209,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText StringColor(this JsonText text, Color color)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.StringStyle = new Style(color);
return text;
@@ -268,10 +223,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText NumberColor(this JsonText text, Color color)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.NumberStyle = new Style(color);
return text;
@@ -285,10 +237,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText BooleanColor(this JsonText text, Color color)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.BooleanStyle = new Style(color);
return text;
@@ -302,10 +251,7 @@ public static class JsonTextExtensions
/// The same instance so that multiple calls can be chained.
public static JsonText NullColor(this JsonText text, Color color)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
text.NullStyle = new Style(color);
return text;
diff --git a/src/Extensions/Spectre.Console.Json/JsonTokenizer.cs b/src/Extensions/Spectre.Console.Json/JsonTokenizer.cs
index d23bbf1d..72acaf70 100644
--- a/src/Extensions/Spectre.Console.Json/JsonTokenizer.cs
+++ b/src/Extensions/Spectre.Console.Json/JsonTokenizer.cs
@@ -25,10 +25,10 @@ internal static class JsonTokenizer
{ "null", JsonTokenType.Null },
};
- _allowedEscapedChars = new HashSet
- {
- '\"', '\\', '/', 'b', 'f', 'n', 'r', 't', 'u',
- };
+ _allowedEscapedChars =
+ [
+ '\"', '\\', '/', 'b', 'f', 'n', 'r', 't', 'u'
+ ];
}
public static List Tokenize(string text)
diff --git a/src/Extensions/Spectre.Console.Json/Properties/Usings.cs b/src/Extensions/Spectre.Console.Json/Properties/Usings.cs
index bd90d278..22d00926 100644
--- a/src/Extensions/Spectre.Console.Json/Properties/Usings.cs
+++ b/src/Extensions/Spectre.Console.Json/Properties/Usings.cs
@@ -1,4 +1,3 @@
global using System.Text;
-global using Spectre.Console.Internal;
global using Spectre.Console.Json.Syntax;
global using Spectre.Console.Rendering;
\ No newline at end of file
diff --git a/src/Extensions/Spectre.Console.Json/Spectre.Console.Json.csproj b/src/Extensions/Spectre.Console.Json/Spectre.Console.Json.csproj
index 13c4279f..1c983266 100644
--- a/src/Extensions/Spectre.Console.Json/Spectre.Console.Json.csproj
+++ b/src/Extensions/Spectre.Console.Json/Spectre.Console.Json.csproj
@@ -11,8 +11,8 @@
true
-
-
+
+
@@ -20,4 +20,8 @@
+
+
+
+
diff --git a/src/Extensions/Spectre.Console.Json/Syntax/JsonArray.cs b/src/Extensions/Spectre.Console.Json/Syntax/JsonArray.cs
index 566e7a9d..b7303715 100644
--- a/src/Extensions/Spectre.Console.Json/Syntax/JsonArray.cs
+++ b/src/Extensions/Spectre.Console.Json/Syntax/JsonArray.cs
@@ -15,7 +15,7 @@ public sealed class JsonArray : JsonSyntax
///
public JsonArray()
{
- Items = new List();
+ Items = [];
}
internal override void Accept(JsonSyntaxVisitor visitor, T context)
diff --git a/src/Extensions/Spectre.Console.Json/Syntax/JsonObject.cs b/src/Extensions/Spectre.Console.Json/Syntax/JsonObject.cs
index 6f3b8a4c..a3ab9640 100644
--- a/src/Extensions/Spectre.Console.Json/Syntax/JsonObject.cs
+++ b/src/Extensions/Spectre.Console.Json/Syntax/JsonObject.cs
@@ -15,7 +15,7 @@ public sealed class JsonObject : JsonSyntax
///
public JsonObject()
{
- Members = new List();
+ Members = [];
}
internal override void Accept(JsonSyntaxVisitor visitor, T context)
diff --git a/src/Spectre.Console.SourceGenerator/Emojis/EmojiEmitter.cs b/src/Spectre.Console.SourceGenerator/Emojis/EmojiEmitter.cs
index 18baa585..66c7eb32 100644
--- a/src/Spectre.Console.SourceGenerator/Emojis/EmojiEmitter.cs
+++ b/src/Spectre.Console.SourceGenerator/Emojis/EmojiEmitter.cs
@@ -16,14 +16,14 @@ internal static class EmojiEmitter
/// Format: (OldName, OldIdentifier, NewName, Description)
///
private static readonly (string OldName, string OldIdentifier, string NewName, string Description)[] LegacyAliases =
- {
+ [
// "hugging face" was renamed to "smiling face with open hands"
("HuggingFace", "hugging_face", "SmilingFaceWithOpenHands", "Hugging face"),
// "knocked out face" was renamed to "face with crossed-out eyes"
("KnockedOutFace", "knocked_out_face", "FaceWithCrossedOutEyes", "Knocked-out face"),
// "pouting face" was renamed to "enraged face"
- ("PoutingFace", "pouting_face", "EnragedFace", "Pouting face"),
- };
+ ("PoutingFace", "pouting_face", "EnragedFace", "Pouting face")
+ ];
///
/// Converts a Unicode escape sequence like "\U0001F9EE" to the actual character.
diff --git a/src/Spectre.Console.SourceGenerator/EquatableArray.cs b/src/Spectre.Console.SourceGenerator/EquatableArray.cs
index 675768fd..ba868702 100644
--- a/src/Spectre.Console.SourceGenerator/EquatableArray.cs
+++ b/src/Spectre.Console.SourceGenerator/EquatableArray.cs
@@ -27,7 +27,7 @@ internal readonly struct EquatableArray : IEquatable>, IEnu
///
/// Creates a new EquatableArray from the given enumerable.
///
- public EquatableArray(IEnumerable items) => _array = items.ToImmutableArray();
+ public EquatableArray(IEnumerable items) => _array = [.. items];
///
/// Gets the number of elements.
diff --git a/src/Spectre.Console.Testing/Extensions/ShouldlyExtensions.cs b/src/Spectre.Console.Testing/Extensions/ShouldlyExtensions.cs
index 4f1d8172..aa5776a1 100644
--- a/src/Spectre.Console.Testing/Extensions/ShouldlyExtensions.cs
+++ b/src/Spectre.Console.Testing/Extensions/ShouldlyExtensions.cs
@@ -18,10 +18,7 @@ public static class ShouldlyExtensions
[DebuggerStepThrough]
public static T And(this T item, Action action)
{
- if (action == null)
- {
- throw new ArgumentNullException(nameof(action));
- }
+ ArgumentNullException.ThrowIfNull(action);
action(item);
return item;
diff --git a/src/Spectre.Console.Testing/Extensions/StringExtensions.cs b/src/Spectre.Console.Testing/Extensions/StringExtensions.cs
index 72c0cd86..6e588d76 100644
--- a/src/Spectre.Console.Testing/Extensions/StringExtensions.cs
+++ b/src/Spectre.Console.Testing/Extensions/StringExtensions.cs
@@ -18,7 +18,7 @@ public static class StringExtensions
}
var result = new List();
- foreach (var line in value.NormalizeLineEndings().Split(new[] { '\n' }))
+ foreach (var line in value.NormalizeLineEndings().Split(['\n']))
{
result.Add(line.TrimEnd());
}
diff --git a/src/Spectre.Console.Testing/Spectre.Console.Testing.csproj b/src/Spectre.Console.Testing/Spectre.Console.Testing.csproj
index 367360f4..58097906 100644
--- a/src/Spectre.Console.Testing/Spectre.Console.Testing.csproj
+++ b/src/Spectre.Console.Testing/Spectre.Console.Testing.csproj
@@ -11,4 +11,8 @@
+
+
+
+
diff --git a/src/Spectre.Console.Testing/TestCapabilities.cs b/src/Spectre.Console.Testing/TestCapabilities.cs
index d4f702b8..6d75f54d 100644
--- a/src/Spectre.Console.Testing/TestCapabilities.cs
+++ b/src/Spectre.Console.Testing/TestCapabilities.cs
@@ -33,10 +33,7 @@ public sealed class TestCapabilities : IReadOnlyCapabilities
/// A with the same capabilities as this instace.
public RenderOptions CreateRenderContext(IAnsiConsole console)
{
- if (console is null)
- {
- throw new ArgumentNullException(nameof(console));
- }
+ ArgumentNullException.ThrowIfNull(console);
return RenderOptions.Create(console, this);
}
diff --git a/src/Spectre.Console.Testing/TestConsole.cs b/src/Spectre.Console.Testing/TestConsole.cs
index 54ae67f5..4e4fa6bc 100644
--- a/src/Spectre.Console.Testing/TestConsole.cs
+++ b/src/Spectre.Console.Testing/TestConsole.cs
@@ -37,7 +37,7 @@ public sealed class TestConsole : IAnsiConsole, IDisposable
///
/// Gets the console output lines.
///
- public IReadOnlyList Lines => Output.NormalizeLineEndings().TrimEnd('\n').Split(new char[] { '\n' });
+ public IReadOnlyList Lines => Output.NormalizeLineEndings().TrimEnd('\n').Split(['\n']);
///
/// Gets or sets a value indicating whether or not VT/ANSI sequences
diff --git a/src/Spectre.Console.Testing/TestConsoleInput.cs b/src/Spectre.Console.Testing/TestConsoleInput.cs
index e471d30e..178f743d 100644
--- a/src/Spectre.Console.Testing/TestConsoleInput.cs
+++ b/src/Spectre.Console.Testing/TestConsoleInput.cs
@@ -21,10 +21,7 @@ public sealed class TestConsoleInput : IAnsiConsoleInput
/// The input string.
public void PushText(string input)
{
- if (input is null)
- {
- throw new ArgumentNullException(nameof(input));
- }
+ ArgumentNullException.ThrowIfNull(input);
foreach (var character in input)
{
diff --git a/src/Spectre.Console.Tests/Data/Exceptions.cs b/src/Spectre.Console.Tests/Data/Exceptions.cs
index 15c4e568..ec4f704c 100644
--- a/src/Spectre.Console.Tests/Data/Exceptions.cs
+++ b/src/Spectre.Console.Tests/Data/Exceptions.cs
@@ -34,14 +34,14 @@ public static class TestExceptions
public static List GenericMethodWithOutThatThrows(out List firstFewItems)
{
- firstFewItems = new List();
+ firstFewItems = [];
throw new InvalidOperationException("Throwing!");
}
public static (string Key, List Values) GetTuplesWithInnerException((int First, string Second) myValue)
{
MethodThatThrows(0);
- return ("key", new List());
+ return ("key", []);
}
}
diff --git a/src/Spectre.Console.Tests/Extensions/StreamExtensions.cs b/src/Spectre.Console.Tests/Extensions/StreamExtensions.cs
index 0eed3b87..7c2490c5 100644
--- a/src/Spectre.Console.Tests/Extensions/StreamExtensions.cs
+++ b/src/Spectre.Console.Tests/Extensions/StreamExtensions.cs
@@ -4,10 +4,7 @@ public static class StreamExtensions
{
public static string ReadText(this Stream stream)
{
- if (stream is null)
- {
- throw new ArgumentNullException(nameof(stream));
- }
+ ArgumentNullException.ThrowIfNull(stream);
using (var reader = new StreamReader(stream))
{
diff --git a/src/Spectre.Console.Tests/Properties/Usings.cs b/src/Spectre.Console.Tests/Properties/Usings.cs
index 761b4c5e..c77c1a0c 100644
--- a/src/Spectre.Console.Tests/Properties/Usings.cs
+++ b/src/Spectre.Console.Tests/Properties/Usings.cs
@@ -9,7 +9,6 @@ global using System.Text.RegularExpressions;
global using System.Threading;
global using System.Threading.Tasks;
global using Shouldly;
-global using Spectre.Console.Advanced;
global using Spectre.Console.Json;
global using Spectre.Console.Rendering;
global using Spectre.Console.Testing;
diff --git a/src/Spectre.Console.Tests/Unit/AnsiConsoleTests.Advanced.cs b/src/Spectre.Console.Tests/Unit/AnsiConsoleTests.Ansi.cs
similarity index 97%
rename from src/Spectre.Console.Tests/Unit/AnsiConsoleTests.Advanced.cs
rename to src/Spectre.Console.Tests/Unit/AnsiConsoleTests.Ansi.cs
index f18f563b..206fc6f8 100644
--- a/src/Spectre.Console.Tests/Unit/AnsiConsoleTests.Advanced.cs
+++ b/src/Spectre.Console.Tests/Unit/AnsiConsoleTests.Ansi.cs
@@ -2,7 +2,7 @@ namespace Spectre.Console.Tests.Unit;
public sealed partial class AnsiConsoleTests
{
- public sealed class Advanced
+ public sealed class Ansi
{
[Fact]
public void Should_Write_Ansi_Codes_To_Console_If_Supported()
diff --git a/src/Spectre.Console.Tests/Unit/Prompts/MultiSelectionPromptTests.cs b/src/Spectre.Console.Tests/Unit/Prompts/MultiSelectionPromptTests.cs
index 26f65ae2..15b65eda 100644
--- a/src/Spectre.Console.Tests/Unit/Prompts/MultiSelectionPromptTests.cs
+++ b/src/Spectre.Console.Tests/Unit/Prompts/MultiSelectionPromptTests.cs
@@ -83,7 +83,7 @@ public sealed class MultiSelectionPromptTests
var actual = prompt.GetParents("item");
// Then
- actual.ShouldBe(new[] { "root", "level-1", "level-2" });
+ actual.ShouldBe(["root", "level-1", "level-2"]);
}
[Fact]
diff --git a/src/Spectre.Console.Tests/Unit/Rendering/SegmentTests.cs b/src/Spectre.Console.Tests/Unit/Rendering/SegmentTests.cs
index 645fb7fd..df30d912 100644
--- a/src/Spectre.Console.Tests/Unit/Rendering/SegmentTests.cs
+++ b/src/Spectre.Console.Tests/Unit/Rendering/SegmentTests.cs
@@ -50,16 +50,15 @@ public sealed class SegmentTests
{
// Given, When
var lines = Segment.SplitLines(
- new[]
- {
- new Segment("Foo"),
+ [
+ new Segment("Foo"),
new Segment("Bar"),
new Segment("\n"),
new Segment("Baz"),
new Segment("Qux"),
new Segment("\n"),
- new Segment("Corgi"),
- });
+ new Segment("Corgi")
+ ]);
// Then
lines.Count.ShouldBe(3);
@@ -81,16 +80,15 @@ public sealed class SegmentTests
{
// Given, When
var lines = Segment.SplitLines(
- new[]
- {
- new Segment("Foo"),
+ [
+ new Segment("Foo"),
new Segment("Bar"),
new Segment("\r\n"),
new Segment("Baz"),
new Segment("Qux"),
new Segment("\r\n"),
- new Segment("Corgi"),
- });
+ new Segment("Corgi")
+ ]);
// Then
lines.Count.ShouldBe(3);
@@ -112,14 +110,13 @@ public sealed class SegmentTests
{
// Given, Given
var lines = Segment.SplitLines(
- new[]
- {
- new Segment("Foo\n"),
+ [
+ new Segment("Foo\n"),
new Segment("Bar\n"),
new Segment("Baz"),
new Segment("Qux\n"),
- new Segment("Corgi"),
- });
+ new Segment("Corgi")
+ ]);
// Then
lines.Count.ShouldBe(4);
diff --git a/src/Spectre.Console.Tests/Unit/Widgets/AlignTests.cs b/src/Spectre.Console.Tests/Unit/Widgets/AlignTests.cs
index 2b0163f0..5400bafd 100644
--- a/src/Spectre.Console.Tests/Unit/Widgets/AlignTests.cs
+++ b/src/Spectre.Console.Tests/Unit/Widgets/AlignTests.cs
@@ -1,5 +1,3 @@
-using Spectre.Console.Extensions;
-
namespace Spectre.Console.Tests.Unit;
[ExpectationPath("Widgets/Align")]
diff --git a/src/Spectre.Console.Tests/Unit/Widgets/Table/TableRowCollectionTests.cs b/src/Spectre.Console.Tests/Unit/Widgets/Table/TableRowCollectionTests.cs
index 6e1dc77a..c0e390dc 100644
--- a/src/Spectre.Console.Tests/Unit/Widgets/Table/TableRowCollectionTests.cs
+++ b/src/Spectre.Console.Tests/Unit/Widgets/Table/TableRowCollectionTests.cs
@@ -27,7 +27,7 @@ public sealed class TableRowCollectionTests
table.AddColumn("Column #1");
// When
- table.Rows.Add(new[] { Text.Empty });
+ table.Rows.Add([Text.Empty]);
// Then
table.Rows.Count.ShouldBe(1);
@@ -39,10 +39,10 @@ public sealed class TableRowCollectionTests
// Given
var table = new Table();
table.AddColumn("Column #1");
- table.Rows.Add(new[] { Text.Empty });
+ table.Rows.Add([Text.Empty]);
// When
- var result = table.Rows.Add(new[] { Text.Empty });
+ var result = table.Rows.Add([Text.Empty]);
// Then
result.ShouldBe(1);
@@ -56,9 +56,9 @@ public sealed class TableRowCollectionTests
var console = new TestConsole();
var table = new Table();
table.AddColumn("Column #1");
- table.Rows.Add(new[] { new Text("1") });
- table.Rows.Add(new[] { new Text("2") });
- table.Rows.Add(new[] { new Text("3") });
+ table.Rows.Add([new Text("1")]);
+ table.Rows.Add([new Text("2")]);
+ table.Rows.Add([new Text("3")]);
// When
console.Write(table);
@@ -90,10 +90,10 @@ public sealed class TableRowCollectionTests
// Given
var table = new Table();
table.AddColumn("Column #1");
- table.Rows.Add(new[] { Text.Empty });
+ table.Rows.Add([Text.Empty]);
// When
- table.Rows.Insert(0, new[] { Text.Empty });
+ table.Rows.Insert(0, [Text.Empty]);
// Then
table.Rows.Count.ShouldBe(2);
@@ -105,11 +105,11 @@ public sealed class TableRowCollectionTests
// Given
var table = new Table();
table.AddColumn("Column #1");
- table.Rows.Add(new[] { new Text("1") });
- table.Rows.Add(new[] { new Text("2") });
+ table.Rows.Add([new Text("1")]);
+ table.Rows.Add([new Text("2")]);
// When
- var result = table.Rows.Insert(1, new[] { new Text("3") });
+ var result = table.Rows.Insert(1, [new Text("3")]);
// Then
result.ShouldBe(1);
@@ -123,9 +123,9 @@ public sealed class TableRowCollectionTests
var console = new TestConsole();
var table = new Table();
table.AddColumn("Column #1");
- table.Rows.Add(new[] { new Text("1") });
- table.Rows.Add(new[] { new Text("2") });
- table.Rows.Insert(1, new[] { new Text("3") });
+ table.Rows.Add([new Text("1")]);
+ table.Rows.Add([new Text("2")]);
+ table.Rows.Insert(1, [new Text("3")]);
// When
console.Write(table);
@@ -158,9 +158,9 @@ public sealed class TableRowCollectionTests
// Given
var table = new Table();
table.AddColumn("Column #1");
- table.Rows.Add(new[] { new Text("1") });
- table.Rows.Add(new[] { new Text("2") });
- table.Rows.Add(new[] { new Text("3") });
+ table.Rows.Add([new Text("1")]);
+ table.Rows.Add([new Text("2")]);
+ table.Rows.Add([new Text("3")]);
// When
var result = Record.Exception(() => table.Rows.RemoveAt(3));
@@ -178,9 +178,9 @@ public sealed class TableRowCollectionTests
var console = new TestConsole();
var table = new Table();
table.AddColumn("Column #1");
- table.Rows.Add(new[] { new Text("1") });
- table.Rows.Add(new[] { new Text("2") });
- table.Rows.Add(new[] { new Text("3") });
+ table.Rows.Add([new Text("1")]);
+ table.Rows.Add([new Text("2")]);
+ table.Rows.Add([new Text("3")]);
table.Rows.RemoveAt(1);
// When
@@ -199,9 +199,9 @@ public sealed class TableRowCollectionTests
// Given
var table = new Table();
table.AddColumn("Column #1");
- table.Rows.Add(new[] { new Text("1") });
- table.Rows.Add(new[] { new Text("2") });
- table.Rows.Add(new[] { new Text("3") });
+ table.Rows.Add([new Text("1")]);
+ table.Rows.Add([new Text("2")]);
+ table.Rows.Add([new Text("3")]);
table.Rows.Clear();
// When
@@ -223,9 +223,9 @@ public sealed class TableRowCollectionTests
table.AddColumn("Column #1");
table.AddColumn("Column #2");
table.AddColumn("Column #3");
- table.Rows.Add(new[] { new Text("1") });
- table.Rows.Add(new[] { new Text("2") });
- table.Rows.Add(new[] { new Text("3"), new Text("4"), new Text("8") });
+ table.Rows.Add([new Text("1")]);
+ table.Rows.Add([new Text("2")]);
+ table.Rows.Add([new Text("3"), new Text("4"), new Text("8")]);
table.UpdateCell(2, 2, "5");
@@ -245,9 +245,9 @@ public sealed class TableRowCollectionTests
table.AddColumn("Column #1");
table.AddColumn("Column #2");
table.AddColumn("Column #3");
- table.Rows.Add(new[] { new Text("1") });
- table.Rows.Add(new[] { new Text("2") });
- table.Rows.Add(new[] { new Text("3"), new Text("4"), new Text("8") });
+ table.Rows.Add([new Text("1")]);
+ table.Rows.Add([new Text("2")]);
+ table.Rows.Add([new Text("3"), new Text("4"), new Text("8")]);
table.UpdateCell(2, 2, new Markup("5"));
@@ -267,9 +267,9 @@ public sealed class TableRowCollectionTests
table.AddColumn("Column #1");
table.AddColumn("Column #2");
table.AddColumn("Column #3");
- table.Rows.Add(new[] { new Text("1") });
- table.Rows.Add(new[] { new Text("2") });
- table.Rows.Add(new[] { new Text("3"), new Text("4"), new Text("8") });
+ table.Rows.Add([new Text("1")]);
+ table.Rows.Add([new Text("2")]);
+ table.Rows.Add([new Text("3"), new Text("4"), new Text("8")]);
table.UpdateCell(2, 2, "5");
// When
@@ -289,9 +289,9 @@ public sealed class TableRowCollectionTests
table.AddColumn("Column #1");
table.AddColumn("Column #2");
table.AddColumn("Column #3");
- table.Rows.Add(new[] { new Text("1") });
- table.Rows.Add(new[] { new Text("2") });
- table.Rows.Add(new[] { new Text("3"), new Text("4"), new Text("8") });
+ table.Rows.Add([new Text("1")]);
+ table.Rows.Add([new Text("2")]);
+ table.Rows.Add([new Text("3"), new Text("4"), new Text("8")]);
table.UpdateCell(2, 2, "5");
// When
@@ -311,9 +311,9 @@ public sealed class TableRowCollectionTests
table.AddColumn("Column #1");
table.AddColumn("Column #2");
table.AddColumn("Column #3");
- table.Rows.Add(new[] { new Text("1") });
- table.Rows.Add(new[] { new Text("2") });
- table.Rows.Add(new[] { new Text("3"), new Text("4"), new Text("8") });
+ table.Rows.Add([new Text("1")]);
+ table.Rows.Add([new Text("2")]);
+ table.Rows.Add([new Text("3"), new Text("4"), new Text("8")]);
table.UpdateCell(2, 2, "5");
// When
@@ -333,9 +333,9 @@ public sealed class TableRowCollectionTests
table.AddColumn("Column #1");
table.AddColumn("Column #2");
table.AddColumn("Column #3");
- table.Rows.Add(new[] { new Text("1") });
- table.Rows.Add(new[] { new Text("2") });
- table.Rows.Add(new[] { new Text("3"), new Text("4"), new Text("8") });
+ table.Rows.Add([new Text("1")]);
+ table.Rows.Add([new Text("2")]);
+ table.Rows.Add([new Text("3"), new Text("4"), new Text("8")]);
table.UpdateCell(2, 2, "5");
// When
diff --git a/src/Spectre.Console.Tests/Utilities/EmbeddedResourceReader.cs b/src/Spectre.Console.Tests/Utilities/EmbeddedResourceReader.cs
index 8d74d9e6..bb10c3c5 100644
--- a/src/Spectre.Console.Tests/Utilities/EmbeddedResourceReader.cs
+++ b/src/Spectre.Console.Tests/Utilities/EmbeddedResourceReader.cs
@@ -4,10 +4,7 @@ public static class EmbeddedResourceReader
{
public static Stream LoadResourceStream(string resourceName)
{
- if (resourceName is null)
- {
- throw new ArgumentNullException(nameof(resourceName));
- }
+ ArgumentNullException.ThrowIfNull(resourceName);
var assembly = Assembly.GetCallingAssembly();
resourceName = resourceName.Replace("/", ".");
@@ -23,15 +20,9 @@ public static class EmbeddedResourceReader
public static Stream LoadResourceStream(Assembly assembly, string resourceName)
{
- if (assembly is null)
- {
- throw new ArgumentNullException(nameof(assembly));
- }
+ ArgumentNullException.ThrowIfNull(assembly);
- if (resourceName is null)
- {
- throw new ArgumentNullException(nameof(resourceName));
- }
+ ArgumentNullException.ThrowIfNull(resourceName);
resourceName = resourceName.Replace("/", ".");
var stream = assembly.GetManifestResourceStream(resourceName);
diff --git a/src/Spectre.Console.Tests/Utilities/TestConsoleExtensions.cs b/src/Spectre.Console.Tests/Utilities/TestConsoleExtensions.cs
index 9e020fa3..542c9445 100644
--- a/src/Spectre.Console.Tests/Utilities/TestConsoleExtensions.cs
+++ b/src/Spectre.Console.Tests/Utilities/TestConsoleExtensions.cs
@@ -30,7 +30,7 @@ public static class TestConsoleExtensions
text = _filenameRegex.Replace(text, match =>
{
var value = match.Value;
- var index = value.LastIndexOfAny(new[] { '\\', '/' });
+ var index = value.LastIndexOfAny(['\\', '/']);
var filename = value.Substring(index + 1, value.Length - index - 1);
return $" in /xyz/{filename}";
diff --git a/src/Spectre.Console/AnsiConsole.Prompt.cs b/src/Spectre.Console/AnsiConsole.Prompt.cs
index d51577c6..42c2a67a 100644
--- a/src/Spectre.Console/AnsiConsole.Prompt.cs
+++ b/src/Spectre.Console/AnsiConsole.Prompt.cs
@@ -13,10 +13,7 @@ public static partial class AnsiConsole
/// The prompt input result.
public static T Prompt(IPrompt prompt)
{
- if (prompt is null)
- {
- throw new ArgumentNullException(nameof(prompt));
- }
+ ArgumentNullException.ThrowIfNull(prompt);
return prompt.Show(Console);
}
@@ -30,10 +27,7 @@ public static partial class AnsiConsole
/// The prompt input result.
public static Task PromptAsync(IPrompt prompt, CancellationToken cancellationToken = default)
{
- if (prompt is null)
- {
- throw new ArgumentNullException(nameof(prompt));
- }
+ ArgumentNullException.ThrowIfNull(prompt);
return prompt.ShowAsync(Console, cancellationToken);
}
diff --git a/src/Spectre.Console/AnsiConsole.Recording.cs b/src/Spectre.Console/AnsiConsole.Recording.cs
index a398a374..e62a0546 100644
--- a/src/Spectre.Console/AnsiConsole.Recording.cs
+++ b/src/Spectre.Console/AnsiConsole.Recording.cs
@@ -56,10 +56,7 @@ public static partial class AnsiConsole
throw new InvalidOperationException("Cannot export HTML since a recording hasn't been started.");
}
- if (encoder is null)
- {
- throw new ArgumentNullException(nameof(encoder));
- }
+ ArgumentNullException.ThrowIfNull(encoder);
return _recorder.Export(encoder);
}
diff --git a/src/Spectre.Console/AnsiConsole.Rendering.cs b/src/Spectre.Console/AnsiConsole.Rendering.cs
index ca56a900..643b01f1 100644
--- a/src/Spectre.Console/AnsiConsole.Rendering.cs
+++ b/src/Spectre.Console/AnsiConsole.Rendering.cs
@@ -21,10 +21,7 @@ public static partial class AnsiConsole
/// The object to render.
public static void Write(IRenderable renderable)
{
- if (renderable is null)
- {
- throw new ArgumentNullException(nameof(renderable));
- }
+ ArgumentNullException.ThrowIfNull(renderable);
Console.Write(renderable);
}
diff --git a/src/Spectre.Console/AnsiConsole.Write.cs b/src/Spectre.Console/AnsiConsole.Write.cs
index 8d40819a..2d42fe3a 100644
--- a/src/Spectre.Console/AnsiConsole.Write.cs
+++ b/src/Spectre.Console/AnsiConsole.Write.cs
@@ -213,10 +213,7 @@ public static partial class AnsiConsole
/// The value to write.
public static void Write(IFormatProvider provider, char[] value)
{
- if (value is null)
- {
- throw new ArgumentNullException(nameof(value));
- }
+ ArgumentNullException.ThrowIfNull(value);
for (var index = 0; index < value.Length; index++)
{
diff --git a/src/Spectre.Console/AnsiConsole.WriteLine.cs b/src/Spectre.Console/AnsiConsole.WriteLine.cs
index 57ba6b77..f65e606f 100644
--- a/src/Spectre.Console/AnsiConsole.WriteLine.cs
+++ b/src/Spectre.Console/AnsiConsole.WriteLine.cs
@@ -229,10 +229,7 @@ public static partial class AnsiConsole
/// The value to write.
public static void WriteLine(IFormatProvider provider, char[] value)
{
- if (value is null)
- {
- throw new ArgumentNullException(nameof(value));
- }
+ ArgumentNullException.ThrowIfNull(value);
for (var index = 0; index < value.Length; index++)
{
diff --git a/src/Spectre.Console/AnsiConsoleFactory.cs b/src/Spectre.Console/AnsiConsoleFactory.cs
index b4406b3e..266a84ea 100644
--- a/src/Spectre.Console/AnsiConsoleFactory.cs
+++ b/src/Spectre.Console/AnsiConsoleFactory.cs
@@ -13,10 +13,7 @@ public sealed class AnsiConsoleFactory
/// An implementation of .
public IAnsiConsole Create(AnsiConsoleSettings settings)
{
- if (settings is null)
- {
- throw new ArgumentNullException(nameof(settings));
- }
+ ArgumentNullException.ThrowIfNull(settings);
var output = settings.Out ?? new AnsiConsoleOutput(System.Console.Out);
if (output.Writer == null)
diff --git a/src/Spectre.Console/BoxBorder.cs b/src/Spectre.Console/BoxBorder.cs
index e30d5f31..513a1cb2 100644
--- a/src/Spectre.Console/BoxBorder.cs
+++ b/src/Spectre.Console/BoxBorder.cs
@@ -16,4 +16,28 @@ public abstract partial class BoxBorder
/// The part to get the character representation for.
/// A character representation of the specified border part.
public abstract string GetPart(BoxBorderPart part);
+}
+
+///
+/// Contains extension methods for .
+///
+public static class BoxExtensions
+{
+ ///
+ /// Gets the safe border for a border.
+ ///
+ /// The border to get the safe border for.
+ /// Whether or not to return the safe border.
+ /// The safe border if one exist, otherwise the original border.
+ public static BoxBorder GetSafeBorder(this BoxBorder border, bool safe)
+ {
+ ArgumentNullException.ThrowIfNull(border);
+
+ if (safe && border.SafeBorder != null)
+ {
+ border = border.SafeBorder;
+ }
+
+ return border;
+ }
}
\ No newline at end of file
diff --git a/src/Spectre.Console/Color.cs b/src/Spectre.Console/Color.cs
index 9c87d62f..fa2951e3 100644
--- a/src/Spectre.Console/Color.cs
+++ b/src/Spectre.Console/Color.cs
@@ -3,7 +3,7 @@ namespace Spectre.Console;
///
/// Represents a color.
///
-public partial struct Color : IEquatable
+public readonly partial struct Color : IEquatable
{
///
/// Gets the default color.
@@ -220,10 +220,7 @@ public partial struct Color : IEquatable
/// The color created from the hexadecimal string.
public static Color FromHex(string hex)
{
- if (hex is null)
- {
- throw new ArgumentNullException(nameof(hex));
- }
+ ArgumentNullException.ThrowIfNull(hex);
if (hex.StartsWith("#"))
{
diff --git a/src/Spectre.Console/Emoji.cs b/src/Spectre.Console/Emoji.cs
index aaea7467..7a02ba21 100644
--- a/src/Spectre.Console/Emoji.cs
+++ b/src/Spectre.Console/Emoji.cs
@@ -19,15 +19,8 @@ public static partial class Emoji
/// The emoji.
public static void Remap(string tag, string emoji)
{
- if (tag is null)
- {
- throw new ArgumentNullException(nameof(tag));
- }
-
- if (emoji is null)
- {
- throw new ArgumentNullException(nameof(emoji));
- }
+ ArgumentNullException.ThrowIfNull(tag);
+ ArgumentNullException.ThrowIfNull(emoji);
tag = tag.TrimStart(':').TrimEnd(':');
emoji = emoji.TrimStart(':').TrimEnd(':');
diff --git a/src/Spectre.Console/Enrichment/ProfileEnricher.cs b/src/Spectre.Console/Enrichment/ProfileEnricher.cs
index 7ae68f34..4842e71b 100644
--- a/src/Spectre.Console/Enrichment/ProfileEnricher.cs
+++ b/src/Spectre.Console/Enrichment/ProfileEnricher.cs
@@ -2,33 +2,30 @@ namespace Spectre.Console.Enrichment;
internal static class ProfileEnricher
{
- private static readonly List _defaultEnrichers = new List
- {
- new AppVeyorEnricher(),
- new AzurePipelinesEnricher(),
- new BambooEnricher(),
- new BitbucketEnricher(),
- new BitriseEnricher(),
- new ContinuaEnricher(),
- new GitHubEnricher(),
- new GitLabEnricher(),
- new GoCDEnricher(),
- new JenkinsEnricher(),
- new MyGetEnricher(),
- new TeamCityEnricher(),
- new TfsEnricher(),
- new TravisEnricher(),
- };
+ private static readonly List _defaultEnrichers =
+ [
+ new AppVeyorEnricher(),
+ new AzurePipelinesEnricher(),
+ new BambooEnricher(),
+ new BitbucketEnricher(),
+ new BitriseEnricher(),
+ new ContinuaEnricher(),
+ new GitHubEnricher(),
+ new GitLabEnricher(),
+ new GoCDEnricher(),
+ new JenkinsEnricher(),
+ new MyGetEnricher(),
+ new TeamCityEnricher(),
+ new TfsEnricher(),
+ new TravisEnricher()
+ ];
public static void Enrich(
Profile profile,
ProfileEnrichment settings,
IDictionary? environmentVariables)
{
- if (profile is null)
- {
- throw new ArgumentNullException(nameof(profile));
- }
+ ArgumentNullException.ThrowIfNull(profile);
settings ??= new ProfileEnrichment();
diff --git a/src/Spectre.Console/Extensions/AlignExtensions.cs b/src/Spectre.Console/Extensions/AlignExtensions.cs
deleted file mode 100644
index ad0413b7..00000000
--- a/src/Spectre.Console/Extensions/AlignExtensions.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-namespace Spectre.Console.Extensions;
-
-///
-/// Contains extension methods for .
-///
-public static class AlignExtensions
-{
- ///
- /// Sets the width.
- ///
- /// The object.
- /// The width, or null for no explicit width.
- /// The same instance so that multiple calls can be chained.
- public static Align Width(this Align align, int? width)
- {
- if (align is null)
- {
- throw new ArgumentNullException(nameof(align));
- }
-
- align.Width = width;
- return align;
- }
-
- ///
- /// Sets the height.
- ///
- /// The object.
- /// The height, or null for no explicit height.
- /// The same instance so that multiple calls can be chained.
- public static Align Height(this Align align, int? height)
- {
- if (align is null)
- {
- throw new ArgumentNullException(nameof(align));
- }
-
- align.Height = height;
- return align;
- }
-
- ///
- /// Sets the vertical alignment.
- ///
- /// The object.
- /// The vertical alignment, or null for no vertical alignment.
- /// The same instance so that multiple calls can be chained.
- public static Align VerticalAlignment(this Align align, VerticalAlignment? vertical)
- {
- if (align is null)
- {
- throw new ArgumentNullException(nameof(align));
- }
-
- align.Vertical = vertical;
- return align;
- }
-
- ///
- /// Sets the object to be top aligned.
- ///
- /// The object.
- /// The same instance so that multiple calls can be chained.
- public static Align TopAligned(this Align align)
- {
- if (align is null)
- {
- throw new ArgumentNullException(nameof(align));
- }
-
- align.Vertical = Console.VerticalAlignment.Top;
- return align;
- }
-
- ///
- /// Sets the object to be middle aligned.
- ///
- /// The object.
- /// The same instance so that multiple calls can be chained.
- public static Align MiddleAligned(this Align align)
- {
- if (align is null)
- {
- throw new ArgumentNullException(nameof(align));
- }
-
- align.Vertical = Console.VerticalAlignment.Middle;
- return align;
- }
-
- ///
- /// Sets the object to be bottom aligned.
- ///
- /// The object.
- /// The same instance so that multiple calls can be chained.
- public static Align BottomAligned(this Align align)
- {
- if (align is null)
- {
- throw new ArgumentNullException(nameof(align));
- }
-
- align.Vertical = Console.VerticalAlignment.Bottom;
- return align;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/AlignableExtensions.cs b/src/Spectre.Console/Extensions/AlignableExtensions.cs
deleted file mode 100644
index 4efc934a..00000000
--- a/src/Spectre.Console/Extensions/AlignableExtensions.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class AlignableExtensions
-{
- ///
- /// Sets the alignment for an object.
- ///
- /// The alignable object type.
- /// The alignable object.
- /// The alignment.
- /// The same instance so that multiple calls can be chained.
- public static T Alignment(this T obj, Justify? alignment)
- where T : class, IAlignable
- {
- if (obj is null)
- {
- throw new System.ArgumentNullException(nameof(obj));
- }
-
- obj.Alignment = alignment;
- return obj;
- }
-
- ///
- /// Sets the object to be left aligned.
- ///
- /// The alignable type.
- /// The alignable object.
- /// The same instance so that multiple calls can be chained.
- public static T LeftAligned(this T obj)
- where T : class, IAlignable
- {
- if (obj is null)
- {
- throw new System.ArgumentNullException(nameof(obj));
- }
-
- obj.Alignment = Justify.Left;
- return obj;
- }
-
- ///
- /// Sets the object to be centered.
- ///
- /// The alignable type.
- /// The alignable object.
- /// The same instance so that multiple calls can be chained.
- public static T Centered(this T obj)
- where T : class, IAlignable
- {
- if (obj is null)
- {
- throw new System.ArgumentNullException(nameof(obj));
- }
-
- obj.Alignment = Justify.Center;
- return obj;
- }
-
- ///
- /// Sets the object to be right aligned.
- ///
- /// The alignable type.
- /// The alignable object.
- /// The same instance so that multiple calls can be chained.
- public static T RightAligned(this T obj)
- where T : class, IAlignable
- {
- if (obj is null)
- {
- throw new System.ArgumentNullException(nameof(obj));
- }
-
- obj.Alignment = Justify.Right;
- return obj;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/Advanced/AnsiConsoleExtensions.cs b/src/Spectre.Console/Extensions/AnsiConsoleExtensions.Ansi.cs
similarity index 84%
rename from src/Spectre.Console/Extensions/Advanced/AnsiConsoleExtensions.cs
rename to src/Spectre.Console/Extensions/AnsiConsoleExtensions.Ansi.cs
index 5df87d48..616b1b91 100644
--- a/src/Spectre.Console/Extensions/Advanced/AnsiConsoleExtensions.cs
+++ b/src/Spectre.Console/Extensions/AnsiConsoleExtensions.Ansi.cs
@@ -1,9 +1,9 @@
-namespace Spectre.Console.Advanced;
+namespace Spectre.Console;
///
/// Contains extension methods for .
///
-public static class AnsiConsoleExtensions
+public static partial class AnsiConsoleExtensions
{
///
/// Writes a VT/Ansi control code sequence to the console (if supported).
@@ -12,10 +12,7 @@ public static class AnsiConsoleExtensions
/// The VT/Ansi control code sequence to write.
public static void WriteAnsi(this IAnsiConsole console, string sequence)
{
- if (console is null)
- {
- throw new ArgumentNullException(nameof(console));
- }
+ ArgumentNullException.ThrowIfNull(console);
if (console.Profile.Capabilities.Ansi)
{
@@ -31,6 +28,8 @@ public static class AnsiConsoleExtensions
/// The VT/ANSI control code sequence.
public static string ToAnsi(this IAnsiConsole console, IRenderable renderable)
{
+ ArgumentNullException.ThrowIfNull(console);
+
return AnsiBuilder.Build(console, renderable);
}
}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/AnsiConsoleExtensions.Async.cs b/src/Spectre.Console/Extensions/AnsiConsoleExtensions.Async.cs
index 34504880..8116a5a9 100644
--- a/src/Spectre.Console/Extensions/AnsiConsoleExtensions.Async.cs
+++ b/src/Spectre.Console/Extensions/AnsiConsoleExtensions.Async.cs
@@ -1,4 +1,4 @@
-namespace Spectre.Console.Extensions;
+namespace Spectre.Console;
///
/// Provides extension methods for running tasks with a spinner animation.
@@ -13,8 +13,11 @@ public static class SpinnerExtensions
/// The style to apply to the spinner.
/// The console to write to.
/// The result of the task.
- public static async Task Spinner(this Task task, Spinner? spinner = null, Style? style = null, IAnsiConsole? ansiConsole = null)
+ public static async Task Spinner(this Task task, Spinner? spinner = null, Style? style = null,
+ IAnsiConsole? ansiConsole = null)
{
+ ArgumentNullException.ThrowIfNull(task);
+
await SpinnerInternal
public static partial class AnsiConsoleExtensions
{
- ///
- /// Creates a recorder for the specified console.
- ///
- /// The console to record.
- /// A recorder for the specified console.
- public static Recorder CreateRecorder(this IAnsiConsole console)
- {
- return new Recorder(console);
- }
-
///
/// Clears the console.
///
/// The console to clear.
public static void Clear(this IAnsiConsole console)
{
- if (console is null)
- {
- throw new ArgumentNullException(nameof(console));
- }
+ ArgumentNullException.ThrowIfNull(console);
console.Clear(true);
}
-
- ///
- /// Writes the specified string value to the console.
- ///
- /// The console to write to.
- /// The text to write.
- public static void Write(this IAnsiConsole console, string text)
- {
- if (console is null)
- {
- throw new ArgumentNullException(nameof(console));
- }
-
- console.Write(new Text(text, Style.Plain));
- }
-
- ///
- /// Writes the specified string value to the console.
- ///
- /// The console to write to.
- /// The text to write.
- /// The text style or if .
- public static void Write(this IAnsiConsole console, string text, Style? style)
- {
- if (console is null)
- {
- throw new ArgumentNullException(nameof(console));
- }
-
- console.Write(new Text(text, style));
- }
-
- ///
- /// Writes an empty line to the console.
- ///
- /// The console to write to.
- public static void WriteLine(this IAnsiConsole console)
- {
- if (console is null)
- {
- throw new ArgumentNullException(nameof(console));
- }
-
- console.Write(Text.NewLine);
- }
-
- ///
- /// Writes the specified string value, followed by the current line terminator, to the console.
- ///
- /// The console to write to.
- /// The text to write.
- public static void WriteLine(this IAnsiConsole console, string text)
- {
- WriteLine(console, text, Style.Plain);
- }
-
- ///
- /// Writes the specified string value, followed by the current line terminator, to the console.
- ///
- /// The console to write to.
- /// The text to write.
- /// The text style or if .
- public static void WriteLine(this IAnsiConsole console, string text, Style? style)
- {
- if (console is null)
- {
- throw new ArgumentNullException(nameof(console));
- }
-
- if (text is null)
- {
- throw new ArgumentNullException(nameof(text));
- }
-
- console.Write(text + Environment.NewLine, style);
- }
}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/BarChartExtensions.cs b/src/Spectre.Console/Extensions/BarChartExtensions.cs
deleted file mode 100644
index 80299817..00000000
--- a/src/Spectre.Console/Extensions/BarChartExtensions.cs
+++ /dev/null
@@ -1,292 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class BarChartExtensions
-{
- ///
- /// Adds an item to the bar chart.
- ///
- /// The bar chart.
- /// The item label.
- /// The item value.
- /// The item color.
- /// The same instance so that multiple calls can be chained.
- public static BarChart AddItem(this BarChart chart, string label, double value, Color? color = null)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.Data.Add(new BarChartItem(label, value, color));
- return chart;
- }
-
- ///
- /// Adds an item to the bar chart.
- ///
- /// A type that implements .
- /// The bar chart.
- /// The item.
- /// The same instance so that multiple calls can be chained.
- public static BarChart AddItem(this BarChart chart, T item)
- where T : IBarChartItem
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- if (item is BarChartItem barChartItem)
- {
- chart.Data.Add(barChartItem);
- }
- else
- {
- chart.Data.Add(
- new BarChartItem(
- item.Label,
- item.Value,
- item.Color));
- }
-
- return chart;
- }
-
- ///
- /// Adds multiple items to the bar chart.
- ///
- /// A type that implements .
- /// The bar chart.
- /// The items.
- /// The same instance so that multiple calls can be chained.
- public static BarChart AddItems(this BarChart chart, IEnumerable items)
- where T : IBarChartItem
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- if (items is null)
- {
- throw new ArgumentNullException(nameof(items));
- }
-
- foreach (var item in items)
- {
- AddItem(chart, item);
- }
-
- return chart;
- }
-
- ///
- /// Adds multiple items to the bar chart.
- ///
- /// A type that implements .
- /// The bar chart.
- /// The items.
- /// The converter that converts instances of T to .
- /// The same instance so that multiple calls can be chained.
- public static BarChart AddItems(this BarChart chart, IEnumerable items, Func converter)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- if (items is null)
- {
- throw new ArgumentNullException(nameof(items));
- }
-
- if (converter is null)
- {
- throw new ArgumentNullException(nameof(converter));
- }
-
- foreach (var item in items)
- {
- chart.Data.Add(converter(item));
- }
-
- return chart;
- }
-
- ///
- /// Sets the value formatter for the bar chart using culture info.
- ///
- /// The bar chart.
- /// The value formatter function with culture info.
- /// The same instance so that multiple calls can be chained.
- public static BarChart UseValueFormatter(this BarChart chart, Func? func)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.ValueFormatter = func;
- return chart;
- }
-
- ///
- /// Sets the value formatter for the bar chart.
- ///
- /// The bar chart.
- /// The value formatter to use.
- /// The same instance so that multiple calls can be chained.
- public static BarChart UseValueFormatter(this BarChart chart, Func? func)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.ValueFormatter = func != null
- ? (value, _) => func(value)
- : null;
-
- return chart;
- }
-
- ///
- /// Sets the width of the bar chart.
- ///
- /// The bar chart.
- /// The bar chart width.
- /// The same instance so that multiple calls can be chained.
- public static BarChart Width(this BarChart chart, int? width)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.Width = width;
- return chart;
- }
-
- ///
- /// Sets the label of the bar chart.
- ///
- /// The bar chart.
- /// The bar chart label.
- /// The same instance so that multiple calls can be chained.
- public static BarChart Label(this BarChart chart, string? label)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.Label = label;
- return chart;
- }
-
- ///
- /// Shows values next to each bar in the bar chart.
- ///
- /// The bar chart.
- /// The same instance so that multiple calls can be chained.
- public static BarChart ShowValues(this BarChart chart)
- {
- return ShowValues(chart, true);
- }
-
- ///
- /// Hides values next to each bar in the bar chart.
- ///
- /// The bar chart.
- /// The same instance so that multiple calls can be chained.
- public static BarChart HideValues(this BarChart chart)
- {
- return ShowValues(chart, false);
- }
-
- ///
- /// Sets whether or not values should be shown
- /// next to each bar.
- ///
- /// The bar chart.
- /// Whether or not values should be shown next to each bar.
- /// The same instance so that multiple calls can be chained.
- public static BarChart ShowValues(this BarChart chart, bool show)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.ShowValues = show;
- return chart;
- }
-
- ///
- /// Aligns the label to the left.
- ///
- /// The bar chart.
- /// The same instance so that multiple calls can be chained.
- public static BarChart LeftAlignLabel(this BarChart chart)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.LabelAlignment = Justify.Left;
- return chart;
- }
-
- ///
- /// Centers the label.
- ///
- /// The bar chart.
- /// The same instance so that multiple calls can be chained.
- public static BarChart CenterLabel(this BarChart chart)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.LabelAlignment = Justify.Center;
- return chart;
- }
-
- ///
- /// Aligns the label to the right.
- ///
- /// The bar chart.
- /// The same instance so that multiple calls can be chained.
- public static BarChart RightAlignLabel(this BarChart chart)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.LabelAlignment = Justify.Right;
- return chart;
- }
-
- ///
- /// Sets the max fixed value for the chart.
- ///
- /// The bar chart.
- /// Max value for the chart.
- /// The same instance so that multiple calls can be chained.
- public static BarChart WithMaxValue(this BarChart chart, double maxValue)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.MaxValue = maxValue;
- return chart;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/CharExtensions.cs b/src/Spectre.Console/Extensions/Bcl/CharExtensions.cs
similarity index 74%
rename from src/Spectre.Console/Extensions/CharExtensions.cs
rename to src/Spectre.Console/Extensions/Bcl/CharExtensions.cs
index 268a2dfa..3f16a59a 100644
--- a/src/Spectre.Console/Extensions/CharExtensions.cs
+++ b/src/Spectre.Console/Extensions/Bcl/CharExtensions.cs
@@ -5,6 +5,7 @@ namespace Spectre.Console;
///
public static partial class CharExtensions
{
+#if WCWIDTH
///
/// Gets the cell width of a character.
///
@@ -14,4 +15,10 @@ public static partial class CharExtensions
{
return Cell.GetCellLength(character);
}
+#endif
+
+ internal static bool IsDigit(this char character, int min = 0)
+ {
+ return char.IsDigit(character) && character >= (char)min;
+ }
}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/DayOfWeekExtensions.cs b/src/Spectre.Console/Extensions/Bcl/DayOfWeekExtensions.cs
similarity index 100%
rename from src/Spectre.Console/Extensions/DayOfWeekExtensions.cs
rename to src/Spectre.Console/Extensions/Bcl/DayOfWeekExtensions.cs
diff --git a/src/Spectre.Console/Extensions/DictionaryExtensions.cs b/src/Spectre.Console/Extensions/Bcl/DictionaryExtensions.cs
similarity index 100%
rename from src/Spectre.Console/Extensions/DictionaryExtensions.cs
rename to src/Spectre.Console/Extensions/Bcl/DictionaryExtensions.cs
diff --git a/src/Spectre.Console/Internal/Extensions/EnumerableExtensions.cs b/src/Spectre.Console/Extensions/Bcl/EnumerableExtensions.cs
similarity index 90%
rename from src/Spectre.Console/Internal/Extensions/EnumerableExtensions.cs
rename to src/Spectre.Console/Extensions/Bcl/EnumerableExtensions.cs
index fbb73bbb..a0148222 100644
--- a/src/Spectre.Console/Internal/Extensions/EnumerableExtensions.cs
+++ b/src/Spectre.Console/Extensions/Bcl/EnumerableExtensions.cs
@@ -6,10 +6,7 @@ internal static class EnumerableExtensions
// so we won't have to cast List to IEnumerable.
public static IEnumerable ReverseEnumerable(this IEnumerable source)
{
- if (source is null)
- {
- throw new ArgumentNullException(nameof(source));
- }
+ ArgumentNullException.ThrowIfNull(source);
return source.Reverse();
}
@@ -76,20 +73,14 @@ internal static class EnumerableExtensions
public static IEnumerable<(int Index, bool First, bool Last, T Item)> Enumerate(this IEnumerable source)
{
- if (source is null)
- {
- throw new ArgumentNullException(nameof(source));
- }
+ ArgumentNullException.ThrowIfNull(source);
return Enumerate(source.GetEnumerator());
}
public static IEnumerable<(int Index, bool First, bool Last, T Item)> Enumerate(this IEnumerator source)
{
- if (source is null)
- {
- throw new ArgumentNullException(nameof(source));
- }
+ ArgumentNullException.ThrowIfNull(source);
var first = true;
var last = !source.MoveNext();
diff --git a/src/Spectre.Console/Extensions/ExceptionExtensions.cs b/src/Spectre.Console/Extensions/Bcl/ExceptionExtensions.cs
similarity index 79%
rename from src/Spectre.Console/Extensions/ExceptionExtensions.cs
rename to src/Spectre.Console/Extensions/Bcl/ExceptionExtensions.cs
index 913162c3..76e1866b 100644
--- a/src/Spectre.Console/Extensions/ExceptionExtensions.cs
+++ b/src/Spectre.Console/Extensions/Bcl/ExceptionExtensions.cs
@@ -14,10 +14,7 @@ public static class ExceptionExtensions
[RequiresDynamicCode(ExceptionFormatter.AotWarning)]
public static IRenderable GetRenderable(this Exception exception, ExceptionFormats format = ExceptionFormats.Default)
{
- if (exception is null)
- {
- throw new ArgumentNullException(nameof(exception));
- }
+ ArgumentNullException.ThrowIfNull(exception);
return GetRenderable(exception, new ExceptionSettings
{
@@ -34,15 +31,9 @@ public static class ExceptionExtensions
[RequiresDynamicCode(ExceptionFormatter.AotWarning)]
public static IRenderable GetRenderable(this Exception exception, ExceptionSettings settings)
{
- if (exception is null)
- {
- throw new ArgumentNullException(nameof(exception));
- }
+ ArgumentNullException.ThrowIfNull(exception);
- if (settings is null)
- {
- throw new ArgumentNullException(nameof(settings));
- }
+ ArgumentNullException.ThrowIfNull(settings);
return ExceptionFormatter.Format(exception, settings);
}
diff --git a/src/Spectre.Console/Extensions/Int32Extensions.cs b/src/Spectre.Console/Extensions/Bcl/Int32Extensions.cs
similarity index 100%
rename from src/Spectre.Console/Extensions/Int32Extensions.cs
rename to src/Spectre.Console/Extensions/Bcl/Int32Extensions.cs
diff --git a/src/Spectre.Console/Extensions/ListExtensions.cs b/src/Spectre.Console/Extensions/Bcl/ListExtensions.cs
similarity index 68%
rename from src/Spectre.Console/Extensions/ListExtensions.cs
rename to src/Spectre.Console/Extensions/Bcl/ListExtensions.cs
index 2a7862c1..021dce7c 100644
--- a/src/Spectre.Console/Extensions/ListExtensions.cs
+++ b/src/Spectre.Console/Extensions/Bcl/ListExtensions.cs
@@ -4,10 +4,7 @@ internal static class ListExtensions
{
public static void RemoveLast(this List list)
{
- if (list is null)
- {
- throw new ArgumentNullException(nameof(list));
- }
+ ArgumentNullException.ThrowIfNull(list);
if (list.Count > 0)
{
@@ -17,10 +14,7 @@ internal static class ListExtensions
public static void AddOrReplaceLast(this List list, T item)
{
- if (list is null)
- {
- throw new ArgumentNullException(nameof(list));
- }
+ ArgumentNullException.ThrowIfNull(list);
if (list.Count == 0)
{
diff --git a/src/Spectre.Console/Extensions/StackExtensions.cs b/src/Spectre.Console/Extensions/Bcl/StackExtensions.cs
similarity index 74%
rename from src/Spectre.Console/Extensions/StackExtensions.cs
rename to src/Spectre.Console/Extensions/Bcl/StackExtensions.cs
index a25143e8..1354cc88 100644
--- a/src/Spectre.Console/Extensions/StackExtensions.cs
+++ b/src/Spectre.Console/Extensions/Bcl/StackExtensions.cs
@@ -4,10 +4,7 @@ internal static class StackExtensions
{
public static void PushRange(this Stack stack, IEnumerable source)
{
- if (stack is null)
- {
- throw new ArgumentNullException(nameof(stack));
- }
+ ArgumentNullException.ThrowIfNull(stack);
if (source != null)
{
diff --git a/src/Spectre.Console/Extensions/StringBuilderExtensions.cs b/src/Spectre.Console/Extensions/Bcl/StringBuilderExtensions.cs
similarity index 100%
rename from src/Spectre.Console/Extensions/StringBuilderExtensions.cs
rename to src/Spectre.Console/Extensions/Bcl/StringBuilderExtensions.cs
diff --git a/src/Spectre.Console/Extensions/StringExtensions.cs b/src/Spectre.Console/Extensions/Bcl/StringExtensions.cs
similarity index 93%
rename from src/Spectre.Console/Extensions/StringExtensions.cs
rename to src/Spectre.Console/Extensions/Bcl/StringExtensions.cs
index 0c324e4f..38b0e524 100644
--- a/src/Spectre.Console/Extensions/StringExtensions.cs
+++ b/src/Spectre.Console/Extensions/Bcl/StringExtensions.cs
@@ -101,8 +101,8 @@ public static class StringExtensions
internal static string[] SplitLines(this string text)
{
- var result = text?.NormalizeNewLines()?.Split(new[] { '\n' }, StringSplitOptions.None);
- return result ?? Array.Empty();
+ var result = text?.NormalizeNewLines()?.Split(['\n'], StringSplitOptions.None);
+ return result ?? [];
}
internal static string[] SplitWords(this string word, StringSplitOptions options = StringSplitOptions.None)
@@ -151,10 +151,7 @@ public static class StringExtensions
internal static string Repeat(this string text, int count)
{
- if (text is null)
- {
- throw new ArgumentNullException(nameof(text));
- }
+ ArgumentNullException.ThrowIfNull(text);
if (count <= 0)
{
@@ -219,20 +216,11 @@ public static class StringExtensions
/// Markup of input with the first matched text highlighted.
internal static string Highlight(this string value, string searchText, Style? highlightStyle)
{
- if (value is null)
- {
- throw new ArgumentNullException(nameof(value));
- }
+ ArgumentNullException.ThrowIfNull(value);
- if (searchText is null)
- {
- throw new ArgumentNullException(nameof(searchText));
- }
+ ArgumentNullException.ThrowIfNull(searchText);
- if (highlightStyle is null)
- {
- throw new ArgumentNullException(nameof(highlightStyle));
- }
+ ArgumentNullException.ThrowIfNull(highlightStyle);
if (searchText.Length == 0)
{
diff --git a/src/Spectre.Console/Extensions/TextWriterExtensions.cs b/src/Spectre.Console/Extensions/Bcl/TextWriterExtensions.cs
similarity index 100%
rename from src/Spectre.Console/Extensions/TextWriterExtensions.cs
rename to src/Spectre.Console/Extensions/Bcl/TextWriterExtensions.cs
diff --git a/src/Spectre.Console/Extensions/BoxExtensions.cs b/src/Spectre.Console/Extensions/BoxExtensions.cs
deleted file mode 100644
index 49250ec7..00000000
--- a/src/Spectre.Console/Extensions/BoxExtensions.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-namespace Spectre.Console.Rendering;
-
-///
-/// Contains extension methods for .
-///
-public static class BoxExtensions
-{
- ///
- /// Gets the safe border for a border.
- ///
- /// The border to get the safe border for.
- /// Whether or not to return the safe border.
- /// The safe border if one exist, otherwise the original border.
- public static BoxBorder GetSafeBorder(this BoxBorder border, bool safe)
- {
- if (border is null)
- {
- throw new ArgumentNullException(nameof(border));
- }
-
- if (safe && border.SafeBorder != null)
- {
- border = border.SafeBorder;
- }
-
- return border;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/BreakdownChartExtensions.cs b/src/Spectre.Console/Extensions/BreakdownChartExtensions.cs
deleted file mode 100644
index ed3610f4..00000000
--- a/src/Spectre.Console/Extensions/BreakdownChartExtensions.cs
+++ /dev/null
@@ -1,317 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class BreakdownChartExtensions
-{
- ///
- /// Adds an item to the breakdown chart.
- ///
- /// The breakdown chart.
- /// The item label.
- /// The item value.
- /// The item color.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart AddItem(this BreakdownChart chart, string label, double value, Color color)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.Data.Add(new BreakdownChartItem(label, value, color));
- return chart;
- }
-
- ///
- /// Adds an item to the breakdown chart.
- ///
- /// A type that implements .
- /// The breakdown chart.
- /// The item.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart AddItem(this BreakdownChart chart, T item)
- where T : IBreakdownChartItem
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- if (item is BreakdownChartItem chartItem)
- {
- chart.Data.Add(chartItem);
- }
- else
- {
- chart.Data.Add(
- new BreakdownChartItem(
- item.Label,
- item.Value,
- item.Color));
- }
-
- return chart;
- }
-
- ///
- /// Adds multiple items to the breakdown chart.
- ///
- /// A type that implements .
- /// The breakdown chart.
- /// The items.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart AddItems(this BreakdownChart chart, IEnumerable items)
- where T : IBreakdownChartItem
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- if (items is null)
- {
- throw new ArgumentNullException(nameof(items));
- }
-
- foreach (var item in items)
- {
- AddItem(chart, item);
- }
-
- return chart;
- }
-
- ///
- /// Adds multiple items to the breakdown chart.
- ///
- /// A type that implements .
- /// The breakdown chart.
- /// The items.
- /// The converter that converts instances of T to .
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart AddItems(this BreakdownChart chart, IEnumerable items, Func converter)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- if (items is null)
- {
- throw new ArgumentNullException(nameof(items));
- }
-
- if (converter is null)
- {
- throw new ArgumentNullException(nameof(converter));
- }
-
- foreach (var item in items)
- {
- chart.Data.Add(converter(item));
- }
-
- return chart;
- }
-
- ///
- /// Sets the width of the breakdown chart.
- ///
- /// The breakdown chart.
- /// The breakdown chart width.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart Width(this BreakdownChart chart, int? width)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.Width = width;
- return chart;
- }
-
- ///
- /// Tags will be shown.
- ///
- /// The breakdown chart.
- /// The value formatter to use.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart UseValueFormatter(this BreakdownChart chart, Func? func)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.ValueFormatter = func;
- return chart;
- }
-
- ///
- /// Tags will be shown.
- ///
- /// The breakdown chart.
- /// The value formatter to use.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart UseValueFormatter(this BreakdownChart chart, Func? func)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.ValueFormatter = func != null
- ? (value, _) => func(value)
- : null;
-
- return chart;
- }
-
- ///
- /// Tags will be shown.
- ///
- /// The breakdown chart.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart ShowPercentage(this BreakdownChart chart)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.ValueFormatter = (value, culture) => string.Format(culture, "{0}%", value);
-
- return chart;
- }
-
- ///
- /// Tags will be shown.
- ///
- /// The breakdown chart.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart ShowTags(this BreakdownChart chart)
- {
- return ShowTags(chart, true);
- }
-
- ///
- /// Tags will be not be shown.
- ///
- /// The breakdown chart.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart HideTags(this BreakdownChart chart)
- {
- return ShowTags(chart, false);
- }
-
- ///
- /// Sets whether or not tags will be shown.
- ///
- /// The breakdown chart.
- /// Whether or not tags will be shown.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart ShowTags(this BreakdownChart chart, bool show)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.ShowTags = show;
- return chart;
- }
-
- ///
- /// Tag values will be shown.
- ///
- /// The breakdown chart.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart ShowTagValues(this BreakdownChart chart)
- {
- return ShowTagValues(chart, true);
- }
-
- ///
- /// Tag values will be not be shown.
- ///
- /// The breakdown chart.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart HideTagValues(this BreakdownChart chart)
- {
- return ShowTagValues(chart, false);
- }
-
- ///
- /// Sets whether or not tag values will be shown.
- ///
- /// The breakdown chart.
- /// Whether or not tag values will be shown.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart ShowTagValues(this BreakdownChart chart, bool show)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.ShowTagValues = show;
- return chart;
- }
-
- ///
- /// Chart and tags is rendered in compact mode.
- ///
- /// The breakdown chart.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart Compact(this BreakdownChart chart)
- {
- return Compact(chart, true);
- }
-
- ///
- /// Chart and tags is rendered in full size mode.
- ///
- /// The breakdown chart.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart FullSize(this BreakdownChart chart)
- {
- return Compact(chart, false);
- }
-
- ///
- /// Sets whether or not the chart and tags should be rendered in compact mode.
- ///
- /// The breakdown chart.
- /// Whether or not the chart and tags should be rendered in compact mode.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart Compact(this BreakdownChart chart, bool compact)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.Compact = compact;
- return chart;
- }
-
- ///
- /// Sets the .
- ///
- /// The breakdown chart.
- /// The to set.
- /// The same instance so that multiple calls can be chained.
- public static BreakdownChart WithValueColor(this BreakdownChart chart, Color color)
- {
- if (chart is null)
- {
- throw new ArgumentNullException(nameof(chart));
- }
-
- chart.ValueColor = color;
- return chart;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/CalendarExtensions.cs b/src/Spectre.Console/Extensions/CalendarExtensions.cs
deleted file mode 100644
index 7ea93583..00000000
--- a/src/Spectre.Console/Extensions/CalendarExtensions.cs
+++ /dev/null
@@ -1,133 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class CalendarExtensions
-{
- ///
- /// Adds a calendar event.
- ///
- /// The calendar to add the calendar event to.
- /// The calendar event date.
- /// The calendar event custom highlight style.
- /// The same instance so that multiple calls can be chained.
- public static Calendar AddCalendarEvent(this Calendar calendar, DateTime date, Style? customEventHighlightStyle = null)
- {
- return AddCalendarEvent(calendar, string.Empty, date.Year, date.Month, date.Day, customEventHighlightStyle);
- }
-
- ///
- /// Adds a calendar event.
- ///
- /// The calendar to add the calendar event to.
- /// The calendar event description.
- /// The calendar event date.
- /// The calendar event custom highlight style.
- /// The same instance so that multiple calls can be chained.
- public static Calendar AddCalendarEvent(this Calendar calendar, string description, DateTime date, Style? customEventHighlightStyle = null)
- {
- return AddCalendarEvent(calendar, description, date.Year, date.Month, date.Day, customEventHighlightStyle);
- }
-
- ///
- /// Adds a calendar event.
- ///
- /// The calendar to add the calendar event to.
- /// The year of the calendar event.
- /// The month of the calendar event.
- /// The day of the calendar event.
- /// The calendar event custom highlight style.
- /// The same instance so that multiple calls can be chained.
- public static Calendar AddCalendarEvent(this Calendar calendar, int year, int month, int day, Style? customEventHighlightStyle = null)
- {
- return AddCalendarEvent(calendar, string.Empty, year, month, day, customEventHighlightStyle);
- }
-
- ///
- /// Adds a calendar event.
- ///
- /// The calendar.
- /// The calendar event description.
- /// The year of the calendar event.
- /// The month of the calendar event.
- /// The day of the calendar event.
- /// The calendar event custom highlight style.
- /// The same instance so that multiple calls can be chained.
- public static Calendar AddCalendarEvent(this Calendar calendar, string description, int year, int month, int day, Style? customEventHighlightStyle = null)
- {
- if (calendar is null)
- {
- throw new ArgumentNullException(nameof(calendar));
- }
-
- calendar.CalendarEvents.Add(new CalendarEvent(description, year, month, day, customEventHighlightStyle));
- return calendar;
- }
-
- ///
- /// Sets the calendar's highlight .
- ///
- /// The calendar.
- /// The default highlight style.
- /// The same instance so that multiple calls can be chained.
- public static Calendar HighlightStyle(this Calendar calendar, Style? style)
- {
- if (calendar is null)
- {
- throw new ArgumentNullException(nameof(calendar));
- }
-
- calendar.HighlightStyle = style ?? Style.Plain;
- return calendar;
- }
-
- ///
- /// Sets the calendar's header .
- ///
- /// The calendar.
- /// The header style.
- /// The same instance so that multiple calls can be chained.
- public static Calendar HeaderStyle(this Calendar calendar, Style? style)
- {
- if (calendar is null)
- {
- throw new ArgumentNullException(nameof(calendar));
- }
-
- calendar.HeaderStyle = style ?? Style.Plain;
- return calendar;
- }
-
- ///
- /// Shows the calendar header.
- ///
- /// The calendar.
- /// The same instance so that multiple calls can be chained.
- public static Calendar ShowHeader(this Calendar calendar)
- {
- if (calendar is null)
- {
- throw new ArgumentNullException(nameof(calendar));
- }
-
- calendar.ShowHeader = true;
- return calendar;
- }
-
- ///
- /// Hides the calendar header.
- ///
- /// The calendar.
- /// The same instance so that multiple calls can be chained.
- public static Calendar HideHeader(this Calendar calendar)
- {
- if (calendar is null)
- {
- throw new ArgumentNullException(nameof(calendar));
- }
-
- calendar.ShowHeader = false;
- return calendar;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/ColumnExtensions.cs b/src/Spectre.Console/Extensions/ColumnExtensions.cs
deleted file mode 100644
index 6a0e4dc0..00000000
--- a/src/Spectre.Console/Extensions/ColumnExtensions.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class ColumnExtensions
-{
- ///
- /// Prevents a column from wrapping.
- ///
- /// An object implementing .
- /// The column.
- /// The same instance so that multiple calls can be chained.
- public static T NoWrap(this T obj)
- where T : class, IColumn
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.NoWrap = true;
- return obj;
- }
-
- ///
- /// Sets the width of the column.
- ///
- /// An object implementing .
- /// The column.
- /// The column width.
- /// The same instance so that multiple calls can be chained.
- public static T Width(this T obj, int? width)
- where T : class, IColumn
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.Width = width;
- return obj;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/ConfirmationPromptExtensions.cs b/src/Spectre.Console/Extensions/ConfirmationPromptExtensions.cs
deleted file mode 100644
index 5fd4bda6..00000000
--- a/src/Spectre.Console/Extensions/ConfirmationPromptExtensions.cs
+++ /dev/null
@@ -1,166 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class ConfirmationPromptExtensions
-{
- ///
- /// Show or hide choices.
- ///
- /// The prompt.
- /// Whether or not the choices should be visible.
- /// The same instance so that multiple calls can be chained.
- public static ConfirmationPrompt ShowChoices(this ConfirmationPrompt obj, bool show)
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.ShowChoices = show;
- return obj;
- }
-
- ///
- /// Shows choices.
- ///
- /// The prompt.
- /// The same instance so that multiple calls can be chained.
- public static ConfirmationPrompt ShowChoices(this ConfirmationPrompt obj)
- {
- return ShowChoices(obj, true);
- }
-
- ///
- /// Hides choices.
- ///
- /// The prompt.
- /// The same instance so that multiple calls can be chained.
- public static ConfirmationPrompt HideChoices(this ConfirmationPrompt obj)
- {
- return ShowChoices(obj, false);
- }
-
- ///
- /// Sets the style in which the list of choices is displayed.
- ///
- /// The confirmation prompt.
- /// The style to use for displaying the choices or to use the default style (blue).
- /// The same instance so that multiple calls can be chained.
- public static ConfirmationPrompt ChoicesStyle(this ConfirmationPrompt obj, Style? style)
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.ChoicesStyle = style;
- return obj;
- }
-
- ///
- /// Show or hide the default value.
- ///
- /// The prompt.
- /// Whether or not the default value should be visible.
- /// The same instance so that multiple calls can be chained.
- public static ConfirmationPrompt ShowDefaultValue(this ConfirmationPrompt obj, bool show)
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.ShowDefaultValue = show;
- return obj;
- }
-
- ///
- /// Shows the default value.
- ///
- /// The prompt.
- /// The same instance so that multiple calls can be chained.
- public static ConfirmationPrompt ShowDefaultValue(this ConfirmationPrompt obj)
- {
- return ShowDefaultValue(obj, true);
- }
-
- ///
- /// Hides the default value.
- ///
- /// The prompt.
- /// The same instance so that multiple calls can be chained.
- public static ConfirmationPrompt HideDefaultValue(this ConfirmationPrompt obj)
- {
- return ShowDefaultValue(obj, false);
- }
-
- ///
- /// Sets the style in which the default value is displayed.
- ///
- /// The confirmation prompt.
- /// The default value style or to use the default style (green).
- /// The same instance so that multiple calls can be chained.
- public static ConfirmationPrompt DefaultValueStyle(this ConfirmationPrompt obj, Style? style)
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.DefaultValueStyle = style;
- return obj;
- }
-
- ///
- /// Sets the "invalid choice" message for the prompt.
- ///
- /// The prompt.
- /// The "invalid choice" message.
- /// The same instance so that multiple calls can be chained.
- public static ConfirmationPrompt InvalidChoiceMessage(this ConfirmationPrompt obj, string message)
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.InvalidChoiceMessage = message;
- return obj;
- }
-
- ///
- /// Sets the character to interpret as "yes".
- ///
- /// The confirmation prompt.
- /// The character to interpret as "yes".
- /// The same instance so that multiple calls can be chained.
- public static ConfirmationPrompt Yes(this ConfirmationPrompt obj, char character)
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.Yes = character;
- return obj;
- }
-
- ///
- /// Sets the character to interpret as "no".
- ///
- /// The confirmation prompt.
- /// The character to interpret as "no".
- /// The same instance so that multiple calls can be chained.
- public static ConfirmationPrompt No(this ConfirmationPrompt obj, char character)
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.No = character;
- return obj;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/CursorExtensions.cs b/src/Spectre.Console/Extensions/CursorExtensions.cs
deleted file mode 100644
index f7eb159f..00000000
--- a/src/Spectre.Console/Extensions/CursorExtensions.cs
+++ /dev/null
@@ -1,151 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class CursorExtensions
-{
- ///
- /// Shows the cursor.
- ///
- /// The cursor.
- public static void Show(this IAnsiConsoleCursor cursor)
- {
- if (cursor is null)
- {
- throw new System.ArgumentNullException(nameof(cursor));
- }
-
- cursor.Show(true);
- }
-
- ///
- /// Hides the cursor.
- ///
- /// The cursor.
- public static void Hide(this IAnsiConsoleCursor cursor)
- {
- if (cursor is null)
- {
- throw new System.ArgumentNullException(nameof(cursor));
- }
-
- cursor.Show(false);
- }
-
- ///
- /// Moves the cursor up.
- ///
- /// The cursor.
- public static void MoveUp(this IAnsiConsoleCursor cursor)
- {
- if (cursor is null)
- {
- throw new System.ArgumentNullException(nameof(cursor));
- }
-
- cursor.Move(CursorDirection.Up, 1);
- }
-
- ///
- /// Moves the cursor up.
- ///
- /// The cursor.
- /// The number of steps to move the cursor.
- public static void MoveUp(this IAnsiConsoleCursor cursor, int steps)
- {
- if (cursor is null)
- {
- throw new System.ArgumentNullException(nameof(cursor));
- }
-
- cursor.Move(CursorDirection.Up, steps);
- }
-
- ///
- /// Moves the cursor down.
- ///
- /// The cursor.
- public static void MoveDown(this IAnsiConsoleCursor cursor)
- {
- if (cursor is null)
- {
- throw new System.ArgumentNullException(nameof(cursor));
- }
-
- cursor.Move(CursorDirection.Down, 1);
- }
-
- ///
- /// Moves the cursor down.
- ///
- /// The cursor.
- /// The number of steps to move the cursor.
- public static void MoveDown(this IAnsiConsoleCursor cursor, int steps)
- {
- if (cursor is null)
- {
- throw new System.ArgumentNullException(nameof(cursor));
- }
-
- cursor.Move(CursorDirection.Down, steps);
- }
-
- ///
- /// Moves the cursor to the left.
- ///
- /// The cursor.
- public static void MoveLeft(this IAnsiConsoleCursor cursor)
- {
- if (cursor is null)
- {
- throw new System.ArgumentNullException(nameof(cursor));
- }
-
- cursor.Move(CursorDirection.Left, 1);
- }
-
- ///
- /// Moves the cursor to the left.
- ///
- /// The cursor.
- /// The number of steps to move the cursor.
- public static void MoveLeft(this IAnsiConsoleCursor cursor, int steps)
- {
- if (cursor is null)
- {
- throw new System.ArgumentNullException(nameof(cursor));
- }
-
- cursor.Move(CursorDirection.Left, steps);
- }
-
- ///
- /// Moves the cursor to the right.
- ///
- /// The cursor.
- public static void MoveRight(this IAnsiConsoleCursor cursor)
- {
- if (cursor is null)
- {
- throw new System.ArgumentNullException(nameof(cursor));
- }
-
- cursor.Move(CursorDirection.Right, 1);
- }
-
- ///
- /// Moves the cursor to the right.
- ///
- /// The cursor.
- /// The number of steps to move the cursor.
- public static void MoveRight(this IAnsiConsoleCursor cursor, int steps)
- {
- if (cursor is null)
- {
- throw new System.ArgumentNullException(nameof(cursor));
- }
-
- cursor.Move(CursorDirection.Right, steps);
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/ExpandableExtensions.cs b/src/Spectre.Console/Extensions/ExpandableExtensions.cs
deleted file mode 100644
index ca72b823..00000000
--- a/src/Spectre.Console/Extensions/ExpandableExtensions.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class ExpandableExtensions
-{
- ///
- /// Tells the specified object to not expand to the available area
- /// but take as little space as possible.
- ///
- /// The expandable object.
- /// The object to collapse.
- /// The same instance so that multiple calls can be chained.
- public static T Collapse(this T obj)
- where T : class, IExpandable
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.Expand = false;
- return obj;
- }
-
- ///
- /// Tells the specified object to expand to the available area.
- ///
- /// The expandable object.
- /// The object to expand.
- /// The same instance so that multiple calls can be chained.
- public static T Expand(this T obj)
- where T : class, IExpandable
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.Expand = true;
- return obj;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/FigletTextExtensions.cs b/src/Spectre.Console/Extensions/FigletTextExtensions.cs
deleted file mode 100644
index e789d914..00000000
--- a/src/Spectre.Console/Extensions/FigletTextExtensions.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class FigletTextExtensions
-{
- ///
- /// Sets the color of the FIGlet text.
- ///
- /// The text.
- /// The color.
- /// The same instance so that multiple calls can be chained.
- public static FigletText Color(this FigletText text, Color? color)
- {
- if (text is null)
- {
- throw new ArgumentNullException(nameof(text));
- }
-
- text.Color = color ?? Console.Color.Default;
- return text;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/GridExtensions.cs b/src/Spectre.Console/Extensions/GridExtensions.cs
deleted file mode 100644
index d9cbcb53..00000000
--- a/src/Spectre.Console/Extensions/GridExtensions.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class GridExtensions
-{
- ///
- /// Adds a column to the grid.
- ///
- /// The grid to add the column to.
- /// The number of columns to add.
- /// The same instance so that multiple calls can be chained.
- public static Grid AddColumns(this Grid grid, int count)
- {
- if (grid is null)
- {
- throw new ArgumentNullException(nameof(grid));
- }
-
- for (var index = 0; index < count; index++)
- {
- grid.AddColumn(new GridColumn());
- }
-
- return grid;
- }
-
- ///
- /// Adds a column to the grid.
- ///
- /// The grid to add the column to.
- /// The columns to add.
- /// The same instance so that multiple calls can be chained.
- public static Grid AddColumns(this Grid grid, params GridColumn[] columns)
- {
- if (grid is null)
- {
- throw new ArgumentNullException(nameof(grid));
- }
-
- if (columns is null)
- {
- throw new ArgumentNullException(nameof(columns));
- }
-
- foreach (var column in columns)
- {
- grid.AddColumn(column);
- }
-
- return grid;
- }
-
- ///
- /// Adds an empty row to the grid.
- ///
- /// The grid to add the row to.
- /// The same instance so that multiple calls can be chained.
- public static Grid AddEmptyRow(this Grid grid)
- {
- if (grid is null)
- {
- throw new ArgumentNullException(nameof(grid));
- }
-
- var columns = new IRenderable[grid.Columns.Count];
- Enumerable.Range(0, grid.Columns.Count).ForEach(index => columns[index] = Text.Empty);
- grid.AddRow(columns);
-
- return grid;
- }
-
- ///
- /// Adds a new row to the grid.
- ///
- /// The grid to add the row to.
- /// The columns to add.
- /// The same instance so that multiple calls can be chained.
- public static Grid AddRow(this Grid grid, params string[] columns)
- {
- if (grid is null)
- {
- throw new ArgumentNullException(nameof(grid));
- }
-
- if (columns is null)
- {
- throw new ArgumentNullException(nameof(columns));
- }
-
- grid.AddRow(columns.Select(column => new Markup(column)).ToArray());
- return grid;
- }
-
- ///
- /// Sets the grid width.
- ///
- /// The grid.
- /// The width.
- /// The same instance so that multiple calls can be chained.
- public static Grid Width(this Grid grid, int? width)
- {
- if (grid is null)
- {
- throw new ArgumentNullException(nameof(grid));
- }
-
- grid.Width = width;
- return grid;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/HasBorderExtensions.cs b/src/Spectre.Console/Extensions/HasBorderExtensions.cs
deleted file mode 100644
index 460a9428..00000000
--- a/src/Spectre.Console/Extensions/HasBorderExtensions.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class HasBorderExtensions
-{
- ///
- /// Enables the safe border.
- ///
- /// An object type with a border.
- /// The object to enable the safe border for.
- /// The same instance so that multiple calls can be chained.
- public static T SafeBorder(this T obj)
- where T : class, IHasBorder
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.UseSafeBorder = true;
- return obj;
- }
-
- ///
- /// Disables the safe border.
- ///
- /// An object type with a border.
- /// The object to disable the safe border for.
- /// The same instance so that multiple calls can be chained.
- public static T NoSafeBorder(this T obj)
- where T : class, IHasBorder
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.UseSafeBorder = false;
- return obj;
- }
-
- ///
- /// Sets the border style.
- ///
- /// An object type with a border.
- /// The object to set the border style for.
- /// The border style to set.
- /// The same instance so that multiple calls can be chained.
- public static T BorderStyle(this T obj, Style style)
- where T : class, IHasBorder
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.BorderStyle = style;
- return obj;
- }
-
- ///
- /// Sets the border color.
- ///
- /// An object type with a border.
- /// The object to set the border color for.
- /// The border color to set.
- /// The same instance so that multiple calls can be chained.
- public static T BorderColor(this T obj, Color color)
- where T : class, IHasBorder
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.BorderStyle = (obj.BorderStyle ?? Style.Plain).Foreground(color);
- return obj;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/HasBoxBorderExtensions.cs b/src/Spectre.Console/Extensions/HasBoxBorderExtensions.cs
deleted file mode 100644
index a79f9819..00000000
--- a/src/Spectre.Console/Extensions/HasBoxBorderExtensions.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class HasBoxBorderExtensions
-{
- ///
- /// Sets the border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The border to use.
- /// The same instance so that multiple calls can be chained.
- public static T Border(this T obj, BoxBorder border)
- where T : class, IHasBoxBorder
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.Border = border;
- return obj;
- }
-
- ///
- /// Do not display a border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T NoBorder(this T obj)
- where T : class, IHasBoxBorder
- {
- return Border(obj, BoxBorder.None);
- }
-
- ///
- /// Display a square border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T SquareBorder(this T obj)
- where T : class, IHasBoxBorder
- {
- return Border(obj, BoxBorder.Square);
- }
-
- ///
- /// Display an ASCII border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T AsciiBorder(this T obj)
- where T : class, IHasBoxBorder
- {
- return Border(obj, BoxBorder.Ascii);
- }
-
- ///
- /// Display a rounded border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T RoundedBorder(this T obj)
- where T : class, IHasBoxBorder
- {
- return Border(obj, BoxBorder.Rounded);
- }
-
- ///
- /// Display a heavy border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T HeavyBorder(this T obj)
- where T : class, IHasBoxBorder
- {
- return Border(obj, BoxBorder.Heavy);
- }
-
- ///
- /// Display a double border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T DoubleBorder(this T obj)
- where T : class, IHasBoxBorder
- {
- return Border(obj, BoxBorder.Double);
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/HasCultureExtensions.cs b/src/Spectre.Console/Extensions/HasCultureExtensions.cs
deleted file mode 100644
index 32d05bde..00000000
--- a/src/Spectre.Console/Extensions/HasCultureExtensions.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class HasCultureExtensions
-{
- ///
- /// Sets the culture.
- ///
- /// An object type with a culture.
- /// The object to set the culture for.
- /// The culture to set.
- /// The same instance so that multiple calls can be chained.
- public static T Culture(this T obj, CultureInfo culture)
- where T : class, IHasCulture
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- if (culture is null)
- {
- throw new ArgumentNullException(nameof(culture));
- }
-
- obj.Culture = culture;
- return obj;
- }
-
- ///
- /// Sets the culture.
- ///
- /// An object type with a culture.
- /// The object to set the culture for.
- /// The culture to set.
- /// The same instance so that multiple calls can be chained.
- public static T Culture(this T obj, string name)
- where T : class, IHasCulture
- {
- if (name is null)
- {
- throw new ArgumentNullException(nameof(name));
- }
-
- return Culture(obj, CultureInfo.GetCultureInfo(name));
- }
-
- ///
- /// Sets the culture.
- ///
- /// An object type with a culture.
- /// The object to set the culture for.
- /// The culture to set.
- /// The same instance so that multiple calls can be chained.
- public static T Culture(this T obj, int culture)
- where T : class, IHasCulture
- {
- return Culture(obj, CultureInfo.GetCultureInfo(culture));
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/HasJustificationExtensions.cs b/src/Spectre.Console/Extensions/HasJustificationExtensions.cs
deleted file mode 100644
index 63b8c4df..00000000
--- a/src/Spectre.Console/Extensions/HasJustificationExtensions.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class HasJustificationExtensions
-{
- ///
- /// Sets the justification for an object.
- ///
- /// The type that can be justified.
- /// The alignable object.
- /// The alignment.
- /// The same instance so that multiple calls can be chained.
- public static T Justify(this T obj, Justify? alignment)
- where T : class, IHasJustification
- {
- if (obj is null)
- {
- throw new System.ArgumentNullException(nameof(obj));
- }
-
- obj.Justification = alignment;
- return obj;
- }
-
- ///
- /// Sets the object to be left justified.
- ///
- /// The type that can be justified.
- /// The alignable object.
- /// The same instance so that multiple calls can be chained.
- public static T LeftJustified(this T obj)
- where T : class, IHasJustification
- {
- if (obj is null)
- {
- throw new System.ArgumentNullException(nameof(obj));
- }
-
- obj.Justification = Console.Justify.Left;
- return obj;
- }
-
- ///
- /// Sets the object to be centered.
- ///
- /// The type that can be justified.
- /// The alignable object.
- /// The same instance so that multiple calls can be chained.
- public static T Centered(this T obj)
- where T : class, IHasJustification
- {
- if (obj is null)
- {
- throw new System.ArgumentNullException(nameof(obj));
- }
-
- obj.Justification = Console.Justify.Center;
- return obj;
- }
-
- ///
- /// Sets the object to be right justified.
- ///
- /// The type that can be justified.
- /// The alignable object.
- /// The same instance so that multiple calls can be chained.
- public static T RightJustified(this T obj)
- where T : class, IHasJustification
- {
- if (obj is null)
- {
- throw new System.ArgumentNullException(nameof(obj));
- }
-
- obj.Justification = Console.Justify.Right;
- return obj;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/HasTableBorderExtensions.cs b/src/Spectre.Console/Extensions/HasTableBorderExtensions.cs
deleted file mode 100644
index fc5705ac..00000000
--- a/src/Spectre.Console/Extensions/HasTableBorderExtensions.cs
+++ /dev/null
@@ -1,242 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class HasTableBorderExtensions
-{
- ///
- /// Do not display a border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T NoBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.None);
- }
-
- ///
- /// Display a square border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T SquareBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.Square);
- }
-
- ///
- /// Display an ASCII border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T AsciiBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.Ascii);
- }
-
- ///
- /// Display another ASCII border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T Ascii2Border(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.Ascii2);
- }
-
- ///
- /// Display an ASCII border with a double header border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T AsciiDoubleHeadBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.AsciiDoubleHead);
- }
-
- ///
- /// Display a rounded border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T RoundedBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.Rounded);
- }
-
- ///
- /// Display a minimal border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T MinimalBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.Minimal);
- }
-
- ///
- /// Display a minimal border with a heavy head.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T MinimalHeavyHeadBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.MinimalHeavyHead);
- }
-
- ///
- /// Display a minimal border with a double header border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T MinimalDoubleHeadBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.MinimalDoubleHead);
- }
-
- ///
- /// Display a simple border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T SimpleBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.Simple);
- }
-
- ///
- /// Display a simple border with heavy lines.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T SimpleHeavyBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.SimpleHeavy);
- }
-
- ///
- /// Display a simple border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T HorizontalBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.Horizontal);
- }
-
- ///
- /// Display a heavy border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T HeavyBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.Heavy);
- }
-
- ///
- /// Display a border with a heavy edge.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T HeavyEdgeBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.HeavyEdge);
- }
-
- ///
- /// Display a border with a heavy header.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T HeavyHeadBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.HeavyHead);
- }
-
- ///
- /// Display a double border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T DoubleBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.Double);
- }
-
- ///
- /// Display a border with a double edge.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T DoubleEdgeBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.DoubleEdge);
- }
-
- ///
- /// Display a markdown border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The same instance so that multiple calls can be chained.
- public static T MarkdownBorder(this T obj)
- where T : class, IHasTableBorder
- {
- return Border(obj, TableBorder.Markdown);
- }
-
- ///
- /// Sets the border.
- ///
- /// An object type with a border.
- /// The object to set the border for.
- /// The border to use.
- /// The same instance so that multiple calls can be chained.
- public static T Border(this T obj, TableBorder border)
- where T : class, IHasTableBorder
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.Border = border;
- return obj;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/HasTreeNodeExtensions.cs b/src/Spectre.Console/Extensions/HasTreeNodeExtensions.cs
deleted file mode 100644
index ae2f8030..00000000
--- a/src/Spectre.Console/Extensions/HasTreeNodeExtensions.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class HasTreeNodeExtensions
-{
- ///
- /// Adds a tree node.
- ///
- /// An object with tree nodes.
- /// The object to add the tree node to.
- /// The node's markup text.
- /// The added tree node.
- public static TreeNode AddNode(this T obj, string markup)
- where T : IHasTreeNodes
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- if (markup is null)
- {
- throw new ArgumentNullException(nameof(markup));
- }
-
- return AddNode(obj, new Markup(markup));
- }
-
- ///
- /// Adds a tree node.
- ///
- /// An object with tree nodes.
- /// The object to add the tree node to.
- /// The renderable to add.
- /// The added tree node.
- public static TreeNode AddNode(this T obj, IRenderable renderable)
- where T : IHasTreeNodes
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- if (renderable is null)
- {
- throw new ArgumentNullException(nameof(renderable));
- }
-
- var node = new TreeNode(renderable);
- obj.Nodes.Add(node);
- return node;
- }
-
- ///
- /// Adds a tree node.
- ///
- /// An object with tree nodes.
- /// The object to add the tree node to.
- /// The tree node to add.
- /// The added tree node.
- public static TreeNode AddNode(this T obj, TreeNode node)
- where T : IHasTreeNodes
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- if (node is null)
- {
- throw new ArgumentNullException(nameof(node));
- }
-
- obj.Nodes.Add(node);
- return node;
- }
-
- ///
- /// Add multiple tree nodes.
- ///
- /// An object with tree nodes.
- /// The object to add the tree nodes to.
- /// The tree nodes to add.
- public static void AddNodes(this T obj, params string[] nodes)
- where T : IHasTreeNodes
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- if (nodes is null)
- {
- throw new ArgumentNullException(nameof(nodes));
- }
-
- obj.Nodes.AddRange(nodes.Select(node => new TreeNode(new Markup(node))));
- }
-
- ///
- /// Add multiple tree nodes.
- ///
- /// An object with tree nodes.
- /// The object to add the tree nodes to.
- /// The tree nodes to add.
- public static void AddNodes(this T obj, IEnumerable nodes)
- where T : IHasTreeNodes
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- if (nodes is null)
- {
- throw new ArgumentNullException(nameof(nodes));
- }
-
- obj.Nodes.AddRange(nodes.Select(node => new TreeNode(new Markup(node))));
- }
-
- ///
- /// Add multiple tree nodes.
- ///
- /// An object with tree nodes.
- /// The object to add the tree nodes to.
- /// The tree nodes to add.
- public static void AddNodes(this T obj, params IRenderable[] nodes)
- where T : IHasTreeNodes
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- if (nodes is null)
- {
- throw new ArgumentNullException(nameof(nodes));
- }
-
- obj.Nodes.AddRange(nodes.Select(node => new TreeNode(node)));
- }
-
- ///
- /// Add multiple tree nodes.
- ///
- /// An object with tree nodes.
- /// The object to add the tree nodes to.
- /// The tree nodes to add.
- public static void AddNodes(this T obj, IEnumerable nodes)
- where T : IHasTreeNodes
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- if (nodes is null)
- {
- throw new ArgumentNullException(nameof(nodes));
- }
-
- obj.Nodes.AddRange(nodes.Select(node => new TreeNode(node)));
- }
-
- ///
- /// Add multiple tree nodes.
- ///
- /// An object with tree nodes.
- /// The object to add the tree nodes to.
- /// The tree nodes to add.
- public static void AddNodes(this T obj, params TreeNode[] nodes)
- where T : IHasTreeNodes
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- if (nodes is null)
- {
- throw new ArgumentNullException(nameof(nodes));
- }
-
- obj.Nodes.AddRange(nodes);
- }
-
- ///
- /// Add multiple tree nodes.
- ///
- /// An object with tree nodes.
- /// The object to add the tree nodes to.
- /// The tree nodes to add.
- public static void AddNodes(this T obj, IEnumerable nodes)
- where T : IHasTreeNodes
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- if (nodes is null)
- {
- throw new ArgumentNullException(nameof(nodes));
- }
-
- obj.Nodes.AddRange(nodes);
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/LayoutExtensions.cs b/src/Spectre.Console/Extensions/LayoutExtensions.cs
deleted file mode 100644
index 995e6f09..00000000
--- a/src/Spectre.Console/Extensions/LayoutExtensions.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class LayoutExtensions
-{
- ///
- /// Sets the ratio of the layout.
- ///
- /// The layout.
- /// The ratio.
- /// The same instance so that multiple calls can be chained.
- public static Layout Ratio(this Layout layout, int ratio)
- {
- if (layout is null)
- {
- throw new ArgumentNullException(nameof(layout));
- }
-
- layout.Ratio = ratio;
- return layout;
- }
-
- ///
- /// Sets the size of the layout.
- ///
- /// The layout.
- /// The size.
- /// The same instance so that multiple calls can be chained.
- public static Layout Size(this Layout layout, int size)
- {
- if (layout is null)
- {
- throw new ArgumentNullException(nameof(layout));
- }
-
- layout.Size = size;
- return layout;
- }
-
- ///
- /// Sets the minimum width of the layout.
- ///
- /// The layout.
- /// The size.
- /// The same instance so that multiple calls can be chained.
- public static Layout MinimumSize(this Layout layout, int size)
- {
- if (layout is null)
- {
- throw new ArgumentNullException(nameof(layout));
- }
-
- layout.MinimumSize = size;
- return layout;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/LiveDisplayExtensions.cs b/src/Spectre.Console/Extensions/LiveDisplayExtensions.cs
deleted file mode 100644
index 123da4d9..00000000
--- a/src/Spectre.Console/Extensions/LiveDisplayExtensions.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class LiveDisplayExtensions
-{
- ///
- /// Sets whether or not auto clear is enabled.
- /// If enabled, the live display will be cleared when done.
- ///
- /// The instance.
- /// Whether or not auto clear is enabled.
- /// The same instance so that multiple calls can be chained.
- public static LiveDisplay AutoClear(this LiveDisplay live, bool enabled)
- {
- if (live is null)
- {
- throw new ArgumentNullException(nameof(live));
- }
-
- live.AutoClear = enabled;
-
- return live;
- }
-
- ///
- /// Sets the vertical overflow strategy.
- ///
- /// The instance.
- /// The overflow strategy to use.
- /// The same instance so that multiple calls can be chained.
- public static LiveDisplay Overflow(this LiveDisplay live, VerticalOverflow overflow)
- {
- if (live is null)
- {
- throw new ArgumentNullException(nameof(live));
- }
-
- live.Overflow = overflow;
-
- return live;
- }
-
- ///
- /// Sets the vertical overflow cropping strategy.
- ///
- /// The instance.
- /// The overflow cropping strategy to use.
- /// The same instance so that multiple calls can be chained.
- public static LiveDisplay Cropping(this LiveDisplay live, VerticalOverflowCropping cropping)
- {
- if (live is null)
- {
- throw new ArgumentNullException(nameof(live));
- }
-
- live.Cropping = cropping;
-
- return live;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/OverflowableExtensions.cs b/src/Spectre.Console/Extensions/OverflowableExtensions.cs
deleted file mode 100644
index a8a47f29..00000000
--- a/src/Spectre.Console/Extensions/OverflowableExtensions.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class OverflowableExtensions
-{
- ///
- /// Folds any overflowing text.
- ///
- /// An object implementing .
- /// The overflowable object instance.
- /// The same instance so that multiple calls can be chained.
- public static T Fold(this T obj)
- where T : class, IOverflowable
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- return Overflow(obj, Console.Overflow.Fold);
- }
-
- ///
- /// Crops any overflowing text.
- ///
- /// An object implementing .
- /// The overflowable object instance.
- /// The same instance so that multiple calls can be chained.
- public static T Crop(this T obj)
- where T : class, IOverflowable
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- return Overflow(obj, Console.Overflow.Crop);
- }
-
- ///
- /// Crops any overflowing text and adds an ellipsis to the end.
- ///
- /// An object implementing .
- /// The overflowable object instance.
- /// The same instance so that multiple calls can be chained.
- public static T Ellipsis(this T obj)
- where T : class, IOverflowable
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- return Overflow(obj, Console.Overflow.Ellipsis);
- }
-
- ///
- /// Sets the overflow strategy.
- ///
- /// An object implementing .
- /// The overflowable object instance.
- /// The overflow strategy to use.
- /// The same instance so that multiple calls can be chained.
- public static T Overflow(this T obj, Overflow overflow)
- where T : class, IOverflowable
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.Overflow = overflow;
- return obj;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/PaddableExtensions.cs b/src/Spectre.Console/Extensions/PaddableExtensions.cs
deleted file mode 100644
index 7cc01ad9..00000000
--- a/src/Spectre.Console/Extensions/PaddableExtensions.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class PaddableExtensions
-{
- ///
- /// Sets the left padding.
- ///
- /// An object implementing .
- /// The paddable object instance.
- /// The left padding.
- /// The same instance so that multiple calls can be chained.
- public static T PadLeft(this T obj, int left)
- where T : class, IPaddable
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- return Padding(obj, new Padding(left, obj.Padding.GetTopSafe(), obj.Padding.GetRightSafe(), obj.Padding.GetBottomSafe()));
- }
-
- ///
- /// Sets the top padding.
- ///
- /// An object implementing .
- /// The paddable object instance.
- /// The top padding.
- /// The same instance so that multiple calls can be chained.
- public static T PadTop(this T obj, int top)
- where T : class, IPaddable
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- return Padding(obj, new Padding(obj.Padding.GetLeftSafe(), top, obj.Padding.GetRightSafe(), obj.Padding.GetBottomSafe()));
- }
-
- ///
- /// Sets the right padding.
- ///
- /// An object implementing .
- /// The paddable object instance.
- /// The right padding.
- /// The same instance so that multiple calls can be chained.
- public static T PadRight(this T obj, int right)
- where T : class, IPaddable
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- return Padding(obj, new Padding(obj.Padding.GetLeftSafe(), obj.Padding.GetTopSafe(), right, obj.Padding.GetBottomSafe()));
- }
-
- ///
- /// Sets the bottom padding.
- ///
- /// An object implementing .
- /// The paddable object instance.
- /// The bottom padding.
- /// The same instance so that multiple calls can be chained.
- public static T PadBottom(this T obj, int bottom)
- where T : class, IPaddable
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- return Padding(obj, new Padding(obj.Padding.GetLeftSafe(), obj.Padding.GetTopSafe(), obj.Padding.GetRightSafe(), bottom));
- }
-
- ///
- /// Sets the left, top, right and bottom padding.
- ///
- /// An object implementing .
- /// The paddable object instance.
- /// The left padding to apply.
- /// The top padding to apply.
- /// The right padding to apply.
- /// The bottom padding to apply.
- /// The same instance so that multiple calls can be chained.
- public static T Padding(this T obj, int left, int top, int right, int bottom)
- where T : class, IPaddable
- {
- return Padding(obj, new Padding(left, top, right, bottom));
- }
-
- ///
- /// Sets the horizontal and vertical padding.
- ///
- /// An object implementing .
- /// The paddable object instance.
- /// The left and right padding.
- /// The top and bottom padding.
- /// The same instance so that multiple calls can be chained.
- public static T Padding(this T obj, int horizontal, int vertical)
- where T : class, IPaddable
- {
- return Padding(obj, new Padding(horizontal, vertical));
- }
-
- ///
- /// Sets the padding.
- ///
- /// An object implementing .
- /// The paddable object instance.
- /// The padding to apply.
- /// The same instance so that multiple calls can be chained.
- public static T Padding(this T obj, Padding padding)
- where T : class, IPaddable
- {
- if (obj is null)
- {
- throw new ArgumentNullException(nameof(obj));
- }
-
- obj.Padding = padding;
- return obj;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/PaddingExtensions.cs b/src/Spectre.Console/Extensions/PaddingExtensions.cs
deleted file mode 100644
index 9949092d..00000000
--- a/src/Spectre.Console/Extensions/PaddingExtensions.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class PaddingExtensions
-{
- ///
- /// Gets the left padding.
- ///
- /// The padding.
- /// The left padding or zero if padding is null.
- public static int GetLeftSafe(this Padding? padding)
- {
- return padding?.Left ?? 0;
- }
-
- ///
- /// Gets the right padding.
- ///
- /// The padding.
- /// The right padding or zero if padding is null.
- public static int GetRightSafe(this Padding? padding)
- {
- return padding?.Right ?? 0;
- }
-
- ///
- /// Gets the top padding.
- ///
- /// The padding.
- /// The top padding or zero if padding is null.
- public static int GetTopSafe(this Padding? padding)
- {
- return padding?.Top ?? 0;
- }
-
- ///
- /// Gets the bottom padding.
- ///
- /// The padding.
- /// The bottom padding or zero if padding is null.
- public static int GetBottomSafe(this Padding? padding)
- {
- return padding?.Bottom ?? 0;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/PanelExtensions.cs b/src/Spectre.Console/Extensions/PanelExtensions.cs
deleted file mode 100644
index d8374650..00000000
--- a/src/Spectre.Console/Extensions/PanelExtensions.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class PanelExtensions
-{
- ///
- /// Sets the panel header.
- ///
- /// The panel.
- /// The header text.
- /// The header alignment.
- /// The same instance so that multiple calls can be chained.
- public static Panel Header(this Panel panel, string text, Justify? alignment = null)
- {
- if (panel is null)
- {
- throw new ArgumentNullException(nameof(panel));
- }
-
- if (text is null)
- {
- throw new ArgumentNullException(nameof(text));
- }
-
- alignment ??= panel.Header?.Justification;
- return Header(panel, new PanelHeader(text, alignment));
- }
-
- ///
- /// Sets the panel header alignment.
- ///
- /// The panel.
- /// The header alignment.
- /// The same instance so that multiple calls can be chained.
- public static Panel HeaderAlignment(this Panel panel, Justify alignment)
- {
- if (panel is null)
- {
- throw new ArgumentNullException(nameof(panel));
- }
-
- if (panel.Header != null)
- {
- // Update existing style
- panel.Header.Justification = alignment;
- }
- else
- {
- // Create header
- Header(panel, string.Empty, alignment);
- }
-
- return panel;
- }
-
- ///
- /// Sets the panel header.
- ///
- /// The panel.
- /// The header to use.
- /// The same instance so that multiple calls can be chained.
- public static Panel Header(this Panel panel, PanelHeader header)
- {
- if (panel is null)
- {
- throw new ArgumentNullException(nameof(panel));
- }
-
- panel.Header = header;
- return panel;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/Progress/PercentageColumnExtensions.cs b/src/Spectre.Console/Extensions/Progress/PercentageColumnExtensions.cs
deleted file mode 100644
index bd365a2d..00000000
--- a/src/Spectre.Console/Extensions/Progress/PercentageColumnExtensions.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class PercentageColumnExtensions
-{
- ///
- /// Sets the style for a non-complete task.
- ///
- /// The column.
- /// The style.
- /// The same instance so that multiple calls can be chained.
- public static PercentageColumn Style(this PercentageColumn column, Style style)
- {
- if (column is null)
- {
- throw new ArgumentNullException(nameof(column));
- }
-
- if (style is null)
- {
- throw new ArgumentNullException(nameof(style));
- }
-
- column.Style = style;
- return column;
- }
-
- ///
- /// Sets the style for a completed task.
- ///
- /// The column.
- /// The style.
- /// The same instance so that multiple calls can be chained.
- public static PercentageColumn CompletedStyle(this PercentageColumn column, Style style)
- {
- if (column is null)
- {
- throw new ArgumentNullException(nameof(column));
- }
-
- if (style is null)
- {
- throw new ArgumentNullException(nameof(style));
- }
-
- column.CompletedStyle = style;
- return column;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/Progress/ProgressBarColumnExtensions.cs b/src/Spectre.Console/Extensions/Progress/ProgressBarColumnExtensions.cs
deleted file mode 100644
index 4d46d0ee..00000000
--- a/src/Spectre.Console/Extensions/Progress/ProgressBarColumnExtensions.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class ProgressBarColumnExtensions
-{
- ///
- /// Sets the style of completed portions of the progress bar.
- ///
- /// The column.
- /// The style.
- /// The same instance so that multiple calls can be chained.
- public static ProgressBarColumn CompletedStyle(this ProgressBarColumn column, Style style)
- {
- if (column is null)
- {
- throw new ArgumentNullException(nameof(column));
- }
-
- if (style is null)
- {
- throw new ArgumentNullException(nameof(style));
- }
-
- column.CompletedStyle = style;
- return column;
- }
-
- ///
- /// Sets the style of a finished progress bar.
- ///
- /// The column.
- /// The style.
- /// The same instance so that multiple calls can be chained.
- public static ProgressBarColumn FinishedStyle(this ProgressBarColumn column, Style style)
- {
- if (column is null)
- {
- throw new ArgumentNullException(nameof(column));
- }
-
- if (style is null)
- {
- throw new ArgumentNullException(nameof(style));
- }
-
- column.FinishedStyle = style;
- return column;
- }
-
- ///
- /// Sets the style of remaining portions of the progress bar.
- ///
- /// The column.
- /// The style.
- /// The same instance so that multiple calls can be chained.
- public static ProgressBarColumn RemainingStyle(this ProgressBarColumn column, Style style)
- {
- if (column is null)
- {
- throw new ArgumentNullException(nameof(column));
- }
-
- if (style is null)
- {
- throw new ArgumentNullException(nameof(style));
- }
-
- column.RemainingStyle = style;
- return column;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/Progress/ProgressExtensions.cs b/src/Spectre.Console/Extensions/Progress/ProgressExtensions.cs
deleted file mode 100644
index dc8cf01c..00000000
--- a/src/Spectre.Console/Extensions/Progress/ProgressExtensions.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class ProgressExtensions
-{
- ///
- /// Sets the columns to be used for an instance.
- ///
- /// The instance.
- /// The columns to use.
- /// The same instance so that multiple calls can be chained.
- public static Progress Columns(this Progress progress, params ProgressColumn[] columns)
- {
- if (progress is null)
- {
- throw new ArgumentNullException(nameof(progress));
- }
-
- if (columns is null)
- {
- throw new ArgumentNullException(nameof(columns));
- }
-
- if (!columns.Any())
- {
- throw new InvalidOperationException("At least one column must be specified.");
- }
-
- progress.Columns.Clear();
- progress.Columns.AddRange(columns);
-
- return progress;
- }
-
- ///
- /// Sets an optional hook to intercept rendering.
- ///
- /// The instance.
- /// The custom render function.
- /// The same instance so that multiple calls can be chained.
- public static Progress UseRenderHook(this Progress progress, Func, IRenderable> renderHook)
- {
- progress.RenderHook = renderHook;
-
- return progress;
- }
-
- ///
- /// Sets whether or not auto refresh is enabled.
- /// If disabled, you will manually have to refresh the progress.
- ///
- /// The instance.
- /// Whether or not auto refresh is enabled.
- /// The same instance so that multiple calls can be chained.
- public static Progress AutoRefresh(this Progress progress, bool enabled)
- {
- if (progress is null)
- {
- throw new ArgumentNullException(nameof(progress));
- }
-
- progress.AutoRefresh = enabled;
-
- return progress;
- }
-
- ///
- /// Sets whether or not auto clear is enabled.
- /// If enabled, the task tabled will be removed once
- /// all tasks have completed.
- ///
- /// The instance.
- /// Whether or not auto clear is enabled.
- /// The same instance so that multiple calls can be chained.
- public static Progress AutoClear(this Progress progress, bool enabled)
- {
- if (progress is null)
- {
- throw new ArgumentNullException(nameof(progress));
- }
-
- progress.AutoClear = enabled;
-
- return progress;
- }
-
- ///
- /// Sets whether or not hide completed is enabled.
- /// If enabled, the task tabled will be removed once it is
- /// completed.
- ///
- /// The instance.
- /// Whether or not hide completed is enabled.
- /// The same instance so that multiple calls can be chained.
- public static Progress HideCompleted(this Progress progress, bool enabled)
- {
- if (progress is null)
- {
- throw new ArgumentNullException(nameof(progress));
- }
-
- progress.HideCompleted = enabled;
-
- return progress;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/Progress/ProgressTaskExtensions.cs b/src/Spectre.Console/Extensions/Progress/ProgressTaskExtensions.cs
deleted file mode 100644
index 309ee861..00000000
--- a/src/Spectre.Console/Extensions/Progress/ProgressTaskExtensions.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class ProgressTaskExtensions
-{
- ///
- /// Sets the task description.
- ///
- /// The task.
- /// The description.
- /// The same instance so that multiple calls can be chained.
- public static ProgressTask Description(this ProgressTask task, string description)
- {
- if (task is null)
- {
- throw new ArgumentNullException(nameof(task));
- }
-
- task.Description = description;
- return task;
- }
-
- ///
- /// Sets the max value of the task.
- ///
- /// The task.
- /// The max value.
- /// The same instance so that multiple calls can be chained.
- public static ProgressTask MaxValue(this ProgressTask task, double value)
- {
- if (task is null)
- {
- throw new ArgumentNullException(nameof(task));
- }
-
- task.MaxValue = value;
- return task;
- }
-
- ///
- /// Sets the value of the task.
- ///
- /// The task.
- /// The value.
- /// The same instance so that multiple calls can be chained.
- public static ProgressTask Value(this ProgressTask task, double value)
- {
- if (task is null)
- {
- throw new ArgumentNullException(nameof(task));
- }
-
- task.Value = value;
- return task;
- }
-
- ///
- /// Sets whether the task is considered indeterminate or not.
- ///
- /// The task.
- /// Whether the task is considered indeterminate or not.
- /// The same instance so that multiple calls can be chained.
- public static ProgressTask IsIndeterminate(this ProgressTask task, bool indeterminate = true)
- {
- if (task is null)
- {
- throw new ArgumentNullException(nameof(task));
- }
-
- task.IsIndeterminate = indeterminate;
- return task;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/Progress/RemainingTimeColumnExtensions.cs b/src/Spectre.Console/Extensions/Progress/RemainingTimeColumnExtensions.cs
deleted file mode 100644
index a542b755..00000000
--- a/src/Spectre.Console/Extensions/Progress/RemainingTimeColumnExtensions.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class RemainingTimeColumnExtensions
-{
- ///
- /// Sets the style of the remaining time text.
- ///
- /// The column.
- /// The style.
- /// The same instance so that multiple calls can be chained.
- public static RemainingTimeColumn Style(this RemainingTimeColumn column, Style style)
- {
- if (column is null)
- {
- throw new ArgumentNullException(nameof(column));
- }
-
- if (style is null)
- {
- throw new ArgumentNullException(nameof(style));
- }
-
- column.Style = style;
- return column;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/Progress/SpinnerColumnExtensions.cs b/src/Spectre.Console/Extensions/Progress/SpinnerColumnExtensions.cs
deleted file mode 100644
index fcfeed23..00000000
--- a/src/Spectre.Console/Extensions/Progress/SpinnerColumnExtensions.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class SpinnerColumnExtensions
-{
- ///
- /// Sets the style of the spinner.
- ///
- /// The column.
- /// The style.
- /// The same instance so that multiple calls can be chained.
- public static SpinnerColumn Style(this SpinnerColumn column, Style? style)
- {
- if (column is null)
- {
- throw new ArgumentNullException(nameof(column));
- }
-
- column.Style = style;
- return column;
- }
-
- ///
- /// Sets the text that should be shown instead of the spinner
- /// once a task completes.
- ///
- /// The column.
- /// The text.
- /// The same instance so that multiple calls can be chained.
- public static SpinnerColumn CompletedText(this SpinnerColumn column, string? text)
- {
- if (column is null)
- {
- throw new ArgumentNullException(nameof(column));
- }
-
- column.CompletedText = text;
- return column;
- }
-
- ///
- /// Sets the completed style of the spinner.
- ///
- /// The column.
- /// The style.
- /// The same instance so that multiple calls can be chained.
- public static SpinnerColumn CompletedStyle(this SpinnerColumn column, Style? style)
- {
- if (column is null)
- {
- throw new ArgumentNullException(nameof(column));
- }
-
- column.CompletedStyle = style;
- return column;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/Progress/StatusContextExtensions.cs b/src/Spectre.Console/Extensions/Progress/StatusContextExtensions.cs
deleted file mode 100644
index 6edcbb40..00000000
--- a/src/Spectre.Console/Extensions/Progress/StatusContextExtensions.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class StatusContextExtensions
-{
- ///
- /// Sets the status message.
- ///
- /// The status context.
- /// The status message.
- /// The same instance so that multiple calls can be chained.
- public static StatusContext Status(this StatusContext context, string status)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- context.Status = status;
- return context;
- }
-
- ///
- /// Sets the spinner.
- ///
- /// The status context.
- /// The spinner.
- /// The same instance so that multiple calls can be chained.
- public static StatusContext Spinner(this StatusContext context, Spinner spinner)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- context.Spinner = spinner;
- return context;
- }
-
- ///
- /// Sets the spinner style.
- ///
- /// The status context.
- /// The spinner style.
- /// The same instance so that multiple calls can be chained.
- public static StatusContext SpinnerStyle(this StatusContext context, Style? style)
- {
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
-
- context.SpinnerStyle = style;
- return context;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/Progress/StatusExtensions.cs b/src/Spectre.Console/Extensions/Progress/StatusExtensions.cs
deleted file mode 100644
index 9b5c9e28..00000000
--- a/src/Spectre.Console/Extensions/Progress/StatusExtensions.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class StatusExtensions
-{
- ///
- /// Sets whether or not auto refresh is enabled.
- /// If disabled, you will manually have to refresh the progress.
- ///
- /// The instance.
- /// Whether or not auto refresh is enabled.
- /// The same instance so that multiple calls can be chained.
- public static Status AutoRefresh(this Status status, bool enabled)
- {
- if (status is null)
- {
- throw new ArgumentNullException(nameof(status));
- }
-
- status.AutoRefresh = enabled;
- return status;
- }
-
- ///
- /// Sets the spinner.
- ///
- /// The instance.
- /// The spinner.
- /// The same instance so that multiple calls can be chained.
- public static Status Spinner(this Status status, Spinner spinner)
- {
- if (status is null)
- {
- throw new ArgumentNullException(nameof(status));
- }
-
- status.Spinner = spinner;
- return status;
- }
-
- ///
- /// Sets the spinner style.
- ///
- /// The instance.
- /// The spinner style.
- /// The same instance so that multiple calls can be chained.
- public static Status SpinnerStyle(this Status status, Style? style)
- {
- if (status is null)
- {
- throw new ArgumentNullException(nameof(status));
- }
-
- status.SpinnerStyle = style;
- return status;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/RecorderExtensions.cs b/src/Spectre.Console/Extensions/RecorderExtensions.cs
deleted file mode 100644
index 459a2ec7..00000000
--- a/src/Spectre.Console/Extensions/RecorderExtensions.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class RecorderExtensions
-{
- private static readonly TextEncoder _textEncoder = new TextEncoder();
- private static readonly HtmlEncoder _htmlEncoder = new HtmlEncoder();
-
- ///
- /// Exports the recorded content as text.
- ///
- /// The recorder.
- /// The recorded content as text.
- public static string ExportText(this Recorder recorder)
- {
- if (recorder is null)
- {
- throw new ArgumentNullException(nameof(recorder));
- }
-
- return recorder.Export(_textEncoder);
- }
-
- ///
- /// Exports the recorded content as HTML.
- ///
- /// The recorder.
- /// The recorded content as HTML.
- public static string ExportHtml(this Recorder recorder)
- {
- if (recorder is null)
- {
- throw new ArgumentNullException(nameof(recorder));
- }
-
- return recorder.Export(_htmlEncoder);
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/RenderOptionsExtensions.cs b/src/Spectre.Console/Extensions/RenderOptionsExtensions.cs
deleted file mode 100644
index a8a721eb..00000000
--- a/src/Spectre.Console/Extensions/RenderOptionsExtensions.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Spectre.Console;
-
-internal static class RenderOptionsExtensions
-{
- public static BoxBorder GetSafeBorder(this RenderOptions options, T border)
- where T : IHasBoxBorder, IHasBorder
- {
- return BoxExtensions.GetSafeBorder(border.Border, !options.Unicode && border.UseSafeBorder);
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/RuleExtensions.cs b/src/Spectre.Console/Extensions/RuleExtensions.cs
deleted file mode 100644
index 02d474fa..00000000
--- a/src/Spectre.Console/Extensions/RuleExtensions.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class RuleExtensions
-{
- ///
- /// Sets the rule title.
- ///
- /// The rule.
- /// The title.
- /// The same instance so that multiple calls can be chained.
- public static Rule RuleTitle(this Rule rule, string title)
- {
- if (rule is null)
- {
- throw new ArgumentNullException(nameof(rule));
- }
-
- if (title is null)
- {
- throw new ArgumentNullException(nameof(title));
- }
-
- rule.Title = title;
- return rule;
- }
-
- ///
- /// Sets the rule style.
- ///
- /// The rule.
- /// The rule style.
- /// The same instance so that multiple calls can be chained.
- public static Rule RuleStyle(this Rule rule, Style style)
- {
- if (rule is null)
- {
- throw new ArgumentNullException(nameof(rule));
- }
-
- if (style is null)
- {
- throw new ArgumentNullException(nameof(style));
- }
-
- rule.Style = style;
- return rule;
- }
-}
\ No newline at end of file
diff --git a/src/Spectre.Console/Extensions/StyleExtensions.cs b/src/Spectre.Console/Extensions/StyleExtensions.cs
deleted file mode 100644
index 1ddc4337..00000000
--- a/src/Spectre.Console/Extensions/StyleExtensions.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-namespace Spectre.Console;
-
-///
-/// Contains extension methods for .
-///
-public static class StyleExtensions
-{
- ///
- /// Creates a new style from the specified one with
- /// the specified foreground color.
- ///
- /// The style.
- /// The foreground color.
- /// The same instance so that multiple calls can be chained.
- public static Style Foreground(this Style style, Color color)
- {
- if (style is null)
- {
- throw new ArgumentNullException(nameof(style));
- }
-
- return new Style(
- foreground: color,
- background: style.Background,
- decoration: style.Decoration);
- }
-
- ///
- /// Creates a new style from the specified one with
- /// the specified background color.
- ///
- /// The style.
- /// The background color.
- /// The same instance so that multiple calls can be chained.
- public static Style Background(this Style style, Color color)
- {
- if (style is null)
- {
- throw new ArgumentNullException(nameof(style));
- }
-
- return new Style(
- foreground: style.Foreground,
- background: color,
- decoration: style.Decoration);
- }
-
- ///
- /// Creates a new style from the specified one with
- /// the specified text decoration.
- ///
- /// The style.
- /// The text decoration.
- /// The same instance so that multiple calls can be chained.
- public static Style Decoration(this Style style, Decoration decoration)
- {
- if (style is null)
- {
- throw new ArgumentNullException(nameof(style));
- }
-
- return new Style(
- foreground: style.Foreground,
- background: style.Background,
- decoration: decoration);
- }
-
- ///
- /// Creates a new style from the specified one with
- /// the specified link.
- ///
- /// The style.
- /// The link.
- /// The same instance so that multiple calls can be chained.
- public static Style Link(this Style style, string link)
- {
- if (style is null)
- {
- throw new ArgumentNullException(nameof(style));
- }
-
- return new Style(
- foreground: style.Foreground,
- background: style.Background,
- decoration: style.Decoration,
- link: link);
- }
-
- internal static Style Combine(this Style style, IEnumerable