This commit is contained in:
Peter Tribe 2019-02-13 13:14:29 -08:00
Родитель 85efdd17a6
Коммит c539c525c9
9 изменённых файлов: 135 добавлений и 12 удалений

Просмотреть файл

@ -6,6 +6,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EquinoxLabs.SVGSharpie", "s
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EquinoxLabs.SVGSharpie.ImageSharp", "src\EquinoxLabs.SVGSharpie.ImageSharp\EquinoxLabs.SVGSharpie.ImageSharp.csproj", "{E4E9C756-3BDE-46B4-AEAD-9837A7316746}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EquinoxLabs.SVGSharpie.ImageSharp", "src\EquinoxLabs.SVGSharpie.ImageSharp\EquinoxLabs.SVGSharpie.ImageSharp.csproj", "{E4E9C756-3BDE-46B4-AEAD-9837A7316746}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EquinoxLabs.SVGSharpie.ImageSharp.Tests", "tests\EquinoxLabs.SVGSharpie.ImageSharp.Tests\EquinoxLabs.SVGSharpie.ImageSharp.Tests.csproj", "{46F9A6AA-1E92-4ADE-9C2B-536EFBEFAA3C}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -20,6 +22,10 @@ Global
{E4E9C756-3BDE-46B4-AEAD-9837A7316746}.Debug|Any CPU.Build.0 = Debug|Any CPU {E4E9C756-3BDE-46B4-AEAD-9837A7316746}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4E9C756-3BDE-46B4-AEAD-9837A7316746}.Release|Any CPU.ActiveCfg = Release|Any CPU {E4E9C756-3BDE-46B4-AEAD-9837A7316746}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4E9C756-3BDE-46B4-AEAD-9837A7316746}.Release|Any CPU.Build.0 = Release|Any CPU {E4E9C756-3BDE-46B4-AEAD-9837A7316746}.Release|Any CPU.Build.0 = Release|Any CPU
{46F9A6AA-1E92-4ADE-9C2B-536EFBEFAA3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{46F9A6AA-1E92-4ADE-9C2B-536EFBEFAA3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46F9A6AA-1E92-4ADE-9C2B-536EFBEFAA3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46F9A6AA-1E92-4ADE-9C2B-536EFBEFAA3C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

Просмотреть файл

@ -24,15 +24,6 @@ environment:
- target_framework: net462 - target_framework: net462
is_32bit: True is_32bit: True
#- target_framework: mono
# is_32bit: False
#- target_framework: mono
# is_32bit: True
#- target_framework: net47
# is_32bit: False
#- target_framework: net47
# is_32bit: True
install: install:
- ps: | - ps: |
if ($env:target_framework -eq "mono") { if ($env:target_framework -eq "mono") {
@ -51,7 +42,7 @@ build_script:
- cmd: build.cmd - cmd: build.cmd
# test_script: # test_script:
# - ps: .\run-tests.ps1 $env:target_framework $env:is_32bit - ps: .\run-tests.ps1 $env:target_framework $env:is_32bit
after_test: after_test:
- cmd: appveyor PushArtifact "artifacts\EquinoxLabs.SVGSharpie.%APPVEYOR_BUILD_VERSION%.nupkg" - cmd: appveyor PushArtifact "artifacts\EquinoxLabs.SVGSharpie.%APPVEYOR_BUILD_VERSION%.nupkg"

Просмотреть файл

@ -46,7 +46,7 @@ if ( ($targetFramework -eq "netcoreapp2.1") -and ($env:CI -eq "True") -and ($is3
$testRunnerCmd = ".\tests\CodeCoverage\CodeCoverage.cmd" $testRunnerCmd = ".\tests\CodeCoverage\CodeCoverage.cmd"
} }
elseif ($targetFramework -eq "mono") { elseif ($targetFramework -eq "mono") {
$testDllPath = "$PSScriptRoot\tests\SVGSharpie.Tests\bin\Release\net462\SixLabors.ImageSharp.Tests.dll" $testDllPath = "$PSScriptRoot\tests\EquinoxLabs.SVGSharpie.ImageSharp.Tests\bin\Release\net462\EquinoxLabs.SVGSharpie.ImageSharp.Tests.dll"
VerifyPath($testDllPath, "test dll missing:") VerifyPath($testDllPath, "test dll missing:")
$xunitRunnerPath = "${env:HOMEPATH}\.nuget\packages\xunit.runner.console\2.3.1\tools\net452\" $xunitRunnerPath = "${env:HOMEPATH}\.nuget\packages\xunit.runner.console\2.3.1\tools\net452\"

Просмотреть файл

@ -6,26 +6,56 @@ using SixLabors.ImageSharp.Processing;
namespace EquinoxLabs.SVGSharpie.ImageSharp namespace EquinoxLabs.SVGSharpie.ImageSharp
{ {
/// <summary>
/// SVG image renderer
/// </summary>
public static class SvgImageRenderer public static class SvgImageRenderer
{ {
/// <summary>
/// Render SVG from xml string
/// </summary>
/// <typeparam name="TPixel"></typeparam>
/// <param name="content"></param>
/// <returns></returns>
public static Image<TPixel> RenderFromString<TPixel>(string content) where TPixel : struct, IPixel<TPixel> public static Image<TPixel> RenderFromString<TPixel>(string content) where TPixel : struct, IPixel<TPixel>
{ {
var document = SvgDocument.Parse(content); var document = SvgDocument.Parse(content);
return RenderInner<TPixel>(document, null, null); return RenderInner<TPixel>(document, null, null);
} }
/// <summary>
/// Render SVG from xml string
/// </summary>
/// <typeparam name="TPixel"></typeparam>
/// <param name="content"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
public static Image<TPixel> RenderFromString<TPixel>(string content, int width, int height) where TPixel : struct, IPixel<TPixel> public static Image<TPixel> RenderFromString<TPixel>(string content, int width, int height) where TPixel : struct, IPixel<TPixel>
{ {
var document = SvgDocument.Parse(content); var document = SvgDocument.Parse(content);
return RenderInner<TPixel>(document, width, height); return RenderInner<TPixel>(document, width, height);
} }
/// <summary>
/// Render SVG from SvgDocument
/// </summary>
/// <typeparam name="TPixel"></typeparam>
/// <param name="document"></param>
/// <returns></returns>
public static Image<TPixel> RenderFromDocument<TPixel>(SvgDocument document) where TPixel : struct, IPixel<TPixel> public static Image<TPixel> RenderFromDocument<TPixel>(SvgDocument document) where TPixel : struct, IPixel<TPixel>
{ {
return RenderInner<TPixel>(document, null, null); return RenderInner<TPixel>(document, null, null);
} }
/// <summary>
/// Render SVG from SvgDocument
/// </summary>
/// <typeparam name="TPixel"></typeparam>
/// <param name="document"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
public static Image<TPixel> RenderFromDocument<TPixel>(SvgDocument document, int width, int height) where TPixel : struct, IPixel<TPixel> public static Image<TPixel> RenderFromDocument<TPixel>(SvgDocument document, int width, int height) where TPixel : struct, IPixel<TPixel>
{ {
return RenderInner<TPixel>(document, width, height); return RenderInner<TPixel>(document, width, height);

Просмотреть файл

@ -0,0 +1,21 @@
@echo off
cd tests\CodeCoverage
nuget restore packages.config -PackagesDirectory .
cd ..
cd ..
dotnet restore EquinoxLabs.SVGSharpie.sln
rem Clean the solution to force a rebuild with /p:codecov=true
dotnet clean EquinoxLabs.SVGSharpie.sln -c Release
rem The -threshold options prevents this taking ages...
tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\EquinoxLabs.SVGSharpie.ImageSharp.Tests\EquinoxLabs.SVGSharpie.ImageSharp.Tests.csproj -c Release -f netcoreapp2.1 /p:codecov=true" -register:user -threshold:10 -oldStyle -safemode:off -output:.\SVGSharpie.Coverage.xml -hideskipped:All -returntargetcode -filter:"+[EquinoxLabs.SVGSharpie*]*"
if %errorlevel% neq 0 exit /b %errorlevel%
SET PATH=C:\\Python34;C:\\Python34\\Scripts;%PATH%
pip install codecov
codecov -f "SVGSharpie.Coverage.xml"

Просмотреть файл

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="OpenCover" version="4.6.519" />
</packages>

Просмотреть файл

@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net462;net472</TargetFrameworks>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<DebugType Condition="$(codecov) != ''">full</DebugType>
<DebugType Condition="$(codecov) == ''">portable</DebugType>
<DebugSymbols>True</DebugSymbols>
<RootNamespace>EquinoxLabs.SVGSharpie.ImageSharp.Tests</RootNamespace>
<AssemblyName>EquinoxLabs.SVGSharpie.ImageSharp.Tests</AssemblyName>
<Platforms>AnyCPU;x64;x86</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.console" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Moq" Version="4.10.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\EquinoxLabs.SVGSharpie.ImageSharp\EquinoxLabs.SVGSharpie.ImageSharp.csproj" />
<ProjectReference Include="..\..\src\EquinoxLabs.SVGSharpie\EquinoxLabs.SVGSharpie.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace EquinoxLabs.SVGSharpie.ImageSharp.Tests
{
public class Tests
{
[Fact]
public void FileTest()
{
string path = Path.GetTempFileName();
string testData = Guid.NewGuid().ToString();
File.WriteAllText(path, testData);
string data = File.ReadAllText(path);
Assert.Equal(testData, data);
File.Delete(path);
}
}
}

Просмотреть файл

@ -0,0 +1,5 @@
{
"shadowCopy": false,
"methodDisplay": "method",
"diagnosticMessages": true
}