-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from guitarrapc/feature/new_sample
feat: add net6.0 test and samples. drop netcoreapp2.2
- Loading branch information
Showing
41 changed files
with
364 additions
and
149 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: dotnet-build | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
branches: | ||
- "main" | ||
|
||
env: | ||
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | ||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | ||
NUGET_XMLDOC_MODE: skip | ||
|
||
jobs: | ||
build-dotnet: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: | | ||
6.0.x | ||
5.0.x | ||
3.1.x | ||
# build | ||
- name: Build | ||
run: dotnet build ./src/SkiaSharp.QrCode/SkiaSharp.QrCode.csproj -c Debug | ||
- name: Build (ManualGenerate) | ||
run: dotnet build ./samples/ManualGenerate/ManualGenerate.csproj -c Debug | ||
- name: Build (SimpleGenerate) | ||
run: dotnet build ./samples/SimpleGenerate/SimpleGenerate.csproj -c Debug | ||
# tests | ||
- name: Test (net3.1) | ||
run: dotnet test ./tests/SkiaSharp.QrCode.Tests.net31/ -c Debug | ||
- name: Test (net5.0) | ||
run: dotnet test ./tests/SkiaSharp.QrCode.Tests.net50/ -c Debug | ||
- name: Test (net6.0) | ||
run: dotnet test ./tests/SkiaSharp.QrCode.Tests.net60/ -c Debug -p:CollectCoverage=true -p:CoverletOutputFormat=opencover | ||
- uses: codecov/codecov-action@v1 | ||
with: | ||
file: ./tests/SkiaSharp.QrCode.Tests.net60/coverage.opencover.xml | ||
flags: unittests | ||
fail_ci_if_error: true | ||
verbose: true | ||
|
||
run-linux: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: | | ||
6.0.x | ||
5.0.x | ||
3.1.x | ||
# run | ||
- name: ManualGenerate (net3.1) | ||
run: dotnet run --project ./samples/ManualGenerate/ManualGenerate.csproj -c Debug -f netcoreapp3.1 | ||
- name: SimpleGenerate (net3.1) | ||
run: dotnet run --project ./samples/SimpleGenerate/SimpleGenerate.csproj -c Debug -f netcoreapp3.1 | ||
- name: ManualGenerate (net5.0) | ||
run: dotnet run --project ./samples/ManualGenerate/ManualGenerate.csproj -c Debug -f net5.0 | ||
- name: SimpleGenerate (net5.0) | ||
run: dotnet run --project ./samples/SimpleGenerate/SimpleGenerate.csproj -c Debug -f net5.0 | ||
- name: ManualGenerate (net6.0) | ||
run: dotnet run --project ./samples/ManualGenerate/ManualGenerate.csproj -c Debug -f net6.0 | ||
- name: SimpleGenerate (net6.0) | ||
run: dotnet run --project ./samples/SimpleGenerate/SimpleGenerate.csproj -c Debug -f net6.0 | ||
- name: Linux Docker Compose Run | ||
run: docker-compose -f ./samples/LinuxRunSamples/compose.yaml up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="SkiaSharp.QrCode" Version="0.4.1" /> | ||
<!-- require libfontconfig1 https://github.com/mono/SkiaSharp/issues/964#issuecomment-549385484 --> | ||
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.80.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="samples\*.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using SkiaSharp; | ||
using System; | ||
using System.IO; | ||
using SkiaSharp.QrCode; | ||
using SkiaSharp.QrCode.Models; | ||
|
||
Directory.CreateDirectory("output"); | ||
|
||
var content = "testtesttest"; | ||
using var generator = new QRCodeGenerator(); | ||
// Generate QrCode | ||
var qr = generator.CreateQrCode(content, ECCLevel.L); | ||
|
||
// Render to canvas | ||
var info = new SKImageInfo(512, 512); | ||
using var surface = SKSurface.Create(info); | ||
var canvas = surface.Canvas; | ||
canvas.Render(qr, info.Width, info.Height); | ||
|
||
// gen color | ||
// yellow https://rgb.to/yellow | ||
canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.FromHsl(60,100,50)); | ||
// red https://rgb.to/red | ||
canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.FromHsl(0, 100, 50)); | ||
|
||
// gen icon | ||
var logo = File.ReadAllBytes("samples/test.png"); | ||
var icon = new IconData | ||
{ | ||
Icon = SKBitmap.Decode(logo), | ||
IconSizePercent = 10, | ||
}; | ||
canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.Parse("000000"), icon); | ||
|
||
// Output to Stream -> File | ||
using var image = surface.Snapshot(); | ||
using var data = image.Encode(SKEncodedImageFormat.Png, 100); | ||
using var stream = File.OpenWrite(@"output/hoge.png"); | ||
data.SaveTo(stream); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash -ex | ||
|
||
FRAMEWORK=netcoreapp3.1 | ||
while [ $# -gt 0 ]; do | ||
case $1 in | ||
-f) FRAMEWORK=$2; shift 2; ;; | ||
*) shift ;; | ||
esac | ||
done | ||
|
||
apt update && apt install -y libfontconfig1 | ||
|
||
dotnet run --csproj BuildTest.csproj -f "${FRAMEWORK}" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="SkiaSharp.QrCode" Version="0.4.1" /> | ||
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.80.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="samples\*.png"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using SkiaSharp; | ||
using System; | ||
using System.IO; | ||
using SkiaSharp.QrCode; | ||
using SkiaSharp.QrCode.Models; | ||
|
||
Directory.CreateDirectory("output"); | ||
|
||
var content = "testtesttest"; | ||
using var generator = new QRCodeGenerator(); | ||
// Generate QrCode | ||
var qr = generator.CreateQrCode(content, ECCLevel.L); | ||
|
||
// Render to canvas | ||
var info = new SKImageInfo(512, 512); | ||
using var surface = SKSurface.Create(info); | ||
var canvas = surface.Canvas; | ||
canvas.Render(qr, info.Width, info.Height); | ||
|
||
// gen color | ||
// yellow https://rgb.to/yellow | ||
canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.FromHsl(60,100,50)); | ||
// red https://rgb.to/red | ||
canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.FromHsl(0, 100, 50)); | ||
|
||
// gen icon | ||
var logo = File.ReadAllBytes("samples/test.png"); | ||
var icon = new IconData | ||
{ | ||
Icon = SKBitmap.Decode(logo), | ||
IconSizePercent = 10, | ||
}; | ||
canvas.Render(qr, info.Width, info.Height, SKColor.Empty, SKColor.Parse("000000"), icon); | ||
|
||
// Output to Stream -> File | ||
using var image = surface.Snapshot(); | ||
using var data = image.Encode(SKEncodedImageFormat.Png, 100); | ||
using var stream = File.OpenWrite(@"output/hoge.png"); | ||
data.SaveTo(stream); |
Oops, something went wrong.