Skip to content

[bug-fix]Duplicate signature fix#906

Merged
Scriptwonder merged 2 commits intoCoplayDev:betafrom
Scriptwonder:fix/duplicate-detection-false-positives
Mar 10, 2026
Merged

[bug-fix]Duplicate signature fix#906
Scriptwonder merged 2 commits intoCoplayDev:betafrom
Scriptwonder:fix/duplicate-detection-false-positives

Conversation

@Scriptwonder
Copy link
Collaborator

@Scriptwonder Scriptwonder commented Mar 10, 2026

Add a duplicate signature check that should fix issue #898, with additional test file.

Summary by Sourcery

Add basic structural validation to detect duplicate method signatures in Unity scripts and cover it with regression tests.

Bug Fixes:

  • Detect and report duplicate method signatures in script validation to prevent corrupted or duplicated methods from slipping through.

Tests:

  • Add reflection-based tests for Unity script validation to assert correct detection of duplicate method signatures and avoidance of common false positives.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced script validation to detect and report duplicate method signatures as errors (now surfaced during basic validation).
  • Tests
    • Added extensive unit tests covering duplicate-signature scenarios to improve validation reliability.
  • Documentation
    • Updated an internal guidance message describing the interior-only edits validation option.

Copilot AI review requested due to automatic review settings March 10, 2026 00:51
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 10, 2026

Reviewer's Guide

Adds a structural duplicate-method-signature detection pass to Unity script validation and introduces focused unit tests that verify correct handling of duplicates versus legitimate variations, including comments, inner classes, overloads, and generic parameters.

Sequence diagram for updated script validation with duplicate signature check

sequenceDiagram
    actor Developer
    participant ManageScript
    participant CSharpLexer
    participant RegexEngine
    participant ErrorList

    Developer->>ManageScript: ValidateScriptSyntax(contents, level, errorList)
    alt syntax invalid
        ManageScript-->>Developer: false
    else syntax structurally valid
        Note over ManageScript: New step: duplicate signature validation
        ManageScript->>ManageScript: CheckDuplicateMethodSignatures(contents, errorList)
        ManageScript->>CSharpLexer: new CSharpLexer(contents)
        loop tokenize non code
            CSharpLexer-->>ManageScript: tokens with InNonCode
            ManageScript->>ManageScript: mask comments and strings in codeChars
        end
        ManageScript->>ManageScript: build depthArr from codeOnly
        ManageScript->>RegexEngine: match methodSigPattern on codeOnly
        loop each matched method
            RegexEngine-->>ManageScript: method name and params
            ManageScript->>ManageScript: CountTopLevelParams(paramStr)
            ManageScript->>ManageScript: ExtractParamTypes(paramStr)
            ManageScript->>ErrorList: add duplicate signature error if key seen
        end
        alt level >= Standard and USE_ROSLYN
            ManageScript->>ManageScript: ValidateScriptSyntaxRoslyn(contents, level, errorList)
        end
        ManageScript-->>Developer: validation result
    end
Loading

Class diagram for new duplicate signature validation helpers

classDiagram
    class ManageScript {
        +ValidateScriptSyntax(string contents, ValidationLevel level, List~string~ errorList)
        +ValidateScriptSyntaxRoslyn(string contents, ValidationLevel level, List~string~ errorList)
        +ValidateScriptSyntaxUnity(string contents, List~string~ errors)
        -CheckDuplicateMethodSignatures(string contents, List~string~ errors)
        -CountTopLevelParams(string paramStr) int
        -ExtractParamTypes(string paramStr) string
    }

    class CSharpLexer {
        +CSharpLexer(string source)
        +Position int
        +InNonCode bool
        +Advance(Token token) bool
    }

    class Regex {
        +Regex(string pattern, RegexOptions options, TimeSpan timeout)
        +Matches(string input) MatchCollection
    }

    class Match {
        +Index int
        +Groups GroupCollection
    }

    class GroupCollection {
        +Item[int index] Group
    }

    class Group {
        +Value string
    }

    class Dictionary_StringInt {
        +Dictionary_StringInt(StringComparer comparer)
        +TryGetValue(string key, int value) bool
        +Item[string key] int
    }

    ManageScript ..> CSharpLexer : uses
    ManageScript ..> Regex : uses
    ManageScript ..> Match : uses
    ManageScript ..> Dictionary_StringInt : uses as seen
Loading

File-Level Changes

Change Details Files
Introduce duplicate method signature detection in Unity script validation.
  • Invoke a new duplicate-signature check from the main ValidateScriptSyntax flow at Basic level, before optional Roslyn validation.
  • Implement a brace-depth–aware detection routine that strips comments/strings using CSharpLexer, computes scope depth, and regex-matches method declarations (including expression-bodied forms).
  • Define a signature key composed of method name, parameter count, normalized parameter type list, and brace depth, and emit an error when a duplicate key is seen.
MCPForUnity/Editor/Tools/ManageScript.cs
Add helper utilities to parse and normalize method parameter lists for signature comparison.
  • Implement CountTopLevelParams to count parameters while respecting nested generic/array/tuple delimiters.
  • Implement ExtractParamTypes to split parameters on top-level commas and remove parameter names, preserving only normalized type strings and collapsing whitespace.
MCPForUnity/Editor/Tools/ManageScript.cs
Extend Unity script validation tests to cover duplicate signature detection behavior.
  • Add reflection-based helper to call ValidateScriptSyntaxUnity and capture its error list for assertions.
  • Introduce tests that ensure no false positives for commented-out methods, inner-class/outer-class name reuse, and valid overloads with different parameter types.
  • Introduce tests that ensure true positives for exact duplicates, expression-bodied duplicates, and duplicates differing only by parameter names including generic parameter scenarios.
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptValidationTests.cs

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 10, 2026

📝 Walkthrough

Walkthrough

Adds duplicate method-signature detection to the script validation flow by introducing parsing helpers for parameter lists and invoking the checker during basic (non-Roslyn) validation; tests covering multiple duplicate and non-duplicate scenarios were added, and a small docstring edit occurred in a server script.

Changes

Cohort / File(s) Summary
Core Validation Logic
MCPForUnity/Editor/Tools/ManageScript.cs
Adds CheckDuplicateMethodSignatures(contents, errorList) and helper methods CountTopLevelParams(string) and ExtractParamTypes(string); integrates duplicate-signature checking into basic validation. Two nearly identical helper implementations appear (duplicate in patch).
Unit Tests
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptValidationTests.cs
Adds reflection-based helper to call private validation, new tests for many duplicate and non-duplicate method-signature scenarios, and utility HasDuplicateMethodError.
Docs/Comment
Server/src/services/tools/script_apply_edits.py
Small comment change: interior-only edits validation option label changed from 'relaxed' to 'basic' (no behavior change).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I nibble through signatures, one hop at a time,
Counting params and generics, parsing each rhyme.
Duplicates tremble when I give them a peep,
I tidy the code while I softly sleep.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding duplicate method signature detection to fix a bug, which aligns with the code changes validating method signatures.
Description check ✅ Passed The description covers the primary objective (duplicate signature check) and includes test additions, but omits several template sections like Type of Change, Changes Made details, and Documentation Updates checklist.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • In CheckDuplicateMethodSignatures, consider making methodSigPattern a static, precompiled Regex (e.g., static readonly Regex) so it isn’t re-instantiated on every validation call, which can be relatively expensive in large projects.
  • The ExtractParamTypes loop currently uses a sentinel comma at i == paramStr.Length to handle the final parameter; refactoring to explicitly process the final segment (instead of relying on that sentinel) would make the logic easier to follow and less error-prone for future maintenance.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `CheckDuplicateMethodSignatures`, consider making `methodSigPattern` a static, precompiled `Regex` (e.g., `static readonly Regex`) so it isn’t re-instantiated on every validation call, which can be relatively expensive in large projects.
- The `ExtractParamTypes` loop currently uses a sentinel comma at `i == paramStr.Length` to handle the final parameter; refactoring to explicitly process the final segment (instead of relying on that sentinel) would make the logic easier to follow and less error-prone for future maintenance.

## Individual Comments

### Comment 1
<location path="MCPForUnity/Editor/Tools/ManageScript.cs" line_range="2678-2680" />
<code_context>
+            }
+
+            // Step 3: Match method signatures on code-only text (includes => for expression-bodied)
+            var methodSigPattern = new Regex(
+                @"(?:public|private|protected|internal)(?:\s+(?:static|virtual|override|abstract|sealed|async|new))*\s+\S+\s+(\w+)\s*\(([^)]*)\)\s*(?:where\s+\S+\s*:\s*\S+\s*)?(?:[{;]|=>)",
+                RegexOptions.Multiline | RegexOptions.CultureInvariant, TimeSpan.FromSeconds(2));
+            var sigMatches = methodSigPattern.Matches(codeOnly);
+            var seen = new System.Collections.Generic.Dictionary<string, int>(System.StringComparer.Ordinal);
</code_context>
<issue_to_address>
**issue (bug_risk):** Using only brace depth to distinguish scopes can produce false positives across different types/namespaces.

The deduplication key currently scopes only by `@{depth}`, so two methods with the same signature in different classes/namespaces at the same brace depth will be treated as duplicates (e.g., `class A { void Foo(int x) { } }` and `class B { void Foo(int x) { } }`). To avoid these false positives, consider enriching the key with surrounding type/namespace context (e.g., a stack of `class/struct/interface` names) or by including the full signature plus a nearby `namespace`/`class` identifier.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

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

Adds a structural validation guard to manage_script edits to detect duplicate method signatures (aimed at preventing anchor_replace-style corruption as described in issue #898), along with new in-memory validation tests.

Changes:

  • Run a new duplicate-method-signature scan during ValidateScriptSyntax to reject corrupted outputs early.
  • Implement helpers to normalize parameter type extraction and brace-depth-based scoping for signature comparison.
  • Add new NUnit tests intended to verify duplicate detection behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptValidationTests.cs Adds reflection-based tests for duplicate method detection.
MCPForUnity/Editor/Tools/ManageScript.cs Adds duplicate method signature detection to core script validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +142 to +150
/// Calls ValidateScriptSyntaxUnity via reflection and returns the error list.
/// </summary>
private List<string> CallValidateScriptSyntaxUnity(string contents)
{
var errors = new List<string>();
var method = typeof(ManageScript).GetMethod("ValidateScriptSyntaxUnity",
BindingFlags.NonPublic | BindingFlags.Static);
Assert.IsNotNull(method, "ValidateScriptSyntaxUnity method must exist");
method.Invoke(null, new object[] { contents, errors });
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

These new duplicate-signature tests call ValidateScriptSyntaxUnity via reflection, but the duplicate signature check is implemented in ValidateScriptSyntax (it calls CheckDuplicateMethodSignatures) and ValidateScriptSyntaxUnity does not invoke that check. As a result, the "*_Flagged" tests will not exercise the new behavior and will fail/produce false confidence. Update the helper to reflectively call ValidateScriptSyntax(contents, ValidationLevel.Basic, out string[] errors) (or call CheckDuplicateMethodSignatures directly) and assert against that error output instead.

Suggested change
/// Calls ValidateScriptSyntaxUnity via reflection and returns the error list.
/// </summary>
private List<string> CallValidateScriptSyntaxUnity(string contents)
{
var errors = new List<string>();
var method = typeof(ManageScript).GetMethod("ValidateScriptSyntaxUnity",
BindingFlags.NonPublic | BindingFlags.Static);
Assert.IsNotNull(method, "ValidateScriptSyntaxUnity method must exist");
method.Invoke(null, new object[] { contents, errors });
/// Calls core ValidateScriptSyntax via reflection (ValidationLevel.Basic) and returns the error list.
/// </summary>
private List<string> CallValidateScriptSyntaxUnity(string contents)
{
var method = typeof(ManageScript).GetMethod("ValidateScriptSyntax",
BindingFlags.NonPublic | BindingFlags.Static);
Assert.IsNotNull(method, "ValidateScriptSyntax method must exist");
var parameters = method.GetParameters();
Assert.AreEqual(3, parameters.Length, "ValidateScriptSyntax signature has changed");
var validationLevelType = parameters[1].ParameterType;
object validationLevelBasic;
if (validationLevelType.IsEnum)
{
validationLevelBasic = Enum.Parse(validationLevelType, "Basic");
}
else
{
// Fallback in case the parameter type changes from an enum.
validationLevelBasic = Activator.CreateInstance(validationLevelType);
}
object[] args = new object[] { contents, validationLevelBasic, null };
method.Invoke(null, args);
var errorsArray = args[2] as string[];
var errors = errorsArray != null ? new List<string>(errorsArray) : new List<string>();

Copilot uses AI. Check for mistakes.
Comment on lines +2682 to +2691
var seen = new System.Collections.Generic.Dictionary<string, int>(System.StringComparer.Ordinal);
foreach (Match sm in sigMatches)
{
string methodName = sm.Groups[1].Value;
int paramCount = CountTopLevelParams(sm.Groups[2].Value);
string paramTypes = ExtractParamTypes(sm.Groups[2].Value);
int depth = depthArr[sm.Index];
string key = $"{methodName}/{paramCount}/{paramTypes}@{depth}";
if (seen.TryGetValue(key, out _))
errors.Add($"ERROR: Duplicate method signature detected: '{methodName}' with {paramCount} parameter(s). This may indicate a corrupted edit.");
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

The duplicate-method signature key uses only brace depth (@{depth}) to represent scope. This will incorrectly flag identical method signatures that exist in two different sibling types/namespaces at the same nesting depth (e.g., class A { public void Foo(int x){} } class B { public void Foo(int x){} } in the same file). Consider including the containing type (and namespace) in the key by tracking a type stack while scanning braces, rather than using depth alone.

Suggested change
var seen = new System.Collections.Generic.Dictionary<string, int>(System.StringComparer.Ordinal);
foreach (Match sm in sigMatches)
{
string methodName = sm.Groups[1].Value;
int paramCount = CountTopLevelParams(sm.Groups[2].Value);
string paramTypes = ExtractParamTypes(sm.Groups[2].Value);
int depth = depthArr[sm.Index];
string key = $"{methodName}/{paramCount}/{paramTypes}@{depth}";
if (seen.TryGetValue(key, out _))
errors.Add($"ERROR: Duplicate method signature detected: '{methodName}' with {paramCount} parameter(s). This may indicate a corrupted edit.");
// Track enclosing scope (namespace/type) so identical signatures in different sibling scopes are not conflated
var scopePattern = new Regex(
@"\b(?:namespace|class|struct|interface|record)\s+([A-Za-z_][A-Za-z0-9_\.]*)\b",
RegexOptions.Multiline | RegexOptions.CultureInvariant);
var scopeMatches = scopePattern.Matches(codeOnly);
int currentScopeIndex = -1;
var seen = new System.Collections.Generic.Dictionary<string, int>(System.StringComparer.Ordinal);
foreach (Match sm in sigMatches)
{
// Advance scope index to the last scope declaration starting at or before this method
while (currentScopeIndex + 1 < scopeMatches.Count &&
scopeMatches[currentScopeIndex + 1].Index <= sm.Index)
{
currentScopeIndex++;
}
string scopeName = currentScopeIndex >= 0
? scopeMatches[currentScopeIndex].Groups[1].Value
: "global";
string methodName = sm.Groups[1].Value;
int paramCount = CountTopLevelParams(sm.Groups[2].Value);
string paramTypes = ExtractParamTypes(sm.Groups[2].Value);
string key = $"{scopeName}.{methodName}/{paramCount}/{paramTypes}";
if (seen.TryGetValue(key, out _))
errors.Add($"ERROR: Duplicate method signature detected: '{methodName}' with {paramCount} parameter(s) in scope '{scopeName}'. This may indicate a corrupted edit.");

Copilot uses AI. Check for mistakes.

// Step 3: Match method signatures on code-only text (includes => for expression-bodied)
var methodSigPattern = new Regex(
@"(?:public|private|protected|internal)(?:\s+(?:static|virtual|override|abstract|sealed|async|new))*\s+\S+\s+(\w+)\s*\(([^)]*)\)\s*(?:where\s+\S+\s*:\s*\S+\s*)?(?:[{;]|=>)",
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

methodSigPattern uses \S+ for the return type. This fails to match common generic return types that contain spaces (e.g. Dictionary<string, int> Get()), so duplicates in those methods won’t be detected. Consider loosening the return-type part of the regex (or tokenizing types) so generic types with whitespace still match.

Suggested change
@"(?:public|private|protected|internal)(?:\s+(?:static|virtual|override|abstract|sealed|async|new))*\s+\S+\s+(\w+)\s*\(([^)]*)\)\s*(?:where\s+\S+\s*:\s*\S+\s*)?(?:[{;]|=>)",
@"(?:public|private|protected|internal)(?:\s+(?:static|virtual|override|abstract|sealed|async|new))*\s+(?:[^{(;=>]+?)\s+(\w+)\s*\(([^)]*)\)\s*(?:where\s+\S+\s*:\s*\S+\s*)?(?:[{;]|=>)",

Copilot uses AI. Check for mistakes.
Comment on lines +2554 to +2569
string param = paramStr.Substring(start, i - start).Trim();
if (types.Length > 0) types.Append(", ");
// The type is everything except the last token (the name).
// But if the last token ends with '>' or ']', it's all type (e.g. "List<int>").
// Find the last whitespace that is NOT inside <> brackets.
int lastSplit = -1;
int d2 = 0;
for (int j = 0; j < param.Length; j++)
{
char pc = param[j];
if (pc == '<' || pc == '(' || pc == '[') d2++;
else if (pc == '>' || pc == ')' || pc == ']') d2--;
else if (d2 == 0 && char.IsWhiteSpace(pc)) lastSplit = j;
}
types.Append(lastSplit > 0 ? param.Substring(0, lastSplit).Trim() : param);
start = i + 1;
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

ExtractParamTypes determines the “type part” by stripping everything after the last whitespace outside generics. This breaks for parameters with default values (e.g. int x = 1), where it will keep int x = as the “type”. That can cause false negatives when comparing Foo(int x) vs Foo(int x = 1) (same signature in C#, but keys won’t match). Consider explicitly removing default value assignments and parameter names/modifiers via a more robust parse (or at least truncate at '=' at top level before the whitespace split).

Copilot uses AI. Check for mistakes.
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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@MCPForUnity/Editor/Tools/ManageScript.cs`:
- Around line 2688-2693: The current duplicate-key uses depthArr[sm.Index]
(brace depth) so the key string
$"{methodName}/{paramCount}/{paramTypes}@{depth}" can collide across different
types; change the key to include the enclosing type identity instead of depth —
obtain the containing type name for the symbol represented by sm (e.g., a
full/qualified type name or namespace+type via the AST/symbol API you already
have access to) and build the key like
$"{containingTypeFullName}/{methodName}/{paramCount}/{paramTypes}" (replace the
use of depthArr[sm.Index] and ensure seen is keyed by that containingType-based
string before calling seen.TryGetValue or seen[...]=1).
- Around line 2678-2680: The regex assigned to methodSigPattern currently
requires an explicit accessibility modifier, so update the pattern used in the
methodSigPattern variable to make the leading accessibility token optional
(e.g., change the "(?:public|private|protected|internal)" group to an optional
group) and allow optional whitespace after it; keep the rest of the pattern
(modifiers, return type, name capture group (\w+) and parameter capture group
([^)]*)) and retain the same RegexOptions and timeout settings so methods
declared without an explicit modifier (like "void Start()") are matched.

In
`@TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptValidationTests.cs`:
- Around line 144-151: The test helper CallValidateScriptSyntaxUnity is invoking
the wrong entrypoint (ValidateScriptSyntaxUnity) so duplicate-signature checks
added to ValidateScriptSyntax are never exercised; update the helper to
reflectively call ManageScript.ValidateScriptSyntax (not
ValidateScriptSyntaxUnity), keeping the same BindingFlags/Invoke pattern and the
same parameters (contents, errors) so tests that assert
CheckDuplicateMethodSignatures behavior exercise the new logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a6cface6-8b46-45ab-85bb-81cdd6144a55

📥 Commits

Reviewing files that changed from the base of the PR and between 096ea32 and b76daf7.

📒 Files selected for processing (2)
  • MCPForUnity/Editor/Tools/ManageScript.cs
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptValidationTests.cs

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.

🧹 Nitpick comments (1)
TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptValidationTests.cs (1)

145-161: Previous issue addressed, but method name is now misleading.

The method correctly calls ValidateScriptSyntax (line 152), which exercises CheckDuplicateMethodSignatures. However, the method name CallValidateScriptSyntaxUnity is confusing since it doesn't call ValidateScriptSyntaxUnity at all.

📝 Consider renaming for clarity
-        private List<string> CallValidateScriptSyntaxUnity(string contents)
+        private List<string> CallValidateScriptSyntax(string contents)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptValidationTests.cs`
around lines 145 - 161, Rename the misleading helper method
CallValidateScriptSyntaxUnity to a clear name like CallValidateScriptSyntax (or
CallManageScriptValidateScriptSyntax) because it invokes
ManageScript.ValidateScriptSyntax and not ValidateScriptSyntaxUnity; update the
method declaration and all its call sites in tests to the new name and ensure
the signature and behavior remain unchanged (references: method
CallValidateScriptSyntaxUnity, ManageScript.ValidateScriptSyntax,
CheckDuplicateMethodSignatures).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptValidationTests.cs`:
- Around line 145-161: Rename the misleading helper method
CallValidateScriptSyntaxUnity to a clear name like CallValidateScriptSyntax (or
CallManageScriptValidateScriptSyntax) because it invokes
ManageScript.ValidateScriptSyntax and not ValidateScriptSyntaxUnity; update the
method declaration and all its call sites in tests to the new name and ensure
the signature and behavior remain unchanged (references: method
CallValidateScriptSyntaxUnity, ManageScript.ValidateScriptSyntax,
CheckDuplicateMethodSignatures).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 05855218-9bfe-4dcd-a4d4-12fa22cdf218

📥 Commits

Reviewing files that changed from the base of the PR and between b76daf7 and 2aba867.

📒 Files selected for processing (3)
  • MCPForUnity/Editor/Tools/ManageScript.cs
  • Server/src/services/tools/script_apply_edits.py
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools/ManageScriptValidationTests.cs
✅ Files skipped from review due to trivial changes (1)
  • Server/src/services/tools/script_apply_edits.py

@Scriptwonder Scriptwonder merged commit 546e4ec into CoplayDev:beta Mar 10, 2026
2 checks passed
@Scriptwonder Scriptwonder deleted the fix/duplicate-detection-false-positives branch March 10, 2026 01:21
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