From 26cacdfceb3ba7a1ab5a91e32b249418fd2c67af Mon Sep 17 00:00:00 2001 From: Oleksii Nikiforov Date: Sun, 17 May 2026 21:55:19 +0300 Subject: [PATCH 1/2] chore: modernize to .NET 10 and Spectre.Console 0.55.2 - Bump TFMs to net10.0 (libs, tests, samples); global.json to 10.0.108. - Pin Spectre.Console 0.55.2 (no wildcard) and Spectre.Console.ImageSharp 0.55.2. - Refresh tooling: MinVer 7.0.0, Threading.Analyzers 17.14.15, SourceLink.GitHub 10.0.300. - Refresh test deps: Test.Sdk 18.5.1, xunit 2.9.3, xunit.runner.visualstudio 3.1.5, Moq 4.20.72, coverlet 10.0.0. - Refresh sample deps: EF Core 10.0.8, M.E.DI 10.0.8, MiniProfiler 4.5.4, Bogus 35.6.5. - Relocate dotnet-tools.json to .config/; bump cake.tool 6.1.0, dotnet-example 5.0.0, replace dotnet-outdated with dotnet-outdated-tool 4.7.1. - CI: setup-dotnet@v4 (.NET 10), checkout/upload/download-artifact@v4, release-drafter@v6. - Replace hand-rolled TestableAnsiConsole/Input with Spectre.Console.Testing.TestConsole. - AnsiConsole.Render -> AnsiConsole.Write in samples (Render removed upstream). --- .../dotnet-tools.json | 8 +- .github/workflows/build.yml | 12 +-- .github/workflows/release-drafter.yml | 2 +- Directory.Build.props | 4 +- Source/Directory.Build.props | 4 +- ...Spectre.Console.Extensions.Progress.csproj | 5 +- .../Spectre.Console.Extensions.Table.csproj | 5 +- Tests/Directory.Build.props | 10 +- Tests/Spectre.Console.Extensions.Test/Spec.cs | 92 ++++++++++--------- .../Spectre.Console.Extensions.Test.csproj | 7 +- .../Tools/TestableAnsiConsole.cs | 74 --------------- .../Tools/TestableConsoleInput.cs | 51 ---------- global.json | 2 +- samples/DataSet/DataSet.csproj | 6 +- samples/DataSet/Program.cs | 28 ++++-- samples/DataTable/DataTable.csproj | 6 +- samples/DataTable/Program.cs | 28 +++--- .../DataTableEfCore/DataTableEfCore.csproj | 17 ++-- samples/DataTableEfCore/Program.cs | 22 +++-- samples/Directory.Build.props | 5 +- samples/http-progress/HttpProgress.csproj | 4 +- .../IProgressAndHttpClient.csproj | 4 +- .../Program.cs | 58 ++++++------ samples/iprogress/IProgress.csproj | 4 +- 24 files changed, 186 insertions(+), 272 deletions(-) rename dotnet-tools.json => .config/dotnet-tools.json (71%) delete mode 100644 Tests/Spectre.Console.Extensions.Test/Tools/TestableAnsiConsole.cs delete mode 100644 Tests/Spectre.Console.Extensions.Test/Tools/TestableConsoleInput.cs diff --git a/dotnet-tools.json b/.config/dotnet-tools.json similarity index 71% rename from dotnet-tools.json rename to .config/dotnet-tools.json index 231a837..414bc41 100644 --- a/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,19 +3,19 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "1.0.0-rc0002", + "version": "6.1.0", "commands": [ "dotnet-cake" ] }, "dotnet-example": { - "version": "1.2.0", + "version": "5.0.0", "commands": [ "dotnet-example" ] }, - "dotnet-outdated": { - "version": "2.11.0", + "dotnet-outdated-tool": { + "version": "4.7.1", "commands": [ "dotnet-outdated" ] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0cd740c..e14ca79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,7 @@ jobs: os: [ubuntu-latest, windows-latest, macOS-latest] steps: - name: 'Checkout' - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: lfs: true fetch-depth: 0 @@ -35,9 +35,9 @@ jobs: run: git fetch --tags shell: pwsh - name: 'Install .NET SDK' - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.100 + dotnet-version: 10.0.x - name: 'Dotnet Tool Restore' run: dotnet tool restore shell: pwsh @@ -51,7 +51,7 @@ jobs: run: dotnet cake --target=Pack shell: pwsh - name: 'Publish Artefacts' - uses: actions/upload-artifact@v1.0.0 + uses: actions/upload-artifact@v4 with: name: ${{matrix.os}} path: './Artefacts' @@ -63,7 +63,7 @@ jobs: runs-on: windows-latest steps: - name: 'Download Artefact' - uses: actions/download-artifact@v1 + uses: actions/download-artifact@v4 with: name: 'windows-latest' - name: 'Dotnet NuGet Add Source' @@ -80,7 +80,7 @@ jobs: runs-on: windows-latest steps: - name: 'Download Artefact' - uses: actions/download-artifact@v1 + uses: actions/download-artifact@v4 with: name: 'windows-latest' - name: 'Dotnet NuGet Push' diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 896edaf..340cea3 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -9,6 +9,6 @@ jobs: update_release_draft: runs-on: ubuntu-latest steps: - - uses: release-drafter/release-drafter@v5 + - uses: release-drafter/release-drafter@v6 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Directory.Build.props b/Directory.Build.props index 166b9e2..51a3bf8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -20,8 +20,8 @@ - - + + diff --git a/Source/Directory.Build.props b/Source/Directory.Build.props index 282c964..a578fdd 100644 --- a/Source/Directory.Build.props +++ b/Source/Directory.Build.props @@ -21,8 +21,8 @@ - - + + diff --git a/Source/Spectre.Console.Extensions.Progress/Spectre.Console.Extensions.Progress.csproj b/Source/Spectre.Console.Extensions.Progress/Spectre.Console.Extensions.Progress.csproj index c228b61..28de3b0 100644 --- a/Source/Spectre.Console.Extensions.Progress/Spectre.Console.Extensions.Progress.csproj +++ b/Source/Spectre.Console.Extensions.Progress/Spectre.Console.Extensions.Progress.csproj @@ -1,8 +1,9 @@ - + - net6.0;netstandard2.1 + net10.0 enable + enable diff --git a/Source/Spectre.Console.Extensions.Table/Spectre.Console.Extensions.Table.csproj b/Source/Spectre.Console.Extensions.Table/Spectre.Console.Extensions.Table.csproj index 809ecfc..80b34af 100644 --- a/Source/Spectre.Console.Extensions.Table/Spectre.Console.Extensions.Table.csproj +++ b/Source/Spectre.Console.Extensions.Table/Spectre.Console.Extensions.Table.csproj @@ -1,8 +1,9 @@ - + - net6.0;netstandard2.1 + net10.0 enable + enable diff --git a/Tests/Directory.Build.props b/Tests/Directory.Build.props index a0b863f..ebc1c24 100644 --- a/Tests/Directory.Build.props +++ b/Tests/Directory.Build.props @@ -3,13 +3,13 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + runtime; build; native; contentfiles; analyzers diff --git a/Tests/Spectre.Console.Extensions.Test/Spec.cs b/Tests/Spectre.Console.Extensions.Test/Spec.cs index da032c8..26ad66c 100644 --- a/Tests/Spectre.Console.Extensions.Test/Spec.cs +++ b/Tests/Spectre.Console.Extensions.Test/Spec.cs @@ -1,56 +1,58 @@ -namespace Spectre.Console.Extensions.Test -{ - using System; - using System.Net.Http; - using System.Threading.Tasks; - using Spectre.Console.Extensions.Progress; - using Spectre.Console; - using Xunit; +namespace Spectre.Console.Extensions.Test; - public class Spec - { - private readonly TestableAnsiConsole testAnsiConsole; +using System; +using System.Net.Http; +using System.Threading.Tasks; +using Spectre.Console; +using Spectre.Console.Extensions.Progress; +using Spectre.Console.Testing; +using Xunit; - public Spec() - { - this.testAnsiConsole = new TestableAnsiConsole(ColorSystem.TrueColor, width: 10); - } +public class Spec +{ + private readonly TestConsole testAnsiConsole; - [Fact] - public async Task Progress_OneBarExtensionFromExtension_ReportIProgressAmountOnce() - { - // Given - const string taskName = "task1"; - const double amountToReport = 10d; - ProgressTask? capturedProgressTask = default; - var progress = new Progress(this.testAnsiConsole) - .Columns(new ProgressColumn[] { new ProgressBarColumn() }) - .AutoRefresh(false) - .AutoClear(true); - await progress.StartAsync( - ctx => capturedProgressTask = ctx.AddTask(taskName), Reporter); + public Spec() + { + this.testAnsiConsole = new TestConsole(); + this.testAnsiConsole.Profile.Width = 10; + this.testAnsiConsole.Profile.Capabilities.ColorSystem = ColorSystem.TrueColor; + this.testAnsiConsole.Profile.Capabilities.Ansi = true; + this.testAnsiConsole.Profile.Capabilities.Interactive = true; + } - Assert.Equal(amountToReport, capturedProgressTask!.Value); + [Fact] + public async Task Progress_OneBarExtensionFromExtension_ReportIProgressAmountOnce() + { + const string taskName = "task1"; + const double amountToReport = 10d; + ProgressTask? capturedProgressTask = default; + var progress = new Progress(this.testAnsiConsole) + .Columns(new ProgressColumn[] { new ProgressBarColumn() }) + .AutoRefresh(false) + .AutoClear(true); + await progress.StartAsync(ctx => capturedProgressTask = ctx.AddTask(taskName), Reporter); - Task Reporter(IProgress reporter) - { - reporter.Report(amountToReport); - return Task.CompletedTask; - } - } + Assert.Equal(amountToReport, capturedProgressTask!.Value); - [Fact(Skip = "Learn how to mock http")] - public async Task HttpProgress_OneHttpRequestFromWithHttp_SuccessProgress() + Task Reporter(IProgress reporter) { - var progress = new Progress(this.testAnsiConsole) - .Columns(new ProgressColumn[] { new ProgressBarColumn() }) - .AutoRefresh(false) - .AutoClear(true); - var httpClient = new HttpClient(); - var request = new HttpRequestMessage(HttpMethod.Get, "/"); - await progress.WithHttp(httpClient, request,"", (stream) => Task.CompletedTask).StartAsync(); + reporter.Report(amountToReport); + return Task.CompletedTask; } + } - // TODO: consider to mock http client https://gingter.org/2018/07/26/how-to-mock-httpclient-in-your-net-c-unit-tests/ + [Fact(Skip = "Learn how to mock http")] + public async Task HttpProgress_OneHttpRequestFromWithHttp_SuccessProgress() + { + var progress = new Progress(this.testAnsiConsole) + .Columns(new ProgressColumn[] { new ProgressBarColumn() }) + .AutoRefresh(false) + .AutoClear(true); + var httpClient = new HttpClient(); + var request = new HttpRequestMessage(HttpMethod.Get, "/"); + await progress + .WithHttp(httpClient, request, string.Empty, (stream) => Task.CompletedTask) + .StartAsync(); } } diff --git a/Tests/Spectre.Console.Extensions.Test/Spectre.Console.Extensions.Test.csproj b/Tests/Spectre.Console.Extensions.Test/Spectre.Console.Extensions.Test.csproj index 075ce26..f7f2f61 100644 --- a/Tests/Spectre.Console.Extensions.Test/Spectre.Console.Extensions.Test.csproj +++ b/Tests/Spectre.Console.Extensions.Test/Spectre.Console.Extensions.Test.csproj @@ -5,9 +5,14 @@ + + + + - net6.0 + net10.0 enable + enable diff --git a/Tests/Spectre.Console.Extensions.Test/Tools/TestableAnsiConsole.cs b/Tests/Spectre.Console.Extensions.Test/Tools/TestableAnsiConsole.cs deleted file mode 100644 index a0c207f..0000000 --- a/Tests/Spectre.Console.Extensions.Test/Tools/TestableAnsiConsole.cs +++ /dev/null @@ -1,74 +0,0 @@ -namespace Spectre.Console.Extensions.Test -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Text; - using Spectre.Console.Rendering; - - public sealed class TestableAnsiConsole : IDisposable, IAnsiConsole - { - private readonly StringWriter writer; - private readonly IAnsiConsole console; - - public TestableAnsiConsole( - ColorSystem system, - AnsiSupport ansi = AnsiSupport.Yes, - InteractionSupport interaction = InteractionSupport.Yes, - int width = 80) - { - this.writer = new StringWriter(); - this.console = AnsiConsole.Create(new AnsiConsoleSettings - { - Ansi = ansi, - ColorSystem = (ColorSystemSupport)system, - Interactive = interaction, - Out = this.writer, - }); - - this.Width = width; - this.Input = new TestableConsoleInput(); - } - - public string Output => this.writer.ToString(); - - public Capabilities Capabilities => this.console.Capabilities; - - public Encoding Encoding => this.console.Encoding; - - public int Width { get; } - - public int Height => this.console.Height; - - public IAnsiConsoleCursor Cursor => this.console.Cursor; - - public TestableConsoleInput Input { get; } - - public RenderPipeline Pipeline => this.console.Pipeline; - - IAnsiConsoleInput IAnsiConsole.Input => this.Input; - - public void Dispose() - { - this.writer?.Dispose(); - } - - public void Clear(bool home) - { - this.console.Clear(home); - } - - public void Write(IEnumerable segments) - { - if (segments is null) - { - return; - } - - foreach (var segment in segments) - { - this.console.Write(segment); - } - } - } -} diff --git a/Tests/Spectre.Console.Extensions.Test/Tools/TestableConsoleInput.cs b/Tests/Spectre.Console.Extensions.Test/Tools/TestableConsoleInput.cs deleted file mode 100644 index 141a53f..0000000 --- a/Tests/Spectre.Console.Extensions.Test/Tools/TestableConsoleInput.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace Spectre.Console.Extensions.Test -{ - using System; - using System.Collections.Generic; - - public sealed class TestableConsoleInput : IAnsiConsoleInput - { - private readonly Queue input; - - public TestableConsoleInput() - { - this.input = new Queue(); - } - - public void PushText(string input) - { - if (input is null) - { - throw new ArgumentNullException(nameof(input)); - } - - foreach (var character in input) - { - this.PushCharacter(character); - } - - this.PushKey(ConsoleKey.Enter); - } - - public void PushCharacter(char character) - { - var control = char.IsUpper(character); - this.input.Enqueue(new ConsoleKeyInfo(character, (ConsoleKey)character, false, false, control)); - } - - public void PushKey(ConsoleKey key) - { - this.input.Enqueue(new ConsoleKeyInfo((char)key, key, false, false, false)); - } - - public ConsoleKeyInfo ReadKey(bool intercept) - { - if (this.input.Count == 0) - { - throw new InvalidOperationException("No input available."); - } - - return this.input.Dequeue(); - } - } -} diff --git a/global.json b/global.json index 310c885..98e2106 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { "rollForward": "latestMinor", - "version": "6.0.100" + "version": "10.0.108" } } diff --git a/samples/DataSet/DataSet.csproj b/samples/DataSet/DataSet.csproj index 2fd9773..cf35f60 100644 --- a/samples/DataSet/DataSet.csproj +++ b/samples/DataSet/DataSet.csproj @@ -5,12 +5,14 @@ - + Exe - net6.0 + net10.0 + enable + enable true diff --git a/samples/DataSet/Program.cs b/samples/DataSet/Program.cs index 01d71c3..893a3b6 100644 --- a/samples/DataSet/Program.cs +++ b/samples/DataSet/Program.cs @@ -13,21 +13,25 @@ internal static class Program private static readonly Faker FakePersons = new Faker() .RuleFor(p => p.FirstName, f => f.Person.FirstName) .RuleFor(p => p.LastName, f => f.Person.LastName) - .RuleFor(p => p.Address, f => new Faker
() - .RuleFor(address => address.City, f1 => f1.Address.City()) - .RuleFor(address => address.Street, f2 => f2.Address.StreetName()) - .RuleFor(address => address.ZipCode, f3 => f3.Random.Number(0, 1_000)).Generate()); + .RuleFor( + p => p.Address, + f => + new Faker
() + .RuleFor(address => address.City, f1 => f1.Address.City()) + .RuleFor(address => address.Street, f2 => f2.Address.StreetName()) + .RuleFor(address => address.ZipCode, f3 => f3.Random.Number(0, 1_000)) + .Generate() + ); private static void Main(string[] args) { var dataSet = GenerateDataSet(); - var panel = dataSet - .FromDataSet((cfg) => - cfg.HeaderAlignment(Justify.Left) - .BorderColor(Color.Grey)); + var panel = dataSet.FromDataSet( + (cfg) => cfg.HeaderAlignment(Justify.Left).BorderColor(Color.Grey) + ); - AnsiConsole.Render(panel); + AnsiConsole.Write(panel); } private static DataRow ToDataRow(Person person, DataTable dataTable) @@ -56,7 +60,11 @@ static DataTable GenerateDataTable(string tableName) _ = dt.Columns.Add(nameof(Person.Address), typeof(string)); const int peopleSize = 10; - foreach (var row in FakePersons.Generate(peopleSize).Select(person => ToDataRow(person, dt))) + foreach ( + var row in FakePersons + .Generate(peopleSize) + .Select(person => ToDataRow(person, dt)) + ) { dt.Rows.Add(row); } diff --git a/samples/DataTable/DataTable.csproj b/samples/DataTable/DataTable.csproj index e13614d..8a51797 100644 --- a/samples/DataTable/DataTable.csproj +++ b/samples/DataTable/DataTable.csproj @@ -5,12 +5,14 @@ - + Exe - net6.0 + net10.0 + enable + enable true diff --git a/samples/DataTable/Program.cs b/samples/DataTable/Program.cs index 56a7a68..b8a0a3f 100644 --- a/samples/DataTable/Program.cs +++ b/samples/DataTable/Program.cs @@ -5,38 +5,44 @@ using System.Linq; using Bogus; using Spectre.Console; - using SpectreTable = Spectre.Console.Table; using Spectre.Console.Extensions.Table; + using SpectreTable = Spectre.Console.Table; // TODO: add example: EF core in memory database + datatable + spectre.console // TODO: add unit tests; integration tests // https://stackoverflow.com/questions/23697467/returning-datatable-using-entity-framework - internal static class Program { private static readonly Faker FakePersons = new Faker() .RuleFor(p => p.FirstName, f => f.Person.FirstName) .RuleFor(p => p.LastName, f => f.Person.LastName) - .RuleFor(p => p.Address, f => new Faker
() - .RuleFor(address => address.City, f1 => f1.Address.City()) - .RuleFor(address => address.Street, f2 => f2.Address.StreetName()) - .RuleFor(address => address.ZipCode, f3 => f3.Random.Number(0, 1_000)).Generate()); + .RuleFor( + p => p.Address, + f => + new Faker
() + .RuleFor(address => address.City, f1 => f1.Address.City()) + .RuleFor(address => address.Street, f2 => f2.Address.StreetName()) + .RuleFor(address => address.ZipCode, f3 => f3.Random.Number(0, 1_000)) + .Generate() + ); private static void Main(string[] args) { var dataTable = GenerateDataTable(); const int peopleSize = 10; - foreach (var row in FakePersons.Generate(peopleSize).Select(person => ToDataRow(person, dataTable))) + foreach ( + var row in FakePersons + .Generate(peopleSize) + .Select(person => ToDataRow(person, dataTable)) + ) { dataTable.Rows.Add(row); } - var tableToDisplay = dataTable - .FromDataTable() - .Border(TableBorder.Rounded); - AnsiConsole.Render(tableToDisplay); + var tableToDisplay = dataTable.FromDataTable().Border(TableBorder.Rounded); + AnsiConsole.Write(tableToDisplay); } private static DataRow ToDataRow(Person person, DataTable dataTable) diff --git a/samples/DataTableEfCore/DataTableEfCore.csproj b/samples/DataTableEfCore/DataTableEfCore.csproj index 1696a73..83c829c 100644 --- a/samples/DataTableEfCore/DataTableEfCore.csproj +++ b/samples/DataTableEfCore/DataTableEfCore.csproj @@ -5,23 +5,24 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - + + + + + Exe - net6.0 + net10.0 false enable + enable latest SA1600 diff --git a/samples/DataTableEfCore/Program.cs b/samples/DataTableEfCore/Program.cs index a9aee7c..cfd9008 100644 --- a/samples/DataTableEfCore/Program.cs +++ b/samples/DataTableEfCore/Program.cs @@ -1,4 +1,5 @@ using System.Data.Common; + namespace DataTable { using System; @@ -31,23 +32,20 @@ public static void Main() { IQueryable query = ctx.Persons; var dataTable = RetrieveDataTable(ctx, query); - var dataset = new DataSet - { - DataSetName = "Greatest of all time", - }; + var dataset = new DataSet { DataSetName = "Greatest of all time" }; dataset.Tables.Add(RetrieveDataTable(ctx, query)); using (profiler.Step("Display...")) { - AnsiConsole.Render( - dataset.FromDataSet(configurePanel: opt => - opt.BorderColor(Color.Aqua))); + AnsiConsole.Write( + dataset.FromDataSet(configurePanel: opt => opt.BorderColor(Color.Aqua)) + ); } } _ = profiler.Stop(); var diagnosticsPanel = new Panel(profiler.RenderPlainText()).RoundedBorder(); diagnosticsPanel.Header = new PanelHeader("Diagnostics"); - AnsiConsole.Render(diagnosticsPanel); + AnsiConsole.Write(diagnosticsPanel); } catch (Exception ex) { @@ -60,13 +58,17 @@ private static ServiceProvider BuildServiceProvider() IServiceCollection services = new ServiceCollection(); services.AddDbContext(opt => opt.UseSqlite("Data Source=people.db") - .LogTo(Console.WriteLine, LogLevel.Information)); + .LogTo(Console.WriteLine, LogLevel.Information) + ); var serviceProvider = services.BuildServiceProvider(); return serviceProvider; } - private static DataTable RetrieveDataTable(PersonContext personContext, IQueryable query) + private static DataTable RetrieveDataTable( + PersonContext personContext, + IQueryable query + ) { var connection = personContext.Database.GetDbConnection(); connection = new ProfiledDbConnection(connection, MiniProfiler.Current); diff --git a/samples/Directory.Build.props b/samples/Directory.Build.props index b337663..0d413b2 100644 --- a/samples/Directory.Build.props +++ b/samples/Directory.Build.props @@ -6,8 +6,7 @@ - - - + + diff --git a/samples/http-progress/HttpProgress.csproj b/samples/http-progress/HttpProgress.csproj index 278b6c1..534e114 100644 --- a/samples/http-progress/HttpProgress.csproj +++ b/samples/http-progress/HttpProgress.csproj @@ -3,7 +3,9 @@ Exe - net6.0 + net10.0 + enable + enable true diff --git a/samples/iprogress-http-client-multiple-calls/IProgressAndHttpClient.csproj b/samples/iprogress-http-client-multiple-calls/IProgressAndHttpClient.csproj index af03e6d..54159d3 100644 --- a/samples/iprogress-http-client-multiple-calls/IProgressAndHttpClient.csproj +++ b/samples/iprogress-http-client-multiple-calls/IProgressAndHttpClient.csproj @@ -2,7 +2,9 @@ Exe - net6.0 + net10.0 + enable + enable true SA1600;CS1591 diff --git a/samples/iprogress-http-client-multiple-calls/Program.cs b/samples/iprogress-http-client-multiple-calls/Program.cs index 2edf7dd..b00cb6e 100644 --- a/samples/iprogress-http-client-multiple-calls/Program.cs +++ b/samples/iprogress-http-client-multiple-calls/Program.cs @@ -25,29 +25,27 @@ public class Program private static async Task RunHttpClientDemoAsync() { - string[] urls = - { - "as5.png", - "dotNET-bot_kamckinn_v2.png", - }; + string[] urls = { "as5.png", "dotNET-bot_kamckinn_v2.png" }; var client = GenerateHttpClient(); - CancellationTokenSource cts = - new CancellationTokenSource(TimeSpan.FromSeconds(30)); - var messagesTasks = urls - .Select(u => client.GetAsync( - u, HttpCompletionOption.ResponseHeadersRead, cts.Token)).ToList(); + CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(30)); + var messagesTasks = urls.Select(u => + client.GetAsync(u, HttpCompletionOption.ResponseHeadersRead, cts.Token) + ) + .ToList(); var work = Task.WhenAll(messagesTasks); var messages = messagesTasks.Select(t => t.Result.EnsureSuccessStatusCode()).ToList(); - IList totals = messages - .Select(m => m.Content.Headers.ContentLength) - .ToList(); + IList totals = messages.Select(m => m.Content.Headers.ContentLength).ToList(); IEnumerable DeclareTasks(ProgressContext context) { yield return context.AddTask( - $"Content-Length: {totals[0]}", new ProgressTaskSettings() { MaxValue = totals[0] ?? -1 }); + $"Content-Length: {totals[0]}", + new ProgressTaskSettings() { MaxValue = totals[0] ?? -1 } + ); yield return context.AddTask( - $"Content-Length: {totals[1]}", new ProgressTaskSettings() { MaxValue = totals[1] ?? -1 }); + $"Content-Length: {totals[1]}", + new ProgressTaskSettings() { MaxValue = totals[1] ?? -1 } + ); } var files = new List(); @@ -74,9 +72,11 @@ async Task ReportReceivedFile(Task t) foreach (var fn in files) { - AnsiConsole.MarkupLine($"{Emoji.Known.CheckMarkButton} [underline grey]{fn}[/]"); + AnsiConsole.MarkupLine( + $"{Emoji.Known.CheckMarkButton} [underline grey]{fn}[/]" + ); var image = new CanvasImage(fn).MaxWidth(16); - AnsiConsole.Render(image); + AnsiConsole.Write(image); } } catch (Exception ex) @@ -86,20 +86,24 @@ async Task ReportReceivedFile(Task t) } private static Progress BuildProgress() => - AnsiConsole.Progress() - .Columns(new ProgressColumn[] - { - new TaskDescriptionColumn(), - new ProgressBarColumn(), - new PercentageColumn(), - new RemainingTimeColumn(), - new SpinnerColumn(), - }); + AnsiConsole + .Progress() + .Columns( + new ProgressColumn[] + { + new TaskDescriptionColumn(), + new ProgressBarColumn(), + new PercentageColumn(), + new RemainingTimeColumn(), + new SpinnerColumn(), + } + ); private static async Task DoSomeWorkCoreAsync( HttpContent content, IProgress progress, - CancellationToken token) + CancellationToken token + ) { string fileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".png"; using var stream = await content.ReadAsStreamAsync(token); diff --git a/samples/iprogress/IProgress.csproj b/samples/iprogress/IProgress.csproj index f17dd84..c3e068e 100644 --- a/samples/iprogress/IProgress.csproj +++ b/samples/iprogress/IProgress.csproj @@ -2,7 +2,9 @@ Exe - net6.0 + net10.0 + enable + enable true From 88763eaee288efd6ece4a57ed8d623aec28f7c6e Mon Sep 17 00:00:00 2001 From: Oleksii Nikiforov Date: Sun, 17 May 2026 21:59:33 +0300 Subject: [PATCH 2/2] fix: cake 6 alias rename and refresh broken README badges --- README.md | 10 ++++------ build.cake | 16 ++++++++-------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b1d03a3..56dfa65 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # Spectre.Console.Extensions -![GitHub Actions Status](https://github.com/nikiforovall/Spectre.Console.Extensions/workflows/Build/badge.svg?branch=main) +[![Build](https://github.com/NikiforovAll/Spectre.Console.Extensions/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/NikiforovAll/Spectre.Console.Extensions/actions/workflows/build.yml) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) -[![GitHub Actions Build History](https://buildstats.info/github/chart/nikiforovall/Spectre.Console.Extensions?branch=main&includeBuildsFromPullRequest=false)](https://github.com/nikiforovall/Spectre.Console.Extensions/actions) - The goal of this project is to extend [Spectre.Console](https://github.com/spectresystems/spectre.console) plugins with some niche functionality. * Progress with `IProgress` Adapter. @@ -16,7 +14,7 @@ Package | Version `Spectre.Console.Extensions.Progress` | [![Nuget](https://img.shields.io/nuget/v/Spectre.Console.Extensions.Progress.svg)](https://nuget.org/packages/Spectre.Console.Extensions.Progress) | IProgress adapter and HttpClient reporting. `Spectre.Console.Extensions.Table` | [![Nuget](https://img.shields.io/nuget/v/Spectre.Console.Extensions.Table.svg)](https://nuget.org/packages/Spectre.Console.Extensions.Table) | DataTable and DataSet support. -## Spectre.Console.Extensions.Progress ![NuGet Badge](https://buildstats.info/nuget/Spectre.Console.Extensions.Progress) +## Spectre.Console.Extensions.Progress [![Nuget](https://img.shields.io/nuget/v/Spectre.Console.Extensions.Progress.svg)](https://nuget.org/packages/Spectre.Console.Extensions.Progress) Extensions for `AnsiConsole.Progress` @@ -79,14 +77,14 @@ await BuildProgress() ``` -## Spectre.Console.Extensions.Table ![NuGet Badge](https://buildstats.info/nuget/Spectre.Console.Extensions.Table) +## Spectre.Console.Extensions.Table [![Nuget](https://img.shields.io/nuget/v/Spectre.Console.Extensions.Table.svg)](https://nuget.org/packages/Spectre.Console.Extensions.Table) Display `System.Data.DataTable`. ```csharp System.Data.DataTable dataTable = DataTableFactory(); var table = dataTable.FromDataTable().Border(TableBorder.Rounded); -AnsiConsole.Render(); +AnsiConsole.Write(table); ``` ## TODO diff --git a/build.cake b/build.cake index da2cc6c..39ef625 100644 --- a/build.cake +++ b/build.cake @@ -20,7 +20,7 @@ Task("Restore") .IsDependentOn("Clean") .Does(() => { - DotNetCoreRestore(); + DotNetRestore(); }); Task("Build") @@ -28,9 +28,9 @@ Task("Build") .IsDependentOn("Restore") .Does(() => { - DotNetCoreBuild( + DotNetBuild( ".", - new DotNetCoreBuildSettings() + new DotNetBuildSettings() { Configuration = configuration, NoRestore = true, @@ -41,9 +41,9 @@ Task("Test") .Description("Runs unit tests and outputs test results to the artefacts directory.") .DoesForEach(GetFiles("./Tests/**/*.csproj"), project => { - DotNetCoreTest( + DotNetTest( project.ToString(), - new DotNetCoreTestSettings() + new DotNetTestSettings() { Collectors = new string[] { "XPlat Code Coverage" }, Configuration = configuration, @@ -63,13 +63,13 @@ Task("Pack") .Description("Creates NuGet packages and outputs them to the artifacts directory.") .Does(() => { - DotNetCorePack( + DotNetPack( ".", - new DotNetCorePackSettings() + new DotNetPackSettings() { Configuration = configuration, IncludeSymbols = true, - MSBuildSettings = new DotNetCoreMSBuildSettings().WithProperty("SymbolPackageFormat", "snupkg"), + MSBuildSettings = new DotNetMSBuildSettings().WithProperty("SymbolPackageFormat", "snupkg"), NoBuild = true, NoRestore = true, OutputDirectory = artefactsDirectory,