Skip to content

Feature/optimize 03 string write maxlength fix - #13

Merged
jogibear9988 merged 3 commits into
dotnetprojects:masterfrom
Stiwa-PohG:feature/optimize-03-string-write-maxlength-fix
Oct 7, 2026
Merged

jogibear9988 merged 3 commits into
dotnetprojects:masterfrom
Stiwa-PohG:feature/optimize-03-string-write-maxlength-fix

Conversation

@Stiwa-PohG

Copy link
Copy Markdown

Contains the sources from branch feature/optimize-02

Port net functional changes from fork package 01 (DataTypes extension /
string array fix, commits 6aef271/519cdeb/ffe8daa):
- PlcTag: add virtual GetValue()/SetValue(object) reflecting the
  concrete tag's public Value property, for generic tag value access.
- POffsetInfoType: add virtual MaxStringLength(), returning 0 by
  default, UnspecifiedOffsetinfo1 for Array1Dim (string array max
  length), and Min(UnspecifiedOffsetinfo1, UnspecifiedOffsetinfo2) for
  String (fixes cases where firmware swaps both fields).

All other changes from this fork package are already superseded by the
target repo's own PlcTag/PlcTags implementation and are documented as
excluded in package 16.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

String serialization, public API compatibility, and concurrent TLS processing still have unresolved correctness issues.

Review effort: Balanced
Findings: 1 High severity · 4 Medium severity

Open (5)
What changed in this PR

This PR carries PLC-declared string limits through tag resolution and caching to correct string-write sizing.

Changes:

  • Propagates string limits and persists them in version-3 catalogs.
  • Adds generic value accessors and string-length regression tests.
  • Synchronizes OpenSSL pending-queue access.
File Description
src/​S7CommPlusDriver/​S7CommPlusTagAccessorCatalog.cs Persists and restores string limits.
src/​S7CommPlusDriver/​S7CommPlusProtocolSession.cs Passes limits into resolved tags.
src/​S7CommPlusDriver/​OpenSSL/​OpenSSLConnector.cs Adds pending-queue locks.
src/​S7CommPlusDriver/​Core/​POffsetInfoType.cs Exposes string-length metadata.
src/​S7CommPlusDriver/​ClientApi/​PlcTags.cs Applies limits during tag creation.
src/​S7CommPlusDriver/​ClientApi/​PlcTag.cs Exposes limits and generic value accessors.
src/​S7CommPlusDriver/​ClientApi/​Browser.cs Includes string limits in browse results.
src/​S7CommPlusDriver.Tests/​PlcTagStringMaxLengthTests.cs Tests factory limits and scalar string payloads.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +36 to +37
private readonly object m_readListLock = new object();
private readonly object m_writeListLock = new object();
/// </param>
/// <returns>The matching concrete tag implementation, or <see langword="null"/> for an unsupported datatype.</returns>
public static PlcTag TagFactory(string name, ItemAddress address, uint softdatatype, bool Is1Dim = false)
public static PlcTag TagFactory(string name, ItemAddress address, uint softdatatype, bool Is1Dim = false, int maxStringLength = 0)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

i think this is not really relevant

Comment on lines +137 to +139
var stringMaxLength = maxStringLength > 0 && maxStringLength <= byte.MaxValue
? (byte)maxStringLength
: (byte)254;
var wstringMaxLength = maxStringLength > 0 && maxStringLength <= ushort.MaxValue
? (ushort)maxStringLength
: (ushort)254;
return new PlcTagWString(name, address, softdatatype, wstringMaxLength);
Comment on lines +551 to +552
// For a string array, UnspecifiedOffsetinfo1 carries the maximum string length of the array elements.
public override int MaxStringLength() { return UnspecifiedOffsetinfo1; }
@jogibear9988
jogibear9988 merged commit fd13375 into dotnetprojects:master Oct 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants