Feature Add Splat Registrations to IViewFor Generator#289
Conversation
Introduces SplatRegistrationType to IViewFor attributes and source generator, enabling automatic registration of views for view models in Splat's service locator. Updates documentation, tests, and sample usage to demonstrate new registration options and extension method for bulk registration.
…eGeneratorsExtensions.g.verified.cs
There was a problem hiding this comment.
Pull Request Overview
This PR introduces Splat integration to the IViewFor source generator, enabling automatic registration of views with view models in Splat's service locator. It adds a SplatRegistrationType parameter to IViewFor attributes and generates an extension method for bulk registration of all views.
- Adds
SplatRegistrationTypeenum with options: None, LazySingleton, Constant, PerRequest - Extends IViewFor attributes to support
RegistrationTypeparameter for Splat registration - Generates
RegisterViewsForViewModelsSourceGenerated()extension method for bulk view registration
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| IViewForInfo.cs | Adds SplatRegistrationType property to track registration type |
| IViewForGenerator.cs | Updates generator to produce registration extension method |
| IViewForGenerator.Execute.cs | Implements registration extension generation logic |
| AttributeDefinitions.cs | Defines SplatRegistrationType enum and updates IViewFor attributes |
| Test files | Updates examples to demonstrate Splat registration usage |
| README.md | Documents new Splat registration functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| public static void Main() => Application.Run(new TestViewWinForms()); | ||
| public static void Main() | ||
| { | ||
| AppLocator.CurrentMutable.RegisterViewsForViewModelsSourceGenerated(); |
There was a problem hiding this comment.
Should use Locator.CurrentMutable instead of AppLocator.CurrentMutable to match the Splat API and be consistent with other usages in the codebase.
| AppLocator.CurrentMutable.RegisterViewsForViewModelsSourceGenerated(); | |
| Locator.CurrentMutable.RegisterViewsForViewModelsSourceGenerated(); |
| public TestViewWpf() => ViewModel = TestViewModel.Instance; | ||
| public TestViewWpf() | ||
| { | ||
| Locator.CurrentMutable.RegisterLazySingleton<IViewFor<TestViewModel>>(() => new TestViewWpf()); |
There was a problem hiding this comment.
This manual registration should be removed since the PR introduces automatic registration via the generated extension method, making this redundant.
| Locator.CurrentMutable.RegisterLazySingleton<IViewFor<TestViewModel>>(() => new TestViewWpf()); |
| /// </summary> | ||
| /// <seealso cref="System.Attribute" /> | ||
| [global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.IViewForGenerator", "1.1.0.0")] | ||
| [global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ReactiveObjectGenerator", "1.1.0.0")] |
There was a problem hiding this comment.
The GeneratedCode attribute should reference 'ReactiveUI.SourceGenerators.IViewForGenerator' instead of 'ReactiveObjectGenerator' for consistency with the actual generator.
| [global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ReactiveObjectGenerator", "1.1.0.0")] | |
| [global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.IViewForGenerator", "1.1.0.0")] |
| /// </summary> | ||
| internal static class ReactiveUISourceGeneratorsExtensions | ||
| { | ||
| [global::System.CodeDom.Compiler.GeneratedCode("{{GeneratorName}}", "{{GeneratorVersion}}")] |
There was a problem hiding this comment.
The template placeholders {{GeneratorName}} and {{GeneratorVersion}} are not being replaced with actual values, which will result in literal placeholder text in the generated code.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What kind of change does this PR introduce?
Feature
What is the new behavior?
Introduces SplatRegistrationType to IViewFor attributes and source generator, enabling automatic registration of views for view models in Splat's service locator.
Updates documentation, tests, and sample usage to demonstrate new registration options and extension method for bulk registration.
What might this PR break?
None
Please check if the PR fulfills these requirements
Other information: