diff --git a/ICSharpCode.Decompiler/Ast/AstBuilder.cs b/ICSharpCode.Decompiler/Ast/AstBuilder.cs index aa97dc9bf..8dbf82cd3 100644 --- a/ICSharpCode.Decompiler/Ast/AstBuilder.cs +++ b/ICSharpCode.Decompiler/Ast/AstBuilder.cs @@ -1521,7 +1521,8 @@ namespace ICSharpCode.Decompiler.Ast } var type = argument.Type.Resolve(); if (type != null && type.IsEnum) { - return MakePrimitive(Convert.ToInt64(argument.Value), type); + long val = (long)CSharpPrimitiveCast.Cast(TypeCode.Int64, argument.Value, false); + return MakePrimitive(val, type); } else if (argument.Value is TypeReference) { return CreateTypeOfExpression((TypeReference)argument.Value); } else { diff --git a/ICSharpCode.Decompiler/Tests/CustomAttributes/S_CustomAttributes.cs b/ICSharpCode.Decompiler/Tests/CustomAttributes/S_CustomAttributes.cs index 37c1c0d71..67052909a 100644 --- a/ICSharpCode.Decompiler/Tests/CustomAttributes/S_CustomAttributes.cs +++ b/ICSharpCode.Decompiler/Tests/CustomAttributes/S_CustomAttributes.cs @@ -39,6 +39,11 @@ namespace aa { } } + [CustomAttributes.MyAttribute(CustomAttributes.ULongEnum.MaxUInt64)] + public enum ULongEnum : ulong + { + MaxUInt64 = 18446744073709551615uL + } [CustomAttributes.MyAttribute(CustomAttributes.EnumWithFlag.Item1 | CustomAttributes.EnumWithFlag.Item2)] private static int field; [CustomAttributes.MyAttribute(CustomAttributes.EnumWithFlag.All)] diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/ICSharpCode.NRefactory.VB.Tests.csproj b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/ICSharpCode.NRefactory.VB.Tests.csproj index 53e04c07e..ee1d38229 100644 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/ICSharpCode.NRefactory.VB.Tests.csproj +++ b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/ICSharpCode.NRefactory.VB.Tests.csproj @@ -102,5 +102,8 @@ ICSharpCode.NRefactory + + + \ No newline at end of file