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

[bug] ignoring does not work correctly #15

Closed
TMaddox opened this issue Aug 31, 2019 · 3 comments
Closed

[bug] ignoring does not work correctly #15

TMaddox opened this issue Aug 31, 2019 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@TMaddox
Copy link

TMaddox commented Aug 31, 2019

This works:

    public class Tree
    {
        [CborProperty("age")]
        public readonly int _age;

        [CborConstructor]
        public Tree(int age)
        {
            _age = age;
        }
    }

While this throws: CborException: Cannot find a field or property named age on type TestApp.Tree

    public class Tree
    {
        [CborProperty("age")]
        public readonly int _age;

        [CborIgnore]
        public long Age2 => 5;     // 1

        [CborConstructor]
        public Tree(int age)
        {
            _age = age;
        }
    }

if you replace the long in the row // 1 with an int, it does work. I tried to ignore it with the [CborIgnore] approach and this one #10, but both doesn't help

@mcatanzariti
Copy link
Member

Please, could you give the whole sample with the CborOptions you initialized?

@TMaddox
Copy link
Author

TMaddox commented Aug 31, 2019

Really hard to say in a few words, can't really break it down to my usual tree example. Basically, I am adding a few custom types with: CborOptions.Default.Registry.ConverterRegistry.RegisterConverter(typeof(byte[]), new DsonObjectConverter<byte[]>(x => x, y => y)); (note: dson = cbor)

and then I am adding exactly what you suggested right here #10

In case you want to have a closer look about how I added these options: https://github.com/helium-party/radixdlt-net/blob/feature/serialization/HeliumParty.RadixDLT/src/HeliumParty.RadixDLT.Dson/Mapping/DsonOutputMapping.cs

@mcatanzariti
Copy link
Member

The issue was about the framwork not being able to match constructor parameter name with field name because of the ''.

The type int or long of the field Age is not changing the problem

@mcatanzariti mcatanzariti self-assigned this Sep 1, 2019
@mcatanzariti mcatanzariti added the bug Something isn't working label Sep 1, 2019
mcatanzariti pushed a commit that referenced this issue Sep 1, 2019
- try to match constructor parameters with MemberName from CborProperty if it exists
- [bug] ignoring does not work correctly #15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants