Skip to content
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

ArgumentOutOfRangeException when accessing private Enum #10

Open
GoogleCodeExporter opened this issue Oct 26, 2015 · 1 comment
Open

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1.
This enum:
----------
public enum EnumA
{
    One,
    Two,
    Three
}

This class:
-----------
public class ClassD
{
    private EnumA _foo;

    public void SetFoo(EnumA foo)
    {
        _foo = foo;
    }

    public EnumA GetFoo()
    {
        return _foo;
    }
}

This test:
----------
[Test]
public void Cant_deserialize_enum()
{
    var value = new ClassD();
    value.SetFoo(EnumA.One);
    var accessor = TypeAccessor.Create(typeof(ClassD));
    var accessed = accessor[value, "_foo"];
    var foo = (EnumA)accessed;
}

What is the expected output? What do you see instead?
It should deserialize--flipping _foo to a public field shows correct behavior, 
private results in ArgumentOutOfRangeException 


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by daniel.crenna on 6 Apr 2014 at 4:40

@GoogleCodeExporter
Copy link
Author

Should note that casting to (object) like other private value types in the unit 
test suite does not work here, as we're not invoking the setter, only the 
getter.

Original comment by daniel.crenna on 6 Apr 2014 at 4:41

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

No branches or pull requests

1 participant