Skip to content

Commit

Permalink
Even if AnalysisSucceded, there could be errors from analysis. This w…
Browse files Browse the repository at this point in the history
…as discovered during a debuggimng session with the AdventureWorks schema. (#708)

Changed the implementation to always report any errors.

Updated SqlServer.Rules: This analyzer was previously split into two .dll files, and this was not handled well in multiple scenarios

Updated TSqlSmellsSCA: Fixed NRE triggered by Computed columns in AdventureWorks schema

fixes #707
  • Loading branch information
ErikEJ authored Feb 3, 2025
1 parent e0c845b commit eaf890e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
6 changes: 4 additions & 2 deletions MSBuild.Sdk.SqlProj.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
# Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178 d17.12
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B0420F9B-A902-4E9D-8B29-55B4F626483B}"
EndProject
Expand All @@ -10,6 +10,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D25C8812-D92E-41D5-9BC9-30AFCF45063B}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.github\workflows\main.yml = .github\workflows\main.yml
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DacpacTool", "src\DacpacTool\DacpacTool.csproj", "{78CA944A-928F-48FA-B29F-C5DC96E67684}"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ You should now have a project file with the following contents:
<ItemGroup>
<!-- These packages adds additional code analysis rules -->
<!-- We recommend using these, but they can be removed if desired -->
<PackageReference Include="ErikEJ.DacFX.SqlServer.Rules" Version="1.2.0">
<PackageReference Include="ErikEJ.DacFX.SqlServer.Rules" Version="1.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ErikEJ.DacFX.TSQLSmellSCA" Version="1.2.0">
<PackageReference Include="ErikEJ.DacFX.TSQLSmellSCA" Version="1.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down Expand Up @@ -615,11 +615,11 @@ We know of the following public rules NuGet packages, that you can add to your p
```xml
<ItemGroup>
<PackageReference Include="ErikEJ.DacFX.SqlServer.Rules" Version="1.2.0">
<PackageReference Include="ErikEJ.DacFX.SqlServer.Rules" Version="1.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ErikEJ.DacFX.TSQLSmellSCA" Version="1.2.0">
<PackageReference Include="ErikEJ.DacFX.TSQLSmellSCA" Version="1.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
13 changes: 8 additions & 5 deletions src/DacpacTool/PackageAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,16 @@ public void Analyze(TSqlModel model, FileInfo outputFile, FileInfo[] analyzers)
}

var result = service.Analyze(model);

var errors = result.GetAllErrors();
foreach (var err in errors)
{
_console.WriteLine(err.GetOutputMessage());
}

if (!result.AnalysisSucceeded)
{
var errors = result.GetAllErrors();
foreach (var err in errors)
{
_console.WriteLine(err.GetOutputMessage());
}
_console.WriteLine($"Analysis of package '{outputFile}' failed");
return;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<ItemGroup>
<!-- These packages adds additional code analysis rules -->
<!-- We recommend using these, but they can be removed if desired -->
<PackageReference Include="ErikEJ.DacFX.SqlServer.Rules" Version="1.2.0">
<PackageReference Include="ErikEJ.DacFX.SqlServer.Rules" Version="1.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ErikEJ.DacFX.TSQLSmellSCA" Version="1.2.0">
<PackageReference Include="ErikEJ.DacFX.TSQLSmellSCA" Version="1.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit eaf890e

Please sign in to comment.