Skip to content

Commit 8966e1d

Browse files
authored
[Server] Use Classes instead of Interfaces for NodeManagers to ensure compatibility for 1.5.378 (#3497)
* Point to concrete classes instead of interfaces * cleanup
1 parent 9f335c3 commit 8966e1d

File tree

13 files changed

+78
-82
lines changed

13 files changed

+78
-82
lines changed

Applications/ConsoleReferenceClient/ClientSamples.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,6 @@ public void ExportNodesToNodeSet2(ISession session, IList<INode> nodes, string f
16171617
stopwatch.ElapsedMilliseconds);
16181618
}
16191619

1620-
16211620
/// <summary>
16221621
/// Exports nodes to separate NodeSet2 XML files, one per namespace.
16231622
/// Excludes OPC Foundation companion specifications (namespaces starting with http://opcfoundation.org/UA/).
@@ -1664,10 +1663,10 @@ public async Task<IReadOnlyDictionary<string, string>> ExportNodesToNodeSet2PerN
16641663
.GroupBy(node => node.NodeId.NamespaceIndex)
16651664
.Where(group =>
16661665
{
1667-
var namespaceUri = session.NamespaceUris.GetString(group.Key);
1666+
string namespaceUri = session.NamespaceUris.GetString(group.Key);
16681667
// Exclude OPC Foundation companion specifications
16691668
return !string.IsNullOrEmpty(namespaceUri) &&
1670-
!namespaceUri.StartsWith("http://opcfoundation.org/UA/", StringComparison.OrdinalIgnoreCase);
1669+
!namespaceUri.StartsWith("http://opcfoundation.org/UA/", StringComparison.OrdinalIgnoreCase);
16711670
})
16721671
.ToDictionary(
16731672
group => group.Key,
@@ -1676,16 +1675,16 @@ public async Task<IReadOnlyDictionary<string, string>> ExportNodesToNodeSet2PerN
16761675
var exportedFiles = new Dictionary<string, string>();
16771676

16781677
// Export each namespace to its own file
1679-
foreach (var kvp in nodesByNamespace)
1678+
foreach (KeyValuePair<ushort, List<INode>> kvp in nodesByNamespace)
16801679
{
16811680
cancellationToken.ThrowIfCancellationRequested();
16821681

1683-
var namespaceUri = session.NamespaceUris.GetString(kvp.Key);
1684-
1682+
string namespaceUri = session.NamespaceUris.GetString(kvp.Key);
1683+
16851684
// Create a safe filename from the namespace URI
1686-
1687-
var fileName = CreateSafeFileName(namespaceUri, kvp.Key);
1688-
var filePath = Path.Combine(outputDirectory, fileName);
1685+
1686+
string fileName = CreateSafeFileName(namespaceUri, kvp.Key);
1687+
string filePath = Path.Combine(outputDirectory, fileName);
16891688

16901689
m_logger.LogInformation(
16911690
"Exporting namespace {NamespaceIndex} ({NamespaceUri}): {Count} nodes to {FilePath}",
@@ -1729,14 +1728,13 @@ await Task.Run(() =>
17291728
private static string CreateSafeFileName(string namespaceUri, ushort namespaceIndex)
17301729
{
17311730
// Extract meaningful part from URI
1732-
var fileName = namespaceUri
1733-
.Replace("http://", "")
1734-
.Replace("https://", "")
1735-
.Replace("urn:", "");
1731+
string fileName = namespaceUri
1732+
.Replace("http://", string.Empty, StringComparison.OrdinalIgnoreCase)
1733+
.Replace("https://", string.Empty, StringComparison.OrdinalIgnoreCase)
1734+
.Replace("urn:", string.Empty, StringComparison.OrdinalIgnoreCase);
17361735

17371736
// Replace invalid filename characters
1738-
var invalidChars = Path.GetInvalidFileNameChars();
1739-
foreach (var c in invalidChars)
1737+
foreach (char c in Path.GetInvalidFileNameChars())
17401738
{
17411739
fileName = fileName.Replace(c, '_');
17421740
}

Applications/Quickstarts.Servers/ReferenceServer/ReferenceServer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public class ReferenceServer : ReverseConnectServer
7575
/// always creates a CoreNodeManager which handles the built-in nodes defined by the specification.
7676
/// Any additional NodeManagers are expected to handle application specific nodes.
7777
/// </remarks>
78-
protected override IMasterNodeManager CreateMasterNodeManager(
78+
protected override MasterNodeManager CreateMasterNodeManager(
7979
IServerInternal server,
8080
ApplicationConfiguration configuration)
8181
{
@@ -332,7 +332,7 @@ private void SessionManager_ImpersonateUser(ISession session, ImpersonateEventAr
332332
m_logger.LogInformation(
333333
Utils.TraceMasks.Security,
334334
"X509 Token Accepted: {Identity}",
335-
args.Identity?.DisplayName);
335+
args.Identity.DisplayName);
336336

337337
return;
338338
}

Libraries/Opc.Ua.Gds.Server.Common/GlobalDiscoverySampleServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected override void OnServerStarted(IServerInternal server)
9191
/// always creates a CoreNodeManager which handles the built-in nodes defined by the specification.
9292
/// Any additional NodeManagers are expected to handle application specific nodes.
9393
/// </remarks>
94-
protected override IMasterNodeManager CreateMasterNodeManager(
94+
protected override MasterNodeManager CreateMasterNodeManager(
9595
IServerInternal server,
9696
ApplicationConfiguration configuration)
9797
{

Libraries/Opc.Ua.PubSub/Transport/MqttPubSubConnection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,13 @@ public override async Task<bool> PublishNetworkMessageAsync(UaNetworkMessage net
257257

258258
try
259259
{
260-
IMqttClient publisherClient;
260+
MqttClient publisherClient;
261261
lock (Lock)
262262
{
263263
publisherClient = m_publisherMqttClient;
264264
}
265265

266-
if (publisherClient != null && publisherClient.IsConnected)
266+
if (publisherClient.IsConnected)
267267
{
268268
// get the encoded bytes
269269
byte[] bytes = networkMessage.Encode(MessageContext);

Libraries/Opc.Ua.Server/Configuration/ConfigurationNodeManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public void HasApplicationSecureAdminAccess(ISystemContext context)
393393
/// <inheritdoc/>
394394
public void HasApplicationSecureAdminAccess(
395395
ISystemContext context,
396-
CertificateStoreIdentifier _)
396+
CertificateStoreIdentifier trustedStore)
397397
{
398398
if (context is SessionSystemContext { OperationContext: OperationContext operationContext })
399399
{

Libraries/Opc.Ua.Server/NodeManager/IMasterNodeManager.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ public interface IMasterNodeManager
4747
/// <summary>
4848
/// Returns the configuration node manager.
4949
/// </summary>
50-
IConfigurationNodeManager ConfigurationNodeManager { get; }
50+
ConfigurationNodeManager ConfigurationNodeManager { get; }
5151

5252
/// <summary>
5353
/// Returns the core node manager.
5454
/// </summary>
55-
ICoreNodeManager CoreNodeManager { get; }
55+
CoreNodeManager CoreNodeManager { get; }
5656

5757
/// <summary>
5858
/// Returns the diagnostics node manager.
5959
/// </summary>
60-
IDiagnosticsNodeManager DiagnosticsNodeManager { get; }
60+
DiagnosticsNodeManager DiagnosticsNodeManager { get; }
6161

6262
/// <summary>
6363
/// The node managers being managed.
@@ -221,7 +221,6 @@ ValueTask ModifyMonitoredItemsAsync(
221221
/// </para>
222222
/// </remarks>
223223
/// <exception cref="ArgumentNullException">Throw if the namespaceUri or the nodeManager are null.</exception>
224-
225224
void RegisterNamespaceManager(string namespaceUri, IAsyncNodeManager nodeManager);
226225

227226
/// <summary>
@@ -248,7 +247,6 @@ ValueTask ModifyMonitoredItemsAsync(
248247
/// Registers a set of node ids.
249248
/// </summary>
250249
/// <exception cref="ArgumentNullException"><paramref name="nodesToRegister"/> is <c>null</c>.</exception>
251-
252250
void RegisterNodes(OperationContext context, NodeIdCollection nodesToRegister, out NodeIdCollection registeredNodeIds);
253251

254252
/// <summary>

Libraries/Opc.Ua.Server/NodeManager/MasterNodeManager.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,15 @@ protected static PermissionType GetHistoryPermissionType(PerformUpdateType updat
303303
}
304304

305305
/// <inheritdoc/>
306-
public ICoreNodeManager CoreNodeManager => m_nodeManagers[1].SyncNodeManager as ICoreNodeManager;
306+
public CoreNodeManager CoreNodeManager => m_nodeManagers[1].SyncNodeManager as CoreNodeManager;
307307

308308
/// <inheritdoc/>
309-
public IDiagnosticsNodeManager DiagnosticsNodeManager
310-
=> m_nodeManagers[0].SyncNodeManager as IDiagnosticsNodeManager;
309+
public DiagnosticsNodeManager DiagnosticsNodeManager
310+
=> m_nodeManagers[0].SyncNodeManager as DiagnosticsNodeManager;
311311

312312
/// <inheritdoc/>
313-
public IConfigurationNodeManager ConfigurationNodeManager
314-
=> m_nodeManagers[0].SyncNodeManager as IConfigurationNodeManager;
313+
public ConfigurationNodeManager ConfigurationNodeManager
314+
=> m_nodeManagers[0].SyncNodeManager as ConfigurationNodeManager;
315315

316316
/// <inheritdoc/>
317317
public virtual async ValueTask StartupAsync(CancellationToken cancellationToken = default)
@@ -3468,7 +3468,7 @@ protected ServiceResult ValidateCallRequestItem(
34683468

34693469
// Initialize input arguments to empty collection if null.
34703470
// Methods with only output parameters (no input parameters) are valid.
3471-
callMethodRequest.InputArguments ??= new VariantCollection();
3471+
callMethodRequest.InputArguments ??= [];
34723472

34733473
return StatusCodes.Good;
34743474
}

Libraries/Opc.Ua.Server/Server/IServerInternal.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,25 @@ public interface IServerInternal : IAuditEventServer, IDisposable
9696
/// The master node manager for the server.
9797
/// </summary>
9898
/// <value>The node manager.</value>
99-
IMasterNodeManager NodeManager { get; }
99+
MasterNodeManager NodeManager { get; }
100100

101101
/// <summary>
102102
/// The internal node manager for the servers.
103103
/// </summary>
104104
/// <value>The core node manager.</value>
105-
ICoreNodeManager CoreNodeManager { get; }
105+
CoreNodeManager CoreNodeManager { get; }
106106

107107
/// <summary>
108108
/// Returns the node manager that managers the server diagnostics.
109109
/// </summary>
110110
/// <value>The diagnostics node manager.</value>
111-
IDiagnosticsNodeManager DiagnosticsNodeManager { get; }
111+
DiagnosticsNodeManager DiagnosticsNodeManager { get; }
112112

113113
/// <summary>
114114
/// Returns the node manager that managers the server configuration.
115115
/// </summary>
116116
/// <value>The configuration node manager.</value>
117-
IConfigurationNodeManager ConfigurationNodeManager { get; }
117+
ConfigurationNodeManager ConfigurationNodeManager { get; }
118118

119119
/// <summary>
120120
/// The manager for events that all components use to queue events that occur.
@@ -298,7 +298,7 @@ void CreateServerObject(
298298
/// Stores the MasterNodeManager and the CoreNodeManager
299299
/// </summary>
300300
/// <param name="nodeManager">The node manager.</param>
301-
void SetNodeManager(IMasterNodeManager nodeManager);
301+
void SetNodeManager(MasterNodeManager nodeManager);
302302

303303
/// <summary>
304304
/// Stores the MainNodeManagerFactory

Libraries/Opc.Ua.Server/Server/ServerInternalData.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ protected virtual void Dispose(bool disposing)
148148
/// Stores the MasterNodeManager, the DiagnosticsNodeManager and the CoreNodeManager
149149
/// </summary>
150150
/// <param name="nodeManager">The node manager.</param>
151-
public void SetNodeManager(IMasterNodeManager nodeManager)
151+
public void SetNodeManager(MasterNodeManager nodeManager)
152152
{
153153
NodeManager = nodeManager;
154154
DiagnosticsNodeManager = nodeManager.DiagnosticsNodeManager;
@@ -285,7 +285,7 @@ public void SetModellingRulesManager(ModellingRulesManager modellingRulesManager
285285
/// The master node manager for the server.
286286
/// </summary>
287287
/// <value>The node manager.</value>
288-
public IMasterNodeManager NodeManager { get; private set; }
288+
public MasterNodeManager NodeManager { get; private set; }
289289

290290
/// <inheritdoc/>
291291
public IMainNodeManagerFactory MainNodeManagerFactory { get; private set; }
@@ -294,16 +294,16 @@ public void SetModellingRulesManager(ModellingRulesManager modellingRulesManager
294294
/// The internal node manager for the servers.
295295
/// </summary>
296296
/// <value>The core node manager.</value>
297-
public ICoreNodeManager CoreNodeManager { get; private set; }
297+
public CoreNodeManager CoreNodeManager { get; private set; }
298298

299299
/// <summary>
300300
/// Returns the node manager that managers the server diagnostics.
301301
/// </summary>
302302
/// <value>The diagnostics node manager.</value>
303-
public IDiagnosticsNodeManager DiagnosticsNodeManager { get; private set; }
303+
public DiagnosticsNodeManager DiagnosticsNodeManager { get; private set; }
304304

305305
/// <inheritdoc/>
306-
public IConfigurationNodeManager ConfigurationNodeManager { get; private set; }
306+
public ConfigurationNodeManager ConfigurationNodeManager { get; private set; }
307307

308308
/// <summary>
309309
/// The manager for events that all components use to queue events that occur.

Libraries/Opc.Ua.Server/Server/StandardServer.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,10 +2327,11 @@ public bool RegisterWithDiscoveryServer()
23272327
/// <inheritdoc/>
23282328
public async ValueTask<bool> RegisterWithDiscoveryServerAsync(CancellationToken ct = default)
23292329
{
2330-
var configuration = new ApplicationConfiguration(Configuration);
2331-
2332-
// use a dedicated certificate validator with the registration, but derive behavior from server config
2333-
configuration.CertificateValidator = new CertificateValidator(MessageContext.Telemetry);
2330+
var configuration = new ApplicationConfiguration(Configuration)
2331+
{
2332+
// use a dedicated certificate validator with the registration, but derive behavior from server config
2333+
CertificateValidator = new CertificateValidator(MessageContext.Telemetry)
2334+
};
23342335
await configuration
23352336
.CertificateValidator.UpdateAsync(
23362337
configuration.SecurityConfiguration,
@@ -2625,8 +2626,8 @@ protected virtual void OnApplicationCertificateError(
26252626
/// <summary>
26262627
/// Verifies that the request header is valid.
26272628
/// </summary>
2628-
/// <param name="requestHeader">The request header.</param>
26292629
/// <param name="secureChannelContext">The secure channel context.</param>
2630+
/// <param name="requestHeader">The request header.</param>
26302631
/// <param name="requestType">Type of the request.</param>
26312632
/// <exception cref="ServiceResultException"></exception>
26322633
protected virtual OperationContext ValidateRequest(
@@ -3044,7 +3045,7 @@ await base.StartApplicationAsync(configuration, cancellationToken)
30443045

30453046
// create the master node manager.
30463047
m_logger.LogInformation(Utils.TraceMasks.StartStop, "Server - CreateMasterNodeManager.");
3047-
IMasterNodeManager masterNodeManager = CreateMasterNodeManager(
3048+
MasterNodeManager masterNodeManager = CreateMasterNodeManager(
30483049
m_serverInternal,
30493050
configuration);
30503051

@@ -3626,7 +3627,7 @@ protected virtual ResourceManager CreateResourceManager(
36263627
/// <param name="server">The server.</param>
36273628
/// <param name="configuration">The configuration.</param>
36283629
/// <returns>Returns the master node manager for the server, the return type is <seealso cref="MasterNodeManager"/>.</returns>
3629-
protected virtual IMasterNodeManager CreateMasterNodeManager(
3630+
protected virtual MasterNodeManager CreateMasterNodeManager(
36303631
IServerInternal server,
36313632
ApplicationConfiguration configuration)
36323633
{

0 commit comments

Comments
 (0)