Skip to content

Commit ea83537

Browse files
fa-yoshinobuclaude
andcommitted
fix: initialize TargetAddress with correct defaults (Station=0xFF, ModuleIo=0x03FF)
new() zero-initializes a record struct, ignoring primary constructor default values. Use named arguments to correctly set Station and ModuleIo defaults. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 249da7a commit ea83537

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/PlcComm.Slmp/SlmpClient.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ public SlmpClient(string host, int port = 1025, SlmpTransportMode transportMode
5050
/// <summary>Gets or sets the device access compatibility mode (Legacy or iQ-R).</summary>
5151
public SlmpCompatibilityMode CompatibilityMode { get; set; } = SlmpCompatibilityMode.Iqr;
5252
/// <summary>Gets or sets the destination routing information.</summary>
53-
#pragma warning disable CA1805 // Explicit initialization to non-default struct defaults (Station=0xFF, ModuleIo=0x03FF)
54-
public SlmpTargetAddress TargetAddress { get; set; } = new();
55-
#pragma warning restore CA1805
53+
public SlmpTargetAddress TargetAddress { get; set; } = new(Station: 0xFF, ModuleIo: 0x03FF);
5654
/// <summary>Gets or sets the monitoring timer value (multiples of 250ms). Default is 0x0010 (4s).</summary>
5755
public ushort MonitoringTimer { get; set; } = 0x0010;
5856
/// <summary>Gets or sets the communication timeout.</summary>

0 commit comments

Comments
 (0)