SVG: SvgDocoument.Transforms is null

https://github.com/vvvv/SVG/blob/master/Source/SvgElement.cs#L383

get { return GetAttribute<SvgTransformCollection>("transform", false); }

Which forwards to https://github.com/vvvv/SVG/blob/master/Source/SvgElement.cs#L299

SvgAttributeCollection.GetAttribute and SvgAttributeCollection.GetInheritedAttribute return null, which - in the end - violates best practice (a collection should never be null, but rather empty).

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 1
  • Comments: 22 (19 by maintainers)

Most upvoted comments

though we would have to check the performance implications here, as this may be called quite often.

We have benchmarks for that now.

I am working of Parse optimizations in #786 and I have noticed sometimes type converters return default objects for null values and sometimes not. Definitely memory usage will increase if we create transforms collection for each objects (and all svg visual elements have transforms). I can do benchmarks to showcase how much it will increase.

to validate my point, please see https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/guidelines-for-collections#collection-properties-and-return-values

X DO NOT return null values from collection properties or from methods returning collections. Return an empty collection or an empty array instead.