Skip to content

Latest commit

 

History

History
80 lines (70 loc) · 3.98 KB

PX1016.md

File metadata and controls

80 lines (70 loc) · 3.98 KB

PX1016

This document describes the PX1016 diagnostic.

Summary

Code Short Description Type Code Fix
PX1016 A DAC or graph extension must include the public static IsActive method with no parameters and the bool return type. Extensions that are constantly active reduce performance. Suppress the error if you need the DAC extension to be constantly active. Error Unavailable

Diagnostic Description

A DAC or a graph extension must include the public static IsActive method with no parameters and the bool return type. Extensions that are constantly active reduce performance.

Graph extensions containing an override of the Configure method are considered to be special extensions that are used only to specify the screen configuration and workflow:

public virtual void Configure(PXScreenConfiguration graph) { }

The diagnostic does not check such extensions for the IsActive method declaration unless they contain business logic elements such as graph actions, views, action and view delegates, graph event handlers, and methods marked with PXOverrideAttribute. The diagnostic also does not report graph and DAC extensions in following cases:

  • Graph or DAC extension is a generic class.
  • DAC extension is an abstract class.
  • Graph extension is an abstract class, and it does not have PXProtectedAccessAttribute on the class declaration. Abstract graph extensions with the PXProtectedAccess attribute are checked.

You can use two approaches to fix the issue in the IsActive method as described in the following sections.

Suppression Comment

If you want your DAC or graph extension to be always enabled, suppress the diagnostic with the suppression comment:

// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    ...
}

It is a well-known suppression case, therefore Acuminator will generate a default justification extension should be constantly active for the suppression. Do not add a trivial IsActive method implementation as shown in the following code. Such implementation will take a small performance cost from your application without any benefit.

public class POOrderEntryExt : PXGraphExtension<POOrderEntry>
{
   public static bool IsActive() => true;   // Do not add such trivial implementations, suppress PX1016 diagnostic instead
}

IsActive Method Implementation

If your a DAC or graph extension should be enabled depending on a condition, implement the IsActive method. For example, you can enable an extension, if the feature for which this extension is needed is enabled, as shown in the following code.

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    ...
	public static bool IsActive() => PXAccess.FeatureInstalled<FeaturesSet.retainage>();
}

Example of Code that Results in the Error

// A diagnostic must be shown on SOOrderEntryExt 
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    ...
	// no isActive method
}

Example of the Fixed Code

If you need an extension to be always enabled, suppress the diagnostic as shown in the following code.

// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    ...
}

If extension should be enabled depending on condition, implement the IsActive method as shown in the following code.

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    ...
	public static bool IsActive() => PXAccess.FeatureInstalled<FeaturesSet.retainage>();
}