Skip to content

Conversation

StefH
Copy link
Collaborator

@StefH StefH commented Jul 8, 2025

No description provided.

@StefH StefH requested a review from Copilot July 8, 2025 06:50
@StefH StefH self-assigned this Jul 8, 2025
@StefH StefH added the feature label Jul 8, 2025
Copilot

This comment was marked as outdated.

Copy link

codecov bot commented Jul 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.19%. Comparing base (35cd06b) to head (c5be10d).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1326      +/-   ##
==========================================
- Coverage   37.50%   37.19%   -0.32%     
==========================================
  Files         175      176       +1     
  Lines       38872    40858    +1986     
==========================================
+ Hits        14579    15197     +618     
- Misses      23813    25236    +1423     
+ Partials      480      425      -55     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@StefH StefH requested a review from Copilot July 11, 2025 14:31
Copilot

This comment was marked as outdated.

@StefH StefH requested a review from Copilot July 12, 2025 07:11
Copilot

This comment was marked as outdated.

@StefH StefH requested a review from Copilot July 12, 2025 07:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces typed abstractions for MIME messages and parts, replacing untyped object usage with new IMimeMessageData and IMimePartData interfaces, and updates utilities, matchers, and tests to leverage these wrappers.

  • Define IMimeMessageData, IMimePartData, IMimeEntityData, IContentTypeData, and IContentDispositionData interfaces.
  • Implement wrapper classes (MimeMessageDataWrapper, MimePartDataWrapper, etc.) that adapt MimeKit types to the new interfaces.
  • Refactor IMimeKitUtils, RequestMessage, RequestMessageMultiPartMatcher, and MimePartMatcher to use the new abstractions and remove legacy GetBodyParts.
  • Update tests to use message.BodyParts instead of MimeKitUtils.GetBodyParts.

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/WireMock.Net.Tests/Matchers/MimePartMatcherTests.cs Switch tests to use BodyParts property instead of helper method
src/WireMock.Net.Shared/Util/IMimeKitUtils.cs Change LoadFromStream/TryGetMimeMessage to return interfaces
src/WireMock.Net.Shared/Matchers/IMimePartMatcher.cs Update matcher interface to accept IMimePartData
src/WireMock.Net.Minimal/RequestMessage.cs Change BodyAsMimeMessage to IMimeMessageData
src/WireMock.Net.Minimal/Matchers/Request/RequestMessageMultiPartMatcher.cs Iterate message.BodyParts instead of GetBodyParts
src/WireMock.Net.MimePart/Util/MimeKitUtils.cs Implement new interface methods and remove old GetBodyParts
src/WireMock.Net.MimePart/Models/*.cs Add wrapper implementations for all new MIME interfaces
src/WireMock.Net.MimePart/Matchers/MimePartMatcher.cs Refactor matcher to use IMimePartData and new wrappers
src/WireMock.Net.Abstractions/Models/Mime/*.cs Define the seven new MIME-related interfaces
Comments suppressed due to low confidence (1)

src/WireMock.Net.MimePart/Models/ContentDispositionDataWrapper.cs:37

  • Returning object for Parameters may force consumers to cast. Consider exposing a more specific type (e.g., IReadOnlyDictionary<string, string> or IEnumerable<string>) to make the API easier to use and reduce the need for casting.
    public object Parameters => _contentDisposition.Parameters;

@@ -52,21 +53,21 @@ public MimePartMatcher(
_funcs =
[
mp => ContentTypeMatcher?.IsMatch(GetContentTypeAsString(mp.ContentType)) ?? MatchScores.Perfect,
mp => ContentDispositionMatcher?.IsMatch(mp.ContentDisposition.ToString().Replace("Content-Disposition: ", string.Empty)) ?? MatchScores.Perfect,
mp => ContentTransferEncodingMatcher?.IsMatch(mp.ContentTransferEncoding.ToString().ToLowerInvariant()) ?? MatchScores.Perfect,
mp => ContentDispositionMatcher?.IsMatch(mp.ContentDisposition?.ToString()?.Replace("Content-Disposition: ", string.Empty)) ?? MatchScores.Perfect,
Copy link
Preview

Copilot AI Jul 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of calling ToString and replacing the header prefix, consider using the Disposition property on IContentDispositionData directly (e.g., mp.ContentDisposition?.Disposition) to match the value more explicitly.

Suggested change
mp => ContentDispositionMatcher?.IsMatch(mp.ContentDisposition?.ToString()?.Replace("Content-Disposition: ", string.Empty)) ?? MatchScores.Perfect,
mp => ContentDispositionMatcher?.IsMatch(mp.ContentDisposition?.Disposition) ?? MatchScores.Perfect,

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant