Repository navigation
fix(reactive): cast awaited command calls to their return type before awaiting - #3228
Merged
Merged
Conversation
… awaiting In __Reactive_BindableInitializeForUpdatedModel the model is dynamic, so each awaitable command's Execute lambda awaited a dynamic value. Roslyn EnC crashes on edits that add or replace such a lambda (dotnet/roslyn#86045), which wedged Hot Reload until the app restarted. The call stays dynamic so it still binds to the updated model; only the await is on the declared return type. The constructor path shares this code and gets an identity cast. Fixes #3227 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WjQPjTHecnxjgcqBhM8z3e
- A command method returning a type awaitable only through an extension `GetAwaiter` now gets a `using static` for that extension's class in the generated view model - Without it, the statically typed await failed to compile with CS1061 on the constructor path whenever the extension's namespace didn't enclose the model's, and the dynamic Hot Reload path could never bind it - Import the declaring static class rather than its namespace, so the generated file's unqualified `Type`/`Task` can't become ambiguous - Add Given_FeedsGenerator_Commands case with the awaitable in an unrelated namespace (fails before the fix) Refs #3227 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JwBEb6W93fTZzohP7V6ZYp
…wait # Conflicts: # src/Uno.HotTesting.Reactive.Tests/Given_FeedsMockGenerator.cs
kazo0
enabled auto-merge
October 14, 2026 19:33
kazo0
disabled auto-merge
October 14, 2026 20:41
This was referenced Nov 3, 2026
agneszitte
added a commit
that referenced
this pull request
Nov 3, 2026
… awaiting (backport #3228) - Backport of #3228 to servicing/7.4, with its Given_FeedsGenerator_Commands test - Uno.HotTesting.Reactive.Tests.csproj: keeps 7.4's System.Collections.Immutable reference, which sat next to the comment #3228 updates Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
GitHub Issue (If applicable): closes #3227
PR Type
What is the current behavior?
In
__Reactive_BindableInitializeForUpdatedModelthe model isdynamic, so each awaitable command's generatedExecutelambda awaits adynamicvalue:Roslyn's EnC crashes on edits that add or replace such a lambda while another lambda captures the dynamic local (dotnet/roslyn#86045). Changing a command's parameters while the app runs then breaks Hot Reload: that edit and every later one fail until the app restarts.
What is the new behavior?
When the method is awaitable, the generated call is cast to the method's declared return type before awaiting:
ToFullString(), so Task, ValueTask,Task<T>,ValueTask<T>and custom awaitables with an instanceGetAwaiterall work with no special case.GetAwaiter: when the return type is awaitable only through an extensionGetAwaiter, the generated file addsusing static global::<ExtensionClass>;so the static await binds. This also fixes the constructor path, which already failed with CS1061 whenever the extension's namespace didn't enclose the model's. It imports the class and not its namespace because the generated file uses unqualifiedType/Task, which a user namespace could make ambiguous. Only extensions declared in source are detected (IsAwaitableusesCompilation.GetSymbolsWithName), as before.async void(which can't be cast tovoid).GetInitialization()and gets an identity cast. Limiting the cast to the dynamic path would mean threading a flag through every mapped member.Executeis the only place the generator emitsawait, since feeds already castmodel.XtoIFeed<...>.ViewModelGenTool_2uses the same command code, so it gets the fix too.dynamiccall throws InvalidOperationException in DeltaMetadataWriter.GetFieldDefinitionHandle dotnet/roslyn#86045, to be removed once Roslyn is fixed.PR Checklist
Unit tests for the changes have been added:
Given_FeedsGenerator_Commandsruns the generator in memory on a model with these commands:ValueTask,ValueTaskwith a parameter,Task,ValueTask<int>,Task<string?>andvoid.GetAwaiterlives in a namespace unrelated to the model's (asserts theusing static).It asserts:
await model.remains;It fails before the fix. The test project now references the generator project.
Given_FeedsMockGenerator's fixture compilation leaves out the generator dll, whose copies of the public attributes otherwise caused CS0433 errors.Uno.HotTesting.Reactive.Tests: 36/36 passed.Uno.Extensions.Reactive.Tests: 1469 passed, 19 skipped.Contains NO breaking changes
Associated with an issue (GitHub or internal)
Other information
Verified end to end. I swapped the patched generator into Uno.Extensions.Reactive 8.0.0-dev.76, whose generator inputs are unchanged since then. I ran it on a recommended-preset MVUX app on Skia desktop with a fresh DevServer:
Increment(CancellationToken)toIncrement(int step, CancellationToken): applied (InternalError before this change).Related: unoplatform/uno#25418, where the DevServer reports this class of compiler crash as a rude edit and not as a stuck InternalError.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WjQPjTHecnxjgcqBhM8z3e