Skip to content

Conversation

Jack251970
Copy link
Member

In generated codes, we should not check old localization API usage warning.

Copy link
Contributor

@Copilot Copilot AI left a 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 adds pragma directive to suppress old localization API warnings (FLAN0001) in generated source code. The generated code legitimately uses old APIs and should not trigger these warnings.

  • Added a constant for the pragma warning suppression directive
  • Inserted the pragma directive in both localization and enum source generators to suppress FLAN0001 warnings

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
Flow.Launcher.Localization.Shared/Constants.cs Defines the pragma directive constant for suppressing FLAN0001 warnings
Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs Adds pragma directive to suppress old localization API warnings in generated code
Flow.Launcher.Localization.SourceGenerators/Localize/EnumSourceGenerator.cs Adds pragma directive to suppress old localization API warnings in generated enum code

@coderabbitai coderabbitai bot added the enhancement New feature or request label Jul 31, 2025
Copy link
Contributor

coderabbitai bot commented Jul 31, 2025

📝 Walkthrough

Walkthrough

A constant string for suppressing a specific compiler warning was added to the shared Constants class. This constant is now inserted into the generated source code by both the Enum and Localize source generators, just after the namespace declaration, to suppress warnings about the old localization API.

Changes

Cohort / File(s) Change Summary
Add suppression constant
Flow.Launcher.Localization.Shared/Constants.cs
Added SuppressWarning constant containing a pragma directive to suppress warning FLAN0001.
Insert suppression directive in generated code
Flow.Launcher.Localization.SourceGenerators/Localize/EnumSourceGenerator.cs, Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs
Modified both source generators to insert the suppression constant after the namespace declaration in generated code.

Sequence Diagram(s)

sequenceDiagram
    participant SourceGenerator
    participant Constants
    participant GeneratedSource

    SourceGenerator->>Constants: Retrieve SuppressWarning constant
    SourceGenerator->>GeneratedSource: Write namespace declaration
    SourceGenerator->>GeneratedSource: Insert SuppressWarning directive
    SourceGenerator->>GeneratedSource: Continue generating class code
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • Yusyuriv

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch suppress_warning

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
Flow.Launcher.Localization.SourceGenerators/Localize/EnumSourceGenerator.cs (1)

196-199: Same restore-pragma consideration as in LocalizeSourceGenerator.

To confine suppression strictly to the generated enum helpers, append a corresponding #pragma warning restore FLAN0001 near the end of GenerateSource. Aligning both generators prevents silent suppression leaks if more content is appended later.

🧹 Nitpick comments (2)
Flow.Launcher.Localization.Shared/Constants.cs (1)

31-31: Constant addition looks good; consider explicit naming.

Adding a single-source constant for the pragma directive avoids magic strings in the generators—nice.
Minor nit: a slightly more explicit name such as PragmaSuppressOldLocalizationWarning would better convey purpose if more suppressions are added later, but this is non-blocking.

Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs (1)

476-479: Suppress directive has no matching #pragma warning restore.

Inserting the disable pragma early guarantees the generator compiles warning-free, but the suppression now extends to the entire generated file.
For tighter scope and future-proofing (e.g., if additional code is appended that shouldn’t be exempt), add a matching restore just before the file footer:

 sourceBuilder.AppendLine(Constants.SuppressWarning);
 sourceBuilder.AppendLine();

 … // existing generated content

+// Re-enable the warning after generated content
+sourceBuilder.AppendLine("#pragma warning restore FLAN0001");

Not critical, yet keeps warning hygiene consistent.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90867d2 and d698da5.

📒 Files selected for processing (3)
  • Flow.Launcher.Localization.Shared/Constants.cs (1 hunks)
  • Flow.Launcher.Localization.SourceGenerators/Localize/EnumSourceGenerator.cs (1 hunks)
  • Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
Flow.Launcher.Localization.SourceGenerators/Localize/EnumSourceGenerator.cs (1)
Flow.Launcher.Localization.Shared/Constants.cs (1)
  • Constants (5-35)
Flow.Launcher.Localization.SourceGenerators/Localize/LocalizeSourceGenerator.cs (1)
Flow.Launcher.Localization.Shared/Constants.cs (1)
  • Constants (5-35)

Copy link
Contributor

@VictoriousRaptor VictoriousRaptor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you post an example of this warning?

@Jack251970
Copy link
Member Author

Could you post an example of this warning?

Here you go. Tested under the latest dev branch & VS.

image

@Jack251970 Jack251970 merged commit 4edbef5 into main Aug 1, 2025
3 checks passed
@Jack251970 Jack251970 deleted the suppress_warning branch August 1, 2025 11:48
@VictoriousRaptor
Copy link
Contributor

Don't forget the version bump if needed.

@Jack251970
Copy link
Member Author

Don't forget the version bump if needed.

I would like to keep it for the next version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants