mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
GetChildByRole<T> returned default! while it can legitimately yield null (empty slot or a kind the node does not declare); it now returns T?. Callers that already null-checked are unchanged; the few that rely on a structural guarantee (name tokens, label identifier, property accessors) now state it with an explicit !, and MethodDeclaration drops a redundant cast that the lie required. Also removes two members left dead by the Role removal: the AddAnnotation override that only forwarded to the base, and GetCSharpNodeBefore, which ignored 'this' and had no callers. On the output path, GetChildNodes() allocates a snapshot List per call; the read-only .Children traversals that never mutate the tree now walk the live FirstChild/NextSibling chain (O(n), allocation-free, since child indices are cached), an EmptyStatement child check uses HasChildren, and the label-statement sibling scan breaks on the first match instead of walking to the end of the block. The generated GetChildNodes snapshot is kept where traversal may mutate. Assisted-by: Claude:claude-opus-4-8:Claude Codepull/3807/head
8 changed files with 22 additions and 31 deletions
Loading…
Reference in new issue