Property with two starting capital letters not updating providers

Issue #74 resolved
Andrew L created an issue

Not sure if this is a bug or intentional w.r.t naming conventions.

If I name my get/set property (an enum) starting with two capital letters (I did not test more than two capitals), my provider scripts fail to get updated with new values. I read up on the naming conventions part of the wiki, and didn't see any mention of a case like this.

// DataContext.cs

    private readonly Property<ARStateEnum> arStateProperty = new Property<ARStateEnum>();
    public ARStateEnum ARState { // If I use "ArState", everything works fine
      get {
        return arStateProperty.Value;
      }
      set {
        arStateProperty.Value = value;
      }
    }
// ARStateEnumConstant.cs

    public enum ARStateEnum {
        Inactive,
        Searching,
        Hit,
        Anchored
    }

Comments (7)

  1. Christian Oeing repo owner

    Hi Andrew,

    Thanks for your report.

    This is the expected behaviour. The data property field is looked up via reflection. In the DataBind settings asset in your project you can set the naming convention to use. The default one is to append "Property" and make THE FIRST character lower case.

    In your example it would need the first two characters to be made lower case. I agree that it would look strange to write aRStateProperty though. Unfortunately it wouldn't be a good option to make everything lower case (which would mean the field has to be named arstateProperty).

    If you can think of a solution that wouldn't result in more work for the lookup (which would mean a performance loss that I'd like to avoid), let me know :) Otherwise I will close the bug as "Won't fix".

    Cheers Christian

  2. Andrew L reporter

    Oooh, I understand. Thanks Christian, that definitely makes sense. I think I didn't recognize the 'r' was lowercase in the property.

  3. Christian Oeing repo owner

    Yeah, I see the issue with abbreviations at the start of a property. I will try to add a setting like "case insensitive", so all upper/lower case combinations are allowed.

  4. Christian Oeing repo owner

    I added a toggle to the data bind settings to enable the case insensitive search for a data provider backing field. By default it is disabled, so the behaviour of existing projects doesn't change. If it's enabled, a lookup of the data path "ARState" would find the backing field "arStateProperty". It would also find a backing field called "arstateproperty" or "aRStaTEProPERty".

  5. Log in to comment