diff --git a/assets/ObfuscatorTest.pbix b/assets/ObfuscatorTest.pbix index e8b9a11..35927d4 100644 Binary files a/assets/ObfuscatorTest.pbix and b/assets/ObfuscatorTest.pbix differ diff --git a/src/Dax.Vpax.Obfuscator/DaxModelObfuscator.cs b/src/Dax.Vpax.Obfuscator/DaxModelObfuscator.cs index a2512f9..dd548a7 100644 --- a/src/Dax.Vpax.Obfuscator/DaxModelObfuscator.cs +++ b/src/Dax.Vpax.Obfuscator/DaxModelObfuscator.cs @@ -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); } } diff --git a/src/Dax.Vpax.Obfuscator/DaxTextCollection.cs b/src/Dax.Vpax.Obfuscator/DaxTextCollection.cs index e09df7a..4987f2d 100644 --- a/src/Dax.Vpax.Obfuscator/DaxTextCollection.cs +++ b/src/Dax.Vpax.Obfuscator/DaxTextCollection.cs @@ -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;