Exception thrown when converting System.Enum To System.Int64 in CustomAttribute #716

Closed
JasonAtGithub opened this Issue May 31, 2016 · 2 comments

Projects

None yet

2 participants

@JasonAtGithub

if (type != null && type.IsEnum) {
return MakePrimitive(Convert.ToInt64(argument.Value), type);
}
In file AstBuilder.cs[line:1524].

My Type definition:
public enum AppID
{
Invalid = 18446744073709551615,
}

The value is overflow, since Its type is System.UInt64.

@siegfriedpammer
Member

Hi, I just tried to reproduce this with the most recent nightly build but was unable to do so. I used your code as example for testing, but it seems ILSpy produces the correct code:

using System;

namespace Bug716
{
    public enum AppID : ulong
    {
        Invalid = 18446744073709551615uL
    }
}
@siegfriedpammer siegfriedpammer self-assigned this Jun 1, 2016
@siegfriedpammer siegfriedpammer added this to the vNext milestone Jun 1, 2016
@JasonAtGithub

Sorry for your time, I have tested the code above, It works well. I just change my code and add system attribute System.ComponentModel.DefaultValue to it, it throw an exception mentioned above.
Code:
[System.ComponentModel.DefaultValue(AppID.Invalid)] public enum AppID : ulong { Invalid = 0xFFFFFFFFFFFFFFFFul, }
@siegfriedpammer

@JasonAtGithub JasonAtGithub changed the title from Exception thrown when converting System.Enum To System.Int64 to Exception thrown when converting System.Enum To System.Int64 in CustomAttribute Jun 1, 2016
@dgrunwald dgrunwald closed this in a6ae2e4 Jun 2, 2016
@siegfriedpammer siegfriedpammer modified the milestone: vNext, 2.4 Jun 5, 2016
@glenrgordon glenrgordon added a commit to glenrgordon/ILSpy that referenced this issue Jul 9, 2016
@dgrunwald @glenrgordon dgrunwald + glenrgordon Fix #716: OverflowException when converting System.Enum To System.Int…
…64 in CustomAttribute
422c7cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment