[Fix] Prompt and get acknowledge to update the missing projectGuid in sqlprojects#21524
[Fix] Prompt and get acknowledge to update the missing projectGuid in sqlprojects#21524
Conversation
PR Changes
|
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (64.00%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #21524 +/- ##
==========================================
- Coverage 72.91% 72.91% -0.01%
==========================================
Files 326 326
Lines 98731 98756 +25
Branches 5569 5570 +1
==========================================
+ Hits 71992 72008 +16
- Misses 26739 26748 +9
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a new user-facing flow and supporting API surface to ensure SQL projects have a valid ProjectGuid, enabling reliable cross-project references and avoiding the all-zeros GUID behavior seen when <ProjectGuid> is missing.
Changes:
- Adds a prompt to detect missing/null
ProjectGuidand optionally generate/write a new GUID to the project. - Introduces a new
setProjectPropertiesrequest/contract and public typings to update SQL project properties via STS. - Adds unit tests and localization strings for the new prompt/label.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| typings/vscode-mssql.d.ts | Exposes setProjectProperties and SetProjectPropertiesParams in the public API typings. |
| localization/xliff/sql-database-projects.xlf | Adds new trans-units for “Add ProjectGuid” and the missing-guid prompt text. |
| extensions/sql-database-projects/test/project.test.ts | Adds tests for prompting behavior and GUID generation/update path. |
| extensions/sql-database-projects/src/models/project.ts | Implements prompt + GUID generation/write logic and calls it during project open/update. |
| extensions/sql-database-projects/src/common/constants.ts | Adds localized label/message constants and the null GUID constant. |
| extensions/sql-database-projects/l10n/bundle.l10n.json | Adds the corresponding localized strings for runtime lookup. |
| extensions/mssql/typings/vscode-mssql.d.ts | Mirrors the public API typing additions in the extension-local typings. |
| extensions/mssql/src/services/sqlProjectsService.ts | Adds client-side setProjectProperties implementation that issues the new request. |
| extensions/mssql/src/models/contracts/sqlProjects/sqlProjectsContracts.ts | Defines the new SetProjectPropertiesRequest request type/route. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated 4 comments.
You can also share your feedback on Copilot code review. Take the survey.
|
@ssreerama please check the failing test before merging the changes. |
This PR requires the STS change, probably the failing test is related to it. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated 2 comments.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated 3 comments.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated 4 comments.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated 5 comments.
You can also share your feedback on Copilot code review. Take the survey.
| public static async checkPromptProjectGuidStatus(projects: Project[]): Promise<void> { | ||
| // De-duplicate by projectFilePath in case the same project was queued | ||
| // multiple times or this method is called directly with duplicates. | ||
| const uniqueProjects = projects.filter( | ||
| (p, index, self) => | ||
| self.findIndex((q) => q.projectFilePath === p.projectFilePath) === index, | ||
| ); | ||
|
|
||
| if (uniqueProjects.length === 0) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
checkPromptProjectGuidStatus builds uniqueProjects only by de-duplicating the input list, but it never filters to projects that are currently missing a GUID. This can lead to showing a prompt even when none of the projects passed in actually need fixing (e.g., if a caller passes mixed projects, or a project's GUID is updated between queueing and prompt display). Consider filtering uniqueProjects with isMissingProjectGuid() before building the message, and returning early if the filtered list is empty.
| public async ensureValidProjectGuid(): Promise<void> { | ||
| if (!this.isMissingProjectGuid()) { | ||
| return; | ||
| } | ||
| const guid = `{${randomUUID().toUpperCase()}}`; | ||
| const result = await this.sqlProjService.setProjectProperties(this.projectFilePath, { | ||
| [constants.ProjectGuid]: guid, | ||
| }); | ||
| utils.throwIfFailed(result); | ||
| this._projectGuid = guid; |
There was a problem hiding this comment.
ensureValidProjectGuid is described as idempotent, but it only checks the in-memory _projectGuid before writing. Since Project.openProject creates new Project instances per call, it’s possible for _projectGuid to be stale relative to the underlying .sqlproj/STS state (e.g., another instance already added a GUID). In that case, this method could overwrite an existing valid GUID. Consider re-reading the current projectGuid from getProjectProperties (or readProjectProperties) immediately before calling setProjectProperties, and only writing when the persisted value is still missing/null.
| project2.projectFileName, | ||
| ]), | ||
| ), | ||
| `showInformationMessage not called with expected message. Actual: "${showInfoStub.firstCall.args[0]}"`, |
There was a problem hiding this comment.
This test uses showInfoStub.firstCall.args[0] to report the actual message. Repo review guidance recommends avoiding “n-th call”/call-index inspection (e.g., firstCall, getCall(0)) because it’s brittle. Prefer asserting the stub was called with the expected message using calledWith/calledWithMatch (and, if needed, use a matcher to capture the argument) instead of inspecting a specific call index.
| `showInformationMessage not called with expected message. Actual: "${showInfoStub.firstCall.args[0]}"`, | |
| "showInformationMessage not called with expected message", |
Description
This pull request :
ProjectGuid, which is important for cross-project references.Code Changes Checklist
npm run test)Reviewers: Please read our reviewer guidelines