public void SetterVisibilityInternal() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var paramType = new CsFundamentalType(typeof(int)); var setMethod = new CsMethod { Name = "SetActive", ReturnValue = new CsReturnValue { PublicType = new CsFundamentalType(typeof(void)) }, AllowProperty = true }; setMethod.Add(new CsParameter { PublicType = paramType }); var iface = new CsInterface(); iface.Add(setMethod); var prop = new CsProperty("Active") { Setter = setMethod }; propertyBuilder.AttachPropertyToParent(prop); Assert.Equal(Visibility.Internal, setMethod.Visibility); }
public void PropertyNotAttachedWhenSetterAllowPropertyIsFalse() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var paramType = new CsFundamentalType(typeof(int)); var setMethod = new CsMethod { Name = "SetActive", ReturnValue = new CsReturnValue { PublicType = new CsFundamentalType(typeof(void)) }, AllowProperty = false }; setMethod.Add(new CsParameter { PublicType = paramType }); var iface = new CsInterface(); iface.Add(setMethod); var prop = new CsProperty("Active") { Setter = setMethod }; propertyBuilder.AttachPropertyToParent(prop); Assert.Null(prop.Parent); }
public void PersistentGetterGeneratesPersistentProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var paramType = new CsFundamentalType(typeof(int)); var getMethod = new CsMethod { Name = "GetActive", ReturnValue = new CsReturnValue { PublicType = paramType, MarshalType = paramType }, AllowProperty = true, IsPersistent = true }; var iface = new CsInterface(); iface.Add(getMethod); var prop = new CsProperty("Active") { Getter = getMethod }; propertyBuilder.AttachPropertyToParent(prop); Assert.True(prop.IsPersistent); }
public void PersistentGetterGeneratesPersistentProperty() { CppMethod cppGetMethod = new("GetActive") { Rule = { Property = true, Persist = true } }; var paramType = TypeRegistry.Int32; var getMethod = new CsMethod(cppGetMethod, cppGetMethod.Name) { ReturnValue = new CsReturnValue(null) { PublicType = paramType, MarshalType = paramType } }; var iface = new CsInterface(null, null); iface.Add(getMethod); var prop = new CsProperty(null, "Active", getMethod, null); PropertyBuilder.AttachPropertyToParent(prop); Assert.True(prop.IsPersistent); }
public void SetterVisibilityInternal() { CppMethod cppSetMethod = new("SetActive") { Rule = { Property = true } }; var paramType = TypeRegistry.Int32; var setMethod = new CsMethod(cppSetMethod, cppSetMethod.Name) { ReturnValue = new CsReturnValue(null) { PublicType = TypeRegistry.Void } }; setMethod.Add(new CsParameter(null, null) { PublicType = paramType }); var iface = new CsInterface(null, null); iface.Add(setMethod); var prop = new CsProperty(null, "Active", null, setMethod); PropertyBuilder.AttachPropertyToParent(prop); Assert.Equal(Visibility.Internal, setMethod.Visibility); }
public void PropertyNotAttachedWhenSetterAllowPropertyIsFalse() { CppMethod cppSetMethod = new("SetActive") { Rule = { Property = false } }; var paramType = TypeRegistry.Int32; var setMethod = new CsMethod(cppSetMethod, cppSetMethod.Name) { ReturnValue = new CsReturnValue(null) { PublicType = TypeRegistry.Void } }; setMethod.Add(new CsParameter(null, null) { PublicType = paramType }); var iface = new CsInterface(null, null); iface.Add(setMethod); var prop = new CsProperty(null, "Active", null, setMethod); PropertyBuilder.AttachPropertyToParent(prop); Assert.Null(prop.Parent); }
public void PropertyAttachedToGetterType() { var paramType = TypeRegistry.Int32; CppMethod cppGetMethod = new("GetActive") { Rule = { Property = true } }; var getMethod = new CsMethod(cppGetMethod, cppGetMethod.Name) { ReturnValue = new CsReturnValue(null) { PublicType = paramType, MarshalType = paramType } }; var iface = new CsInterface(null, null); iface.Add(getMethod); var prop = new CsProperty(null, "Active", getMethod, null); PropertyBuilder.AttachPropertyToParent(prop); Assert.Equal(iface, prop.Parent); }
public void GetterVisibiltyInternal() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider("SharpGen.Runtime")); var paramType = new CsFundamentalType(typeof(int)); var getMethod = new CsMethod { Name = "GetActive", ReturnValue = new CsReturnValue { PublicType = paramType, MarshalType = paramType }, AllowProperty = true }; var iface = new CsInterface(); iface.Add(getMethod); var prop = new CsProperty("Active") { Getter = getMethod }; propertyBuilder.AttachPropertyToParent(prop); Assert.Equal(Visibility.Internal, getMethod.Visibility); }
public void PropertyNotAttachedWhenGetterAllowPropertyIsFalse() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider("SharpGen.Runtime")); var paramType = new CsFundamentalType(typeof(int)); var getMethod = new CsMethod { Name = "GetActive", ReturnValue = new CsReturnValue { PublicType = paramType, MarshalType = paramType }, AllowProperty = false }; var iface = new CsInterface(); iface.Add(getMethod); var prop = new CsProperty("Active") { Getter = getMethod }; propertyBuilder.AttachPropertyToParent(prop); Assert.Null(prop.Parent); }
public void SetOnlyPropertyAttachedToSetterType() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider("SharpGen.Runtime")); var paramType = new CsFundamentalType(typeof(int)); var setMethod = new CsMethod { Name = "SetActive", ReturnValue = new CsReturnValue { PublicType = new CsFundamentalType(typeof(void)) }, AllowProperty = true }; setMethod.Add(new CsParameter { PublicType = paramType }); var iface = new CsInterface(); iface.Add(setMethod); var prop = new CsProperty("Active") { Setter = setMethod }; propertyBuilder.AttachPropertyToParent(prop); Assert.Equal(iface, prop.Parent); }