Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 2 KB

PX1062.md

File metadata and controls

47 lines (34 loc) · 2 KB

PX1062

This document describes the PX1062 diagnostic.

Summary

Code Short Description Type Code Fix
PX1062 You cannot declare static views, actions, mutable fields, and properties in graphs or graph extensions Error Available

Diagnostic Description

In graphs and graph extensions, it is strictly forbidden to use the following static members: actions, views, mutable properties, and mutable fields. The diagnostic shows the error for these static members.

The diagnostic behavior and the code fix depend on the type of field or property as follows:

  • For a static view or action, the diagnostic always reports an error. The only available code fix is to remove the static keyword. Even if the action or view is read-only, it is still forbidden.
  • Other static fields and properties are reported only if they are mutable (not read-only). In that case, two code fixes are available:
    • Make the field or property read-only. Note that the fix works differently for fields and properties. For a field, the fix adds the readonly modifier. For a property, the fix removes the property setter.
    • Remove the static modifier.

Example of Incorrect Code

public class SomeGraph : PXGraph<SomeGraph>
{
    public static int SalesSubMask;

    public static PXAction<PX.Objects.AR.ARInvoice> Release;

    public static IFinPeriodRepository FinPeriodRepository { get; set; }
}

Example of the Code Fix

public class SomeGraph : PXGraph<SomeGraph>
{
	// the fix added the readonly modifier
    public static readonly int SalesSubMask;

	// the fix removed the static modifier
    public PXAction<PX.Objects.AR.ARInvoice> Release;

	// the fix removed the static modifier
    public IFinPeriodRepository FinPeriodRepository { get; set; }
}