Pregunta

En Delphi las directivas del compilador {$ d-} y {} $ l- le permiten evitar de manera efectiva la generación de depuración y la información variable local para una sección de código definido.

En la práctica que tiene el efecto de "ocultar" el código de la vista de depuración, que no aparece en la pila de llamadas y no lo hace entrar en él durante la depuración.

¿Hay alguna manera de conseguir el mismo resultado en C # utilizando VS 2008?

Nota: La razón es que tenemos un marco estable que no necesita ser depurado, pero tienden a estropear con la pila de llamadas y con el flujo de depuración estándar.

¿Fue útil?

Solución

I use DebuggerNonUserCodeAttribute so that you by default do not break or step into the code; However, the benifit to this over DebuggerStepThrough is that you can go to the Options->Debugger->Just My Code setting and allow breaking/debugging of the code you marked. This helps significantly if you have issues. I typically use it on entire classes.

BTW, the call stack will automatically hide non-user code as marked with this attribute :) Of course you can simply right-click the call stack window and toggle "Show External Code" to hide/show the missing stack information.

Otros consejos

I think you want the DebuggerStepThrough attribute:

DebuggerStepThrough instructs the debugger to step through the code instead of stepping into the code.

[DebuggerStepThrough]
public void MyMethod()
{

}

This is especially useful for setters/getters since debugging into those usually just adds noise (example from msdn):

public int Quantity
{ 
    [DebuggerStepThrough] 
    get { return ComplexLogicConvertedToMethod(); } 
    [DebuggerStepThrough]      
    set { this.quantity = value ; }
}

Or to skip a specific section of the code:

... some production code
#if DEBUG
    Console.WriteLine("Debug version");
#endif
... some more production code
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top