You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request improves the code generation logic for event delegates with by-ref parameters (ref, out, in, and ref readonly) in the mock class source generator. The changes ensure that parameter modifiers are preserved in both method declarations and invocations, and that definite assignment requirements for out parameters are satisfied, preventing potential compiler errors. Additionally, a new test verifies correct behavior for events with ref and out delegate parameters.
Code generation improvements for by-ref parameters:
Updated FormatParametersWithTypeAndName and FormatParametersAsNames to preserve ref, out, and in modifiers, ensuring generated method signatures and invocations match the original delegate signatures. Introduced the helper method RefKindKeyword for cleaner modifier handling.
In the mock event raise implementation, added logic to pre-assign default values to out parameters when there are no subscribers, ensuring definite assignment as required by the compiler.
Modified argument generation for delegate invocations to bind by-ref arguments to local variables with default values, ensuring addressable storage and correct modifier usage.
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.
This pull request improves the code generation logic for event delegates with by-ref parameters (
ref,out,in, andref readonly) in the mock class source generator. The changes ensure that parameter modifiers are preserved in both method declarations and invocations, and that definite assignment requirements foroutparameters are satisfied, preventing potential compiler errors. Additionally, a new test verifies correct behavior for events withrefandoutdelegate parameters.Code generation improvements for by-ref parameters:
FormatParametersWithTypeAndNameandFormatParametersAsNamesto preserveref,out, andinmodifiers, ensuring generated method signatures and invocations match the original delegate signatures. Introduced the helper methodRefKindKeywordfor cleaner modifier handling.outparameters when there are no subscribers, ensuring definite assignment as required by the compiler.