While writing some of the specs for ViewWeaver, I noticed that one was failing:
When passed a type with one write only property
- it should return no mappings
When I stepped through the code, it was indeed not filtering out the write only property. This is the code used to find all readable properties:
For some reason
CanRead was returning true, then I noticed how I had defined my class under test:
So it turns out that even though I had filtered to all Public Properties, a private Getter (or Setter) still passes through.
Changing the expression to check for the GetMethod existing, and being public fixed this, and seems obvious in retrospect, but it is worth remembering that an Auto Property is ever so slightly different from a plain property with only a Get or Set method defined.