Skip to content

Reworked the generated RegisterAll extension#1199

Open
Umoxfo wants to merge 1 commit into
CommunityToolkit:mainfrom
Umoxfo:mvvm/Messenger.RegisterAll-AOT
Open

Reworked the generated RegisterAll extension#1199
Umoxfo wants to merge 1 commit into
CommunityToolkit:mainfrom
Umoxfo:mvvm/Messenger.RegisterAll-AOT

Conversation

@Umoxfo
Copy link
Copy Markdown

@Umoxfo Umoxfo commented Jun 2, 2026

... to ensure it is AOT-safe

  1. IMessengerRegisterAllGenerator.Execute.cs
  • Change the IMessenger RegisterAll source-generation to emit public extension methods in the CommunityToolkit.Mvvm.Messaging namespace (RegisterAll(this IMessenger, TRecipient) and RegisterAll<TToken>(this IMessenger, TRecipient, TToken)) instead of producing factory delegates in an CommunityToolkit.Mvvm.Messaging.__Internals namespace.
  • Enable nullable instead of null check.
  • Update comments.
  1. IMessengerExtensions class
  • Simplify the runtime fallback/reflection path.
  • Update RequiresDynamicCode/RequiresUnreferencedCode annotetion message and reference URLs.
  • Update documentation comments.
  1. ObservableRecipient class
  • Update RequiresDynamicCode/RequiresUnreferencedCode annotetion message and reference URLs.
  • Update documentation comments.
  1. Unit Tests
  • Add new generator test, update expectations, and call sites.

Closes #1123

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • Tested code with current supported SDKs
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

... to ensure it is AOT-safe

1. `IMessengerRegisterAllGenerator.Execute.cs`
* Change the IMessenger RegisterAll source-generation to emit public extension methods in the `CommunityToolkit.Mvvm.Messaging` namespace (`RegisterAll(this IMessenger, TRecipient)` and `RegisterAll<TToken>(this IMessenger, TRecipient, TToken)`) instead of producing factory delegates in an `CommunityToolkit.Mvvm.Messaging.__Internals` namespace.
* Enable nullable instead of null check.
* Update comments.
2. `IMessengerExtensions` class
* Simplify the runtime fallback/reflection path.
* Update `RequiresDynamicCode`/`RequiresUnreferencedCode` annotetion message and reference URLs.
* Update documentation comments.
3. `ObservableRecipient` class
* Update `RequiresDynamicCode`/`RequiresUnreferencedCode` annotetion message and reference URLs.
* Update documentation comments.
4. Unit Tests
* Add new generator test, update expectations, and call sites.
@Umoxfo
Copy link
Copy Markdown
Author

Umoxfo commented Jun 2, 2026

@dotnet-policy-service agree

@Umoxfo Umoxfo marked this pull request as ready for review June 2, 2026 19:03
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.

Trimming warning for ObservableRecipient.IsActive is useless, and AOT warning is not helpful

1 participant