Skip to content

Latest commit

 

History

History
87 lines (72 loc) · 3 KB

File metadata and controls

87 lines (72 loc) · 3 KB

PX1000

This document describes the PX1000 diagnostic.

Summary

Code Short Description Type Code Fix
PX1000 The action delegate has incompatible return type and parameters. Error Available

Diagnostic Description

A valid signature of an action delegate method must satisfy the following requirements:

  • The action delegate method must have the same name as its corresponding graph action (the PXAction field) but with a different casing for the first letter. Acumatica naming conventions recommend using the camel case for action delegate methods and the pascal case for graph action fields.
  • The parameters and the return type of the action delegate can take one of the two forms:
    • No parameters and void as the return type:
    public virtual void actionName()
    {
    	...
    }
    • One or more parameters, the first parameter has the PXAdapter type, and the return type is System.Collections.IEnumerable:
    protected virtual IEnumerable actionName(PXAdapter adapter)
    {
    	...
    	return adapter.Get();
    }

The same rules apply to overrides of action delegates via the PXOverride mechanism. The only exception is that the delegate may have an additional parameter of the delegate type which represents the base delegate.

The PX1000 diagnostic checks graphs and graph extensions for action delegates whose return type and parameters do not match any of the valid signatures described above.

Code Fix Description

The PX1000 code fix changes the action delegate signature to the correct form with, as shown in the following code.

public virtual IEnumerable actionName(PXAdapter adapter)
{
	...
	return adapter.Get();
}

For PXOverride overrides of action delegates, the code fix is not registered. This is because the change of the PXOverride method signature will break the override mechanism and make the changed override incompatible with the base action delegate.

Example of Incorrect Code

public class SomeEntry : PXGraph<SomeEntry, Primary>
{
	public PXAction<Primary> Release = null!;
	public PXAction<Primary> Report = null!;

	public void release(PXAdapter adapter) // The PX1000 error is displayed for this line.
	{
	}
	
	public IEnumerable report() // Another PX1000 error is displayed for this line.
	{
	}
}

Example of Code Fix

public class SomeEntry : PXGraph<SomeEntry, Primary>
{
	public PXAction<Primary> Release = null!;
	public PXAction<Primary> Report = null!;

	public IEnumerable release(PXAdapter adapter)
	{
		return adapter.Get();
	}
	
	public IEnumerable report(PXAdapter adapter)
	{
		return adapter.Get();
	}
}

Related Articles