Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion S7.Net/S7.Net.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net452;net462;netstandard2.0;netstandard1.3;net5.0;net6.0;net7.0</TargetFrameworks>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the policy for supporting older targets, but the same could apply to .NET 5 too.

My feeling is that for PLCs quite a lot of older targets are around, because they run and an running system isn't touched (in that area).

So maybe NS 1.3 should be kept too (except everything from these API are covered by net452 or net462 -- which I don't know as NS 1.3 is soo old 😉).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this is not necessary. This happened when I was testing another code and the compilation failed. Later, I forgot to restore it.

<TargetFrameworks>net452;net462;netstandard2.0;net5.0;net6.0;net7.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Properties\S7.Net.snk</AssemblyOriginatorKeyFile>
<InternalsVisibleTo>S7.Net.UnitTest</InternalsVisibleTo>
Expand Down
24 changes: 16 additions & 8 deletions S7.Net/Types/Struct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace S7.Net.Types
/// </summary>
public static class Struct
{
/// <summary>
/// Gets the size of the struct in bytes.
/// </summary>
/// <param name="structType">the type of the struct</param>
/// <returns>the number of bytes</returns>
public static int GetStructSize(Type structType)
/// <summary>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: keep the spaces, so undo this change.

/// Gets the size of the struct in bytes.
/// </summary>
/// <param name="structType">the type of the struct</param>
/// <returns>the number of bytes</returns>
public static int GetStructSize(Type structType)
{
double numBytes = 0.0;

Expand All @@ -28,7 +28,11 @@ public static int GetStructSize(Type structType)
foreach (var info in infos)
{
count++;
switch (info.FieldType.Name)
var type = info.FieldType;
string name = info.FieldType.Name;
if (type.BaseType == typeof(System.Enum))
name = Enum.GetUnderlyingType(type).Name;
switch (name)
{
case "Boolean":
numBytes += 0.125;
Expand Down Expand Up @@ -116,7 +120,11 @@ public static int GetStructSize(Type structType)

foreach (var info in infos)
{
switch (info.FieldType.Name)
var type = info.FieldType;
string name = info.FieldType.Name;
if (type.BaseType == typeof(System.Enum))
name = Enum.GetUnderlyingType(type).Name;
switch (name)
{
case "Boolean":
// get the value
Expand Down