{"record":{"id":"dee0f20c82a648a1","repo":"stride3d/stride","slug":"y-axis-should-not-be-null-when-transforming","errorCode":null,"errorMessage":"Y axis should not be null when transforming.","messagePattern":"Y axis should not be null when transforming\\.","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/CurveEditor/Axes/AxisBase.cs","lineNumber":498,"sourceCode":"        /// <param name=\"sx\">The relative screen coordinate.</param>\n        /// <param name=\"isVector\">True if the transform is a vector transform (i.e. only applies scale, not translation). The default value is False.</param>\n        /// <returns>The value.</returns>\n        public virtual double InverseTransform(double sx, bool isVector = false)\n        {\n            return PostInverseTransform((sx / Scale) + (isVector ? 0 : Offset));\n        }\n\n        /// <summary>\n        /// Inverse transform the specified screen point.\n        /// </summary>\n        /// <param name=\"x\">The x coordinate.</param>\n        /// <param name=\"y\">The y coordinate.</param>\n        /// <param name=\"yaxis\">The y-axis.</param>\n        /// <param name=\"isVector\">True if the transform is a vector transform (i.e. only applies scale, not translation). The default value is False.</param>\n        /// <returns>The data point.</returns>\n        public virtual Point InverseTransform(double x, double y, AxisBase yaxis, bool isVector = false)\n        {\n            if (yaxis == null) throw new ArgumentNullException(nameof(yaxis), \"Y axis should not be null when transforming.\");\n            return new Point(InverseTransform(x, isVector), yaxis.InverseTransform(y, isVector));\n        }\n\n        /// <summary>\n        /// Determines whether the axis is horizontal.\n        /// </summary>\n        /// <returns><c>true</c> if the axis is horizontal; otherwise, <c>false</c> .</returns>\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public bool IsHorizontal()\n        {\n            return Position == AxisPosition.Top || Position == AxisPosition.Bottom;\n        }\n\n        /// <summary>\n        /// Determines whether the specified value is valid.\n        /// </summary>\n        /// <param name=\"value\">The value.</param>\n        /// <returns><c>true</c> if the specified value is valid; otherwise, <c>false</c>.</returns>","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/CurveEditor/Axes/AxisBase.cs#L480-L516","documentation":"This InverseTransform overload converts a point in screen/render coordinates back to data coordinates and requires a Y axis to invert the y component. A null yaxis would cause a NullReferenceException deeper in the call, so the method throws ArgumentNullException up front with the parameter name 'yaxis'.","triggerScenarios":"Calling axis.InverseTransform(x, y, null) — passing a null yaxis argument, or passing a view model/axis object whose YAxis property has not been initialized yet.","commonSituations":"Curve editor panels constructed before axes are bound; code that only configures the X axis and forgets Y; transforms invoked during layout before the axis collection is populated.","solutions":["Pass a non-null AxisBase instance as the yaxis argument","Initialize/assign the YAxis of the chart or view model before transforming points","Guard with a null check before calling and skip/schedule the transform","Catch ArgumentNullException if null is an expected transient state"],"exampleFix":"// before\nvar point = xAxis.InverseTransform(x, y, yAxis); // yAxis may be null\n// after\nif (yAxis != null)\n{\n    var point = xAxis.InverseTransform(x, y, yAxis);\n}","handlingStrategy":"validation","validationCode":"if (yaxis == null) return; // or defer\ndataPoint = axis.InverseTransform(x, y, yaxis);","typeGuard":"bool CanTransform(AxisBase yaxis) => yaxis != null;","tryCatchPattern":"try { p = axis.InverseTransform(x, y, yaxis); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"yaxis\") { /* defer until axes ready */ }","preventionTips":["Bind YAxis before any render/hit-test transforms run","Null-check axis references at the start of layout code","Avoid constructing transforms with optional/unset axis parameters"],"tags":["argument-null-exception","curve-editor","transform"],"backgroundTag":"null-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}