Esempio n. 1
0
        public static void Local()
        {
            var anonymousType = new { property = true };

            Assert.AreEqual(Name.Of(anonymousType), "anonymousType");
            // ldloc.0
            // call string [Name.Of]Name::Of(object)

            Nullable <Single> nullableType = 42.0f;

            Assert.AreEqual(Name.Of(nullableType), "nullableType");
            // ldloc.1
            // box [mscorlib]System.Nullable`1<float32>
            // call string [Name.Of]Name::Of(object)

            Boolean systemValueType = true;

            Assert.AreEqual(Name.Of(systemValueType), "systemValueType");
            // ldloc.2
            // box bool
            // call string [Name.Of]Name::Of(object)

            String systemReferenceType = "foo";

            Assert.AreEqual(Name.Of(systemReferenceType), "systemReferenceType");
            // ldloc.3
            // call string [Name.Of]Name::Of(object)

            Abc valueType = new Abc();

            valueType.GetHashCode();
            Assert.AreEqual(Name.Of(valueType), "valueType");
            // ldloc.s valueType
            // box AssemblyToProcess.Abc
            // call string [Name.Of]Name::Of(object)

            Def referenceType = new Def();

            Assert.AreEqual(Name.Of(referenceType), "referenceType");
            // ldloc.s referenceType
            // call string [Name.Of]Name::Of(object)

            Func <Int32> valueTypeDelegate = () => 1337;

            Assert.AreEqual(Name.Of(valueTypeDelegate), "valueTypeDelegate");
            // ldloc.s valueTypeDelegate
            // call string [Name.Of]Name::Of<int32>(class [mscorlib]System.Func`1<!!0>)

            Func <Object> referenceTypeDelegate = () => new Object();

            Assert.AreEqual(Name.Of(referenceTypeDelegate), "referenceTypeDelegate");
            // ldloc.s referenceTypeDelegate
            // call string [Name.Of]Name::Of<object>(class [mscorlib]System.Func`1<!!0>)

            Action referenceTypeDelegate2 = () => { };

            Assert.AreEqual(Name.Of(referenceTypeDelegate2), "referenceTypeDelegate2");
            // ldloc.s referenceTypeDelegate2
            // call string [Name.Of]Name::Of(object)
        }