mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
Obsolete the AnsiConsoleFactory class (#585)
`AnsiConsoleFactory` should be an internal static class. Creating an `IAnsiConsole` can be achieved through `Spectre.Console.AnsiConsole.Create(AnsiConsoleSettings)` Since `AnsiConsoleFactory` is public, it can't be changed from a non static class to a static class so obsoleting it is the second best thing to do. Eventually, when `AnsiConsoleFactory` becomes internal and static, `AnsiConsole.Create` can be simplified to this (and the private static field `_factory` can be removed) ``` public static IAnsiConsole Create(AnsiConsoleSettings settings) { return AnsiConsoleFactory.Create(settings); } ```
This commit is contained in:
parent
1d8154f9b0
commit
7998ece6b6
@ -56,8 +56,7 @@ public sealed class TestConsole : IAnsiConsole, IDisposable
|
||||
Input = new TestConsoleInput();
|
||||
EmitAnsiSequences = false;
|
||||
|
||||
var factory = new AnsiConsoleFactory();
|
||||
_console = factory.Create(new AnsiConsoleSettings
|
||||
_console = AnsiConsole.Create(new AnsiConsoleSettings
|
||||
{
|
||||
Ansi = AnsiSupport.Yes,
|
||||
ColorSystem = (ColorSystemSupport)ColorSystem.TrueColor,
|
||||
|
@ -5,6 +5,10 @@ namespace Spectre.Console;
|
||||
/// </summary>
|
||||
public static partial class AnsiConsole
|
||||
{
|
||||
#pragma warning disable CS0618 // 'AnsiConsoleFactory' is obsolete
|
||||
private static readonly AnsiConsoleFactory _factory = new AnsiConsoleFactory();
|
||||
#pragma warning restore CS0618
|
||||
|
||||
private static Recorder? _recorder;
|
||||
private static Lazy<IAnsiConsole> _console = new Lazy<IAnsiConsole>(
|
||||
() =>
|
||||
@ -61,8 +65,7 @@ public static partial class AnsiConsole
|
||||
/// <returns>An <see cref="IAnsiConsole"/> instance.</returns>
|
||||
public static IAnsiConsole Create(AnsiConsoleSettings settings)
|
||||
{
|
||||
var factory = new AnsiConsoleFactory();
|
||||
return factory.Create(settings);
|
||||
return _factory.Create(settings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -3,6 +3,7 @@ namespace Spectre.Console;
|
||||
/// <summary>
|
||||
/// Factory for creating an ANSI console.
|
||||
/// </summary>
|
||||
[Obsolete("Consider using AnsiConsole.Create instead.")]
|
||||
public sealed class AnsiConsoleFactory
|
||||
{
|
||||
/// <summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user