Problem
Custom code analysis rules come from NuGet analyzer packages and are only discoverable once those packages have been restored. If the restored package is missing, or is a different version than the one referenced in the .sqlproj, the rule list in the Code Analysis dialog can be stale or incomplete — and nothing in the UI tells the user why.
This is easy to reproduce: reference a package version that is not available locally and restore.
error NU1102: Unable to find package SampleRules with version (>= 1.0.4)
- Found 1 version(s) in local-sampleRules [ Nearest version: 1.0.3 ]
Restore failed with 1 error(s) in 4.8s
At that point the dialog will show whatever rules were last resolvable, with no indication that they do not match the .sqlproj.
Proposed work
Show a warning in the Code Analysis dialog when the analyzer package is out of sync, with a button that runs the restore and then refreshes the rule list.
The dialog already has most of the plumbing:
CodeAnalysisState.message?: DialogMessageSpec renders a message bar
DialogMessageSpec already supports intent (so warning works) and buttons: DialogMessageButtonSpec[]
So the remaining work is:
- detecting the mismatch (see questions below)
- a new reducer in
CodeAnalysisReducers to trigger the restore
- refreshing the rules once the restore completes
Now that #22648 has landed a restoreProject method on ProjectsController, the button should be able to reuse it rather than shelling out separately.
Acceptance criteria
Problem
Custom code analysis rules come from NuGet analyzer packages and are only discoverable once those packages have been restored. If the restored package is missing, or is a different version than the one referenced in the
.sqlproj, the rule list in the Code Analysis dialog can be stale or incomplete — and nothing in the UI tells the user why.This is easy to reproduce: reference a package version that is not available locally and restore.
At that point the dialog will show whatever rules were last resolvable, with no indication that they do not match the
.sqlproj.Proposed work
Show a warning in the Code Analysis dialog when the analyzer package is out of sync, with a button that runs the restore and then refreshes the rule list.
The dialog already has most of the plumbing:
CodeAnalysisState.message?: DialogMessageSpecrenders a message barDialogMessageSpecalready supportsintent(sowarningworks) andbuttons: DialogMessageButtonSpec[]So the remaining work is:
CodeAnalysisReducersto trigger the restoreNow that #22648 has landed a
restoreProjectmethod onProjectsController, the button should be able to reuse it rather than shelling out separately.Acceptance criteria
.sqlproj