-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failing test for .NET Core 3.1 and .NET 5 #789
Comments
Added smaller repro in #787 |
Repro: <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
width="100"
height="100"
>
<rect
width="100"
height="100"
x="0"
y="0"
style="color:#000000;fill:#f0f0f0;fill-opacity:1;stroke:#000000;stroke-width:1.62123179;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
</svg> |
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100" height="100">
<rect width="100" height="100" x="0" y="0" style="color:#000000;fill:#f0f0f0" />
</svg> |
__issue-789-03.svg <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100" height="100">
<rect width="100" height="100" x="0" y="0" style="color:#000000;fill:#f0f0f0" />
</svg> _issue-789-0.NETCoreApp,Version=v2.1.svg <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100" height="100" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xml="http://www.w3.org/XML/1998/namespace" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="100" height="100" color="black" style="fill:#F0F0F0;" />
</svg> _issue-789-0.NETCoreApp,Version=v3.1.svg <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100" height="100" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xml="http://www.w3.org/XML/1998/namespace" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="100" height="100" color="black" />
</svg> _issue-789-0.NETCoreApp,Version=v5.0.svg <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100" height="100" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xml="http://www.w3.org/XML/1998/namespace" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="100" height="100" color="black" />
</svg> _issue-789-0.NETFramework,Version=v4.5.2.svg <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100" height="100" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xml="http://www.w3.org/XML/1998/namespace" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="100" height="100" color="black" style="fill:#F0F0F0;" />
</svg> _issue-789-0.NETFramework,Version=v4.6.1.svg <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100" height="100" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xml="http://www.w3.org/XML/1998/namespace" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="100" height="100" color="black" style="fill:#F0F0F0;" />
</svg> Test [Test]
public void Test_Issue_789()
{
var svgPath = Path.Combine(AssemblyDirectory, "..", "..", "..", "..", "W3CTestSuite", "svg");
var file = Directory.GetFiles(svgPath, "__issue-789-03.svg").FirstOrDefault();
var doc1 = SvgDocument.Open<SvgDocument>(file);
using (var memStream = new MemoryStream())
{
var targetFrameworkAttribute = Assembly.GetExecutingAssembly()
.GetCustomAttributes(typeof(System.Runtime.Versioning.TargetFrameworkAttribute), false)
.SingleOrDefault() as System.Runtime.Versioning.TargetFrameworkAttribute;
doc1.Write(memStream);
memStream.Position = 0;
var streamReader = new StreamReader(memStream);
var str = streamReader.ReadToEnd();
File.WriteAllText($"c:\\DOWNLOADS\\__issue-789-0_{targetFrameworkAttribute.FrameworkName}.svg", str);
memStream.Position = 0;
var baseUri = doc1.BaseUri;
var doc2 = SvgDocument.Open<SvgDocument>(memStream);
doc2.BaseUri = baseUri;
}
} |
Tested color string and they all work: [TestCase("#f0f0f0")]
[TestCase("#000000")]
public void Test_Issue_789_SvgColourConverter_ConvertFrom(string hex)
{
var converter = new SvgColourConverter();
var color = converter.ConvertFrom(null, CultureInfo.InvariantCulture, hex);
Assert.NotNull(color);
Assert.AreEqual(typeof(Color), color.GetType());
}
[TestCase("#f0f0f0")]
[TestCase("#000000")]
public void Test_Issue_789_System_Drawing_ColorConverter_ConvertFrom(string hex)
{
var converter = new System.Drawing.ColorConverter();
var color = converter.ConvertFrom(null, CultureInfo.InvariantCulture, hex);
Assert.NotNull(color);
Assert.AreEqual(typeof(Color), color.GetType());
Assert.AreEqual(typeof(Color), color.GetType());
}
[Test]
public void Test_Issue_789_SvgColourConverter_ConvertTo_f0f0f0()
{
var converter = new SvgColourConverter();
var hex = converter.ConvertTo(null, CultureInfo.InvariantCulture, Color.FromArgb(0xFF, 0xf0, 0xf0, 0xf0), typeof(string));
Assert.NotNull(hex);
Assert.AreEqual("#f0f0f0".ToUpper(), hex);
}
[Test]
public void Test_Issue_789_SvgColourConverter_ConvertTo_000000()
{
var converter = new SvgColourConverter();
var hex = converter.ConvertTo(null, CultureInfo.InvariantCulture, Color.FromArgb(0xFF, 0x00, 0x00, 0x00), typeof(string));
Assert.NotNull(hex);
Assert.AreEqual("#000000".ToUpper(), hex);
} |
Simpler repro: <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100" height="100">
<rect width="100" height="100" x="0" y="0" style="fill:#f0f0f0" />
</svg> the issue is when document is saved and loaded again the style is not preserved |
When I invert this condition Line 87 in 197d4dc
than repro passes, but there are few tests that fail, not sure why |
Failing test: [Test]
public void Test_Issue_789()
{
var converter = new SvgPaintServerFactory();
var server = SvgPaintServerFactory.Create("#f0f0f0", null);
var value = converter.ConvertTo(null, CultureInfo.InvariantCulture, server, typeof(string));
Assert.AreEqual("#F0F0F0", value);
} |
* Migrate to supported .NET Core versions: - from .NET Core 2.2 (Out of support version) to .NET Core 2.1 - from .NET Core 3.0 (Out of support version) to .NET Core 3.1 * Add support for .NET 5.0 as the currently recommended .NET SDK * Added ToSvgString extension method for float * Added ToStringBenchmarks * Add netcoreapp3.1 target for test runner * Add smaller image to reproduce #789
One test image comparison test (
__issue-084-01
) fails for the .NET Core 3.1 and .NET 5 builds, while its passes for .NET Core 2.1 and .NET 4.x.This is not a regression, as we did not test these framework versions before. The test will be removed from the run tests until this issue is fixed.
See also this comment.
The text was updated successfully, but these errors were encountered: