-
-
Notifications
You must be signed in to change notification settings - Fork 0
Generate INotifyPropertyChanged for Display property & Use global namespace for List type #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the EnumSourceGenerator to implement INotifyPropertyChanged
for the Display property and uses global namespace references for List<T>
types. The changes ensure proper change notification when Display property values are updated through the UpdateLabels
method.
- Implements
INotifyPropertyChanged
interface with proper event notification for the Display property - Replaces using directive with global namespace references for better code isolation
- Updates the documentation reference from Flow.Launcher to Flow.Bar
Flow.Launcher.Localization.SourceGenerators/Localize/EnumSourceGenerator.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughGenerated enum data class now implements INotifyPropertyChanged, adds PropertyChanged and OnPropertyChanged, converts Display to a backing-field property that raises notifications, and fully-qualifies System types (including List) in signatures and usage. Changes
Sequence Diagram(s)sequenceDiagram
actor Consumer
participant EnumData as GeneratedEnumData
participant Subscribers as PropertyChangedSubscribers
Consumer->>EnumData: set Display(newValue)
EnumData->>EnumData: if value changed: _display = newValue
EnumData->>Subscribers: OnPropertyChanged("Display")
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (4)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (1)
Flow.Launcher.Localization.SourceGenerators/Localize/EnumSourceGenerator.cs (1)
342-342
: Consider widening UpdateLabels parameter to IEnumerable for broader applicabilityYou only enumerate items to update Display; accepting IEnumerable improves API flexibility without sacrificing behavior.
Apply this diff:
- sb.AppendLine($"{tabString}public static void UpdateLabels(global::System.Collections.Generic.List<{enumDataClassName}> options)"); + sb.AppendLine($"{tabString}public static void UpdateLabels(global::System.Collections.Generic.IEnumerable<{enumDataClassName}> options)");
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Flow.Launcher.Localization.SourceGenerators/Localize/EnumSourceGenerator.cs
(5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (3)
Flow.Launcher.Localization.SourceGenerators/Localize/EnumSourceGenerator.cs (3)
201-201
: INotifyPropertyChanged on generated class — good upgradeThis aligns with the goal of notifying UI bindings when Display changes. Solid move.
258-261
: Fully-qualifying List in generated API — consistent and clearUsing global::System.Collections.Generic.List in the generated code avoids relying on usings in the consumer and matches the PR objective.
274-275
: No-op: whitespaceNo functional change here.
Flow.Launcher.Localization.SourceGenerators/Localize/EnumSourceGenerator.cs
Show resolved
Hide resolved
Flow.Launcher.Localization.SourceGenerators/Localize/EnumSourceGenerator.cs
Show resolved
Hide resolved
Flow.Launcher.Localization.SourceGenerators/Localize/EnumSourceGenerator.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Does it make sense to remove |
Using Microsoft.CommunityToolkit.MVVM also uses this to generate its |
I understand why. What I meant is now that you're explicitly specifying the namespace on each use, should we delete |
Hmm, I have deleted it already? |
GeneratedHeaderFromPath(sourceBuilder, enumFullName); | ||
sourceBuilder.AppendLine(); | ||
|
||
// Generate using directives |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using removed here
Sorry, I must have missed this. LGTM |
Generate INotifyPropertyChanged interface for Enum localize Display property
Since Display property will be changed with
DemoLocalize.UpdateLabels
method, we should implementINotifyPropertyChanged
interface so that its change event will be notified.Use global namespace for List type
Use
global::System.Collections.Generic.List
instead ofusing System.Collections.Generic;
andList
for code quality