1
 using System;
 using System.Diagnostics;
 using NUnit.Framework;

 namespace TestExperiment
 {
     [TestFixture]
     internal class TestAAA
     {
         [Test]
         public void Test_ThrowSwallowThirdParty()
         {
             ThrowSwallowThirdParty();
         }

         [Test]
         public void Test_ThrowSwallowLocal()
         {
             ThrowSwallowLocal();
         }

         [DebuggerStepThrough]
         [DebuggerNonUserCode]
         [DebuggerHidden]
         public void ThrowSwallowThirdParty()
         {
             ThirdPartyLibrary.ThrowEmbedded();
         }

         [DebuggerStepThrough]
         [DebuggerNonUserCode]
         [DebuggerHidden]
         public void ThrowSwallowLocal()
         {
             try
             {
                 throw new Exception();
             }
             catch (Exception e)
             {
             }
         }
     }

     // imagine this is a 3rd party library provided in a dll which I am referencing
     internal static class ThirdPartyLibrary
     {
         public static void ThrowEmbedded()
         {
             try
             {
                 throw new Exception();
             }
             catch (Exception e)
             {
             }
         }
     }
 }

As per here and here I understand you can use the [DebuggerHidden] attribute to prevent the debugger from stopping at a swallowed exception even if it is told to break on all thrown exceptions. This works for Test_ThrowSwallowLocal(). However I would like to duplicate this when calling code in a 3rd party library which is throwing and swallowing its own exceptions - which I am trying to emulate in Test_ThrowSwalloThirdParty() - at the moment the debugger continues to break at the exception throw.

Is there a way to avoid this without editing the ThirdPartyLibrary code (which I cannot easily do?)

Community
  • 1
  • 1
fostandy
  • 4,282
  • 4
  • 37
  • 41

1 Answers1

2

I would look into the Just My Code Option in VS

Micah Armantrout
  • 6,781
  • 4
  • 40
  • 66