Ejemplo n.º 1
0
        public void MethodHandleMultiDomainTests()
        {
            ulong[] methodDescs;
            using (DataTarget dt = TestTargets.AppDomains.LoadFullDump())
            {
                ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime();

                ClrModule module = runtime.GetModule("sharedlibrary.dll");
                ClrType   type   = module.GetTypeByName("Foo");
                ClrMethod method = type.GetMethod("Bar");
                methodDescs = method.EnumerateMethodDescs().ToArray();

                Assert.AreEqual(2, methodDescs.Length);
            }

            using (DataTarget dt = TestTargets.AppDomains.LoadFullDump())
            {
                ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime();
                ClrMethod  method  = runtime.GetMethodByHandle(methodDescs[0]);

                Assert.IsNotNull(method);
                Assert.AreEqual("Bar", method.Name);
                Assert.AreEqual("Foo", method.Type.Name);
            }

            using (DataTarget dt = TestTargets.AppDomains.LoadFullDump())
            {
                ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime();
                ClrMethod  method  = runtime.GetMethodByHandle(methodDescs[1]);

                Assert.IsNotNull(method);
                Assert.AreEqual("Bar", method.Name);
                Assert.AreEqual("Foo", method.Type.Name);
            }
        }
Ejemplo n.º 2
0
        public void MethodHandleSingleDomainTests()
        {
            ulong methodDesc;

            using (DataTarget dt = TestTargets.Types.LoadFullDump())
            {
                ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime();

                ClrModule module = runtime.GetModule("sharedlibrary.dll");
                ClrType   type   = module.GetTypeByName("Foo");
                ClrMethod method = type.GetMethod("Bar");
                methodDesc = method.EnumerateMethodDescs().Single();

                Assert.AreNotEqual(0ul, methodDesc);
            }

            using (DataTarget dt = TestTargets.Types.LoadFullDump())
            {
                ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime();
                ClrMethod  method  = runtime.GetMethodByHandle(methodDesc);

                Assert.IsNotNull(method);
                Assert.AreEqual("Bar", method.Name);
                Assert.AreEqual("Foo", method.Type.Name);
            }

            using (DataTarget dt = TestTargets.Types.LoadFullDump())
            {
                ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime();

                ClrModule module = runtime.GetModule("sharedlibrary.dll");
                ClrType   type   = module.GetTypeByName("Foo");
                ClrMethod method = type.GetMethod("Bar");
                Assert.AreEqual(methodDesc, method.EnumerateMethodDescs().Single());
            }
        }