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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Normalize line endings via .gitattributes
0c13f9c93ad456ab66c4690b553979cd865dff2c
26 changes: 26 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Normalize line endings
#
# This file was added after the repository had already accumulated a mix of
# CRLF and LF files; the history was renormalized in a single dedicated commit
# (see .git-blame-ignore-revs).

* text=auto

# Source and project files. diff=csharp gives hunk headers that name the
# enclosing type or method.
*.cs text diff=csharp
*.csproj text
*.props text
*.targets text

*.sln text

# Always LF: these are consumed by tools that dislike CR.
*.sh text eol=lf
*.yml text eol=lf
*.yaml text eol=lf

*.md text diff=markdown
*.json text
*.svg text
LICENSE text
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
branches: [main, develop]
pull_request:

jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v7
with:
# MinVer reads the version from Git tags, so it requires the tags and full history.
fetch-depth: 0

- uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'

- name: Build
run: dotnet build --configuration Release

- name: Test
run: dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage"

- name: Upload coverage
# Upload coverage from one platform. An upload error does not fail the build.
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
fail_ci_if_error: false

pack:
name: Verify the package builds
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0

- uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'

# Packing every change detects packaging faults before a release tag fixes the package version.
- name: Pack
run: dotnet pack InteractiveReadLine/InteractiveReadLine.csproj --configuration Release --output ./artifacts

- name: Upload package
uses: actions/upload-artifact@v7
with:
name: nuget-package
path: ./artifacts/*.nupkg
if-no-files-found: error
29 changes: 0 additions & 29 deletions .github/workflows/ci_netcore.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Documentation

on:
push:
branches: [main]
paths:
- 'InteractiveReadLine/**'
- 'docs/**'
- '.github/workflows/docs.yml'
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

# Let the active deployment finish. If other runs are pending, GitHub Actions keeps only the newest one,
# which then deploys after the active run completes.
concurrency:
group: pages
cancel-in-progress: false

jobs:
build:
name: Build the site
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7

- uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'

- name: Install DocFX
run: dotnet tool update -g docfx

# DocFX compiles the library to extract API metadata, so restore and build the project first. DocFX
# also reads the XML documentation generated by this build.
- name: Build the library
run: dotnet build InteractiveReadLine/InteractiveReadLine.csproj --configuration Release

- name: Build the documentation
run: docfx docs/docfx.json --warningsAsErrors

- name: Upload the site
uses: actions/upload-pages-artifact@v5
with:
path: docs/_site

deploy:
name: Deploy to GitHub Pages
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v5
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release

on:
push:
tags: ['v*']

permissions:
contents: write

jobs:
release:
name: Publish to NuGet
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7
with:
# Without the full history and tags, MinVer cannot see the release tag and silently
# produces 0.0.0-alpha, which would publish a package under the wrong version.
fetch-depth: 0

- uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'

- name: Test
run: dotnet test --configuration Release

- name: Pack
run: >
dotnet pack InteractiveReadLine/InteractiveReadLine.csproj
--configuration Release
-p:ContinuousIntegrationBuild=true
--output ./artifacts

- name: Confirm the packed version matches the tag
# MinVer derives the version from the tag, so a mismatch means that MinVer did not resolve the
# release tag. Stop before publishing because NuGet packages cannot be replaced after publication.
run: |
expected="${GITHUB_REF_NAME#v}"
actual=$(ls ./artifacts/InteractiveReadLine.*.nupkg | sed -E 's|.*/InteractiveReadLine\.(.*)\.nupkg|\1|')
echo "tag: $expected packed: $actual"
if [ "$expected" != "$actual" ]; then
echo "::error::Packed version '$actual' does not match tag '$expected'"
exit 1
fi

- name: Push to NuGet
run: >
dotnet nuget push "./artifacts/*.nupkg"
--api-key ${{ secrets.NUGET_API_KEY }}
--source https://api.nuget.org/v3/index.json
--skip-duplicate

- name: Create the GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: >
gh release create "$GITHUB_REF_NAME"
--title "$GITHUB_REF_NAME"
--generate-notes
./artifacts/*.nupkg
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,8 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/

# DocFX generates the API metadata and site output from the source during each documentation build,
# so these directories do not belong in the repository.
docs/api/
docs/_site/
130 changes: 65 additions & 65 deletions InteractiveReadLine.Demo/DemoNode.cs
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
namespace InteractiveReadLine.Demo
{
public class DemoNode
{
private readonly Dictionary<string, DemoNode> _children;
private readonly List<string> _childOrder;
public DemoNode(DemoNode parent, string name, IDemo demo)
: this(parent, name, demo?.Description)
{
Demo = demo;
}
public DemoNode(DemoNode parent, string name, string description)
{
Description = description;
Name = name;
Parent = parent;
_children = new Dictionary<string, DemoNode>();
_childOrder = new List<string>();
}
public DemoNode Parent { get; }
public string Name { get; }
public string Description { get; }
public IDemo Demo { get; }
public string Path => string.Join("/", this.GetPath(Array.Empty<string>()));
public IReadOnlyDictionary<string, DemoNode> Children => _children;
public string[] OrderedChildKeys => _childOrder.ToArray();
public DemoNode AddChild(string name, string description)
{
var node = new DemoNode(this, name, description);
_childOrder.Add(name);
_children[name] = node;
return node;
}
public DemoNode AddChild(string name, IDemo demo)
{
var node = new DemoNode(this, name, demo);
_childOrder.Add(name);
_children[name] = node;
return node;
}
private string[] GetPath(string[] basePath)
{
var path = new string[]{this.Name}.Concat(basePath).ToArray();
return this.Parent == null ? path : this.Parent.GetPath(path);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;

namespace InteractiveReadLine.Demo
{
public class DemoNode
{
private readonly Dictionary<string, DemoNode> _children;
private readonly List<string> _childOrder;

public DemoNode(DemoNode parent, string name, IDemo demo)
: this(parent, name, demo?.Description)
{
Demo = demo;
}

public DemoNode(DemoNode parent, string name, string description)
{
Description = description;
Name = name;
Parent = parent;
_children = new Dictionary<string, DemoNode>();
_childOrder = new List<string>();
}

public DemoNode Parent { get; }

public string Name { get; }

public string Description { get; }

public IDemo Demo { get; }

public string Path => string.Join("/", this.GetPath(Array.Empty<string>()));

public IReadOnlyDictionary<string, DemoNode> Children => _children;

public string[] OrderedChildKeys => _childOrder.ToArray();

public DemoNode AddChild(string name, string description)
{
var node = new DemoNode(this, name, description);
_childOrder.Add(name);
_children[name] = node;
return node;
}

public DemoNode AddChild(string name, IDemo demo)
{
var node = new DemoNode(this, name, demo);
_childOrder.Add(name);
_children[name] = node;
return node;
}

private string[] GetPath(string[] basePath)
{
var path = new string[]{this.Name}.Concat(basePath).ToArray();
return this.Parent == null ? path : this.Parent.GetPath(path);
}


}
}
Loading