{"record":{"id":"f09a2e5de3a7fea2","repo":"dotnet/maui","slug":"cannot-convert-self-to-nameof-flowdirection","errorCode":null,"errorMessage":"Cannot convert {self} to {nameof(FlowDirection)}.","messagePattern":"Cannot convert (.+?) to (.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"info","filePath":"src/Controls/src/Core/EffectiveFlowDirectionExtensions.cs","lineNumber":49,"sourceCode":"\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\treturn EffectiveFlowDirection.RightToLeft;\n\t\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new InvalidOperationException($\"Cannot convert {self} to {nameof(EffectiveFlowDirection)}.\");\n\t\t\t}\n\t\t}\n\n\t\tinternal static FlowDirection ToFlowDirection(this EffectiveFlowDirection self)\n\t\t{\n\t\t\tif (self.IsLeftToRight())\n\t\t\t\treturn FlowDirection.LeftToRight;\n\t\t\telse\n\t\t\t\treturn FlowDirection.RightToLeft;\n\n\t\t\tthrow new InvalidOperationException($\"Cannot convert {self} to {nameof(FlowDirection)}.\");\n\t\t}\n\n\t\t/// <summary>Returns <see langword=\"true\"/> if the flow direction is right-to-left. Otherwise, returns <see langword=\"false\"/>.</summary>\n\t\t/// <param name=\"self\">The enumeration value on which this method operates.</param>\n\t\t/// <returns><see langword=\"true\"/> if the flow direction is right-to-left. Otherwise, <see langword=\"false\"/>.</returns>\n\t\tpublic static bool IsRightToLeft(this EffectiveFlowDirection self)\n\t\t{\n\t\t\treturn (self & EffectiveFlowDirection.RightToLeft) == EffectiveFlowDirection.RightToLeft;\n\t\t}\n\n\t\t/// <summary>Returns <see langword=\"true\"/> if the flow direction is left-to-right. Otherwise, returns <see langword=\"false\"/>.</summary>\n\t\t/// <param name=\"self\">The enumeration value on which this method operates.</param>\n\t\t/// <returns><see langword=\"true\"/> if the flow direction is left-to-right. Otherwise, <see langword=\"false\"/>.</returns>\n\t\tpublic static bool IsLeftToRight(this EffectiveFlowDirection self)\n\t\t{\n\t\t\treturn (self & EffectiveFlowDirection.RightToLeft) != EffectiveFlowDirection.RightToLeft;\n\t\t}\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/EffectiveFlowDirectionExtensions.cs#L31-L67","documentation":"This throw is effectively UNREACHABLE: ToFlowDirection contains an if/else where both branches return (LeftToRight or RightToRight), so the throw statement after them can never execute under normal control flow. It exists only as defensive dead code. In practice you cannot trigger it; if you see this exception, it indicates the assembly was patched or the decompiled view differs from the running IL.","triggerScenarios":"Not reachable via public API in the shipped IL — the preceding if/else always returns before the throw. Would only fire if the method body were altered to make a branch non-returning.","commonSituations":"Essentially none in production; possibly observed in a modified/debug build or an AOT/rewriting edge case that changes control flow.","solutions":["Treat an actual occurrence as a tooling/IL anomaly: verify the running assembly matches the source (clean rebuild, check for IL weaving/rewriting).","If you genuinely cannot convert an EffectiveFlowDirection, normalize it with IsLeftToRight()/IsRightToLeft() checks yourself instead of relying on ToFlowDirection."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// The throw is unreachable in shipped IL; defensively normalize EffectiveFlowDirection before converting.\nstatic FlowDirection SafeToFlowDirection(EffectiveFlowDirection efd) =>\n    efd.IsLeftToRight() ? FlowDirection.LeftToRight : FlowDirection.RightToLeft;","typeGuard":"static bool IsKnownEffectiveFlowDirection(EffectiveFlowDirection efd) => efd.IsLeftToRight() || efd.IsRightToLeft();","tryCatchPattern":null,"preventionTips":["If you ever hit this, suspect IL rewriting/tooling — clean rebuild.","Prefer the IsLeftToRight()/IsRightToLeft() helpers over ToFlowDirection.","Normalize EffectiveFlowDirection values from untrusted sources."],"tags":["flowdirection","deadcode","unreachable","rtl"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}