{"record":{"id":"c4d74e72e66d6c57","repo":"Unity-Technologies/UnityCsReference","slug":"specify-exactly-one-edge","errorCode":null,"errorMessage":"Specify exactly one edge","messagePattern":"Specify exactly one edge","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/GUI/SplitView.cs","lineNumber":54,"sourceCode":"            FitsHorizontal = Left | Right,\n            Before = Top | Left, // \"Before\" in SplitView children\n            After = Bottom | Right // \"After\" in SplitView children\n        }\n\n        private Rect RectFromEdge(Rect rect, ViewEdge edge, float thickness, float offset)\n        {\n            switch (edge)\n            {\n                case ViewEdge.Left:\n                    return new Rect(rect.x - offset, rect.y, thickness, rect.height);\n                case ViewEdge.Right:\n                    return new Rect(rect.xMax - thickness + offset, rect.y, thickness, rect.height);\n                case ViewEdge.Top:\n                    return new Rect(rect.x, rect.y - offset, rect.width, thickness);\n                case ViewEdge.Bottom:\n                    return new Rect(rect.x, rect.yMax - thickness + offset, rect.width, thickness);\n                default:\n                    throw new ArgumentException(\"Specify exactly one edge\");\n            }\n        }\n\n        // Extra info for dropping.\n        internal class ExtraDropInfo\n        {\n            public bool rootWindow;\n            public ViewEdge edge;\n            public int index;\n            public ExtraDropInfo(bool rootWindow, ViewEdge edge, int index)\n            {\n                this.rootWindow = rootWindow;\n                this.edge = edge;\n                this.index = index;\n            }\n        }\n\n        SplitterState splitState = null;","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/GUI/SplitView.cs#L36-L72","documentation":"Thrown by a SplitView helper that computes the hover/drag rectangle for a given view edge (Left, Right, Top, Bottom). The switch falls through to a default case when the supplied ViewEdge value does not match any known edge, meaning exactly one valid edge was not provided. It indicates either an invalid enum value or an enum that has been extended without updating this switch.","triggerScenarios":"Calling the edge-rect helper with a ViewEdge value outside {Left, Right, Top, Bottom} — e.g. casting an arbitrary integer to ViewEdge, passing an uninitialized field, or a new enum member added to ViewEdge without a matching case here.","commonSituations":"Extending the ViewEdge enum with a new edge type and forgetting to handle it in SplitView; a serialization/deserialization desync producing an out-of-range enum value; default(ViewEdge) used before assignment when '0' is not a valid edge.","solutions":["Ensure the ViewEdge value passed is one of Left, Right, Top, or Bottom before calling the helper.","If you added a new ViewEdge member, add the corresponding case branch returning the correct Rect.","Validate/normalize the enum at the call site and fall back to a known edge (e.g. Left) instead of forwarding an unknown value."],"exampleFix":"// before\nvar r = GetDropRect(edge, rect, thickness, offset); // edge may be invalid\n\n// after\nViewEdge safeEdge = (edge == ViewEdge.Left || edge == ViewEdge.Right || edge == ViewEdge.Top || edge == ViewEdge.Bottom)\n    ? edge\n    : ViewEdge.Left;\nvar r = GetDropRect(safeEdge, rect, thickness, offset);","handlingStrategy":"validation","validationCode":"bool IsValidEdge(ViewEdge e) => e == ViewEdge.Left || e == ViewEdge.Right || e == ViewEdge.Top || e == ViewEdge.Bottom;","typeGuard":"static bool IsDefinedEdge(ViewEdge edge) => Enum.IsDefined(typeof(ViewEdge), edge) && (edge == ViewEdge.Left || edge == ViewEdge.Right || edge == ViewEdge.Top || edge == ViewEdge.Bottom);","tryCatchPattern":null,"preventionTips":["Always initialize ViewEdge fields to a known edge rather than relying on default(0).","When extending ViewEdge, grep for all switch statements and add cases.","Validate enum values at deserialization boundaries before use."],"tags":["unity-editor","gui","enum","argument"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}