m-kovalsky / Tabular

Useful code for tabular modeling and automation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Script to ExportBPAResults fails (TE3)

eudesmcf opened this issue · comments

Hello @m-kovalsky ,

The script gives an error when I try to run it.

https://github.com/m-kovalsky/Tabular/blob/master/ExportBPAResults.cs

image

Can you help?

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.

Hi @m-kovalsky.

The problem continue, I'm using TE3 3.14.

image

See the script now. Make sure to use the second line instead of the first line when executing in TE3.

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();

I updated the script for use with TE2. Try it now.