public void CreateProperty() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IPropertyBuilder TestProperty = TestType.CreateProperty("TestProperty", typeof(int)); Assert.NotNull(TestProperty); Assert.Equal("TestProperty", TestProperty.Name); Assert.Equal(typeof(int), TestProperty.DataType); Assert.NotNull(TestProperty.Builder); Assert.Equal(PropertyAttributes.SpecialName, TestProperty.Attributes); Assert.NotNull(TestProperty.GetMethod); Assert.NotNull(TestProperty.SetMethod); Assert.Equal(MethodAttributes.Public | MethodAttributes.Virtual, TestProperty.GetMethodAttributes); Assert.Equal(MethodAttributes.Public | MethodAttributes.Virtual, TestProperty.SetMethodAttributes); }
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 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)); }
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; }