Skip to content

Types cleanup #2076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/System.CommandLine/Binding/ServiceProviderExtensions.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/System.CommandLine/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void AddCompletionsFor(Symbol identifier, AliasSet? aliases)
{
if (identifier.Name.ContainsCaseInsensitive(textToMatch))
{
completions.Add(new CompletionItem(identifier.Name, CompletionItemKind.Keyword, detail: identifier.Description));
completions.Add(new CompletionItem(identifier.Name, CompletionItem.KindKeyword, detail: identifier.Description));
}

if (aliases is not null)
Expand All @@ -243,7 +243,7 @@ void AddCompletionsFor(Symbol identifier, AliasSet? aliases)
{
if (alias.ContainsCaseInsensitive(textToMatch))
{
completions.Add(new CompletionItem(alias, CompletionItemKind.Keyword, detail: identifier.Description));
completions.Add(new CompletionItem(alias, CompletionItem.KindKeyword, detail: identifier.Description));
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/System.CommandLine/Completions/CompletionItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ namespace System.CommandLine.Completions
/// </summary>
public class CompletionItem : IEquatable<CompletionItem>
{
// reference: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion
internal const string KindKeyword = "Keyword";
internal const string KindValue = "Value";

/// <param name="label">The label value, which is the text displayed to users and, unless <paramref name="insertText"/> is set, is also used to populate the <see cref="InsertText"/> property.</param>
/// <param name="kind">The kind of completion item.</param>
/// <param name="sortText">The value used to sort the completion item in a list. If this is not provided, then <paramref name="label"/> is used.</param>
Expand All @@ -16,7 +20,7 @@ public class CompletionItem : IEquatable<CompletionItem>
/// <param name="detail">Additional details regarding the completion item.</param>
public CompletionItem(
string label,
string kind = CompletionItemKind.Value,
string kind = CompletionItem.KindValue,
string? sortText = null,
string? insertText = null,
string? documentation = null,
Expand Down
12 changes: 0 additions & 12 deletions src/System.CommandLine/Completions/CompletionItemKind.cs

This file was deleted.

25 changes: 0 additions & 25 deletions src/System.CommandLine/DebugAssert.cs

This file was deleted.

42 changes: 0 additions & 42 deletions src/System.CommandLine/DictionaryExtensions.cs

This file was deleted.

32 changes: 28 additions & 4 deletions src/System.CommandLine/IO/ConsoleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,51 @@ namespace System.CommandLine.IO
{
internal static class ConsoleExtensions
{
private static bool? _isConsoleRedirectionCheckSupported;

private static bool IsConsoleRedirectionCheckSupported
{
get
{
if (_isConsoleRedirectionCheckSupported is null)
{
try
{
var check = Console.IsOutputRedirected;
_isConsoleRedirectionCheckSupported = true;
}

catch (PlatformNotSupportedException)
{
_isConsoleRedirectionCheckSupported = false;
}
}

return _isConsoleRedirectionCheckSupported.Value;
}
}

internal static void SetTerminalForegroundRed(this IConsole console)
{
if (Platform.IsConsoleRedirectionCheckSupported &&
if (IsConsoleRedirectionCheckSupported &&

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related bug #1851.

!Console.IsOutputRedirected)
{
Console.ForegroundColor = ConsoleColor.Red;
}
else if (Platform.IsConsoleRedirectionCheckSupported)
else if (IsConsoleRedirectionCheckSupported)
{
Console.ForegroundColor = ConsoleColor.Red;
}
}

internal static void ResetTerminalForegroundColor(this IConsole console)
{
if (Platform.IsConsoleRedirectionCheckSupported &&
if (IsConsoleRedirectionCheckSupported &&
!Console.IsOutputRedirected)
{
Console.ResetColor();
}
else if (Platform.IsConsoleRedirectionCheckSupported)
else if (IsConsoleRedirectionCheckSupported)
{
Console.ResetColor();
}
Expand Down
29 changes: 0 additions & 29 deletions src/System.CommandLine/Platform.cs

This file was deleted.