Unity3D version: 5.6.1f1 Personal.
Summary / TLDR
How do I get the Unity3D debugger to show an exception in the calling function/method?
Details
I'm trying to use a static class/method to make null checks easier. In this static class Ensure
I have a static method NotNull
with the System.Diagnostics.DebuggerStepThrough
attribute on it. This method does the typical null check and exception throwing for me. This attribute is supposed to, as I understand it, make it look like the calling method is throwing the exception. It's not.
The unity debugger still shows the exception being thrown in the static class's method. Does anyone know what I'm missing to get the debugger to work as I described earlier? I've tried this with JMC enabled and disabled.
Static class & method
public static class Ensure
{
[System.Diagnostics.DebuggerStepThrough]
public static void NotNull(object valueToTest, string valueName)
{
if (valueToTest == null)
throw new System.NullReferenceException(valueName + " is null");
}
}
Calling the method
public class foo
{
public Timer()
{
object obj = null;
Ensure.NotNull(obj, "obj");
}
}