public void GetDefinition()
 {
     Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.Interfaces.IPropertyBuilder Property = TestType.CreateDefaultProperty("Property1", typeof(int));
     Assert.NotEmpty(Property.GetDefinition());
 }
 public void CreateType()
 {
     Utilities.Reflection.Emit.Assembly    TestObject = new Utilities.Reflection.Emit.Assembly("TestingThis");
     Utilities.Reflection.Emit.TypeBuilder TypeObject = TestObject.CreateType("TestClass");
     Assert.NotNull(TypeObject);
     Assert.DoesNotThrow(() => TestObject.Create());
 }
 public void GetDefinition()
 {
     Utilities.Reflection.Emit.Assembly     Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder  TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.FieldBuilder Field    = TestType.CreateField("Field1", typeof(int));
     Assert.NotEmpty(Field.GetDefinition());
 }
Esempio n. 4
0
 public void Create()
 {
     Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Assert.NotNull(TestType);
     Assert.DoesNotThrow(() => Assembly.Create());
     Assert.NotNull(Activator.CreateInstance(TestType.DefinedType));
 }
Esempio n. 5
0
        public void Create()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");

            Assert.NotNull(Method);
        }
Esempio n. 6
0
        public void Call()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));

            Assert.DoesNotThrow <Exception>(() => Local1.Call("ToString"));
        }
Esempio n. 7
0
        public void Assign()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");

            Utilities.Reflection.Emit.FieldBuilder Field = TestType.CreateField("Field1", typeof(int));
            Assert.DoesNotThrow(() => Field.Assign(12));
        }
Esempio n. 8
0
        public void PlusPlus()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateConstructor();

            Utilities.Reflection.Emit.PropertyBuilder TestProperty = (Utilities.Reflection.Emit.PropertyBuilder)TestType.CreateProperty("TestProperty", typeof(int));
            ++TestProperty;
        }
Esempio n. 9
0
        public void Save()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));

            Local1.Save(Method.Generator);
        }
        public void Save()
        {
            Utilities.Reflection.Emit.Assembly     Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder  TestType = Assembly.CreateType("TestType");
            Utilities.Reflection.Emit.FieldBuilder Field    = TestType.CreateField("Field1", typeof(int));
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");

            Field.Save(Method.Generator);
        }
Esempio n. 11
0
        public void Load()
        {
            Utilities.Reflection.Emit.Assembly     Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder  TestType = Assembly.CreateType("TestType");
            Utilities.Reflection.Emit.FieldBuilder Field    = TestType.CreateField("Field1", typeof(int));
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");

            Assert.DoesNotThrow <Exception>(() => Field.Load(Method.Generator));
        }
        public void Call()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");

            Utilities.Reflection.Emit.FieldBuilder Field = TestType.CreateField("Field1", typeof(int));
            Field.Call("ToString");
        }
Esempio n. 13
0
        public void MinusMinus()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateConstructor();

            Utilities.Reflection.Emit.PropertyBuilder TestProperty = (Utilities.Reflection.Emit.PropertyBuilder)TestType.CreateProperty("TestProperty", typeof(int));
            Assert.DoesNotThrow(() => -- TestProperty);
        }
        public void Load()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));

            Assert.DoesNotThrow(() => Local1.Load(Method.Generator));
        }
Esempio n. 15
0
        public void NewObj()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2 = Method.CreateLocal("Local2", typeof(int));

            Assert.NotNull(Method.NewObj(typeof(DateTime), new object[] { Local1 }));
        }
        public void Return()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod", ReturnType: typeof(int));
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2 = Method.CreateLocal("Local2", typeof(int));

            Assert.DoesNotThrow <Exception>(() => Method.Return(Local1));
        }
        public void Create()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            Utilities.Reflection.Emit.Interfaces.IMethodBuilder Constructor = TestType.CreateConstructor();
            VariableBase Constant = Constructor.CreateConstant(12);

            Assert.NotNull(Constant);
            Assert.Equal(typeof(int), Constant.DataType);
        }
Esempio n. 18
0
        public void Throw()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2 = Method.CreateLocal("Local2", typeof(int));

            Method.Throw(Method.NewObj(typeof(Exception)));
        }
Esempio n. 19
0
        public void Cast()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2 = Method.CreateLocal("Local2", typeof(int));

            Assert.DoesNotThrow(() => Method.Cast(Method.This, typeof(object)));
        }
Esempio n. 20
0
        public void Box()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2 = Method.CreateLocal("Local2", typeof(int));

            Assert.NotNull(Method.Box(Local1));
        }
Esempio n. 21
0
        public void Save()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateConstructor();

            Utilities.Reflection.Emit.PropertyBuilder TestProperty = (Utilities.Reflection.Emit.PropertyBuilder)TestType.CreateProperty("TestProperty", typeof(int));
            Assert.Throws <NullReferenceException>(() => TestProperty.Save(null));
            Assert.DoesNotThrow(() => TestProperty.Save(Method.Generator));
        }
Esempio n. 22
0
        public void Call()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method  = TestType.CreateMethod("TestMethod");
            IMethodBuilder Method2 = TestType.CreateMethod("TestMethod2");
            VariableBase   Local1  = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2  = Method.CreateLocal("Local2", typeof(int));

            Method.This.Call(Method2, null);
        }
 public void Create()
 {
     Utilities.Reflection.Emit.Assembly     Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder  TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.FieldBuilder Field    = TestType.CreateField("Field1", typeof(int));
     Assert.NotNull(Field);
     Assert.Equal(typeof(int), Field.DataType);
     Assert.Equal("Field1", Field.Name);
     Assert.Equal(FieldAttributes.Public, Field.Attributes);
     Assert.NotNull(Field.Builder);
 }
Esempio n. 24
0
        public void Save()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateConstructor();

            Assert.NotNull(Method.This);
            Assert.Null(Method.This.DataType);
            Assert.Equal("this", Method.This.Name);
            Method.This.Save(Method.Generator);
        }
 public void Create()
 {
     Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.Interfaces.IMethodBuilder Constructor = TestType.CreateConstructor();
     Assert.NotNull(Constructor);
     Assert.Equal(MethodAttributes.Public, Constructor.Attributes);
     Assert.NotNull(Constructor.Generator);
     Assert.NotNull(Constructor.Parameters);
     Assert.Equal(1, Constructor.Parameters.Count);
 }
        public void Load()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateConstructor();

            Assert.NotNull(Method.This);
            Assert.Null(Method.This.DataType);
            Assert.Equal("this", Method.This.Name);
            Assert.DoesNotThrow <Exception>(() => Method.This.Load(Method.Generator));
        }
Esempio n. 27
0
        public void Create()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));

            Assert.NotNull(Local1);
            Assert.Equal(typeof(int), Local1.DataType);
            Assert.Equal("Local1", Local1.Name);
        }
Esempio n. 28
0
        public void While()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2 = Method.CreateLocal("Local2", typeof(int));

            Utilities.Reflection.Emit.Commands.While While = Method.While(Local1, Utilities.Reflection.Emit.Enums.Comparison.Equal, Local2);
            Method.EndWhile(While);
            Assert.NotNull(While);
        }
Esempio n. 29
0
 public void CreateMethod()
 {
     Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
     Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
     Utilities.Reflection.Emit.Interfaces.IMethodBuilder TestMethod = TestType.CreateMethod("TestMethod");
     Assert.NotNull(TestMethod);
     Assert.Equal("TestMethod", TestMethod.Name);
     Assert.Equal(typeof(void), TestMethod.ReturnType);
     Assert.NotNull(TestMethod.Generator);
     Assert.NotNull(TestMethod.This);
     Assert.Equal(1, TestMethod.Parameters.Count);
     Assert.Equal(MethodAttributes.Public | MethodAttributes.Virtual, TestMethod.Attributes);
 }
Esempio n. 30
0
        public void TryCatch()
        {
            Utilities.Reflection.Emit.Assembly    Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly");
            Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType");
            IMethodBuilder Method = TestType.CreateMethod("TestMethod");
            VariableBase   Local1 = Method.CreateLocal("Local1", typeof(int));
            VariableBase   Local2 = Method.CreateLocal("Local2", typeof(int));

            Utilities.Reflection.Emit.Commands.Try   Try   = Method.Try();
            Utilities.Reflection.Emit.Commands.Catch Catch = Method.Catch(typeof(Exception));
            Method.EndTry();
            Assert.NotNull(Try);
            Assert.NotNull(Catch);
        }