mntone / SvgForXaml

Draw SVG image with Win2D
MIT License
94 stars 18 forks source link

Dictionary is not checked for duplicate keys #8

Closed GeertvanHorrik closed 6 years ago

GeertvanHorrik commented 7 years ago

An item with the same key has already been added. Key: 'MyKey'

Call stack:

   at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(Object key)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Mntone.SvgForXaml.SvgElement..ctor(INode parent, XmlElement element)
   at Mntone.SvgForXaml.SvgGroupElement..ctor(INode parent, XmlElement element)
   at Mntone.SvgForXaml.SvgElement.ParseChildren(INode parent, XmlNodeList nodes)
   at Mntone.SvgForXaml.SvgElement..ctor(INode parent, XmlElement element)
   at Mntone.SvgForXaml.SvgGroupElement..ctor(INode parent, XmlElement element)
   at Mntone.SvgForXaml.SvgElement.ParseChildren(INode parent, XmlNodeList nodes)
   at Mntone.SvgForXaml.SvgElement..ctor(INode parent, XmlElement element)
   at Mntone.SvgForXaml.SvgSvgElement..ctor(INode parent, XmlElement element)
   at Mntone.SvgForXaml.SvgDocument.Parse(XmlDocument document)
   at Mntone.SvgForXaml.SvgDocument.Parse(String document)
   at Mntone.SvgForXaml.SvgDocument.Parse(Byte[] document)

Is it forbidden in svg formats to use duplicate names? If not, I am happy to provide a PR, but need to be sure you will be releasing a new version with this PR.

Other apps (e.g. Inkscape) can parse and display this svg correctly. I think id's should be managed on parent level, not on document level (basically every SvgElement could / should have a dictionary with id's).

mntone commented 7 years ago

Add support for duplicate ids. 13372aa

Method GetElementById retrieve the first matching object.