You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously asked here as we use the Svg.Skia package, however I was redirected by @wieslawsoltes to post the question here, as this is the underlying package that is used in Svg.Skia: wieslawsoltes/Svg.Skia#58
Currently we are using SKSvg().Load(filepath), which returns a valid svg, however our svg file was slightly mal-formed, so the process of loading gave some exceptions:
System.FormatException
HResult=0x80131537
Message=Input string was not in a correct format.
Source=System.Private.CoreLib
StackTrace:
at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
and
System.ArgumentException
HResult=0x80070057
Message=9c2e3e is not a valid value for Int32.
Source=System.ComponentModel.TypeConverter
StackTrace:
at System.Drawing.ColorConverterCommon.IntFromString(String text, CultureInfo culture)
This exception was originally thrown at this call stack:
System.Number.ThrowOverflowOrFormatException(System.Number.ParsingStatus, System.TypeCode)
int.Parse(string, System.Globalization.NumberStyles, System.IFormatProvider)
System.Drawing.ColorConverterCommon.IntFromString(string, System.Globalization.CultureInfo)
Inner Exception 1:
FormatException: Input string was not in a correct format.
In the case of the exception above, a color in the file was invalid: "9c2e3e" instead of "#9c2e3e".
Even though these exceptions are thrown, they appear to be handled in the Load() method, so that a valid SVG is returned.
However we would like some unit tests to make sure our SVG files are all correct, so that we can fix any that have these problems. At the moment this exception is only seen when debugging, since it's handled.
Ideally our unit test would check for any errors in the format of an SVG file, so that we can fix them in our own files, instead of needing these to be handled at runtime.
Is there a way to know that a given svg file will have these exceptions when loading (a try catch isn't working since Svg.Load is already handling) - i.e. something like a strict mode on load or verifySvg() method?
This discussion was converted from issue #823 on March 26, 2021 19:43.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Previously asked here as we use the Svg.Skia package, however I was redirected by @wieslawsoltes to post the question here, as this is the underlying package that is used in Svg.Skia:
wieslawsoltes/Svg.Skia#58
Currently we are using
SKSvg().Load(filepath)
, which returns a valid svg, however our svg file was slightly mal-formed, so the process of loading gave some exceptions:and
In the case of the exception above, a color in the file was invalid: "9c2e3e" instead of "#9c2e3e".
Even though these exceptions are thrown, they appear to be handled in the Load() method, so that a valid SVG is returned.
However we would like some unit tests to make sure our SVG files are all correct, so that we can fix any that have these problems. At the moment this exception is only seen when debugging, since it's handled.
Ideally our unit test would check for any errors in the format of an SVG file, so that we can fix them in our own files, instead of needing these to be handled at runtime.
Is there a way to know that a given svg file will have these exceptions when loading (a try catch isn't working since
Svg.Load
is already handling) - i.e. something like a strict mode on load orverifySvg()
method?Beta Was this translation helpful? Give feedback.
All reactions