A C#/.NET port of the gh-badges library that powers shields.io
GhBadgesSharp is a C#/.NET port of the gh-badges library that powers shields.io.
See Acknowledgments for license info.
GhBadgesSharp is distributed as NuGet package.
After installation, a badge can be rendered by calling Badge.MakeBadge
.
It will return the badge as an SVG image (as XElement
).
The following code shows how to render this badge:
using System.IO;
using System.Xml.Linq;
using Grynwald.GhBadgesSharp;
public class Program
{
public static void Main(string[] args)
{
XElement badge = Badge.MakeBadge(
style: BadgeStyle.Flat,
leftText: "Hello",
rightText: "World",
color: NamedColor.Green
);
File.WriteAllText("badge.svg", badge.ToString());
}
}
Note: This repository uses git submodules, clone using git clone --recursive
Building GhBadgesSharp from source requires the .NET 6 SDK (version 6.0.101 as specified in global.json) and uses Cake for the build.
To execute the default task, run
.\build.ps1
This will build the project, run all tests and pack the NuGet package.
This library is a C# port of the gh-badges library.
- gh-badges is licensed under Creative Commons Zero v1.0 Universal license.
- Portions of this library were ported from the is-css-color library, licensed under the MIT License
- Portions of this library were ported from the anafanafo library, licensed under the MIT License
Libraries used (aside from .NET Core and .NET Standard):
- Json.NET
- Fluid
- Nerdbank.GitVersioning
- SourceLink
- ReportGenerator
- Cake
- Cake.BuildSystems.Module
- xUnit
- ApprovalTests
- PublicApiGenerator
The version of this project is automatically derived from git and the information
in version.json
using Nerdbank.GitVersioning:
- The master branch always contains the latest version. Packages produced from
master are always marked as pre-release versions (using the
-pre
suffix). - Stable versions are built from release branches. Build from release branches
will have no
-pre
suffix - Builds from any other branch will have both the
-pre
prerelease tag and the git commit hash included in the version string
To create a new release branch use the nbgv
tool:
dotnet tool restore
dotnet tool run nbgv -- prepare-release