Skip to content

Commit

Permalink
Fix error in incremental obfuscation when a KPI already exists (#14)
Browse files Browse the repository at this point in the history
* Update ObfuscatorTest.pbix

* Fix KPIs incremental obfuscation error
  • Loading branch information
albertospelta authored Mar 2, 2024
1 parent d9f2659 commit b305f72
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Binary file modified assets/ObfuscatorTest.pbix
Binary file not shown.
4 changes: 4 additions & 0 deletions src/Dax.Vpax.Obfuscator/DaxModelObfuscator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ void CreateKpiMeasure(DaxExpression kpi, string type)
var text = new DaxText($"_{measureText.Value} {type}");
text.ObfuscatedValue = $"_{measureText.ObfuscatedValue} {type}";

// It may already exist in case of incremental obfuscation
if (Texts.IsIncrementalObfuscation && Texts.Contains(text))
return;

Texts.Add(text);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Dax.Vpax.Obfuscator/DaxTextCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ public DaxTextCollection(ObfuscationDictionary? dictionary = null)
{
if (dictionary != null)
{
IsIncrementalObfuscation = true;
foreach (var text in dictionary.Texts)
Add(new DaxText(text.Value, text.Obfuscated));
}
}

public bool IsIncrementalObfuscation { get; }

public int Count => _plaintexts.Count;

public bool IsReadOnly => false;
Expand Down

0 comments on commit b305f72

Please sign in to comment.