示例#1
0
 public bool CanInstrument()
 {
     try
     {
         if (InstrumentationHelper.HasPdb(_module, out bool embeddedPdb))
         {
             if (embeddedPdb)
             {
                 if (InstrumentationHelper.EmbeddedPortablePdbHasLocalSource(_module))
                 {
                     return(true);
                 }
                 else
                 {
                     _logger.LogWarning($"Unable to instrument module: {_module}, embedded pdb without local source files");
                     return(false);
                 }
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         _logger.LogWarning($"Unable to instrument module: '{_module}' because : {ex.Message}");
         return(false);
     }
 }
示例#2
0
 public bool CanInstrument()
 {
     try
     {
         return(InstrumentationHelper.HasPdb(_module));
     }
     catch (Exception ex)
     {
         _logger.LogWarning($"Unable to instrument module: '{_module}' because : {ex.Message}");
         return(false);
     }
 }
示例#3
0
        public void SkipEmbeddedPpdbWithoutLocalSource()
        {
            string       xunitDll     = Directory.GetFiles(Directory.GetCurrentDirectory(), "xunit.*.dll").First();
            var          loggerMock   = new Mock <ILogger>();
            Instrumenter instrumenter = new Instrumenter(xunitDll, "_xunit_instrumented", Array.Empty <string>(), Array.Empty <string>(), Array.Empty <string>(), Array.Empty <string>(), false, loggerMock.Object);

            Assert.True(InstrumentationHelper.HasPdb(xunitDll, out bool embedded));
            Assert.True(embedded);
            Assert.False(instrumenter.CanInstrument());
            loggerMock.Verify(l => l.LogWarning(It.IsAny <string>()));

            // Default case
            string coverletCoreDll = Directory.GetFiles(Directory.GetCurrentDirectory(), "coverlet.core.dll").First();

            instrumenter = new Instrumenter(coverletCoreDll, "_coverlet_core_instrumented", Array.Empty <string>(), Array.Empty <string>(), Array.Empty <string>(), Array.Empty <string>(), false, loggerMock.Object);
            Assert.True(InstrumentationHelper.HasPdb(coverletCoreDll, out embedded));
            Assert.False(embedded);
            Assert.True(instrumenter.CanInstrument());
            loggerMock.VerifyNoOtherCalls();
        }
示例#4
0
 public bool CanInstrument() => InstrumentationHelper.HasPdb(_module);
 public void TestHasPdb()
 {
     Assert.True(InstrumentationHelper.HasPdb(typeof(InstrumentationHelperTests).Assembly.Location, out bool embeddedPdb));
     Assert.False(embeddedPdb);
 }
示例#6
0
 public void TestHasPdb()
 {
     Assert.True(InstrumentationHelper.HasPdb(typeof(InstrumentationHelperTests).Assembly.Location));
 }