Skip to content

Commit 72d98a5

Browse files
authored
Merge pull request #6 from fernandezja/develop
Support for multiple .NET versions
2 parents cd940e3 + dbdd9dc commit 72d98a5

22 files changed

+807
-40
lines changed

.github/workflows/dotnet-core.yml

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
name: .NET Core
1+
name: CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ master, develop ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ master, develop ]
88

99
jobs:
10-
build:
11-
12-
runs-on: ubuntu-latest
13-
10+
build-and-test:
11+
runs-on: windows-latest
12+
strategy:
13+
matrix:
14+
test-framework: ['net9.0']
15+
#test-framework: [ 'net8.0', 'net9.0', 'net48', 'net481' ]
1416
steps:
15-
- uses: actions/checkout@v2
16-
- name: Setup .NET Core
17-
uses: actions/setup-dotnet@v1
18-
with:
19-
dotnet-version: 3.1.101
20-
- name: Install dependencies
21-
working-directory: src
22-
run: dotnet restore
23-
- name: Build
24-
working-directory: src
25-
run: dotnet build --configuration Release --no-restore
26-
- name: Test
27-
working-directory: src
28-
run: dotnet test --no-restore --verbosity normal
17+
- uses: actions/checkout@v2
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version:
22+
9.0.x
23+
- name: Install dependencies
24+
working-directory: src
25+
run: dotnet restore
26+
- name: Build
27+
working-directory: src
28+
run: dotnet build --configuration Release --no-restore
29+
- name: Test
30+
working-directory: src
31+
run: dotnet test --no-restore --verbosity normal --framework ${{ matrix.test-framework }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,4 @@ ASALocalRun/
328328

329329
# MFractors (Xamarin productivity tool) working folder
330330
.mfractor/
331+
/src/ColorHashSharp.Tests/coverage.json

Benchmark.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# ColorHashSharp Benchmark
2+
3+
### Benchmark NET6 & NET7
4+
5+
BenchmarkDotNet=v0.13.2, OS=Windows 11 (10.0.22000.1281/21H2)
6+
Intel Core i7-8550U CPU 1.80GHz (Kaby Lake R), 1 CPU, 8 logical and 4 physical cores
7+
.NET SDK=7.0.100
8+
[Host] : .NET 6.0.11 (6.0.1122.52304), X64 RyuJIT AVX2 [AttachedDebugger]
9+
.NET 6.0 : .NET 6.0.11 (6.0.1122.52304), X64 RyuJIT AVX2
10+
.NET 7.0 : .NET 7.0.0 (7.0.22.51805), X64 RyuJIT AVX2
11+
12+
13+
| Method | Job | Runtime | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
14+
|------- |--------- |--------- |---------:|----------:|----------:|---------:|------:|--------:|-------:|----------:|------------:|
15+
| Hsl | .NET 6.0 | .NET 6.0 | 1.289 us | 0.0292 us | 0.0789 us | 1.263 us | 1.00 | 0.00 | 0.5360 | 2.2 KB | 1.00 |
16+
| Rgb | .NET 6.0 | .NET 6.0 | 1.296 us | 0.0256 us | 0.0639 us | 1.280 us | 1.00 | 0.08 | 0.5360 | 2.2 KB | 1.00 |
17+
| Hex | .NET 6.0 | .NET 6.0 | 1.435 us | 0.0284 us | 0.0433 us | 1.432 us | 1.09 | 0.07 | 0.5741 | 2.35 KB | 1.07 |
18+
| Hsl | .NET 7.0 | .NET 7.0 | 1.432 us | 0.0674 us | 0.1911 us | 1.372 us | 1.12 | 0.17 | 0.5360 | 2.2 KB | 1.00 |
19+
| Rgb | .NET 7.0 | .NET 7.0 | 1.497 us | 0.0678 us | 0.1890 us | 1.448 us | 1.15 | 0.15 | 0.5360 | 2.2 KB | 1.00 |
20+
| Hex | .NET 7.0 | .NET 7.0 | 1.358 us | 0.0272 us | 0.0381 us | 1.350 us | 1.03 | 0.07 | 0.5741 | 2.35 KB | 1.07 |

Links.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ColorHashSharp resources links
2+
3+
#### Links
4+
- [Packaging Icon within the nupkg](https://github.com/NuGet/Home/wiki/Packaging-Icon-within-the-nupkg)
5+
- [Supporting Multiple Target Frameworks](https://learn.microsoft.com/en-us/nuget/create-packages/supporting-multiple-target-frameworks)
6+
- [NuGet Package Explorer](https://apps.microsoft.com/detail/9WZDNCRDMDM3?hl=en-us&gl=AR&ocid=pdpshare)
7+
- [NuGet Package Explorer GitHub](https://github.com/NuGetPackageExplorer/NuGetPackageExplorer)
8+
9+
#### Command to push a package to NuGet
10+
```bash
11+
dotnet nuget push file.nupkg -k {YOUR_API_KEY_HERE} -s https://api.nuget.org/v3/index.json
12+
```
13+
14+
#### Command to pack a project
15+
```bash
16+
dotnet pack --configuration Release
17+
```

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
# ColorHashSharp
22
Generate color based on the given string. C# port of [ColorHash Javascript Library](https://github.com/zenozeng/color-hash).
33

4-
[![NuGet version (ColorHashSharp)](https://img.shields.io/nuget/v/ColorHashSharp.svg?style=flat-square)](https://www.nuget.org/packages/ColorHashSharp/)
5-
![.NET Core](https://github.com/fernandezja/ColorHashSharp/workflows/.NET%20Core/badge.svg?branch=master)
6-
[![Build status](https://fernandezja.visualstudio.com/ColorHashSharp/_apis/build/status/ColorHashSharp-CI)](https://fernandezja.visualstudio.com/ColorHashSharp/_build/latest?definitionId=4)
4+
[![NuGet version (ColorHashSharp)](https://img.shields.io/nuget/v/ColorHashSharp.svg?style=flat-square)](https://www.nuget.org/packages/ColorHashSharp/)   [![NuGet Downloads](https://img.shields.io/nuget/dt/ColorHashSharp.svg)](https://www.nuget.org/packages/Serilog/)
5+
6+
[![CI](https://github.com/fernandezja/ColorHashSharp/actions/workflows/dotnet-core.yml/badge.svg)](https://github.com/fernandezja/ColorHashSharp/actions/workflows/dotnet-core.yml)  [![Build status](https://fernandezja.visualstudio.com/ColorHashSharp/_apis/build/status/ColorHashSharp-CI)](https://fernandezja.visualstudio.com/ColorHashSharp/_build/latest?definitionId=4)
7+
8+
#### Status
9+
10+
11+
|Actions |master |develop |
12+
|--- |--- |--- |
13+
|CI |[![CI](https://github.com/fernandezja/ColorHashSharp/actions/workflows/dotnet-core.yml/badge.svg?branch=master)](https://github.com/fernandezja/ColorHashSharp/actions/workflows/dotnet-core.yml) |[![CI](https://github.com/fernandezja/ColorHashSharp/actions/workflows/dotnet-core.yml/badge.svg?branch=develop)](https://github.com/fernandezja/ColorHashSharp/actions/workflows/dotnet-core.yml) |
14+
715

816
#### Basic
917

-75.2 KB
Loading

assets/icon/ColorHashSharp.png

85.4 KB
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\ColorHashSharp\ColorHashSharp.csproj" />
16+
</ItemGroup>
17+
18+
</Project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using BenchmarkDotNet.Attributes;
2+
using BenchmarkDotNet.Jobs;
3+
using Fernandezja.ColorHashSharp;
4+
using Fernandezja.ColorHashSharp.Interfaces;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace ColorHashSharp.Benchmarks
12+
{
13+
[MemoryDiagnoser]
14+
[SimpleJob(RuntimeMoniker.Net48)]
15+
[SimpleJob(RuntimeMoniker.Net481)]
16+
[SimpleJob(RuntimeMoniker.Net80, baseline: true)]
17+
[SimpleJob(RuntimeMoniker.Net90)]
18+
[SimpleJob(RuntimeMoniker.Net10_0)]
19+
public class ColorHashSharpBenchmarks
20+
{
21+
private const string STRING_TO_HASH = "The Force will be with you always";
22+
23+
private ColorHash _colorHash = new();
24+
25+
26+
[Benchmark(Baseline = true)]
27+
public void Hsl()
28+
{
29+
_ = _colorHash.Hsl(STRING_TO_HASH);
30+
}
31+
32+
[Benchmark]
33+
public void Rgb()
34+
{
35+
_ = _colorHash.Rgb(STRING_TO_HASH);
36+
}
37+
38+
[Benchmark]
39+
public void Hex()
40+
{
41+
_ = _colorHash.Hex(STRING_TO_HASH);
42+
}
43+
}
44+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using BenchmarkDotNet.Running;
2+
using ColorHashSharp.Benchmarks;
3+
4+
Console.WriteLine("ColorHashSharp benchmarks!");
5+
6+
_ = BenchmarkRunner.Run<ColorHashSharpBenchmarks>();
7+
8+
Console.ReadKey();

0 commit comments

Comments
 (0)