Skip to content

Add a log-invalid-remappings switch for ABI-illegal remappings#747

Closed
tannergooding wants to merge 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-log-invalid-remappings
Closed

Add a log-invalid-remappings switch for ABI-illegal remappings#747
tannergooding wants to merge 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-log-invalid-remappings

Conversation

@tannergooding

Copy link
Copy Markdown
Member

This adds a new opt-in --log-invalid-remappings config switch that emits a DiagnosticLevel.Info diagnostic for each configured remapping whose value is structurally not a legal unmanaged type name, scoped precisely to the array/fixed-buffer shape (a numeric subscript [<digit>, the same rule as the lowering, so a managed int[] with an empty subscript is left untouched).

The message names the remapping and states the applied lowering, e.g.:

Potential invalid remapping 'MyBuffer=sbyte[8]'. A fixed-size-buffer type is not directly expressible in an unmanaged signature; it was lowered to the pointer 'sbyte*'.

The lowering used to compute the shown pointer is factored into a shared TryLowerFixedSizeBufferRemapping helper so the diagnostic and GetRemappedTypeName can't drift.


This builds on #745 (the fixed-size-buffer-to-pointer lowering), which has since merged; the branch is based directly on that commit so the diff here is just the diagnostic feature.

Emits a DiagnosticLevel.Info diagnostic for each configured remapping whose value is a fixed-size-buffer shape that is not directly expressible in an unmanaged signature, naming the applied pointer lowering. The lowering logic is shared with GetRemappedTypeName so the two sites cannot drift.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tannergooding

Copy link
Copy Markdown
Member Author

Dropping this — not high enough value relative to the number of ABI edge cases it would need to cover to be trustworthy.

@tannergooding tannergooding deleted the tannergooding-log-invalid-remappings branch July 13, 2026 15:51
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.

1 participant