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

Missing Properties from Parent/Child classes in new Feature #110

Open
Jadaw1n opened this issue Sep 17, 2018 · 3 comments
Open

Missing Properties from Parent/Child classes in new Feature #110

Jadaw1n opened this issue Sep 17, 2018 · 3 comments

Comments

@Jadaw1n
Copy link

Jadaw1n commented Sep 17, 2018

Hi

When creating a new Feature (and possibly other objects) with the properties = a child class, then the Parent properties aren't in the resulting properties.

Using this code:

// class structure
        public class Parent
        {
            public string ParentString { get; set; } = "Test Parent";
        }

        public class Child : Parent
        {
            public string ChildString { get; set; } = "Test Child";
        }

// run this bit
var ls = new LineString(new List<Position> { new Position(47, 8), new Position(47.1, 8) });
var x = new Feature(ls, new Child()); // <--

results in the following value for x.Properties:

x.Properties
Count = 1
[0]: {[ChildString, Test Child]}

Where I'd expect it to have both ChildString and ParentString properties.
Is this an oversight, or is it maybe configurable somehow?

Otherwise thanks for the great library :)

@xfischer
Copy link
Member

Hi @Jadaw1n, thanks for taking time.
The current method reads public properties from the supplied type, and could look at the BaseType.
I'm not sure on how to implement this.
@matt-lethargic I would recurse on BaseType until hitting "System.Object". I don't know if there's a better way.
BTW perfs seem awful, maybe should we test and implement a simple property cache to speed up things.

@Jadaw1n
Copy link
Author

Jadaw1n commented Sep 18, 2018

Looked a bit through the source code, and exactly there you have a differentiation for 3.5/4.0 vs. newer versions of .Net. https://github.com/GeoJSON-Net/GeoJSON.Net/blob/master/src/GeoJSON.Net/Feature/Feature.cs#L160
If you just use the code meant for 3.5 it should work just like this. Or does it have an even bigger performance impact?

@xfischer
Copy link
Member

@Jadaw1n The bad perfs were while testing for .Net Standard. "Classic" code should work ok.
I'll try to get that fixed by the end of the week.

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

2 participants