Tags: csa7mdm/roslyn
Tags
Improve error message for misplaced variable designator in property p… …atterns (dotnet#81287) ## Summary: Improve error messages when variable designation is in incorrect order with property pattern ### Problem Statement When users write `o is string s { Length: 5 }` (with designation before property pattern), the compiler produced confusing error messages: - `error CS1026: ) expected` - `error CS1002: ; expected` - `error CS1513: } expected` The correct syntax should be `o is string { Length: 5 } s` (designation after property pattern). ### Solution This PR adds a new error code `ERR_DesignatorBeneathPattern` (CS8525) that provides a clear error message: ``` error CS8525: The variable designator 's' must come after any property pattern. ``` ### Changes Made ✅ **Error Code & Resources:** - Added `ERR_DesignatorBeneathPattern` error code (CS8525) to `ErrorCode.cs` - Added error message to `CSharpResources.resx` - Updated all XLF localization files - Added error code to `ErrorFacts.cs` ✅ **Parser Implementation:** - Modified `parsePropertyPatternClause` local function in `ParsePatternContinued` to detect identifier followed by `{` - When detected, the parser now: - Consumes the misplaced identifier token - Parses the property pattern - Reports the new CS8525 error with the variable name - Places the identifier token as skipped syntax on the property pattern - Continues parsing to provide better recovery ✅ **Testing:** - Added 1 test in `PatternParsingTests.cs`: - `DesignatorBeforePropertyPattern` - tests `string s { Length: 5 }` - All 301 existing pattern parsing tests still pass - Verified the exact scenario from issue dotnet#50220 ### Scope This fix only handles the property pattern case (`x { ... }`). Positional patterns (`x ( ... )`) are not covered by this change. ### Validation - ✅ Builds successfully with no warnings - ✅ All 302 pattern parsing tests pass (301 passed, 1 skipped) - ✅ Correct syntax continues to work without the new error - ✅ Error message is clear and concise - ✅ Simplified implementation with direct token consumption - ✅ No security vulnerabilities introduced Fixes dotnet#50220 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: CyrusNajmabadi <[email protected]> Co-authored-by: Cyrus Najmabadi <[email protected]>
Build Branch: refs/heads/release/dev18.3 Internal ID: 20251105.5 Internal VS ID: rel.d18.3-11222.16
Build Branch: refs/heads/release/dev18.0 Internal ID: 20251029.7 Internal VS ID: rel.d18.0-11222.15
Build Branch: refs/heads/release/dev18.3 Internal ID: 20251105.5 Internal VS ID: rel.d18.3-11218.70
Use work done progress to handle restore server side (dotnet#81233) Followup to the canonical misc changes. This PR has two parts ## Move server initiated restore entirely to server Previously restores initiated by the server had to call out to the client to setup the correct UI, which then called back to the server to run the restore, all using custom LSP requests. This wasn't ideal as it meant extra custom client side code and an extra server -> client -> server loop. Instead, we can utilize the standard LSP [server initiated work done progress](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#serverInitiatedProgress) API to display progress from the server on the client side. This means server initiated restores no longer need any custom client code, and the server can choose when to display a UI without a client code change. This did require a bit of complex code to handle either the server or client cancelling the request. Additionally, we still have custom requests for manually initiated restores from the client. ## Hide restore progress for canonical files Utilizing the above change, I modified the server behavior to not show any progress when restoring the canonical file. This is an internal server operation and does not need to be displayed client side (based on feedback it only causes confusion). CLient side change - dotnet/vscode-csharp#8780
Build Branch: refs/heads/release/dev18.0 Internal ID: 20251029.7 Internal VS ID: rel.d18.0-11217.181
Roslyn Version: 4.14.0-3.25465.8 Internal ID: 20250915.8 SDK Tag: v9.0.308
Build Branch: refs/heads/release/dev18.3 Internal ID: 20251105.5 Internal VS ID: rel.d18.3-11206.111
File-based programs live directive diagnostics (dotnet#80575)
Build Branch: refs/heads/release/dev18.0 Internal ID: 20251029.7 Internal VS ID: rel.d18.0-11205.157
PreviousNext