Analyzer back#361
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Reintroduces/extends live T-SQL static analysis in the SSMS VSIX by adding editor squiggles (tagger) and Error List integration backed by a shared analysis cache, plus small supporting project/UX updates across the solution.
Changes:
- Added SSMS-side live linting pipeline:
SqlAnalysisCache+ editor tagger + Error List table data source/listeners. - Added configuration/UX support for analyzer usage (new option to disable live analysis; updated rules-package messaging; broadened rules package detection/installation).
- Updated project settings/dependencies (LangVersion alignment; DacFx/SqlClient version adjustments; minor PackageReference metadata tweak).
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Vsix/Vsix.csproj | Aligns C# language version setting with repo build props. |
| src/SsmsVsix/SsmsVsix.csproj | Aligns language version; adjusts a PackageReference ExcludeAssets value casing. |
| src/SsmsVsix/Linter/Tagging/SqlLintTaggerProvider.cs | MEF tagger provider that conditionally enables SQL lint tagger per options/project settings. |
| src/SsmsVsix/Linter/Tagging/SqlLintTagger.cs | Tagger that converts cached analysis results into editor error/warning squiggles. |
| src/SsmsVsix/Linter/Tagging/LintResult.cs | Tracks lint violations via tracking spans for snapshot translation. |
| src/SsmsVsix/Linter/Linting/SqlAnalyzerDiagnosticInfo.cs | Diagnostic DTO for analyzer results (range/message/code/link). |
| src/SsmsVsix/Linter/Linting/SqlAnalysisCache.cs | Shared analysis cache with immediate + debounced analysis triggering. |
| src/SsmsVsix/Linter/Linting/PendingAnalysis.cs | Tracks pending analysis CTS + snapshot version per buffer. |
| src/SsmsVsix/Linter/Linting/DiagnosticSeverity.cs | Defines severity levels for lint diagnostics. |
| src/SsmsVsix/Linter/Linting/CachedAnalysisResult.cs | Stores cached violations tied to a snapshot version. |
| src/SsmsVsix/Linter/Linting/AnalyzerUtilities.cs | Runs tsqlanalyze, parses output, returns diagnostics. |
| src/SsmsVsix/Linter/Linting/AnalysisUpdatedEventArgs.cs | Event args for publishing updated analysis results. |
| src/SsmsVsix/Linter/ErrorList/TableEntriesSnapshot.cs | Error List snapshot implementation for SQL lint errors. |
| src/SsmsVsix/Linter/ErrorList/SqlLintTableDataSource.cs | Error List table source; manages per-file snapshots and sink subscriptions. |
| src/SsmsVsix/Linter/ErrorList/SqlLintError.cs | Maps diagnostics to Error List entry fields/severity. |
| src/SsmsVsix/Linter/ErrorList/SqlDocumentListener.cs | Hooks document creation to attach an Error List handler. |
| src/SsmsVsix/Linter/ErrorList/SinkManager.cs | Manages sink subscription lifetime. |
| src/SsmsVsix/Linter/ErrorList/DocumentHandler.cs | Listens to shared cache updates and pushes entries to Error List. |
| src/SsmsVsix/Dialogs/ManageRulesDialog.xaml | Updates UI text to mention additional rules package. |
| src/SqlServer.Rules.Report/SqlServer.Rules.Report.csproj | Adjusts DacFx package version. |
| src/Shared/Options/ToolOptions.cs | Adds option to disable live code analysis. |
| src/Shared/Extensions/ProjectExtension.cs | Recognizes/installs both SQL rules packages (SqlServer.Rules + TSQLSmellSCA). |
| src/DacFXToolLib/DacFXToolLib.csproj | Adjusts SqlClient and DacFx package versions (including a preview DacFx). |
Comment on lines
+76
to
+95
| private async Task PerformAnalysisAsync(ITextBuffer buffer, string filePath, string sqlVersion, string rules, string projectName, ITextSnapshot snapshot, string text, CancellationToken cancellationToken) | ||
| { | ||
| try | ||
| { | ||
| await Task.Delay(_debounceDelayMs, cancellationToken); | ||
|
|
||
| if (!cancellationToken.IsCancellationRequested) | ||
| { | ||
| PerformAnalysis(buffer, snapshot, text, filePath, sqlVersion, rules, projectName, cancellationToken); | ||
| } | ||
| } | ||
| catch (OperationCanceledException) | ||
| { | ||
| // Expected when user types again before delay expires | ||
| } | ||
| catch (ObjectDisposedException) | ||
| { | ||
| // CancellationTokenSource was disposed - this is fine, just stop | ||
| } | ||
| } |
Comment on lines
+18
to
+26
| public SqlAnalyzerDiagnosticInfo(Range range, string message, string errorCode, Uri helpLink) | ||
| { | ||
| this.Range = range; | ||
| this.Message = message; | ||
| this.ErrorCode = errorCode; | ||
| this.HelpLink = helpLink; | ||
| } | ||
|
|
||
| public Uri HelpLink { get; set; } |
Comment on lines
+78
to
+92
| lock (_snapshots) | ||
| { | ||
| if (_snapshots.TryGetValue(filePath, out TableEntriesSnapshot oldSnapshot)) | ||
| { | ||
| _snapshots.Remove(filePath); | ||
| NotifySinks(sink => sink.RemoveSnapshot(oldSnapshot)); | ||
| } | ||
|
|
||
| if (errors.Count > 0) | ||
| { | ||
| var snapshot = new TableEntriesSnapshot(filePath, errors); | ||
| _snapshots[filePath] = snapshot; | ||
| NotifySinks(sink => sink.AddSnapshot(snapshot)); | ||
| } | ||
| } |
Comment on lines
+55
to
+62
| // Send existing snapshots to new sink | ||
| lock (_snapshots) | ||
| { | ||
| foreach (TableEntriesSnapshot snapshot in _snapshots.Values) | ||
| { | ||
| sink.AddSnapshot(snapshot); | ||
| } | ||
| } |
Comment on lines
+102
to
+109
| lock (_snapshots) | ||
| { | ||
| if (_snapshots.TryGetValue(filePath, out TableEntriesSnapshot snapshot)) | ||
| { | ||
| _snapshots.Remove(filePath); | ||
| NotifySinks(sink => sink.RemoveSnapshot(snapshot)); | ||
| } | ||
| } |
Comment on lines
+114
to
+122
| lock (_snapshots) | ||
| { | ||
| foreach (TableEntriesSnapshot snapshot in _snapshots.Values) | ||
| { | ||
| NotifySinks(sink => sink.RemoveSnapshot(snapshot)); | ||
| } | ||
|
|
||
| _snapshots.Clear(); | ||
| } |
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.