New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

This comment has been minimized.

Show comment
Hide comment
@siegfriedpammer

siegfriedpammer Jun 1, 2016

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
    }
}
Member

siegfriedpammer commented Jun 1, 2016

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

This comment has been minimized.

Show comment
Hide comment
@JasonAtGitHub

JasonAtGitHub Jun 1, 2016

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

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 milestones: vNext, 2.4 Jun 5, 2016

glenrgordon added a commit to glenrgordon/ILSpy that referenced this issue Jul 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment