How does this work? It's very simple:

[TestMethod]
[DeploymentItem("GoodAssembly.il")]
public void VerifyAssemblyViaFileInfo()
{
	AssemblyCreator.Create("GoodAssembly.il", "/dll");
	AssemblyVerification.Verify(new FileInfo("GoodAssembly.dll"));
}

The idea is you provide an assembly as a file to Verify(), and if you don't get an exception, that assembly is verified. You need to have peverify accessible from the command-line so when Verify() tries to launch that executable it won't fail. If it can't find peverify, it'll choke :).

If you create a lot of dynamic code, this technique makes it very easy to quickly ensure your generated code doesn't contain any bad IL-related mistakes.

Last edited Feb 14, 2011 at 12:29 AM by jasonrbock, version 1

Comments

No comments yet.