Skip to content

Fix #399 - Fix mapper interface generation for internal types - #1010

Open
andrerav wants to merge 1 commit into
developmentfrom
andrerav/399/interface-accessibility
Open

Fix #399 - Fix mapper interface generation for internal types#1010
andrerav wants to merge 1 commit into
developmentfrom
andrerav/399/interface-accessibility

Conversation

@andrerav

Copy link
Copy Markdown
Member

Fixes mapper generation for interfaces that use internal source or destination types. The generated mapper class now uses the same effective visibility rule for both the class modifier and generated mapper members. If the generated class must be internal, its implicit interface implementation members can still be emitted as public.

Fixes #399.

@andrerav
andrerav requested a review from DocSvartz August 20, 2026 08:42
@andrerav
andrerav force-pushed the andrerav/399/interface-accessibility branch from 52bf8ae to 621ecb3 Compare August 20, 2026 08:52
Comment on lines +60 to +66
{
if (Definitions == null)
return false;

return Definitions.IsInternal ||
Definitions.Implements?.Any(it => !it.GetTypeInfo().IsVisible) == true;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@andrerav Have you checked if this has a negative impact on the generation of Extension mappers?

I haven't figured out what's actually going on there yet.

Origin creation logic is absolutely correct for generating class-based mappers. There is no need for implementation or inheritance.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe internal class with proper implementations should be generated even in case MapperAttribute.IsInternal hasn't been specified

I think this statement contradicts the logic of C# itself.
Implemention an internal interface doesn't force a class to be internal, since implementation is not inheritance 😅

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