Added "delayed" generation of delegate signatures (follow-up) #81
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.
This is a reopening of #53, rebased on top of the latest
main
branch.I apologize for not replying to the request of an example, sorry.
I'll show an example in this PR; I'm not 100% sure this is the best way to fix the issue, but we can start from this for a discussion.
Description
Just as before, with this patch if a delegate is found during the construction of a method, its declaration is still emitted, after all the other types have been.
This is implemented through an HashSet of forward declarations that is used as now for delegates, but can be expanded to include other item types in the future.
Example
Take this example Rust source:
This CORRECTLY generates the following C# code:
So far so good. Now, that Rust declaration is nasty and would probably get refactored as:
which produces
which is obviously bad because
set_callback_alloc_callback_delegate
's definition is nowhere to be found.The proposed fix produces this version instead:
Differences from the version in PR #53
The code is verbatim the same with these small differences:
public
visibility modifier, given that the declaration is now inside the class and would default toprivate
instead ofinternal
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
boilerplate