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: Inlined argument with full namespace #1233

Merged
merged 1 commit into from
Apr 14, 2024

Conversation

trejjam
Copy link
Contributor

@trejjam trejjam commented Apr 11, 2024

The inlined method does not resolve arguments full namespace

Description

The following mapping produces an invalid code:

private partial System.Linq.IQueryable<B> Map(System.Linq.IQueryable<A> source);

private static DateTimeOffset MapToDateTimeOffset(
    DateTime dateTime
) => new(dateTime, TimeSpan.Zero);

The argument was kept as-is, therefore, without namespace or using statements.

Before:

[global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "0.0.1.0")]
private partial global::System.Linq.IQueryable<global::B> Map(global::System.Linq.IQueryable<global::A> source)
{
#nullable disable
    return System.Linq.Queryable.Select(source, x => new global::B()
    {
        Value = new(x.Value, TimeSpan.Zero),
    });
#nullable enable
}

Expected:

[global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "0.0.1.0")]
private partial global::System.Linq.IQueryable<global::B> Map(global::System.Linq.IQueryable<global::A> source)
{
#nullable disable
    return System.Linq.Queryable.Select(source, x => new global::B()
    {
        Value = new(x.Value, global::System.TimeSpan.Zero),
    });
#nullable enable
}

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)

@trejjam trejjam force-pushed the fix/inlined-methods branch from 67df2bd to 3d3a962 Compare April 11, 2024 07:47
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 Fix 😊

While looking at your example, I came up with the idea that we should also extend Target-Type new. I'm not sure if it really causes problems, but since the compilation context changes quite a bit by inlining these expressions it should be safer to just expand them... WDYT? (If we decide to fix this we should do it in another PR 😊)

@trejjam trejjam force-pushed the fix/inlined-methods branch from 3d3a962 to 91a435a Compare April 13, 2024 18:30
@trejjam trejjam requested a review from latonz April 13, 2024 18:32
@latonz latonz force-pushed the fix/inlined-methods branch from 91a435a to 7e264d9 Compare April 14, 2024 22:26
@latonz latonz merged commit de3b332 into riok:main Apr 14, 2024
17 checks passed
@latonz
Copy link
Contributor

latonz commented Apr 14, 2024

Created a fix for the implicit new in #1238

Copy link

🎉 This PR is included in version 3.5.1-next.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@trejjam trejjam deleted the fix/inlined-methods branch April 15, 2024 15:16
Copy link

🎉 This PR is included in version 3.5.1 🎉

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.

2 participants