C# program is changing the datatype for outports

I have just installed the new C# plugin for version 2020.0. When I create a new program and compile it, the datatype of my outport is different in C# and the Engineer. Is this a bug or a feature?

Hi Stefan, According to this table: https://www.plcnext.help/te/PLCnext_Runtime/Available_data_types.htmint isn’t a valid port type in C#, but if your FB builds then I guess this is a bug in our documentation. In any case, a C# int is a 32-bit signed integer, so this maps to a DINT in IEC 61131 (which is what PLCnext Engineer shows in the Port list). ~ Martin.

Oh, but I have just noticed that you seem to be able to match the C# int input ports to INT Output ports ! Can you confirm that this is also what you are seeing? If so, this looks like a problem … ====================== EDIT: … actually perhaps its not a problem. It seems like it is possible to match any OUT port to any IN port of the same or greater size - so an INT can be mapped to a DINT, I guess because there will be no data loss (an INT can fit in a DINT), but the opposite would not be possible. I will ask for our documentation to be updated to reflect this feature.

Hi Martin, I understand that an int in C# is mapped to a DINT in IEC61131. But as you can see the mapping is only done for the outport. The inports are int both in C# and in IEC61131. The inports can be mapped to INT variables in IEC61131. I also tried to set the DataType attribute to DINT for the inports. There is no change in IEC, the inports are mapped to INT. Then I changed the datatypes of the in and outports in C# to short. Still no change in IEC, the outport is DINT and the inports are INT. So this seems to be a bug.

From the screen shot, it looks like the C# variable a is being shown as a DINT, and the IEC variables OP_iValue1 and OP_iValue2 are being shown as INT. To see what the C# variables b and c are being shown as in PLCnext Engineer, you need to click the > symbol on the top right of the screen shot to see the “Type” column for those variables. If they are shown as INT, then this would appear to be a problem. The fact that b and c can receive values from an IEC INT variable is not a problem, as described above. Martin.

Discussed by phone. Looks like it is not an issue with the C# add-in.