Skip to content

fix: upper-case Roslyn severity with the invariant culture - #1420

Merged
Scriptwonder merged 1 commit into
CoplayDev:betafrom
RizgarOzan:fix/roslyn-severity-invariant
Oct 3, 2026
Merged

Scriptwonder merged 1 commit into
CoplayDev:betafrom
RizgarOzan:fix/roslyn-severity-invariant

Conversation

@RizgarOzan

@RizgarOzan RizgarOzan commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

With USE_ROSLYN defined, ValidateScriptSyntaxRoslyn builds each diagnostic as $"{severity}: …" with diagnostic.Severity.ToString().ToUpper(). On an editor running under the Turkish (or Azerbaijani) culture "Warning".ToUpper() is "WARNİNG" and "Info" is "İNFO", so the validate action's ^(ERROR|WARNING|INFO): … regex doesn't match. The warning comes back as severity info with line = 0 and the whole raw string as the message. ERROR has no i in it, so errors were not affected.

The fix uses ToUpperInvariant(), like the other upper/lower-casing in ManageScript.cs (ToLowerInvariant() for level, refresh, validate).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

  • MCPForUnity/Editor/Tools/ManageScript.cs: one line in ValidateScriptSyntaxRoslyn.

Compatibility / Package Source

  • Unity version(s) tested: none, see below
  • Package source used: n/a

Testing/Screenshots/Recordings

  • Not applicable (explain why in Additional Notes)

Related Issues

None open.

Additional Notes

The line sits inside #if USE_ROSLYN, which the test project doesn't define, so neither the EditMode tests nor CI compile it. To check it I copied the diagnostic loop and the validate regex into a small console app against Microsoft.CodeAnalysis.CSharp 4.8.0 and fed it a file with a #warning:

tr-TR  ToUpper()          raw='WARNİNG: #warning: 'check this' (Line 3)' -> severity=info line=0
tr-TR  ToUpperInvariant() raw='WARNING: #warning: 'check this' (Line 3)' -> severity=warning line=3
en-US  ToUpper()          raw='WARNING: #warning: 'check this' (Line 3)' -> severity=warning line=3

AI use: Claude Code found this, wrote the fix and the repro, and drafted this description at my request; the output above is from a real run on my machine.

Summary by CodeRabbit

  • Bug Fixes
    • Diagnostic severity labels now use consistent capitalization across different system language settings.

On a tr-TR editor "Warning".ToUpper() gives "WARNİNG", so the validate parser's ^(ERROR|WARNING|INFO): regex misses it and the diagnostic comes back as severity info, line 0.
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a4f70c35-deb0-41ef-9abd-7abf17c3be17
📥 Commits

Reviewing files that changed from the base of the PR and between 91eb0f4 and 5b77b6b.

📒 Files selected for processing (1)
  • MCPForUnity/Editor/Tools/ManageScript.cs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Roslyn diagnostic severity labels now use invariant-culture uppercase conversion in ValidateScriptSyntaxRoslyn. Diagnostic classification and validation outcomes are unchanged.

Changes

Diagnostic formatting

Layer / File(s) Summary
Severity label formatting
MCPForUnity/Editor/Tools/ManageScript.cs
Severity labels use ToUpperInvariant instead of culture-sensitive uppercase conversion.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 5b77b

Severity labels remain compatible with validation parsing and are now locale-independent. No actionable merge-blocking risk is evident.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the invariant-culture casing fix for Roslyn severity.
Description check ✅ Passed The description explains the bug, the fix, the change made, compatibility context, testing approach, documentation status, and related issues. It also explains why Unity tests were not run.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Comment @coderabbitai help to get the list of available commands.

@Scriptwonder
Scriptwonder merged commit c040d6d into CoplayDev:beta Oct 3, 2026
7 checks passed
toxifly added a commit to toxifly/unity-mcp that referenced this pull request Nov 26, 2026
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.

2 participants