public void Should_verify_current_assembly() { var verify = PeVerifier.Verify(assemblyPath, GetIgnoreCodes(), out var output); Assert.True(verify); Assert.NotNull(output); }
public void Should_verify_current_assembly() { var verify = PeVerifier.Verify(GetAssemblyPath(), Enumerable.Empty<string>(), out var output); Assert.True(verify); Assert.NotNull(output); Assert.NotEmpty(output); }
private void RunPeVerify(IEnumerable <string> ignoreErrorCodes) { Action action = () => { var runIlSpy = false; try { PeVerifier.Verify(WeavedAssemblyPath, ignoreErrorCodes); } catch (Exception) { runIlSpy = true; throw; } finally { if (runIlSpy || IlSpy.AlwaysRunIlSpy) { RunIlSpy(); } } }; action.Should().NotThrow(); }
protected void AssertRunPeVerify(ModuleWeaver weaver) { Action action = () => { var runIlSpy = false; try { PeVerifier.Verify(Weave.DllPath); } catch (Exception) { runIlSpy = true; throw; } finally { if (runIlSpy || IlSpy.AlwaysRunIlSpy) { var methodName = weaver?.MethodFilters.Single(); IlSpy.ShowMethod(methodName, Weave.DllPath); IlSpy.ShowMethod(methodName, Source.DllPath); Thread.Sleep(TimeSpan.FromSeconds(2)); // wait until ILSpy is started because weaved dll will be deleted when unittests exits -> TryCleanupWeavedFiles() } } }; action.Should().NotThrow(); }
private void RunPeVerify() { Action action = () => { var runIlSpy = false; try { PeVerifier.Verify(WeavedAssemblyPath); } catch (Exception) { runIlSpy = true; throw; } finally { if (runIlSpy || IlSpy.AlwaysRunIlSpy) { RunIlSpy(); } } }; action.Should().NotThrow(); }
public void Setup() { var weavingTask = new ModuleWeaver { ClassNames = new List <string> { BaseClassName }, AllowNonPublic = ProcessNonPublicToo }; var asm = Assembly.GetAssembly(typeof(InjectionTests)); var subjectPath = Path.Combine(Path.GetDirectoryName(asm.Location), TestLibraryName); // run pe verify separately to prevent 'Unable to resolve token.(Error: 0x80131869)' errors with weavingTask var valid = PeVerifier.Verify(subjectPath, subjectPath, PEVerifyIgnoreCodes, out var beforeOutput, out var afterOutput); Assert.IsTrue(valid); testResult = weavingTask.ExecuteTestRun(subjectPath, runPeVerify: false); processedAssembly = testResult.Assembly; TestContext.Out.WriteLine($"Run tests for {BaseClassName}, {nameof(ProcessNonPublicToo)}={ProcessNonPublicToo}"); }
bool InnerVerify() { if (!File.Exists(TargetPath)) { Logger.LogInfo($" Cannot verify assembly, file '{TargetPath}' does not exist"); return(true); } if (!ReadShouldVerifyAssembly(out var ignoreCodes)) { Logger.LogInfo(" Skipped Verifying assembly since it is disabled in configuration"); return(true); } if (!PeVerifier.FoundPeVerify) { Logger.LogInfo(" Skipped Verifying assembly since could not find peverify.exe."); return(true); } Logger.LogInfo(" Verifying assembly"); ignoreCodes.Add("0x80070002"); if (PeVerifier.Verify(TargetPath, ignoreCodes, out var output)) { return(true); } Logger.LogError($"PEVerify of the assembly failed.\n{output}"); return(false); }
bool InnerVerify() { if (!File.Exists(TargetPath)) { Logger.LogInfo($" Cannot verify assembly, file '{TargetPath}' does not exist"); return(true); } if (!ReadShouldVerifyAssembly(out var ignoreCodes)) { Logger.LogInfo(" Skipped Verifying assembly since it is disabled in configuration"); return(true); } if (!PeVerifier.FoundPeVerify) { Logger.LogInfo(" Skipped Verifying assembly since could not find peverify.exe."); return(true); } var stopwatch = Stopwatch.StartNew(); try { Logger.LogInfo(" Verifying assembly"); ignoreCodes.Add("0x80070002"); if (PeVerifier.Verify(TargetPath, ignoreCodes, out var output)) { return(true); } Logger.LogError($"PEVerify of the assembly failed.\n{output}"); return(false); } finally { Logger.LogInfo($" Finished verification in {stopwatch.ElapsedMilliseconds}ms."); } }
private void RunPeVerify() { var result = PeVerifier.Verify(WeavedAssemblyPath); result.Should().Be(0, "PeVerifier failed!"); }
private void RunPeVerify() { Action action = () => PeVerifier.Verify(WeavedAssemblyPath); action.ShouldNotThrow(); }