-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Queryable projections: Inline user-implemented mapping expressions from different file #1406
Comments
We decided to not support this in the first iteration of inlining, since the source syntax of external methods is not always available (e.g. if it is part of another assembly). However, this could be improved and inlining could always happen if the source syntax is available. |
I have tried to provide a PR for this, but struggle as Failing Unit-Test: namespace Riok.Mapperly.Tests.Mapping;
public class QueryableProjectionExternalTest
{
[Fact]
public Task UseStaticMapperInlinedExpression()
{
var source = TestSourceBuilder.CSharp(
$$"""
using System;
using System.Linq;
using System.Collections.Generic;
using Riok.Mapperly.Abstractions;
using Riok.Mapperly.Abstractions.ReferenceHandling;
[Mapper]
[UseStaticMapper(typeof(OtherMapper))]
public partial class Mapper
{
private partial IQueryable<B> Map(IQueryable<A> source);
}
[Mapper]
static partial class OtherMapper
{
public static partial D MapToD(C v);
}
class A { public string StringValue { get; set; } public C NestedValue { get; set; } }
class B { public string StringValue { get; set; } public D NestedValue { get; set; } }
class C { public string Value { get; set; } }
class D { public string Value { get; set; } }
"""
);
return TestHelper.VerifyGenerator(source);
}
} P.S. While debugging Mapperly #1422 happened as a side-effect. |
Thanks for your efforts! |
Is your feature request related to a problem? Please describe.
When having mappings defined in different classes/files, I get RMG068: Cannot inline user implemented queryable expression mapping. In contrast, when I move the two mapper definitions into one class, the mapping gets propertly inlined.
Describe the solution you'd like
A clear and concise description of what you want to happen including a proposal on the API surface and the matching generated code.
Describe alternatives you've considered
Copying all dependend configurations into one class works as ugly workaround.
Additional context
Mapperly v3.6.0
The text was updated successfully, but these errors were encountered: