Upstream Tyrrrz/CliFx state of the touched files before 72b7d869fc

This commit is contained in:
upstream committed 2026-08-28 10:12:58 +02:00
1 parent 8f11b8ff38
commit 50964082ba
6 files changed
+3 -132

No files matched your search

+1 -12
View File
@@ -3,7 +3,6 @@ using System.Linq;
using CliFx.Generators.Utils;
using CliFx.Generators.Utils.Extensions;
using Microsoft.CodeAnalysis;
using PowerKit.Extensions;
namespace CliFx.Generators.Binding;
@@ -11,7 +10,6 @@ internal partial record CommandSymbol(
INamedTypeSymbol Type,
string? Name,
string? Description,
IReadOnlyList<string> Examples,
IReadOnlyList<CommandInputSymbol> Inputs
)
{
@@ -73,19 +71,10 @@ internal partial record CommandSymbol
attribute?.NamedArguments.FirstOrDefault(a => a.Key == "Description").Value.Value
as string;
var examples =
attribute
?.NamedArguments.Where(a => a.Key == "Examples")
.SelectMany(a => a.Value.Values)
.Select(v => v.Value as string)
.WhereNotNull()
.ToArray()
?? [];
var properties = type.GetProperties().ToArray();
var parameters = CommandParameterSymbol.Resolve(properties, diagnostics);
var options = CommandOptionSymbol.Resolve(properties, diagnostics);
return new CommandSymbol(type, name, description, examples, [.. parameters, .. options]);
return new CommandSymbol(type, name, description, [.. parameters, .. options]);
}
}
@@ -31,17 +31,6 @@ internal static class CommandDescriptor
""";
}
private static string EmitExamples(IReadOnlyList<string> examples)
{
if (examples.Count == 0)
return "global::System.Array.Empty<string>()";
// lang=csharp
return $$"""
new[] { {{string.Join(", ", examples.Select(CSharp.Encode))}} }
""";
}
private static string? TryEmitDefaultScalarConverter(ITypeSymbol type)
{
// Object
@@ -533,7 +522,6 @@ internal static class CommandDescriptor
new global::CliFx.Binding.CommandDescriptor<{{command.Type.GetGloballyQualifiedName()}}>(
{{CSharp.Encode(command.Name)}},
{{CSharp.Encode(command.Description)}},
{{EmitExamples(command.Examples)}},
new global::CliFx.Binding.CommandInputDescriptor[]
{
{{string.Join(",", command.Inputs