-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[wasm] Fix reverse P/Invoke thunk key for nested [UnmanagedCallersOnly] types (CoreCLR + Mono) #130740
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
Merged
lewing
merged 6 commits into
dotnet:main
from
lewing:lewing-wasm-nested-uco-thunk-key-fix
Jul 15, 2026
Merged
[wasm] Fix reverse P/Invoke thunk key for nested [UnmanagedCallersOnly] types (CoreCLR + Mono) #130740
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6f4a6ac
[wasm] Fix reverse P/Invoke thunk key for nested [UnmanagedCallersOnl…
lewing 5eb01de
[wasm] Reference tracking issue for nested UCO thunk key limitation
lewing 2e3187d
[wasm] Add nested-type UnmanagedCallersOnly regression test
lewing 3a36672
[wasm] Add skipped nested UCO name-collision test for #130739
lewing 20175fa
[wasm] Fix nested UCO thunk key on the Mono generator too
lewing ff72549
[wasm] Clarify nested UCO test executes on browser-wasm
lewing File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/mono/wasm/testassets/EntryPoints/PInvoke/UnmanagedCallbackNested.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| using System; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| public class Test | ||
| { | ||
| public unsafe static int Main() | ||
| { | ||
| // Cold ldftn of a nested [UnmanagedCallersOnly] callback. The reverse-thunk key | ||
| // must use the metadata namespace (empty for nested types) to match the runtime, | ||
| // otherwise the lookup misses and the interpreter asserts at method-compile time. | ||
| ((delegate* unmanaged<void>)&Namespaced.Outer.Nested.C)(); | ||
| ((delegate* unmanaged<void>)&Namespaced.Outer.Nested.Deeper.D)(); | ||
| return 42; | ||
| } | ||
| } | ||
|
|
||
| namespace Namespaced | ||
| { | ||
| public class Outer | ||
| { | ||
| public class Nested | ||
| { | ||
| [UnmanagedCallersOnly] | ||
| public static void C() | ||
| { | ||
| Console.WriteLine("TestOutput -> Namespaced.Outer.Nested.C"); | ||
| } | ||
|
|
||
| public class Deeper | ||
| { | ||
| [UnmanagedCallersOnly] | ||
| public static void D() | ||
| { | ||
| Console.WriteLine("TestOutput -> Namespaced.Outer.Nested.Deeper.D"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
src/mono/wasm/testassets/EntryPoints/PInvoke/UnmanagedCallbackNestedConflict.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| using System; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| public class Test | ||
| { | ||
| public unsafe static int Main() | ||
| { | ||
| // Two nested types share the simple name "Conflict" under different enclosing types. | ||
| // The reverse-thunk key drops the enclosing-type chain (Method#argCount:Assembly::Type), | ||
| // so both callbacks currently map to the same key and the build fails (#130739). | ||
| ((delegate* unmanaged<void>)&Conflicting.OuterA.Conflict.C)(); | ||
| ((delegate* unmanaged<void>)&Conflicting.OuterB.Conflict.C)(); | ||
| return 42; | ||
| } | ||
| } | ||
|
|
||
| namespace Conflicting | ||
| { | ||
| public class OuterA | ||
| { | ||
| public class Conflict | ||
| { | ||
| [UnmanagedCallersOnly] | ||
| public static void C() | ||
| { | ||
| Console.WriteLine("TestOutput -> Conflicting.OuterA.Conflict.C"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public class OuterB | ||
| { | ||
| public class Conflict | ||
| { | ||
| [UnmanagedCallersOnly] | ||
| public static void C() | ||
| { | ||
| Console.WriteLine("TestOutput -> Conflicting.OuterB.Conflict.C"); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.