Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: extension method parameters for existing target mappings #923

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

trejjam
Copy link
Contributor

@trejjam trejjam commented Nov 20, 2023

Extension methods may generate invalid code

Description

Source

[Mapper]
class Mapper
{
  static partial void MapToB(this A value, B value);
}
class A {
    public int Value { get; set; }
}
class B {
    public int Value { get; set; }
}

Generates:

public partial class Mapper
{
    static partial void MapToB(this global::A source, this global::B target)
    {
        target.Value = source.Value;
    }
}

Notice this before the second parameter

Checklist

  • The existing code style is followed
  • The commit message follows our guidelines
  • Performed a self-review of my code
  • Hard-to-understand areas of my code are commented
  • The documentation is updated (as applicable)
  • Unit tests are added/updated
  • Integration tests are added/updated (as applicable, especially if feature/bug depends on roslyn or framework version in use)

Copy link

codecov bot commented Nov 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3e5ed87) 91.49% compared to head (c291aea) 91.49%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #923   +/-   ##
=======================================
  Coverage   91.49%   91.49%           
=======================================
  Files         215      215           
  Lines        7217     7217           
  Branches      872      873    +1     
=======================================
  Hits         6603     6603           
  Misses        408      408           
  Partials      206      206           

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

@trejjam trejjam force-pushed the fix/extension-methods branch 2 times, most recently from 7871b13 to fb24d33 Compare November 20, 2023 16:57
Copy link
Contributor

@latonz latonz left a comment

Choose a reason for hiding this comment

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

Thank you for this PR!

test/Riok.Mapperly.Tests/Mapping/ExtensionMethodTest.cs Outdated Show resolved Hide resolved
@latonz latonz changed the title fix: extension method parameters fix: extension method parameters for existing target mappings Nov 20, 2023
@trejjam trejjam force-pushed the fix/extension-methods branch 2 times, most recently from 06baed9 to 60dc83f Compare November 20, 2023 17:16
@trejjam trejjam requested a review from latonz November 20, 2023 17:17
@latonz latonz enabled auto-merge (squash) November 20, 2023 17:17
@latonz latonz merged commit 86408ce into riok:main Nov 20, 2023
17 of 19 checks passed
@trejjam trejjam deleted the fix/extension-methods branch November 20, 2023 17:29
Copy link

🎉 This PR is included in version 3.3.0-next.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants