NonNullablePropertyHelper uses NullabilityInfoContext to get info about nullability of the given property. There was used WriteState to get that info. But when property has no setter, WriteState is null.
The fix is to use ReadState instead WriteState, because property has to have getter when it should be validated.
I've created separate commit with failing tests to repro the bug: b6ba1c0e55743304448e6e3522a89c0afca2e445
NonNullablePropertyHelper
usesNullabilityInfoContext
to get info about nullability of the given property. There was usedWriteState
to get that info. But when property has no setter,WriteState
isnull
.The fix is to use
ReadState
insteadWriteState
, because property has to have getter when it should be validated.I've created separate commit with failing tests to repro the bug: b6ba1c0e55743304448e6e3522a89c0afca2e445
Tests that fail:
NonNullablePropertyHelperTests.IsNonNullableReferenceType_Identifies_Correct_Properties_Of_Class
TryValidate.PropertyWithoutSetter_Nullable_Valid_When_Null
This PR solves #16