[PR #387] Add missing Descendants<T> api #980

Open
opened 2026-01-29 14:48:06 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/xoofx/markdig/pull/387

State: closed
Merged: Yes


We were missing a few conveniance overloads (#63)

IEnumerable<T> Descendants<T>(this MarkdownObject) where T : Inline
IEnumerable<T> Descendants<T>(this MarkdownObject) where T : Block

Since these can't coexist in C#, I added one where T : MarkdownObject that then calls the appropriate internal overload for optimal traversal (has the added bonus of not allocating when it's obvious there can't be any descendants).

Added tests for all the different overloads to make sure the traversal logic is correct.

**Original Pull Request:** https://github.com/xoofx/markdig/pull/387 **State:** closed **Merged:** Yes --- We were missing a few conveniance overloads (#63) ```c# IEnumerable<T> Descendants<T>(this MarkdownObject) where T : Inline IEnumerable<T> Descendants<T>(this MarkdownObject) where T : Block ``` Since these can't coexist in C#, I added one `where T : MarkdownObject` that then calls the appropriate internal overload for optimal traversal (has the added bonus of not allocating when it's obvious there can't be any descendants). Added tests for all the different overloads to make sure the traversal logic is correct.
claunia added the pull-request label 2026-01-29 14:48:06 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#980