Skip to content

fix: respect Use configuration on read-only collection members to improve reported diagnostics#2356

Merged
latonz merged 1 commit into
riok:mainfrom
latonz:fix/2352-use-ignored-readonly-collection
Jul 6, 2026
Merged

fix: respect Use configuration on read-only collection members to improve reported diagnostics#2356
latonz merged 1 commit into
riok:mainfrom
latonz:fix/2352-use-ignored-readonly-collection

Conversation

@latonz

@latonz latonz commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

When a member mapping referenced a mapping by name (Use = ...) that is a new instance mapping, and the target member was a read-only collection or dictionary (e.g. a protobuf MapField), Mapperly silently ignored the configuration and built an implicit existing target mapping instead, producing a confusing RMG020 diagnostic.

The referenced new instance mapping is now respected: it is assigned for settable members and reports RMG009 (cannot map to read only member) when the target cannot be set, instead of being silently ignored.

Closes #2352

Checklist

  • I did not use AI tools to generate this PR, or I have manually verified that the code is correct, optimal, and follows the project guidelines and architecture
  • I understand that low-quality, AI-generated PRs will be closed immediately without further explanation
  • 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)

When a member mapping referenced a mapping by name (Use = ...) that is a
new instance mapping, and the target member was a read-only collection or
dictionary (e.g. a protobuf MapField), Mapperly silently ignored the
configuration and built an implicit existing target mapping instead,
producing a confusing RMG020 diagnostic.

The referenced new instance mapping is now respected: it is assigned for
settable members and reports RMG009 (cannot map to read only member) when
the target cannot be set, instead of being silently ignored.

Closes riok#2352
@latonz latonz self-assigned this Jul 6, 2026
@latonz latonz added the enhancement New feature or request label Jul 6, 2026
@latonz latonz changed the title fix: respect Use configuration on read-only collection members fix: respect Use configuration on read-only collection members to improve reported diagnostics Jul 6, 2026
@latonz
latonz merged commit ad57e5e into riok:main Jul 6, 2026
17 of 18 checks passed
@latonz
latonz deleted the fix/2352-use-ignored-readonly-collection branch July 6, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom mapping from VO to MapField not worked

1 participant