mgravell / fast-member

Automatically exported from code.google.com/p/fast-member
Apache License 2.0
1.03k stars 139 forks source link

[Feature Request] Support alternate property names from Attributes #81

Open gilmae opened 4 years ago

gilmae commented 4 years ago

Super contrived example:

public class Foo {

   [JsonProperty("bar-baz")]
   [DataMember(Name="bar_baz")]
   [XmlAttribute(AttributeName="barBaz")]
   public string BarBaz {get; set;}
}

var f = new Foo();
var a = TypeAccessor.Create(typeof(Foo));

a[f, "bar-baz"]
a[f, "barBaz"]
a[f, "bar_baz"]

Scenarios in which the property is requested using one of the serialised names will fail with an exception. (The mooted IsDefined(name) method would help here

It would be desirable if the accessor supports the serialised versions of property names.