Created
February 15, 2012 10:16
-
-
Save gfraiteur/1834882 to your computer and use it in GitHub Desktop.
Debug a StackOverflowException in 1 minute with PostSharp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using PostSharp.Aspects; | |
using PostSharp.Aspects.Configuration; | |
using PostSharp.Aspects.Serialization; | |
using Resonance.Messenging.Diagnostics; | |
[assembly: StackOverflowDetection] | |
namespace Resonance.Messenging.Diagnostics | |
{ | |
[OnMethodBoundaryAspectConfiguration(SerializerType = typeof(MsilAspectSerializer))] | |
public class StackOverflowDetectionAttribute : OnMethodBoundaryAspect | |
{ | |
[ThreadStatic] private static int level; | |
public override void OnEntry(MethodExecutionArgs args) | |
{ | |
level++; | |
if ( level > 100 ) throw new StackOverflowException(); | |
} | |
public override void OnExit(MethodExecutionArgs args) | |
{ | |
level--; | |
} | |
} | |
} |
Aah, you were the inventor. I couldn't remember :).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I know this one! ;-)
http://blog.johanneshoppe.de/2011/01/findstackoverlowattribute-vs-stackoverlowexception/