[FEATURE] Reset clipPath autoincrement ids
Is your feature request related to a problem?
My unit tests produce set of SVG files and compare them with expected result. In version 2.88, clipPath id property is being autoincrement of every run, resulting in different SVG content produced on every run.
Describe the solution you would like
- some manual API call to reset seed/suffix value
- automatically restart seed for each SVG (is it a static counter used?)
Describe alternatives you have considered
It is possible to parse SVG and manually reset id attribute to some known value on each test run, which is not ideal.
public static string FixClipPathId(string svg)
{
var doc = XDocument.Parse(svg);
var clipPathElements = doc.Root.Elements().Where(e => e.Name.LocalName == "clipPath");
var cpCounter = 0;
foreach (var clipPath in clipPathElements)
{
var id = clipPath.Attribute("id");
if (id != null)
{
svg = svg.Replace(id.Value, $"cp_{cpCounter}");
cpCounter++;
}
}
return svg;
}
Additional context
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Is there some sample code I can run to start writing a test for this? Looking at the code quickly, the field counter is not a static so this is interesting. I may be looking at something wrong, but some code on what you are doing will help me start debugging.
@mattleibow, please have a look at these examples
https://github.com/EvgenyMuryshkin/SVGBugs/blob/main/SVGBugs/SVGClipPathTests.cs
If you run them one by one, result clip path index is always cl_3, but if you run whole test class a once, they start to increment
This repo also contains samples for bunch of other issues from https://github.com/mono/SkiaSharp/issues/2602