Reputation: 51063
I have the following code:
Debug.Assert(model.OrganizationId != null, "model.OrganizationId != null");
var orgId = model.OrganizationId.Value;
Yet the Debug.Assert
line is grayed out, and when I hover over it, I get the message:
Method invocation is skipped. Compiler will not generate method invocation because method is conditional, or is partial method without implementation.
My IDE is in Debug
mode and I see nothing else unusual. Why is this assert being skipped? I am not too concerned with OrganizationId
being null, as it is marked as Required
on the model, but I am concerned that a very normal looking Debug.Assert
is being skipped.
Upvotes: 3
Views: 343
Reputation: 19149
Debug.Assert is marked with this attribute.
[System.Diagnostics.Conditional("DEBUG")]
That means this method is compiled when you have the "DEBUG" constant defined in your project configuration.
Note that this is irrelevant to release or debug build mode. But by default debug configuration has "DEBUG" constant defined.
In order to fix this goto your project settings, build section, make sure configuration is set to Debug. Then tick the option "define DEBUG constant".
Upvotes: 3