Skip to content

Latest commit

 

History

History
22 lines (14 loc) · 1.69 KB

File metadata and controls

22 lines (14 loc) · 1.69 KB

Iec028 - String length and size have to be correct

Severity: Error Error

The size of user strings has to be correct. structs with the attribute [String] have to fulfill:

  • if the second parameter in the String attribute is true (e.g. [String(<value>, true]) the string is a wide string, therefore:
    • the Size parameter of the StructLayout attribute has to be 6 greater than the first parameter (size) of the [String] attribute multiplicated by 2. ([StructLayout(LayoutKind.Explicit, Size = <2*value+6>)])
    • the m_cap of the string's IecWString field (set in Init() ) has to be equal to the first parameter (size) of the [String] attribute.
  • else
    • the Size parameter of the StructLayout attribute has to be 6 greater than the first parameter (size) of the [String] attribute. ([StructLayout(LayoutKind.Explicit, Size = <value+6>)])
    • the maximumLength of the string's IecStringEx field (set in Init() ) has to be equal to the first parameter (size) of the [String] attribute.

Also see the [String] pattern Iec026 asks for.

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 adjust the sizes to the definition in the [String] attribute. ( Press Alt + Enter on the Error line to find the Code Fix in the context menu)

Assign the size defined in the [String] attribute to the IecStringEx/IecWString field. Set it (multiplicated with 2 for wide strings and) increased by 6 as the [StructLayout] attribute's Size parameter.