This document describes the PX1096 diagnostic.
| Code | Short Description | Type | Code Fix |
|---|---|---|---|
| PX1096 | The signature of a method with the PXOverride attribute must match the overridden method. |
Error | Unavailable |
The signature of a method with the PXOverride attribute must match the overridden method.
The signatures of the overridden and overriding methods must comply with one of the following rules:
- The signatures of both methods are identical. Note, that the use of this mechanism is currently discouraged by Acumatica best practices.
- The signatures of both methods are identical, except that the overriding method has one additional parameter, which is a delegate that points to the base method. In this scenario, the delegate signature must also match the overridden method.
- The overriding method must be declared in a graph extension.
- The overriding method should not be
static. - The overriding method cannot be
virtual,abstract, oroverride. - The overriding method cannot be a generic method.
- The overriding method should always declare an additional delegate parameter.
- The overriding method should declare an XML documentation comment with a reference to the base method in the format
/// Overrides <seealso cref="{Base method}">. - The base method must be
virtual(have eithervirtualoroverridemodifiers). - The base method must have one of the following accessibility levels:
public,protected, orprotected internal. - The names of the derived method and the base method must match.
The following example demonstrates the correct override of a method with a base method delegate.
public class MyGraph : PXGraph<MyGraph>
{
}
public class BaseGraphExtension : PXGraphExtension<MyGraph>
{
public virtual int Add(int x, string y)
{
return x + Convert.ToInt32(y);
}
}
public class DerivedGraphExtension : PXGraphExtension<BaseGraphExtension, MyGraph>
{
/// Overrides <seealso cref="BaseGraphExtension.Add(int, string)"/>
[PXOverride]
public int Add(int x, string y, Func<int, string, int> base_Add)
{
if (x < 10)
{
return x + Convert.ToInt32(y) * 2;
}
return base_Add(x, y);
}
}In the following example, the delegate signature does not correspond to the signature of the base method.
public class MyGraph : PXGraph<MyGraph>
{
}
public class BaseGraphExtension : PXGraphExtension<MyGraph>
{
public virtual int Add(int x, string y, bool z)
{
return x + Convert.ToInt32(y);
}
}
public class DerivedGraphExtension : PXGraphExtension<BaseGraphExtension, MyGraph>
{
/// Overrides <seealso cref="BaseGraphExtension.Add(int, string, bool)"/>
[PXOverride]
public int Add(int x, string y, bool z, Func<int, string, int> base_Add)
{
if (x < 10 && z)
{
return x + Convert.ToInt32(y) * 2;
}
return base_Add(x, y);
}
}