Skip to content

VsCode Tasks PR2: Adding sqlproj-build Task Definition and Problem Matcher to Extension Package #26316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 3, 2025

Conversation

ssreerama
Copy link
Contributor

This pull request introduces task provider support for SQL database projects in Visual Studio Code. It adds functionality to define, register, and manage tasks for building .sqlproj files, including tasks with optional code analysis. It also includes tests to validate the new functionality. Below are the most important changes grouped by theme:

Task Provider Implementation:

  • Introduced a new SqlDatabaseProjectTaskProvider class to provide tasks for .sqlproj files. It supports creating build tasks and build-with-code-analysis tasks, leveraging vscode.Task and vscode.ShellExecution. The class also includes file system watchers to dynamically update tasks when .sqlproj files are added, modified, or removed. (extensions/sql-database-projects/src/tasks/sqlDatabaseProjectTaskProvider.ts)

Configuration and Constants:

  • Added task definitions and problem matchers to the package.json file for .sqlproj tasks, enabling integration with the VS Code task system. (extensions/sql-database-projects/package.json)
  • Defined new constants for task types, problem matchers, and build-related parameters in constants.ts. These constants are used throughout the task provider implementation. (extensions/sql-database-projects/src/common/constants.ts) [1] [2]

Extension Activation:

  • Updated the extension activation logic to register the SqlDatabaseProjectTaskProvider as a task provider when the extension is activated. (extensions/sql-database-projects/src/extension.ts) [1] [2]

Unit Tests:

  • Added unit tests for the SqlDatabaseProjectTaskProvider to ensure tasks are created correctly for .sqlproj files. The tests validate task properties, such as task names, problem matchers, and execution commands. (extensions/sql-database-projects/src/test/tasks/sqlDatabaseProjectTaskProvider.test.ts)# Pull Request Template – Azure Data Studio

Description

This PR adds the ability of creating sql-proj build and build with code analysis tasks during the project creation and can be run from 'Run tasks' option.
Pr2_vscodeRunTsks

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (npm run test)
  • Code follows contributing guidelines
  • No UI regressions introduced
  • Logging/telemetry updated if applicable
  • Cross-platform support checked (Windows, macOS, Linux if relevant)

Reviewers: Please read our reviewer guidelines

@ssreerama ssreerama requested review from Benjin and kisantia as code owners May 24, 2025 05:03
@chlafreniere chlafreniere requested a review from Copilot May 28, 2025 01:02
Copy link
Contributor

@Copilot 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

This pull request adds support for SQL database project tasks in the VS Code extension by implementing a new task provider, updating task definitions and problem matchers in the package configuration, and adding unit tests to validate the functionality.

  • Introduced SqlDatabaseProjectTaskProvider to create tasks for building .sqlproj files with optional code analysis.
  • Updated extension activation to register the new task provider.
  • Added corresponding constants and package.json configurations for task definitions and a problem matcher.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
extensions/sql-database-projects/src/test/tasks/sqlDatabaseProjectTaskProvider.test.ts Added unit tests to validate task creation and task properties for .sqlproj files.
extensions/sql-database-projects/src/tasks/sqlDatabaseProjectTaskProvider.ts Implemented a task provider to dynamically create build and build-with-code-analysis tasks.
extensions/sql-database-projects/src/extension.ts Updated extension activation to register the new task provider.
extensions/sql-database-projects/src/common/constants.ts Added constants for task types, shell command parameters, and problem matcher identifiers.
extensions/sql-database-projects/package.json Configured task definitions and problem matchers to integrate with the VS Code tasks system.
Comments suppressed due to low confidence (2)

extensions/sql-database-projects/src/common/constants.ts:561

  • The documentation in the task definition indicates that runCodeAnalysis is optional with a default of true, but the implementation in getTask defaults it to false. Consider aligning the default behavior between the documentation and the implementation.
"runCodeAnalysis": {

extensions/sql-database-projects/src/tasks/sqlDatabaseProjectTaskProvider.ts:142

  • [nitpick] There appears to be an extra whitespace between the constants in the shell command construction when runCodeAnalysis is true. Consider removing the extra space to ensure consistent command formatting.
const shellCommand = runCodeAnalysis ? `${constants.dotnetBuild}  ${constants.runCodeAnalysisParam}` : `${constants.dotnetBuild}`;

…jectTaskProvider.test.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ssreerama ssreerama requested a review from Copilot May 30, 2025 18:11
Copy link
Contributor

@Copilot 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

This pull request adds task provider support for SQL database projects in VS Code by introducing a new task provider for building .sqlproj files with optional code analysis, updating related constants and package definitions, and including unit tests to validate the functionality.

  • Adds the SqlDatabaseProjectTaskProvider to create build tasks.
  • Updates the extension activation to register the new task provider.
  • Defines task constants, problem matcher, and task definitions in constants.ts and package.json.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
extensions/sql-database-projects/src/test/tasks/sqlDatabaseProjectTaskProvider.test.ts Unit tests to validate task creation logic and properties for .sqlproj files
extensions/sql-database-projects/src/tasks/sqlDatabaseProjectTaskProvider.ts Implements the logic for building SQL project tasks and handles file watching
extensions/sql-database-projects/src/extension.ts Registers the new task provider during extension activation
extensions/sql-database-projects/src/common/constants.ts Introduces new constants pertinent to SQL project tasks and problem matching
extensions/sql-database-projects/package.json Defines problem matchers and task definitions for SQL project tasks

@ssreerama ssreerama self-assigned this Jun 2, 2025
@ssreerama ssreerama added this to the June 2025 Release milestone Jun 2, 2025
@@ -22,7 +22,7 @@ export function activate(context: vscode.ExtensionContext): Promise<SqlDatabaseP
context.subscriptions.push(TelemetryReporter);

// Register the Sql project task provider
const workspaceFolders = vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 ? vscode.workspace.workspaceFolders : undefined;
const workspaceFolders = vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders?.length > 0 ? vscode.workspace.workspaceFolders : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

I was just mentioning that vscode.workspace.workspaceFolders isn't needed anymore now that you have ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it shouldn't as we are using the optional chaining, but I believe typescript is validating it differently compared to null-condition operator (like in c#). It seems we are checking the same thing twice, but since the workspaceFolders can return a list | undefined, first check is required to verify if the folders exists then only go for second check to get the lenght, otherwise it could check for undefined?.length which is causing the runtime error
"'vscode.workspace.workspaceFolders.length' is possibly 'undefined'.ts(18048)"

@ssreerama ssreerama merged commit 7ff9082 into main Jun 3, 2025
11 of 12 checks passed
@ssreerama ssreerama deleted the sai/SqlProjTasksProvider branch June 3, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants