Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 1.24 KB

File metadata and controls

43 lines (34 loc) · 1.24 KB

Iec026 - IEC String Pattern has to be correct

Severity: Error Error

All structs with the attribute [String] must have these elements:

  • attribute (with Size parameter): [StructLayout(LayoutKind.Explicit, Size = <value + 6>)]

  • IecStringEx declaration:

     [FieldOffset(0)]
     public IecStringEx s;
  • Init method that sets the minimumLength:

    public void Init()
    {
    	s.maximumLength = <value>;
    }	

If the Attribute's second Parameter is true (e.g. [String(200, true)]) instead these elements are necessary:

  • attribute (with Size parameter): [StructLayout(LayoutKind.Explicit, Size = <2*value + 6>)]

  • IecWString declaration:

     [FieldOffset(0)]
     public IecWString s;
  • Init method that sets the minimumLength:

    public void Init()
    {
    	s.m_cap = <value>;
    }	

You can also view an explanation and example of a string implementation on Gitub

Solution

You can also use the provided automatic Code Fix to add all missing elements. ( Press Alt + Enter on the Error line to find the Code Fix in the context menu)

Provide all missing elements.