diff --git a/Applications/ConsoleReferenceClient/ClientSamples.cs b/Applications/ConsoleReferenceClient/ClientSamples.cs index 5ec8ff807..398116f05 100644 --- a/Applications/ConsoleReferenceClient/ClientSamples.cs +++ b/Applications/ConsoleReferenceClient/ClientSamples.cs @@ -1617,7 +1617,6 @@ public void ExportNodesToNodeSet2(ISession session, IList nodes, string f stopwatch.ElapsedMilliseconds); } - /// /// Exports nodes to separate NodeSet2 XML files, one per namespace. /// Excludes OPC Foundation companion specifications (namespaces starting with http://opcfoundation.org/UA/). @@ -1664,10 +1663,10 @@ public async Task> ExportNodesToNodeSet2PerN .GroupBy(node => node.NodeId.NamespaceIndex) .Where(group => { - var namespaceUri = session.NamespaceUris.GetString(group.Key); + string namespaceUri = session.NamespaceUris.GetString(group.Key); // Exclude OPC Foundation companion specifications return !string.IsNullOrEmpty(namespaceUri) && - !namespaceUri.StartsWith("http://opcfoundation.org/UA/", StringComparison.OrdinalIgnoreCase); + !namespaceUri.StartsWith("http://opcfoundation.org/UA/", StringComparison.OrdinalIgnoreCase); }) .ToDictionary( group => group.Key, @@ -1676,16 +1675,16 @@ public async Task> ExportNodesToNodeSet2PerN var exportedFiles = new Dictionary(); // Export each namespace to its own file - foreach (var kvp in nodesByNamespace) + foreach (KeyValuePair> kvp in nodesByNamespace) { cancellationToken.ThrowIfCancellationRequested(); - var namespaceUri = session.NamespaceUris.GetString(kvp.Key); - + string namespaceUri = session.NamespaceUris.GetString(kvp.Key); + // Create a safe filename from the namespace URI - - var fileName = CreateSafeFileName(namespaceUri, kvp.Key); - var filePath = Path.Combine(outputDirectory, fileName); + + string fileName = CreateSafeFileName(namespaceUri, kvp.Key); + string filePath = Path.Combine(outputDirectory, fileName); m_logger.LogInformation( "Exporting namespace {NamespaceIndex} ({NamespaceUri}): {Count} nodes to {FilePath}", @@ -1729,14 +1728,13 @@ await Task.Run(() => private static string CreateSafeFileName(string namespaceUri, ushort namespaceIndex) { // Extract meaningful part from URI - var fileName = namespaceUri - .Replace("http://", "") - .Replace("https://", "") - .Replace("urn:", ""); + string fileName = namespaceUri + .Replace("http://", string.Empty, StringComparison.OrdinalIgnoreCase) + .Replace("https://", string.Empty, StringComparison.OrdinalIgnoreCase) + .Replace("urn:", string.Empty, StringComparison.OrdinalIgnoreCase); // Replace invalid filename characters - var invalidChars = Path.GetInvalidFileNameChars(); - foreach (var c in invalidChars) + foreach (char c in Path.GetInvalidFileNameChars()) { fileName = fileName.Replace(c, '_'); } diff --git a/Applications/Quickstarts.Servers/ReferenceServer/ReferenceServer.cs b/Applications/Quickstarts.Servers/ReferenceServer/ReferenceServer.cs index 248f2d6f0..f764e476c 100644 --- a/Applications/Quickstarts.Servers/ReferenceServer/ReferenceServer.cs +++ b/Applications/Quickstarts.Servers/ReferenceServer/ReferenceServer.cs @@ -75,7 +75,7 @@ public class ReferenceServer : ReverseConnectServer /// always creates a CoreNodeManager which handles the built-in nodes defined by the specification. /// Any additional NodeManagers are expected to handle application specific nodes. /// - protected override IMasterNodeManager CreateMasterNodeManager( + protected override MasterNodeManager CreateMasterNodeManager( IServerInternal server, ApplicationConfiguration configuration) { @@ -332,7 +332,7 @@ private void SessionManager_ImpersonateUser(ISession session, ImpersonateEventAr m_logger.LogInformation( Utils.TraceMasks.Security, "X509 Token Accepted: {Identity}", - args.Identity?.DisplayName); + args.Identity.DisplayName); return; } diff --git a/Libraries/Opc.Ua.Gds.Server.Common/GlobalDiscoverySampleServer.cs b/Libraries/Opc.Ua.Gds.Server.Common/GlobalDiscoverySampleServer.cs index 493eb0361..e0ea9d9ae 100644 --- a/Libraries/Opc.Ua.Gds.Server.Common/GlobalDiscoverySampleServer.cs +++ b/Libraries/Opc.Ua.Gds.Server.Common/GlobalDiscoverySampleServer.cs @@ -91,7 +91,7 @@ protected override void OnServerStarted(IServerInternal server) /// always creates a CoreNodeManager which handles the built-in nodes defined by the specification. /// Any additional NodeManagers are expected to handle application specific nodes. /// - protected override IMasterNodeManager CreateMasterNodeManager( + protected override MasterNodeManager CreateMasterNodeManager( IServerInternal server, ApplicationConfiguration configuration) { diff --git a/Libraries/Opc.Ua.PubSub/Transport/MqttPubSubConnection.cs b/Libraries/Opc.Ua.PubSub/Transport/MqttPubSubConnection.cs index 24875ee1c..a20d8b081 100644 --- a/Libraries/Opc.Ua.PubSub/Transport/MqttPubSubConnection.cs +++ b/Libraries/Opc.Ua.PubSub/Transport/MqttPubSubConnection.cs @@ -257,13 +257,13 @@ public override async Task PublishNetworkMessageAsync(UaNetworkMessage net try { - IMqttClient publisherClient; + MqttClient publisherClient; lock (Lock) { publisherClient = m_publisherMqttClient; } - if (publisherClient != null && publisherClient.IsConnected) + if (publisherClient.IsConnected) { // get the encoded bytes byte[] bytes = networkMessage.Encode(MessageContext); diff --git a/Libraries/Opc.Ua.Server/Configuration/ConfigurationNodeManager.cs b/Libraries/Opc.Ua.Server/Configuration/ConfigurationNodeManager.cs index f21e37e87..a020e8a0f 100644 --- a/Libraries/Opc.Ua.Server/Configuration/ConfigurationNodeManager.cs +++ b/Libraries/Opc.Ua.Server/Configuration/ConfigurationNodeManager.cs @@ -393,7 +393,7 @@ public void HasApplicationSecureAdminAccess(ISystemContext context) /// public void HasApplicationSecureAdminAccess( ISystemContext context, - CertificateStoreIdentifier _) + CertificateStoreIdentifier trustedStore) { if (context is SessionSystemContext { OperationContext: OperationContext operationContext }) { diff --git a/Libraries/Opc.Ua.Server/NodeManager/IMasterNodeManager.cs b/Libraries/Opc.Ua.Server/NodeManager/IMasterNodeManager.cs index 8543d45c2..9c10d8c26 100644 --- a/Libraries/Opc.Ua.Server/NodeManager/IMasterNodeManager.cs +++ b/Libraries/Opc.Ua.Server/NodeManager/IMasterNodeManager.cs @@ -47,17 +47,17 @@ public interface IMasterNodeManager /// /// Returns the configuration node manager. /// - IConfigurationNodeManager ConfigurationNodeManager { get; } + ConfigurationNodeManager ConfigurationNodeManager { get; } /// /// Returns the core node manager. /// - ICoreNodeManager CoreNodeManager { get; } + CoreNodeManager CoreNodeManager { get; } /// /// Returns the diagnostics node manager. /// - IDiagnosticsNodeManager DiagnosticsNodeManager { get; } + DiagnosticsNodeManager DiagnosticsNodeManager { get; } /// /// The node managers being managed. @@ -221,7 +221,6 @@ ValueTask ModifyMonitoredItemsAsync( /// /// /// Throw if the namespaceUri or the nodeManager are null. - void RegisterNamespaceManager(string namespaceUri, IAsyncNodeManager nodeManager); /// @@ -248,7 +247,6 @@ ValueTask ModifyMonitoredItemsAsync( /// Registers a set of node ids. /// /// is null. - void RegisterNodes(OperationContext context, NodeIdCollection nodesToRegister, out NodeIdCollection registeredNodeIds); /// diff --git a/Libraries/Opc.Ua.Server/NodeManager/MasterNodeManager.cs b/Libraries/Opc.Ua.Server/NodeManager/MasterNodeManager.cs index 7c3eb42f2..92c36727a 100644 --- a/Libraries/Opc.Ua.Server/NodeManager/MasterNodeManager.cs +++ b/Libraries/Opc.Ua.Server/NodeManager/MasterNodeManager.cs @@ -303,15 +303,15 @@ protected static PermissionType GetHistoryPermissionType(PerformUpdateType updat } /// - public ICoreNodeManager CoreNodeManager => m_nodeManagers[1].SyncNodeManager as ICoreNodeManager; + public CoreNodeManager CoreNodeManager => m_nodeManagers[1].SyncNodeManager as CoreNodeManager; /// - public IDiagnosticsNodeManager DiagnosticsNodeManager - => m_nodeManagers[0].SyncNodeManager as IDiagnosticsNodeManager; + public DiagnosticsNodeManager DiagnosticsNodeManager + => m_nodeManagers[0].SyncNodeManager as DiagnosticsNodeManager; /// - public IConfigurationNodeManager ConfigurationNodeManager - => m_nodeManagers[0].SyncNodeManager as IConfigurationNodeManager; + public ConfigurationNodeManager ConfigurationNodeManager + => m_nodeManagers[0].SyncNodeManager as ConfigurationNodeManager; /// public virtual async ValueTask StartupAsync(CancellationToken cancellationToken = default) @@ -3468,7 +3468,7 @@ protected ServiceResult ValidateCallRequestItem( // Initialize input arguments to empty collection if null. // Methods with only output parameters (no input parameters) are valid. - callMethodRequest.InputArguments ??= new VariantCollection(); + callMethodRequest.InputArguments ??= []; return StatusCodes.Good; } diff --git a/Libraries/Opc.Ua.Server/Server/IServerInternal.cs b/Libraries/Opc.Ua.Server/Server/IServerInternal.cs index 33f49e96e..bbc42ec23 100644 --- a/Libraries/Opc.Ua.Server/Server/IServerInternal.cs +++ b/Libraries/Opc.Ua.Server/Server/IServerInternal.cs @@ -96,25 +96,25 @@ public interface IServerInternal : IAuditEventServer, IDisposable /// The master node manager for the server. /// /// The node manager. - IMasterNodeManager NodeManager { get; } + MasterNodeManager NodeManager { get; } /// /// The internal node manager for the servers. /// /// The core node manager. - ICoreNodeManager CoreNodeManager { get; } + CoreNodeManager CoreNodeManager { get; } /// /// Returns the node manager that managers the server diagnostics. /// /// The diagnostics node manager. - IDiagnosticsNodeManager DiagnosticsNodeManager { get; } + DiagnosticsNodeManager DiagnosticsNodeManager { get; } /// /// Returns the node manager that managers the server configuration. /// /// The configuration node manager. - IConfigurationNodeManager ConfigurationNodeManager { get; } + ConfigurationNodeManager ConfigurationNodeManager { get; } /// /// The manager for events that all components use to queue events that occur. @@ -298,7 +298,7 @@ void CreateServerObject( /// Stores the MasterNodeManager and the CoreNodeManager /// /// The node manager. - void SetNodeManager(IMasterNodeManager nodeManager); + void SetNodeManager(MasterNodeManager nodeManager); /// /// Stores the MainNodeManagerFactory diff --git a/Libraries/Opc.Ua.Server/Server/ServerInternalData.cs b/Libraries/Opc.Ua.Server/Server/ServerInternalData.cs index 15c9ea5f9..65ac02155 100644 --- a/Libraries/Opc.Ua.Server/Server/ServerInternalData.cs +++ b/Libraries/Opc.Ua.Server/Server/ServerInternalData.cs @@ -148,7 +148,7 @@ protected virtual void Dispose(bool disposing) /// Stores the MasterNodeManager, the DiagnosticsNodeManager and the CoreNodeManager /// /// The node manager. - public void SetNodeManager(IMasterNodeManager nodeManager) + public void SetNodeManager(MasterNodeManager nodeManager) { NodeManager = nodeManager; DiagnosticsNodeManager = nodeManager.DiagnosticsNodeManager; @@ -285,7 +285,7 @@ public void SetModellingRulesManager(ModellingRulesManager modellingRulesManager /// The master node manager for the server. /// /// The node manager. - public IMasterNodeManager NodeManager { get; private set; } + public MasterNodeManager NodeManager { get; private set; } /// public IMainNodeManagerFactory MainNodeManagerFactory { get; private set; } @@ -294,16 +294,16 @@ public void SetModellingRulesManager(ModellingRulesManager modellingRulesManager /// The internal node manager for the servers. /// /// The core node manager. - public ICoreNodeManager CoreNodeManager { get; private set; } + public CoreNodeManager CoreNodeManager { get; private set; } /// /// Returns the node manager that managers the server diagnostics. /// /// The diagnostics node manager. - public IDiagnosticsNodeManager DiagnosticsNodeManager { get; private set; } + public DiagnosticsNodeManager DiagnosticsNodeManager { get; private set; } /// - public IConfigurationNodeManager ConfigurationNodeManager { get; private set; } + public ConfigurationNodeManager ConfigurationNodeManager { get; private set; } /// /// The manager for events that all components use to queue events that occur. diff --git a/Libraries/Opc.Ua.Server/Server/StandardServer.cs b/Libraries/Opc.Ua.Server/Server/StandardServer.cs index d9d1e6ddd..0234add73 100644 --- a/Libraries/Opc.Ua.Server/Server/StandardServer.cs +++ b/Libraries/Opc.Ua.Server/Server/StandardServer.cs @@ -2327,10 +2327,11 @@ public bool RegisterWithDiscoveryServer() /// public async ValueTask RegisterWithDiscoveryServerAsync(CancellationToken ct = default) { - var configuration = new ApplicationConfiguration(Configuration); - - // use a dedicated certificate validator with the registration, but derive behavior from server config - configuration.CertificateValidator = new CertificateValidator(MessageContext.Telemetry); + var configuration = new ApplicationConfiguration(Configuration) + { + // use a dedicated certificate validator with the registration, but derive behavior from server config + CertificateValidator = new CertificateValidator(MessageContext.Telemetry) + }; await configuration .CertificateValidator.UpdateAsync( configuration.SecurityConfiguration, @@ -2625,8 +2626,8 @@ protected virtual void OnApplicationCertificateError( /// /// Verifies that the request header is valid. /// - /// The request header. /// The secure channel context. + /// The request header. /// Type of the request. /// protected virtual OperationContext ValidateRequest( @@ -3044,7 +3045,7 @@ await base.StartApplicationAsync(configuration, cancellationToken) // create the master node manager. m_logger.LogInformation(Utils.TraceMasks.StartStop, "Server - CreateMasterNodeManager."); - IMasterNodeManager masterNodeManager = CreateMasterNodeManager( + MasterNodeManager masterNodeManager = CreateMasterNodeManager( m_serverInternal, configuration); @@ -3626,7 +3627,7 @@ protected virtual ResourceManager CreateResourceManager( /// The server. /// The configuration. /// Returns the master node manager for the server, the return type is . - protected virtual IMasterNodeManager CreateMasterNodeManager( + protected virtual MasterNodeManager CreateMasterNodeManager( IServerInternal server, ApplicationConfiguration configuration) { diff --git a/Tests/Opc.Ua.Client.Tests/ReferenceServerWithLimits.cs b/Tests/Opc.Ua.Client.Tests/ReferenceServerWithLimits.cs index 13c0a1f25..6b8a333ca 100644 --- a/Tests/Opc.Ua.Client.Tests/ReferenceServerWithLimits.cs +++ b/Tests/Opc.Ua.Client.Tests/ReferenceServerWithLimits.cs @@ -97,7 +97,7 @@ public void SetMaxNumberOfContinuationPoints(uint maxNumberOfContinuationPoints) } } - protected override IMasterNodeManager CreateMasterNodeManager( + protected override MasterNodeManager CreateMasterNodeManager( IServerInternal server, ApplicationConfiguration configuration) { diff --git a/Tests/Opc.Ua.Security.Certificates.Tests/Pkcs10CertificationRequestTests.cs b/Tests/Opc.Ua.Security.Certificates.Tests/Pkcs10CertificationRequestTests.cs index 8109e9663..66b899f44 100644 --- a/Tests/Opc.Ua.Security.Certificates.Tests/Pkcs10CertificationRequestTests.cs +++ b/Tests/Opc.Ua.Security.Certificates.Tests/Pkcs10CertificationRequestTests.cs @@ -29,11 +29,9 @@ using System; using System.IO; -using System.Linq; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using NUnit.Framework; -using Opc.Ua.Tests; using Assert = NUnit.Framework.Legacy.ClassicAssert; namespace Opc.Ua.Security.Certificates.Tests @@ -48,7 +46,6 @@ namespace Opc.Ua.Security.Certificates.Tests [SetCulture("en-us")] public class Pkcs10CertificationRequestTests { - #region Test Methods /// /// Test parsing a valid RSA CSR from file. /// @@ -82,8 +79,8 @@ public void ParseValidRsaCsrFromFile() public void CreateAndParseRsaCsr() { const string subject = "CN=Test RSA CSR, O=OPC Foundation"; - string applicationUri = "urn:localhost:opcfoundation.org:TestRsaCsr"; - string[] domainNames = new[] { "localhost", "127.0.0.1" }; + const string applicationUri = "urn:localhost:opcfoundation.org:TestRsaCsr"; + string[] domainNames = ["localhost", "127.0.0.1"]; // Create a certificate to generate CSR from using X509Certificate2 certificate = CertificateBuilder.Create(subject) @@ -102,7 +99,7 @@ public void CreateAndParseRsaCsr() // Verify subject Assert.NotNull(csr.Subject); - Assert.That(csr.Subject.Name, Does.Contain("CN=Test RSA CSR")); + NUnit.Framework.Assert.That(csr.Subject.Name, Does.Contain("CN=Test RSA CSR")); // Verify signature bool isValid = csr.Verify(); @@ -120,8 +117,8 @@ public void CreateAndParseRsaCsr() public void CreateAndParseEcdsaCsrP256() { const string subject = "CN=Test ECDSA P256 CSR, O=OPC Foundation"; - string applicationUri = "urn:localhost:opcfoundation.org:TestEcdsaCsr"; - string[] domainNames = new[] { "localhost", "127.0.0.1" }; + const string applicationUri = "urn:localhost:opcfoundation.org:TestEcdsaCsr"; + string[] domainNames = ["localhost", "127.0.0.1"]; // Create a certificate to generate CSR from using X509Certificate2 certificate = CertificateBuilder.Create(subject) @@ -141,7 +138,7 @@ public void CreateAndParseEcdsaCsrP256() // Verify subject Assert.NotNull(csr.Subject); - Assert.That(csr.Subject.Name, Does.Contain("CN=Test ECDSA P256 CSR")); + NUnit.Framework.Assert.That(csr.Subject.Name, Does.Contain("CN=Test ECDSA P256 CSR")); // Verify SubjectPublicKeyInfo Assert.NotNull(csr.SubjectPublicKeyInfo); @@ -153,7 +150,7 @@ public void CreateAndParseEcdsaCsrP256() Assert.True(isValid, "ECDSA CSR signature should be valid"); #else // ECDSA verification not supported on older frameworks - Assert.Throws(() => csr.Verify()); + NUnit.Framework.Assert.Throws(() => csr.Verify()); #endif } @@ -163,7 +160,7 @@ public void CreateAndParseEcdsaCsrP256() [Test] public void ParseNullCsrThrowsArgumentNullException() { - Assert.Throws(() => new Pkcs10CertificationRequest(null)); + NUnit.Framework.Assert.Throws(() => new Pkcs10CertificationRequest(null)); } /// @@ -172,8 +169,8 @@ public void ParseNullCsrThrowsArgumentNullException() [Test] public void ParseInvalidCsrThrowsCryptographicException() { - byte[] invalidData = new byte[] { 0x01, 0x02, 0x03, 0x04 }; - Assert.Throws(() => new Pkcs10CertificationRequest(invalidData)); + byte[] invalidData = [0x01, 0x02, 0x03, 0x04]; + NUnit.Framework.Assert.Throws(() => new Pkcs10CertificationRequest(invalidData)); } /// @@ -183,8 +180,8 @@ public void ParseInvalidCsrThrowsCryptographicException() public void ParseCsrWithTamperedSignatureFails() { const string subject = "CN=Test Tampered CSR, O=OPC Foundation"; - string applicationUri = "urn:localhost:opcfoundation.org:TestTamperedCsr"; - string[] domainNames = new[] { "localhost" }; + const string applicationUri = "urn:localhost:opcfoundation.org:TestTamperedCsr"; + string[] domainNames = ["localhost"]; // Create a certificate to generate CSR from using X509Certificate2 certificate = CertificateBuilder.Create(subject) @@ -215,8 +212,8 @@ public void ParseCsrWithTamperedSignatureFails() public void ParseCsrAndExtractSubjectAltName() { const string subject = "CN=Test SAN CSR, O=OPC Foundation"; - string applicationUri = "urn:localhost:opcfoundation.org:TestSanCsr"; - string[] domainNames = new[] { "localhost", "testhost.local", "192.168.1.1" }; + const string applicationUri = "urn:localhost:opcfoundation.org:TestSanCsr"; + string[] domainNames = ["localhost", "testhost.local", "192.168.1.1"]; // Create a certificate to generate CSR from using X509Certificate2 certificate = CertificateBuilder.Create(subject) @@ -235,12 +232,12 @@ public void ParseCsrAndExtractSubjectAltName() X509SubjectAltNameExtension sanExtension = Pkcs10Utils.GetSubjectAltNameExtension(csr.Attributes); Assert.NotNull(sanExtension); - Assert.That(sanExtension.Uris, Has.Count.EqualTo(1)); - Assert.That(sanExtension.Uris[0], Is.EqualTo(applicationUri)); + NUnit.Framework.Assert.That(sanExtension.Uris, Has.Count.EqualTo(1)); + NUnit.Framework.Assert.That(sanExtension.Uris[0], Is.EqualTo(applicationUri)); // Verify domain names (may include URIs and domain names) int totalNames = sanExtension.DomainNames.Count + sanExtension.IPAddresses.Count; - Assert.That(totalNames, Is.EqualTo(domainNames.Length)); + NUnit.Framework.Assert.That(totalNames, Is.EqualTo(domainNames.Length)); } /// @@ -293,6 +290,8 @@ public void GetCertificationRequestInfoReturnsValidData() Assert.Greater(requestInfo.Length, 0); } + private static readonly string[] s_domainNames = ["localhost"]; + /// /// Test parsing multiple CSRs in sequence. /// @@ -310,7 +309,7 @@ public void ParseMultipleCsrsInSequence() using X509Certificate2 certificate = CertificateBuilder.Create(subject) .SetNotBefore(DateTime.UtcNow.AddDays(-1)) .SetLifeTime(TimeSpan.FromDays(30)) - .AddExtension(new X509SubjectAltNameExtension(applicationUri, new[] { "localhost" })) + .AddExtension(new X509SubjectAltNameExtension(applicationUri, s_domainNames)) .CreateForRSA(); byte[] csrData = CertificateFactory.CreateSigningRequest(certificate); @@ -321,7 +320,7 @@ public void ParseMultipleCsrsInSequence() csrList.Add(csr); } - Assert.That(csrList, Has.Count.EqualTo(count)); + NUnit.Framework.Assert.That(csrList, Has.Count.EqualTo(count)); } /// @@ -341,9 +340,8 @@ public void SubjectContainsExpectedDNComponents() var csr = new Pkcs10CertificationRequest(csrData); string subjectName = csr.Subject.Name; - Assert.That(subjectName, Does.Contain("CN=TestSubject")); - Assert.That(subjectName, Does.Contain("O=TestOrg")); + NUnit.Framework.Assert.That(subjectName, Does.Contain("CN=TestSubject")); + NUnit.Framework.Assert.That(subjectName, Does.Contain("O=TestOrg")); } - #endregion } } diff --git a/Tests/Opc.Ua.Server.Tests/ReferenceServerTest.cs b/Tests/Opc.Ua.Server.Tests/ReferenceServerTest.cs index aa43b7821..f69106e8c 100644 --- a/Tests/Opc.Ua.Server.Tests/ReferenceServerTest.cs +++ b/Tests/Opc.Ua.Server.Tests/ReferenceServerTest.cs @@ -1138,7 +1138,7 @@ public async Task ServerEventNotifierHistoryReadBitAsync() [Test] public async Task ServerStatusTimestampsMatchAsync() { - var logger = m_telemetry.CreateLogger(); + ILogger logger = m_telemetry.CreateLogger(); // Read ServerStatus children (CurrentTime, StartTime, State, etc.) var nodesToRead = new ReadValueIdCollection @@ -1149,7 +1149,7 @@ public async Task ServerStatusTimestampsMatchAsync() }; m_requestHeader.Timestamp = DateTime.UtcNow; - var readResponse = await m_server.ReadAsync( + ReadResponse readResponse = await m_server.ReadAsync( m_secureChannelContext, m_requestHeader, 0, @@ -1163,7 +1163,7 @@ public async Task ServerStatusTimestampsMatchAsync() // Verify that SourceTimestamp and ServerTimestamp are equal for all ServerStatus children for (int i = 0; i < readResponse.Results.Count; i++) { - var result = readResponse.Results[i]; + DataValue result = readResponse.Results[i]; logger.LogInformation( "NodeId: {NodeId}, SourceTimestamp: {SourceTimestamp}, ServerTimestamp: {ServerTimestamp}", nodesToRead[i].NodeId, @@ -1187,7 +1187,7 @@ public async Task HistoryReadInt32ValueNodeAsync() ILogger logger = telemetry.CreateLogger(); // Get the NodeId for Data_Dynamic_Scalar_Int32Value - NodeId int32ValueNodeId = new NodeId( + var int32ValueNodeId = new NodeId( TestData.Variables.Data_Dynamic_Scalar_Int32Value, (ushort)m_server.CurrentInstance.NamespaceUris.GetIndex(TestData.Namespaces.TestData)); @@ -1227,7 +1227,8 @@ public async Task HistoryReadInt32ValueNodeAsync() "Int32Value node should have HistoryRead access level"); // Perform a history read operation - var historyReadDetails = new ReadRawModifiedDetails { + var historyReadDetails = new ReadRawModifiedDetails + { StartTime = DateTime.UtcNow.AddHours(-1), EndTime = DateTime.UtcNow, NumValuesPerNode = 10, @@ -1271,7 +1272,7 @@ public async Task HistoryReadInt32ValueNodeAsync() Assert.Greater(historyData.DataValues.Count, 0, "Should have at least one historical value"); // Verify the data values have proper timestamps - foreach (var dataValue in historyData.DataValues) + foreach (DataValue dataValue in historyData.DataValues) { Assert.IsNotNull(dataValue, "DataValue should not be null"); Assert.IsTrue(dataValue.ServerTimestamp != DateTime.MinValue, @@ -1280,7 +1281,7 @@ public async Task HistoryReadInt32ValueNodeAsync() } else { - Assert.Fail("HistoryData body should be of type HistoryData"); + NUnit.Framework.Assert.Fail("HistoryData body should be of type HistoryData"); } }