diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs index 743aaae17..6862acb88 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs @@ -685,12 +685,14 @@ namespace ICSharpCode.Decompiler.CSharp } } + readonly HashSet definedSymbols = new HashSet(); + void AddDefinesForConditionalAttributes(ILFunction function) { foreach (var call in function.Descendants.OfType()) { var attr = call.Method.GetAttribute(new TopLevelTypeName("System.Diagnostics", nameof(ConditionalAttribute))); var symbolName = attr?.PositionalArguments.FirstOrDefault()?.ConstantValue as string; - if (symbolName == null) + if (symbolName == null || !definedSymbols.Add(symbolName)) continue; syntaxTree.InsertChildAfter(null, new PreProcessorDirective(PreProcessorDirectiveType.Define, symbolName), Roles.PreProcessorDirective); }