{"record":{"id":"2895b121c9769bf6","repo":"dotnet/wpf","slug":"sr-enumerator-notstarted-transform3dcollection","errorCode":null,"errorMessage":"SR.Enumerator_NotStarted","messagePattern":"SR\\.Enumerator_NotStarted","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Transform3DCollection.cs","lineNumber":882,"sourceCode":"            /// <summary>\n            /// Current element\n            ///\n            /// The behavior of IEnumerable&lt;T>.Current is undefined\n            /// before the first MoveNext and after we have walked\n            /// off the end of the list. However, the IEnumerable.Current\n            /// contract requires that we throw exceptions\n            /// </summary>\n            public Transform3D Current\n            {\n                get\n                {\n                    if (_index > -1)\n                    {\n                        return _current;\n                    }\n                    else if (_index == -1)\n                    {\n                        throw new InvalidOperationException(SR.Enumerator_NotStarted);\n                    }\n                    else\n                    {\n                        Debug.Assert(_index == -2, \"expected -2, got \" + _index + \"\\n\");\n                        throw new InvalidOperationException(SR.Enumerator_ReachedEnd);\n                    }\n                }\n            }\n\n            #endregion\n\n            #region Data\n            private Transform3D _current;\n            private Transform3DCollection _list;\n            private uint _version;\n            private int _index;\n            #endregion\n        }","sourceCodeStart":864,"sourceCodeEnd":900,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Transform3DCollection.cs#L864-L900","documentation":"Accessing the enumerator's Current property before the first MoveNext call throws InvalidOperationException (SR.Enumerator_NotStarted). Internally _index == -1 means the cursor is still positioned before the first element, so there is no current item to return.","triggerScenarios":"Reading enumerator.Current immediately after GetEnumerator() without calling MoveNext().","commonSituations":"Hand-written enumerator loops that read Current before advancing; assuming Current defaults to the first element.","solutions":["Call MoveNext() (and check it returns true) before reading Current.","Prefer foreach, which handles cursor state automatically.","Initialize the current value from MoveNext's result: if (e.MoveNext()) var item = e.Current;"],"exampleFix":"// before\nvar e = collection.GetEnumerator();\nvar first = e.Current; // not started\n// after\nvar e = collection.GetEnumerator();\nif (e.MoveNext()) { var first = e.Current; }","handlingStrategy":"type-guard","validationCode":"if (e.MoveNext()) { var item = e.Current; }","typeGuard":"bool HasCurrent<T>(IEnumerator<T> e) => e is { }; // only after a successful MoveNext","tryCatchPattern":"try { var item = e.Current; } catch (InvalidOperationException) { /* MoveNext not called yet */ }","preventionTips":["Always pair Current with a preceding successful MoveNext","Prefer foreach/LINQ over manual enumerators","Remember Current is undefined before the first MoveNext"],"tags":["wpf","enumerator","current","invalidoperation"],"backgroundTag":"enumerator-not-started","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"}