|
namespace Emit.Test
{
using System;
using System.IO;
using System.Linq;
using Mono.Cecil;
using Xunit;
/// <summary>
/// Collection of tests to check the validity of the emmited dynamic methods generated at runtime.
/// </summary>
public class Serializer
{
[Fact]
public void CheckWithLSpy()
{
// create the dynamic methods and store them in a DLL 1 per
// object and to run the IL analysis.
var dllPath = Path.Combine(Environment.CurrentDirectory, "$_test.dll");
TestTargets.CreateDLL(dllPath);
var assemblyDefinition = AssemblyDefinition.ReadAssembly(dllPath, new ReaderParameters(ReadingMode.Immediate));
var typeDef = assemblyDefinition.MainModule.GetType(string.Empty, "EmitClass");
var emitCode = typeDef.Methods.First(m => m.Name == "EmitCode");
PEVerifier.VerifyMethods(new[] { emitCode });
}
[Fact]
public void CheckWithPEVerify()
{
var dllPath = Path.Combine(Environment.CurrentDirectory, "$_test.dll");
TestTargets.CreateDLL(dllPath);
PEVerifier.VerifyPEFile(dllPath);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.