Skip to content

Latest commit

 

History

History
71 lines (57 loc) · 2.56 KB

PX1091.md

File metadata and controls

71 lines (57 loc) · 2.56 KB

PX1091

This document describes the PX1091 diagnostic.

Summary

Code Short Description Type Code Fix
PX1091 This invocation of the base action handler can cause a StackOverflowException. Warning (ISV Level 1: Significant) Unavailable

Diagnostic Description

If an action delegate that is overridden in PXGraphExtension invokes the base action delegate, you must either override the action delegate by using the PXOverride attribute or redeclare the PXAction field member inside PXGraphExtension. If you do not follow this rule, the customization can cause a StackOverflowException.

Example of Code that Results in the Warning

public class AccountByPeriodEnq_Extension : PXGraphExtension<AccountByPeriodEnq>
{
    [PXUIField(DisplayName = "View Document",
        MapEnableRights = PXCacheRights.Select,
        MapViewRights = PXCacheRights.Select)]
    [PXButton]
    public virtual IEnumerable viewDocument(PXAdapter adapter)
    {
        GLTranR current = Base.GLTranEnq.Current;
        if (current != null)
            return Base.ViewDocument.Press(adapter); // The PX1091 warning is displayed for this line.

        return adapter.Get();
    }
}

Example of Possible Code Fix (The Use of the PXOverride Attribute)

public class AccountByPeriodEnq_Extension : PXGraphExtension<AccountByPeriodEnq>
{
    public delegate IEnumerable viewDocumentDelegate(PXAdapter adapter);
    [PXOverride]
    public IEnumerable viewDocument(PXAdapter adapter, viewDocumentDelegate baseMethod)
    {
        return baseMethod(adapter);
    }
}

Example of Possible Code Fix (Redeclaration of the PXAction Field Member)

public class AccountByPeriodEnq_Extension : PXGraphExtension<AccountByPeriodEnq>
{
    public PXAction<AccountByPeriodFilter> ViewDocument;

    [PXUIField(DisplayName = "View Document",
        MapEnableRights = PXCacheRights.Select,
        MapViewRights = PXCacheRights.Select)]
    [PXButton]
    public virtual IEnumerable viewDocument(PXAdapter adapter)
    {
        GLTranR current = Base.GLTranEnq.Current;
        if (current != null)
            return Base.ViewDocument.Press(adapter); 

        return adapter.Get();
    }
}

Related Articles

Customization of an Action