{"record":{"id":"4a7e1e9e7131c6ef","repo":"dotnet/wpf","slug":"sr-format-sr-textcompositionmanager-4a7e1e","errorCode":null,"errorMessage":"SR.Format(SR.TextCompositionManager_TextCompositionNotStarted, \"composition\")","messagePattern":"SR\\.Format\\(SR\\.TextCompositionManager_TextCompositionNotStarted, \"composition\"\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/TextCompositionManager.cs","lineNumber":342,"sourceCode":"            {\n                RoutedEvent = TextCompositionManager.PreviewTextInputStartEvent,\n                Source = composition.Source\n            };\n            return composition._InputManager.ProcessInput(textargs);\n        }\n\n        private static bool UnsafeUpdateComposition(TextComposition composition)\n        {\n            ArgumentNullException.ThrowIfNull(composition);\n\n            if (composition._InputManager == null)\n            {\n                throw new ArgumentException(SR.Format(SR.TextCompositionManager_NoInputManager, \"composition\"));\n            }\n\n            if (composition.Stage == TextCompositionStage.None)\n            {\n                throw new ArgumentException(SR.Format(SR.TextCompositionManager_TextCompositionNotStarted, \"composition\"));\n            }\n\n            if (composition.Stage == TextCompositionStage.Done)\n            {\n                throw new ArgumentException(SR.Format(SR.TextCompositionManager_TextCompositionHasDone, \"composition\"));\n            }\n\n            TextCompositionEventArgs textargs = new TextCompositionEventArgs(composition._InputDevice, composition)\n            {\n                RoutedEvent = TextCompositionManager.PreviewTextInputUpdateEvent,\n                Source = composition.Source\n            };\n            return composition._InputManager.ProcessInput(textargs);\n        }\n\n        private static bool UnsafeCompleteComposition(TextComposition composition)\n        {\n            ArgumentNullException.ThrowIfNull(composition);","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/TextCompositionManager.cs#L324-L360","documentation":"UnsafeUpdateComposition throws ArgumentException when the composition's Stage is still TextCompositionStage.None, meaning UpdateComposition was called before StartComposition. WPF requires the start/update/complete lifecycle order.","triggerScenarios":"Calling TextCompositionManager.UpdateComposition on a composition for which StartComposition was never called (or failed before setting Stage to Started).","commonSituations":"Skipping the StartComposition step in custom IME emulation; calling UpdateComposition after a start attempt was aborted by an exception or a suppressed input event.","solutions":["Call TextCompositionManager.StartComposition(composition) before any UpdateComposition call.","Guard the update: only update when composition.Stage == TextCompositionStage.Started.","Fix earlier errors in the start path that left the stage at None."],"exampleFix":"// before\nTextCompositionManager.UpdateComposition(composition); // never started\n// after\nTextCompositionManager.StartComposition(composition);\nTextCompositionManager.UpdateComposition(composition);","handlingStrategy":"validation","validationCode":"if (composition.Stage == TextCompositionStage.None) throw new InvalidOperationException(\"Call StartComposition before UpdateComposition.\");","typeGuard":"static bool CanUpdate(TextComposition c) => c != null && c.Stage == TextCompositionStage.Started;","tryCatchPattern":"try { TextCompositionManager.UpdateComposition(composition); } catch (ArgumentException ex) { /* not started yet */ }","preventionTips":["Enforce lifecycle order Start → Update → Complete in a wrapper API.","Never call Update on freshly created compositions.","Handle failures of StartComposition before proceeding to updates."],"tags":["wpf","text-composition","lifecycle"],"backgroundTag":"invalid-state-transition","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}