From d9187912f16fcf9991e6a2c2ef4c5a2ecbbd5a41 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 18 Jul 2018 14:15:50 +0200 Subject: [PATCH] Fix #1216: OverflowException while decompiling enum value. --- ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs index 4d3c6756b..408af5557 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs @@ -1144,7 +1144,7 @@ namespace ICSharpCode.Decompiler.CSharp enumDec.Initializer = typeSystemAstBuilder.ConvertConstantValue(decompilationContext.CurrentTypeDefinition.EnumUnderlyingType, field.ConstantValue); if (enumDec.Initializer is PrimitiveExpression primitive && (decompilationContext.CurrentTypeDefinition.HasAttribute(KnownAttribute.Flags) - || (initValue > 9 && ((initValue & (initValue - 1)) == 0 || (initValue & (initValue + 1)) == 0)))) + || (initValue > 9 && (unchecked(initValue & (initValue - 1)) == 0 || unchecked(initValue & (initValue + 1)) == 0)))) { primitive.SetValue(initValue, $"0x{initValue:X}"); }