Skip to content

Latest commit

 

History

History
77 lines (60 loc) · 3.22 KB

File metadata and controls

77 lines (60 loc) · 3.22 KB

PX1013

This document describes the PX1013 diagnostic.

Summary

Code Short Description Type Code Fix
PX1013 In a graph action, the return type of the action delegate that initiates a long-running operation must be IEnumerable. Error Available

Diagnostic Description

The PX1013 diagnostic checks graphs and graph extensions for the presence of action delegates with void return type that start long-running operations. Long-running operations are started by the following APIs:

  • The PXLongOperation.StartOperation methods
  • The ILongOperationManager.StartOperation, ILongOperationManager.StartAsyncOperation, and ILongOperationManager.Await methods
  • The IGraphLongOperationManager.StartOperation and IGraphLongOperationManager.StartAsyncOperation methods

The return type of an action delegate of a graph action must be IEnumerable in order to correctly support long-running operations. The processing of the long-running operation and its result will not be displayed in the UI for action delegates with the void return type.

Code Fix Description

The code fix for PX1013 diagnostic changes the return type of the action delegate from void to IEnumerable and adds return adapter.Get() statement to before the exit.

Example of Incorrect Code

public class SMUserProcess : PXGraph
{
	public PXSelect<Users> Users;

	public PXAction<Users> SyncMyUsers;

	[PXButton]
	[PXUIField]
	public virtual void syncMyUsers() // The PX1013 error is displayed for this line.
	{
		SyncUsers();		// Initiate a long-running operation indirectly
	}
		
	private void SyncUsers()
	{
		PXLongOperation.StartOperation(this, () => Console.WriteLine("Synced"));
	}
}

Example of Code Fix

public class SMUserProcess : PXGraph
{
	public PXSelect<Users> Users;

	public PXAction<Users> SyncMyUsers;

	[PXButton]
	[PXUIField]
	public virtual IEnumerable syncMyUsers(PXAdapter adapter)
	{
		SyncUsers();
		return adapter.Get();
	}
		
	private void SyncUsers()
	{
		PXLongOperation.StartOperation(this, () => Console.WriteLine("Synced"));
	}
}

Related Articles