expressappframework-403392-debugging-testing-and-error-handling-code-diagnostics-xaf0002.md
Severity: Warning
XAF and XPO do not support the following business object’s properties:
new keyword.For more information about these requirements, see the following article: Can I override properties of business objects?.
This diagnostic works only for XPO classes derived from the DevExpress.Xpo.PersistentBase class. This diagnostic does not check static properties.
using DevExpress.Persistent.BaseImpl;
using DevExpress.Xpo;
namespace MySolution.Module.BusinessObjects {
public class TestClass : TestClassBase {
public TestClass(Session session) : base(session) { }
private int testProperty1;
// The property must not be virtual
//public virtual int TestProperty1 { // Warning: XAF0002
// get { return testProperty1; }
// set { SetPropertyValue(nameof(TestProperty1), ref testProperty1, value); }
//}
private int testProperty2;
// The property must not override a property from a base class
//public override int TestProperty2 { // Warning: XAF0002
// get { return testProperty2 + 1; }
// set { SetPropertyValue(nameof(TestProperty2), ref testProperty2, value); }
//}
private int testProperty3;
// The property must not be declared with the `new` keyword
//public new int TestProperty3 { // Warning: XAF0002
// get { return testProperty3 + 1; }
// set { SetPropertyValue(nameof(TestProperty3), ref testProperty3, value); }
//}
}
}
using DevExpress.Persistent.BaseImpl;
using DevExpress.Xpo;
namespace MySolution.Module.BusinessObjects {
public class TestClass : TestClassBase {
public TestClass(Session session) : base(session) { }
private int testProperty;
// The property that meets the requirements
public int TestProperty {
get { return testProperty; }
set { SetPropertyValue(nameof(TestProperty), ref testProperty, value); }
}
}
}
Check the business object’s property declaration and ensure the property is declared without the following modifiers:
abstractvirtualoverridenew