This document describes the PX1013 diagnostic.
| 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 |
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.StartOperationmethods - The
ILongOperationManager.StartOperation,ILongOperationManager.StartAsyncOperation, andILongOperationManager.Awaitmethods - The
IGraphLongOperationManager.StartOperationandIGraphLongOperationManager.StartAsyncOperationmethods
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.
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.
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"));
}
}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"));
}
}