Skip to content

Fix binary compatibility issue with MoveCssInline method signatures#435

Merged
martinnormark merged 3 commits into
mainfrom
copilot/fix-434
Apr 23, 2026
Merged

Fix binary compatibility issue with MoveCssInline method signatures#435
martinnormark merged 3 commits into
mainfrom
copilot/fix-434

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jul 31, 2025

This PR fixes a binary compatibility issue where applications compiled against older versions of PreMailer.Net would fail at runtime with "Method not found" errors when calling MoveCssInline methods.

Problem

The issue occurred because the useEmailFormatter parameter was added to all MoveCssInline method overloads, changing their signatures from:

// Old signature (7/8 parameters)
MoveCssInline(bool, string, string, bool, bool, IMarkupFormatter, bool)

to:

// New signature (8/9 parameters) 
MoveCssInline(bool, string, string, bool, bool, IMarkupFormatter, bool, bool)

When applications compiled against the old signatures tried to call these methods, the runtime couldn't find the exact method signatures they expected, resulting in MethodNotFoundException.

Solution

Added backward-compatible method overloads that match the old signatures exactly:

  • Static method overloads for all 4 variants:

    • MoveCssInline(string html, ...7 params)
    • MoveCssInline(Stream stream, ...7 params)
    • MoveCssInline(Uri baseUri, string html, ...8 params)
    • MoveCssInline(Uri baseUri, Stream stream, ...8 params)
  • Instance method overload:

    • MoveCssInline(...7 params)

All backward-compatible overloads delegate to the corresponding new methods with useEmailFormatter = false, preserving the original behavior.

Testing

  • Added comprehensive unit tests covering all backward-compatible method signatures
  • Verified with a standalone console application that both old and new signatures work correctly
  • All existing tests continue to pass (178/178)
  • No breaking changes for existing code

This ensures applications compiled against any version of PreMailer.Net will continue to work without recompilation.

Fixes #434.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Method not found: 'PreMailer.Net.InlineResult PreMailer.Net.PreMailer.MoveCssInline(Boolean, System.String, System.String, Boolean, Boolean, AngleSharp.IMarkupFormatter, Boolean)' Fix binary compatibility issue with MoveCssInline method signatures Jul 31, 2025
Copilot AI requested a review from martinnormark July 31, 2025 10:07
Comment thread PreMailer.Net/Benchmarks/Benchmarks.csproj Outdated
Comment thread PreMailer.Net/PreMailer.Net.Tests/PreMailer.Net.Tests.csproj Outdated
@martinnormark
Copy link
Copy Markdown
Contributor

@copilot can you fix this?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot can you fix this?

Both suggestions have already been applied in commit fefd11c ("Revert target framework change") — both Benchmarks.csproj and PreMailer.Net.Tests.csproj now target net9.0.

Copilot AI and others added 2 commits April 23, 2026 15:20
…ary compatibility issue

Co-authored-by: martinnormark <67565+martinnormark@users.noreply.github.com>
@martinnormark martinnormark marked this pull request as ready for review April 23, 2026 13:24
- Fix duplicated/malformed <param name="baseUri"> XML-doc comments
  on the Uri-based MoveCssInline overloads (pre-existing typo now
  corrected across all four).
- Extend the backward-compatibility tests to also assert that the
  7/8-param overloads actually apply useEmailFormatter=false, by
  probing the &copy; entity decoding that differentiates the two
  formatter code paths.
@martinnormark martinnormark merged commit 549740e into main Apr 23, 2026
2 checks passed
@martinnormark martinnormark deleted the copilot/fix-434 branch April 23, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants