Example #1
0
        public void TypeForwarder()
        {
            var resolver   = new CustomResolver();
            var parameters = new ReaderParameters {
                AssemblyResolver = resolver
            };

            var types = ModuleDefinition.ReadModule(
                CompilationService.CompileResource(GetCSharpResourcePath("CustomAttributes.cs", typeof(ResolveTests).Assembly)),
                parameters);

            resolver.Register(types.Assembly);

            var current_module = GetCurrentModule(parameters);
            var reference      = new TypeReference("System.Diagnostics", "DebuggableAttribute", current_module, AssemblyNameReference.Parse(types.Assembly.FullName), false);

            var definition = reference.Resolve();

            Assert.IsNotNull(definition);
            Assert.AreEqual("System.Diagnostics.DebuggableAttribute", definition.FullName);
            Assert.AreEqual("mscorlib", definition.Module.Assembly.Name.Name);
        }
Example #2
0
        public void NestedTypeForwarder()
        {
            var resolver   = new CustomResolver();
            var parameters = new ReaderParameters {
                AssemblyResolver = resolver
            };

            var types = ModuleDefinition.ReadModule(
                CompilationService.CompileResource(GetCSharpResourcePath("CustomAttributes.cs")),
                parameters);

            resolver.Register(types.Assembly);

            var current_module = GetCurrentModule(parameters);
            var reference      = new TypeReference("", "DebuggingModes", current_module, null, true);

            reference.DeclaringType = new TypeReference("System.Diagnostics", "DebuggableAttribute", current_module, AssemblyNameReference.Parse(types.Assembly.FullName), false);

            var definition = reference.Resolve();

            Assert.IsNotNull(definition);
            Assert.AreEqual("System.Diagnostics.DebuggableAttribute/DebuggingModes", definition.FullName);
            Assert.AreEqual(Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", definition.Module.Assembly.Name.Name);
        }
Example #3
0
 public override string GetModuleLocation(Assembly assembly)
 {
     return(CompilationService.CompileResource(
                BaseTestFixture.GetILResourcePath(file, assembly)));
 }