Commit 7f5cd16
Fix create_script validator false-positive on constructor invocations (#1045)
* Fix create_script validator false-positive on constructor invocations
The regex-based duplicate method signature check misidentified
`new Type(...)` constructor calls as method declarations, causing
valid C# like `new GameObject("A"); new GameObject("B");` to be
rejected. Capture the return-type token and skip when it is `new`.
Addresses #1044
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Address review: Ordinal comparison, add new-modifier + constructor test
Use string.Equals with StringComparison.Ordinal for the "new" check.
Add test combining `public new void Init()` with nearby constructor
invocations to guard against modifier vs return-type parsing regressions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 38292bd commit 7f5cd16
2 files changed
Lines changed: 64 additions & 4 deletions
File tree
- MCPForUnity/Editor/Tools
- TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2744 | 2744 | | |
2745 | 2745 | | |
2746 | 2746 | | |
2747 | | - | |
| 2747 | + | |
2748 | 2748 | | |
2749 | 2749 | | |
2750 | 2750 | | |
2751 | 2751 | | |
2752 | 2752 | | |
2753 | | - | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
2754 | 2756 | | |
2755 | | - | |
2756 | | - | |
| 2757 | + | |
| 2758 | + | |
2757 | 2759 | | |
2758 | 2760 | | |
2759 | 2761 | | |
| |||
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
323 | 381 | | |
324 | 382 | | |
325 | 383 | | |
| |||
0 commit comments