I have a property with a getter method and a setter backing field. I get this error message. Although the code calculates the value and assigns it, nothing in the code gets the value. But the property IS bound to a control in xaml. So actually, it WILL be read, just not in code.
I wish I could suppress this warning as it actually isn’t true (though of course, as far as the CODE part of the project is concerned, it is).
I suppose I could do some bogus read of the property somewhere which would get rid of the error message, but that doesn’t seem like a good idea.
Am I missing something?
… time passes …
hmm… I added this to the constructor:
EditObservationViewModel = public partial class( DBViewModel, IEditableObject )
...
constructor EditObservationViewModel;
begin
// bogus code to avoid compiler warning
var x := OverallBehaviorSafePercent;
x := OverallConditionSafePercent;
...
I still get the error message on the two properties on the right side. I thought having that code there would get rid of the error message, but it just put it in a new spot.
So now it is in TWO spots. I have split the viewmodel that contains this code into two files that are two partial classes. Now both of them complain. Is there maybe something about them being partials that is confusing the compiler?
Here is the declaration in the first partial class:
property OverallConditionSafePercent : nullable Int32 read GetOverallConditionSafePercent write fOverallConditionSafePercent; notify;
property OverallBehaviorSafePercent : nullable Int32 read GetOverallBehaviorSafePercent write fOverallBehaviorSafePercent; notify;
Here is the other part:
EditObservationViewModel = public partial class( DBViewModel, IEditableObject )
private
function CalculateOverallConditionSafePercent : nullable Int32;
function CalculateOverallBehaviorSafePercent : nullable Int32;
private
fOverallBehaviorSafePercent: nullable Int32;
method GetOverallBehaviorSafePercent: nullable Int32;
private
fOverallConditionSafePercent: nullable Int32;
method GetOverallConditionSafePercent: nullable Int32;
… time passes …
I tried moving the property together with the getter and backing field in the same partial class file. That didn’t help. Then I put it back the way it was and now there is no warning. I’m reloading the IDE and the solution and seeing if I can reproduce the problem.