Skip to content
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: 4 additions & 4 deletions dotnet-tools.json → .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ 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
- name: 'Git Fetch Tags'
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
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
</PropertyGroup>

<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" PrivateAssets="all" Version="17.1.46" />
<PackageReference Include="MinVer" PrivateAssets="all" Version="3.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" PrivateAssets="all" Version="17.14.15" />
<PackageReference Include="MinVer" PrivateAssets="all" Version="7.0.0" />
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="all" Version="1.1.118" />
</ItemGroup>

Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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`

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</PropertyGroup>

<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="all" Version="1.1.1" />
<PackageReference Include="Spectre.Console" Version="0.32.*" />
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="all" Version="10.0.300" />
<PackageReference Include="Spectre.Console" Version="0.55.2" />
</ItemGroup>

<ItemGroup Label="Files">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Label="Build">
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<PropertyGroup Label="Package">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Label="Build">
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<PropertyGroup Label="Package">
Expand Down
10 changes: 5 additions & 5 deletions Tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<ItemGroup Label="Package References">
<PackageReference Include="coverlet.collector" PrivateAssets="all" Version="1.3.0">
<PackageReference Include="coverlet.collector" PrivateAssets="all" Version="10.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="Moq" Version="4.15.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" Version="3.1.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
Expand Down
92 changes: 47 additions & 45 deletions Tests/Spectre.Console.Extensions.Test/Spec.cs
Original file line number Diff line number Diff line change
@@ -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<double> 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<double> reporter)

Check warning on line 38 in Tests/Spectre.Console.Extensions.Test/Spec.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Use "Async" suffix in names of methods that return an awaitable type (https://microsoft.github.io/vs-threading/analyzers/VSTHRD200.html)

Check warning on line 38 in Tests/Spectre.Console.Extensions.Test/Spec.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Use "Async" suffix in names of methods that return an awaitable type (https://microsoft.github.io/vs-threading/analyzers/VSTHRD200.html)

Check warning on line 38 in Tests/Spectre.Console.Extensions.Test/Spec.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Use "Async" suffix in names of methods that return an awaitable type (https://microsoft.github.io/vs-threading/analyzers/VSTHRD200.html)

Check warning on line 38 in Tests/Spectre.Console.Extensions.Test/Spec.cs

View workflow job for this annotation

GitHub Actions / Build-macOS-latest

Use "Async" suffix in names of methods that return an awaitable type (https://microsoft.github.io/vs-threading/analyzers/VSTHRD200.html)

Check warning on line 38 in Tests/Spectre.Console.Extensions.Test/Spec.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Use "Async" suffix in names of methods that return an awaitable type (https://microsoft.github.io/vs-threading/analyzers/VSTHRD200.html)

Check warning on line 38 in Tests/Spectre.Console.Extensions.Test/Spec.cs

View workflow job for this annotation

GitHub Actions / Build-windows-latest

Use "Async" suffix in names of methods that return an awaitable type (https://microsoft.github.io/vs-threading/analyzers/VSTHRD200.html)
{
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
<ProjectReference Include="..\..\Source\Spectre.Console.Extensions.Progress\Spectre.Console.Extensions.Progress.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Spectre.Console.Testing" Version="0.55.2" />
</ItemGroup>

<PropertyGroup Label="Build">
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

</Project>
74 changes: 0 additions & 74 deletions Tests/Spectre.Console.Extensions.Test/Tools/TestableAnsiConsole.cs

This file was deleted.

Loading
Loading