Script to ExportBPAResults fails (TE3)
eudesmcf opened this issue · comments
eudesmcf commented
Hello @m-kovalsky ,
The script gives an error when I try to run it.
https://github.com/m-kovalsky/Tabular/blob/master/ExportBPAResults.cs
Can you help?
m-kovalsky commented
I updated the script to account for differences between TE2 & TE3 and inherent changes in how c# is processed in both applications. Now it should work. Thanks for reporting.
eudesmcf commented
m-kovalsky commented
See the script now. Make sure to use the second line instead of the first line when executing in TE3.
eudesmcf commented
Hi @m-kovalsky, in TE3 it works when you include the LoadExternalRuleCollectionsAsync method.
//using TabularEditor.BestPracticeAnalyzer; // Use this for Tabular Editor 2
using TabularEditor.Shared.BPA; // Use this instead of the first line when using Tabular Editor 3
var bpa = new Analyzer();
bpa.SetModel(Model);
bpa.LoadExternalRuleCollectionsAsync(); // When using Tabular Editor 3
var sb = new System.Text.StringBuilder();
string newline = Environment.NewLine;
sb.Append("RuleCategory" + '\t' + "RuleName" + '\t' + "ObjectName" + '\t' + "ObjectType" + '\t' + "RuleSeverity" + '\t' + "HasFixExpression" + newline);
foreach (var a in bpa.AnalyzeAll().ToList())
{
sb.Append(a.Rule.Category + '\t' + a.RuleName + '\t' + a.ObjectName + '\t' + a.ObjectType + '\t' + a.Rule.Severity + '\t' + a.CanFix + newline);
}
// Output the results
sb.Output();
m-kovalsky commented
I updated the script for use with TE2. Try it now.