{"record":{"id":"5633bd4bcc638749","repo":"HandyOrg/HandyControl","slug":"specified-type-0-is-not-supported","errorCode":null,"errorMessage":"Specified type '{0}' is not supported.","messagePattern":"Specified type '(.+?)' is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Shared/Microsoft.Expression.Drawing/Drawing/PathSegmentHelper.cs","lineNumber":534,"sourceCode":"        public abstract PathSegment ApplyTransform(GeneralTransform transform);\n\n        public static PathSegmentImplementation Create(PathSegment segment)\n        {\n            PathSegmentImplementation implementation;\n            if ((implementation = BezierSegmentImplementation.Create(segment as BezierSegment)) == null &&\n                (implementation = LineSegmentImplementation.Create(segment as LineSegment)) == null &&\n                (implementation = ArcSegmentImplementation.Create(segment as ArcSegment)) == null &&\n                (implementation = PolyLineSegmentImplementation.Create(segment as PolyLineSegment)) ==\n                null &&\n                (implementation = PolyBezierSegmentImplementation.Create(segment as PolyBezierSegment)) ==\n                null &&\n                (implementation =\n                    QuadraticBezierSegmentImplementation.Create(segment as QuadraticBezierSegment)) ==\n                null &&\n                (implementation =\n                    PolyQuadraticBezierSegmentImplementation.Create(segment as PolyQuadraticBezierSegment)\n                ) == null)\n                throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture,\n                    ExceptionStringTable.TypeNotSupported, new object[] { segment.GetType().FullName }));\n            return implementation;\n        }\n\n        public static PathSegmentImplementation Create(PathSegment segment, Point start)\n        {\n            var implementation = Create(segment);\n            implementation.Start = start;\n            return implementation;\n        }\n\n        public abstract void Flatten(IList<Point> points, double tolerance);\n\n        public abstract Point GetPoint(int index);\n\n        public abstract IEnumerable<SimpleSegment> GetSimpleSegments();\n    }\n","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/HandyOrg/HandyControl/blob/2c0875ebd67326e0c67282967e3e809c69282fee/src/Shared/Microsoft.Expression.Drawing/Drawing/PathSegmentHelper.cs#L516-L552","documentation":"PathSegmentHelper.Create attempts to build a PathSegmentImplementation for each known PathSegment subclass (LineSegment, PolyLineSegment, BezierSegment, PolyBezierSegment, QuadraticBezierSegment, PolyQuadraticBezierSegment, ArcSegment). If the supplied segment matches none of them, it throws NotSupportedException with the segment's type name inserted via ExceptionStringTable.TypeNotSupported.","triggerScenarios":"Passing a PathSegment that is not one of the seven supported WPF segment types — e.g. a custom PathSegment subclass or a null-derived unknown type — into PathSegmentHelper.Create(segment) or Create(segment, start).","commonSituations":"Custom geometry code where a user-defined PathSegment subclass was added to a PathGeometry; third-party geometry libraries producing their own segment types; geometry deserialization that produced unexpected segment instances.","solutions":["Only use the built-in WPF segment types (LineSegment, PolyLineSegment, BezierSegment, PolyBezierSegment, QuadraticBezierSegment, PolyQuadraticBezierSegment, ArcSegment).","Convert custom segments to an equivalent built-in type before passing to path helpers (e.g. approximate a custom curve with a PolyBezierSegment).","Check segment types before calling Create and handle unsupported ones explicitly.","Catch NotSupportedException and skip/log the unsupported segment instead of failing the whole path."],"exampleFix":"// before\nvar impl = PathSegmentHelper.Create(myCustomSegment); // throws NotSupportedException\n\n// after\nPathSegment safeSegment = myCustomSegment is LineSegment || myCustomSegment is BezierSegment\n    ? myCustomSegment\n    : new PolyLineSegment(); // or convert custom segment to a supported type\nvar impl = PathSegmentHelper.Create(safeSegment);","handlingStrategy":"type-guard","validationCode":"bool supported = seg is LineSegment || seg is PolyLineSegment || seg is BezierSegment || seg is PolyBezierSegment || seg is QuadraticBezierSegment || seg is PolyQuadraticBezierSegment || seg is ArcSegment;\nif (!supported) throw new NotSupportedException($\"{seg.GetType().Name} must be converted to a built-in segment.\");","typeGuard":"static bool IsSupportedSegment(PathSegment s) => s is LineSegment || s is PolyLineSegment || s is BezierSegment || s is PolyBezierSegment || s is QuadraticBezierSegment || s is PolyQuadraticBezierSegment || s is ArcSegment;","tryCatchPattern":"try { impl = PathSegmentHelper.Create(segment); }\ncatch (NotSupportedException ex) { Log.Warn(ex.Message); impl = null; /* skip segment */ }","preventionTips":["Only put built-in WPF PathSegment types into PathGeometry.Segments.","Convert custom segment subclasses to Bezier/PolyLine approximations before helper calls.","Add an IsSupportedSegment check when accepting geometry from external sources.","Unit-test geometry deserialization paths for unknown segment types."],"tags":["not-supported","geometry","path-segment","wpf"],"backgroundTag":"unsupported-operation","analyzedSha":"2c0875ebd67326e0c67282967e3e809c69282fee","analyzedAt":"2026-09-14T14:45:29.754Z","contentChangedAt":"2026-09-14T14:45:29.754Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}