Skip to content

Latest commit

 

History

History
222 lines (193 loc) · 22.2 KB

Overview.md

File metadata and controls

222 lines (193 loc) · 22.2 KB

IecAnalyzer for Phoenix Contact C# Add-In

The IecAnalyzer is a roslyn based Code Analyzer with the goal to help the development with the Phoenix Contact C# Add-In.

For general information on the PLCnext C# developement have a look at our samples on github.

Installation

The IecAnalyzer is installed via the PLCnext Toolchain. The PLCnext Toolchain also installs the Visual Studio Project Template "PLCnext C# Firmware Library". If you create a new Project with this Template the IecAnalyzer is active in the new project by default.

Disable the IecAnalyzer

You may disable the IecAnalyzer by changing UseIecAnalyzer to false in the .csproj file:

<PropertyGroup>
    <UseIecAnalyzer>false</UseIecAnalyzer>
</PropertyGroup>

Change the severity of the rules the IecAnalyzer provides

You can adjust the severity of each rule with a .editorconfig. Additional information about automatic or manual creation at .Net Code-Analysis Configuration

  • An example that disables the rule Iec001 in all .cs files (on and beneath the level of the EditorConfig file) would be:
[*.cs] # next block applies to all .cs files
# sets Iec001 severity to none (possible severities: default|none|silent|suggestion|warning|error)
dotnet_diagnostic.Iec001.severity = none

Suppression

You can also suppress a rule only for a single code region using the context menu to create a SuppressMessage attribute or pragma.

Overview of all rules

Diagnostic ID Summary Default Severity
Iec001 Old Attributes are not allowed Warning Warning
Iec002 Name of the pou type too long Error Error
Iec003 Method missing that FunctionBlock/Function/Program needs Error Error
Iec004 Parameters of user types or Any have to use ref Warning Warning
Iec005 Return Type has to be IEC compatible Error Error
Iec006 Parameter type has to be IEC compaible Error Error
Iec007 Field type has to be IEC compatible Error Error
Iec008 Return type is ambiguous in IEC and should be explicitly defined with a DataType attribute Suggestion Suggestion
Iec009 Parameter type is ambiguous in IEC and should be explicitly defined with a DataType attribute Suggestion Suggestion
Iec010 Field type is ambiguous in IEC and should be explicitly defined with a DataType attribute Suggestion Suggestion
Iec011 Return type needs correct DataType attribute Error Error
Iec012 Parameter type needs correct DataType attribute Error Error
Iec013 Field type needs correct DataType attribute Error Error
Iec014 Fields of type Any must not be Outputs Error Error
Iec015 Do not use GdsRetain Suggestion Suggestion
Iec018 Structure fields should be InOut pointers Suggestion Suggestion
Iec019 Functions and FunctionContainers are not allowed to have attributed fields Error Error
Iec020 Methods attributed Execution or Initialization are not allowed to have parameters Error Error
Iec021 Methods can only have one Output parameter at the first position Error Error
Iec022 Return types must not be Any or IecString or user structure Error Error
Iec023 Program port types must not be of type Any Error Error
Iec024 Silently reports any struct declaration to provide templates for User Array, Structure and String Silent
Iec025 IEC Array pattern has to be correct Error Error
Iec026 IEC String Pattern has to be correct Error Error
Iec027 IEC Structure and all its fields have to be public Error Error
Iec028 String length and size have to be correct Error Error
Iec029 Init/ctor has to be called in Initialization for FunctionBlock fields that provide Init/ctor Error Error
Iec030 IEC Structs have to provide an Init Method calling field's Init/ctor method when any fields have it Error Error
Iec031 Array element type is ambiguous and should be explicitly defined with a DataType attribute Suggestion Suggestion
Iec032 Array element type needs correct DataType attribute Error Error
Iec033 Array element type has to be IEC compatible Error Error
Iec034 Structure field type is ambiguous and should be explicitly defined with a DataType attribute Suggestion Suggestion
Iec035 Structure field type has to be Iec compatible Error Error
Iec036 Structure field needs correct DataType attribute Error Error
Iec037 Program must not have Input Output or InOut attributes Error Error
Iec038 Init Methods of user types must not have an Initialization attribute Warning Warning
Iec039 User type Init methods must not have parameters Error Error
Iec040 Structure parameters should use ref Suggestion Suggestion
Iec041 Init/ctor must only be called once in Init or __Init Error Error
Iec042 unsafe blocks are only allowed when pointers are used inside Warning Warning
Iec043 Output parameter name unequal to class name Error Error
Iec044 Output parameter name unequal to method name Error Error
Iec045 Output parameter must be ref or out Error Error
Iec046 Function Container Functions have to be static Error Error
Iec047 Arrays must not have fields apart from the Anchor field Error Error
Iec048 Only use Initialization and Execution where correct Error Error
Iec049 User attribute should only be used in Function Blocks Error Error
Iec050 Input or Output fields and parameters shall not be pointers Error Error
Iec051 Structures must not have Any or Pointer fields Error Error
Iec052 Retaining on Input can be better achieved with Variable Flag Warning Warning
Iec053 Retaining should only be used in FB or Program Error Error
Iec054 Only use Function attribute in Function Container or on classes Error Error
Iec055 Strings must not have fields apart from the s field Error Error
Iec056 Do not use intern attributes Error Error
Iec057 Namespace names must not be keywords Error Error
Iec058 Do not mix Retain and GdsRetain Error Error
Iec059 Only use Retaining where possible Error Error
Iec060 Only use Hidden on user defined data types and POUs Error Error
Iec061 Only use NotOverridable on POUs Error Error
Iec062 Only use OPC, Ehmi, ProfiCloud and Redundant where possible Error Error
Iec064 Exported fields have to be public Error Error
Iec065 Do not use the suffix attribute when using attributes Error Error
Iec066 Methods returning values must not have Output parameters Error Error
Iec067 Do not use partial Warning Warning
Iec068 Initialize all Array elements Error Error
Iec069 Only Initialize in Init method Error Error
Iec070 Only use Invisible where possible Error Error
Iec071 Elements need unique names Error Error
Iec072 Use Init instead of old ctor Warning Warning
Iec073 rctor is deprecated Warning Warning
Iec074 Multidimensional Arrays are not supported yet Error Error
Iec075 Only use Eno where possible Error Error
Iec076 Do not use POU attributes on abstract classes Error Error
Iec077 Exported Identifiers must not be keywords Error Error
Iec078 Parameters of type Any must not be InOuts Error Error
Iec079 Only use Port attributes in Program Error Error
Iec080 DataType Attribute can only be used on classes if they are Functions Error Error
Iec081 DataType Attribute can only be used on methods if they are User methods or Function methods in FunctionContainer Error Error
Iec082 DataType Attribute for Output parameters positioned on class or method instead Error Error
Iec084 Generic methods are not supported Error Error
Iec085 Max 8 type parameters are supported Error Error
Iec086 Do not nest type arguments Error Error
Iec087 Generic delegates can not be parameters Error Error
Iec088 Fields must not use class type parameters Error Error
Iec089 Also implement non-generic IComparer when implementing generic IComparer Error Error

Rule groups

Typing

IEC element structure

Iec002 Iec020 Iec021

IEC type Initialization

Pointers and References

Generics

Attribute Usage