[PR #216] [CLOSED] Changed: Configure extensions by reflection #874

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

📋 Pull Request Information

Original PR: https://github.com/xoofx/markdig/pull/216
Author: @nea
Created: 3/2/2018
Status: Closed

Base: masterHead: configure-extensions-by-reflection


📝 Commits (4)

  • cf39008 Changed: Configure now looks for extension classes to build its pipeline
  • 47ae9b6 Added: Special handling for nohtml
  • 1d01bb6 Changed: Tests to match extension class names for consistency with new Configure method
  • 9efc00c Changed: Added parameterless constructors to Extensions for easier use with Configure as well as the new Use<> implementation

📊 Changes

12 files changed (+241 additions, -150 deletions)

View changed files

📝 src/Markdig.Tests/Markdig.Tests.csproj (+1 -0)
📝 src/Markdig.Tests/Specs/Specs.cs (+50 -50)
📝 src/Markdig.Tests/Specs/Specs.tt (+7 -7)
src/Markdig.Tests/TestMarkdownExtensions.cs (+64 -0)
📝 src/Markdig.Tests/TestPlayParser.cs (+1 -1)
📝 src/Markdig.Tests/TestSourcePosition.cs (+4 -4)
📝 src/Markdig/Extensions/AutoIdentifiers/AutoIdentifierExtension.cs (+6 -0)
📝 src/Markdig/Extensions/Emoji/EmojiExtension.cs (+2 -0)
📝 src/Markdig/Extensions/EmphasisExtras/EmphasisExtraExtension.cs (+5 -0)
📝 src/Markdig/Extensions/JiraLinks/JiraLinkExtension.cs (+2 -2)
📝 src/Markdig/Markdig.csproj (+3 -2)
📝 src/Markdig/MarkdownExtensions.cs (+96 -84)

📄 Description

Hey

This PR is a suggestion for something further in the future.

I changed to the MarkdownExtensions.Configure() method to work with reflection, therefore grabbing all classes implementing the IMarkdownExtension interface and adding them to the pipeline if configured.

I thought of this to be a little more flexible also in the future without having to adapt the switch/case all the time.

But: I know the change is drastic! And it's not 100% backwards compatible to previous Configure() strings as I work with the extension class name which isn't the same as in the switch case for every plugin.

I adapted the tests accordingly and also added a small test for my changes.

I am open for feedback and suggestions as I would be happy to have this system as flexible as possible to use in the future.

Thanks


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/xoofx/markdig/pull/216 **Author:** [@nea](https://github.com/nea) **Created:** 3/2/2018 **Status:** ❌ Closed **Base:** `master` ← **Head:** `configure-extensions-by-reflection` --- ### 📝 Commits (4) - [`cf39008`](https://github.com/xoofx/markdig/commit/cf39008fe59d80b62d1fabb83b39c30701270b84) Changed: Configure now looks for extension classes to build its pipeline - [`47ae9b6`](https://github.com/xoofx/markdig/commit/47ae9b6fb9f0b55e701c8c3c0c9bb5f3d4a9107c) Added: Special handling for nohtml - [`1d01bb6`](https://github.com/xoofx/markdig/commit/1d01bb6fd3133b4b1d1921a3e9ccb7ff108f65f7) Changed: Tests to match extension class names for consistency with new Configure method - [`9efc00c`](https://github.com/xoofx/markdig/commit/9efc00cea2d727d8c3d8ff6bb527928430a1ccae) Changed: Added parameterless constructors to Extensions for easier use with Configure as well as the new Use<> implementation ### 📊 Changes **12 files changed** (+241 additions, -150 deletions) <details> <summary>View changed files</summary> 📝 `src/Markdig.Tests/Markdig.Tests.csproj` (+1 -0) 📝 `src/Markdig.Tests/Specs/Specs.cs` (+50 -50) 📝 `src/Markdig.Tests/Specs/Specs.tt` (+7 -7) ➕ `src/Markdig.Tests/TestMarkdownExtensions.cs` (+64 -0) 📝 `src/Markdig.Tests/TestPlayParser.cs` (+1 -1) 📝 `src/Markdig.Tests/TestSourcePosition.cs` (+4 -4) 📝 `src/Markdig/Extensions/AutoIdentifiers/AutoIdentifierExtension.cs` (+6 -0) 📝 `src/Markdig/Extensions/Emoji/EmojiExtension.cs` (+2 -0) 📝 `src/Markdig/Extensions/EmphasisExtras/EmphasisExtraExtension.cs` (+5 -0) 📝 `src/Markdig/Extensions/JiraLinks/JiraLinkExtension.cs` (+2 -2) 📝 `src/Markdig/Markdig.csproj` (+3 -2) 📝 `src/Markdig/MarkdownExtensions.cs` (+96 -84) </details> ### 📄 Description Hey This PR is a suggestion for something further in the future. I changed to the _MarkdownExtensions.Configure()_ method to work with reflection, therefore grabbing all classes implementing the _IMarkdownExtension_ interface and adding them to the pipeline if configured. I thought of this to be a little more flexible also in the future without having to adapt the switch/case all the time. But: I know the change is drastic! And it's not 100% backwards compatible to previous _Configure()_ strings as I work with the extension class name which isn't the same as in the switch case for every plugin. I adapted the tests accordingly and also added a small test for my changes. I am open for feedback and suggestions as I would be happy to have this system as flexible as possible to use in the future. Thanks --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 14:46:40 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#874