Reputation: 97
I am being plagued by weird behavior in a debug build of a C# project (target .Net Framework 4.7.2).
var wHasOvernightShifts = this.ScheduleSegments.Any(
x => x.SegmentTypeId == eSegmentType.Schedule
&& !x.IsDeleted
&& x.ShiftDate == pShiftDate
&& x.StartTime.Value.DayOfWeek != x.FinishTime.Value.DayOfWeek);
I know this to be the wrong answer. When I evaluate the RHS in Quick Watch (at the same point with the same data) the same code returns true. Step back the debugger and re-execute the statement returns false again. (n.b. All properties referenced have no side affects).
If I perform a clean and rebuild then everything behaves as expected. Note that a rebuild by itself is insufficient.
In case 2, following a clean/rebuild, the method returns a non-empty collection and the breakpoint inside it works, as does step-into.
It looks like the incremental part of the compiler is broken, or the execution environment has just forgotten that the module is loaded.
Has anyone else hit similar problems? Is there a simple solution (apart from clean/rebuild)?
n.b. I have turned off "Enable Just My Code" and turned on "Require source files to exactly match the original version" in an attempt to cure this problem - no luck.
Upvotes: 2
Views: 232
Reputation: 97
It has been several weeks now since I updated the project to make sure that each configuration builds into a separate directory. The problem seems to have gone away.
I am pretty sure that this was the solution to the problem.
Upvotes: 1