diff --git a/Libraries/Opc.Ua.Client.ComplexTypes/ComplexTypeSystem.cs b/Libraries/Opc.Ua.Client.ComplexTypes/ComplexTypeSystem.cs index a07b70f577..92093b9ae6 100644 --- a/Libraries/Opc.Ua.Client.ComplexTypes/ComplexTypeSystem.cs +++ b/Libraries/Opc.Ua.Client.ComplexTypes/ComplexTypeSystem.cs @@ -276,7 +276,7 @@ namespace Opc.Ua.Client.ComplexTypes var typeSystem = await m_session.LoadDataTypeSystem().ConfigureAwait(false); // sort dictionaries with import dependencies to the end of the list - var sortedTypeSystem = typeSystem.OrderBy(t => t.Value.TypeDictionary?.Import?.Count()).ToList(); + var sortedTypeSystem = typeSystem.OrderBy(t => t.Value.TypeDictionary?.Import?.Length).ToList(); bool allTypesLoaded = true; diff --git a/Libraries/Opc.Ua.Client.ComplexTypes/TypeBuilder/AttributeExtensions.cs b/Libraries/Opc.Ua.Client.ComplexTypes/TypeBuilder/AttributeExtensions.cs index fae7202aaa..fd4dbaf624 100644 --- a/Libraries/Opc.Ua.Client.ComplexTypes/TypeBuilder/AttributeExtensions.cs +++ b/Libraries/Opc.Ua.Client.ComplexTypes/TypeBuilder/AttributeExtensions.cs @@ -87,7 +87,7 @@ namespace Opc.Ua.Client.ComplexTypes ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes); CustomAttributeBuilder builder = new CustomAttributeBuilder( ctorInfo, - new object[0], // constructor arguments + Array.Empty(), // constructor arguments new[] // properties to assign { attributeType.GetProperty("DefaultEncodingId"), @@ -117,7 +117,7 @@ namespace Opc.Ua.Client.ComplexTypes ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes); CustomAttributeBuilder builder = new CustomAttributeBuilder( ctorInfo, - new object[0], // constructor arguments + Array.Empty(), // constructor arguments new[] // properties to assign { attributeType.GetProperty("ComplexTypeId"), @@ -144,7 +144,7 @@ namespace Opc.Ua.Client.ComplexTypes ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes); CustomAttributeBuilder builder = new CustomAttributeBuilder( ctorInfo, - new object[0], // constructor arguments + Array.Empty(), // constructor arguments new[] // properties to assign { attributeType.GetProperty("ValueRank"), @@ -170,7 +170,7 @@ namespace Opc.Ua.Client.ComplexTypes ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes); CustomAttributeBuilder builder = new CustomAttributeBuilder( ctorInfo, - new object[0], // constructor arguments + Array.Empty(), // constructor arguments new[] // properties to assign { attributeType.GetProperty("Value") @@ -193,7 +193,7 @@ namespace Opc.Ua.Client.ComplexTypes ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes); CustomAttributeBuilder builder = new CustomAttributeBuilder( ctorInfo, - new object[0], // constructor arguments + Array.Empty(), // constructor arguments new[] // properties to assign { attributeType.GetProperty("Name"), @@ -218,7 +218,7 @@ namespace Opc.Ua.Client.ComplexTypes ConstructorInfo ctorInfo = attributeType.GetConstructor(Type.EmptyTypes); CustomAttributeBuilder builder = new CustomAttributeBuilder( ctorInfo, - new object[0], // constructor arguments + Array.Empty(), // constructor arguments new[] // properties to assign { attributeType.GetProperty("Namespace") diff --git a/Libraries/Opc.Ua.Client.ComplexTypes/Types/BaseComplexType.cs b/Libraries/Opc.Ua.Client.ComplexTypes/Types/BaseComplexType.cs index 5df6f9a1ad..446678accc 100644 --- a/Libraries/Opc.Ua.Client.ComplexTypes/Types/BaseComplexType.cs +++ b/Libraries/Opc.Ua.Client.ComplexTypes/Types/BaseComplexType.cs @@ -278,7 +278,7 @@ namespace Opc.Ua.Client.ComplexTypes { if (body.Length == 0) { - body.Append("{"); + body.Append('{'); } else { @@ -302,17 +302,17 @@ namespace Opc.Ua.Client.ComplexTypes { bool first = true; var enumerable = value as IEnumerable; - body.Append("["); + body.Append('['); foreach (var item in enumerable) { if (!first) { - body.Append(","); + body.Append(','); } AppendPropertyValue(formatProvider, body, item); first = false; } - body.Append("]"); + body.Append(']'); } else { diff --git a/Libraries/Opc.Ua.Client.ComplexTypes/Types/OptionalFieldsComplexType.cs b/Libraries/Opc.Ua.Client.ComplexTypes/Types/OptionalFieldsComplexType.cs index d91eed7634..908fea5784 100644 --- a/Libraries/Opc.Ua.Client.ComplexTypes/Types/OptionalFieldsComplexType.cs +++ b/Libraries/Opc.Ua.Client.ComplexTypes/Types/OptionalFieldsComplexType.cs @@ -202,7 +202,7 @@ namespace Opc.Ua.Client.ComplexTypes if (body.Length > 0) { - body.Append("}"); + body.Append('}'); return body.ToString(); } diff --git a/Libraries/Opc.Ua.Client.ComplexTypes/Types/UnionComplexType.cs b/Libraries/Opc.Ua.Client.ComplexTypes/Types/UnionComplexType.cs index 1cb7df0250..a7f2b78847 100644 --- a/Libraries/Opc.Ua.Client.ComplexTypes/Types/UnionComplexType.cs +++ b/Libraries/Opc.Ua.Client.ComplexTypes/Types/UnionComplexType.cs @@ -215,7 +215,7 @@ namespace Opc.Ua.Client.ComplexTypes if (body.Length > 0) { - body.Append("}"); + body.Append('}'); return body.ToString(); } diff --git a/Libraries/Opc.Ua.Gds.Server.Common/ApplicationsDatabaseBase.cs b/Libraries/Opc.Ua.Gds.Server.Common/ApplicationsDatabaseBase.cs index d97ee23025..def03bca14 100644 --- a/Libraries/Opc.Ua.Gds.Server.Common/ApplicationsDatabaseBase.cs +++ b/Libraries/Opc.Ua.Gds.Server.Common/ApplicationsDatabaseBase.cs @@ -1,4 +1,4 @@ -/* ======================================================================== +/* ======================================================================== * Copyright (c) 2005-2020 The OPC Foundation, Inc. All rights reserved. * * OPC Foundation MIT License 1.00 @@ -494,7 +494,7 @@ namespace Opc.Ua.Gds.Server.Database ii++; } - buffer.Append("]"); + buffer.Append(']'); tokens.Add(buffer.ToString()); buffer.Length = 0; diff --git a/Libraries/Opc.Ua.Gds.Server.Common/ApplicationsNodeManager.cs b/Libraries/Opc.Ua.Gds.Server.Common/ApplicationsNodeManager.cs index 2884b82fba..06489e8abb 100644 --- a/Libraries/Opc.Ua.Gds.Server.Common/ApplicationsNodeManager.cs +++ b/Libraries/Opc.Ua.Gds.Server.Common/ApplicationsNodeManager.cs @@ -681,7 +681,7 @@ namespace Opc.Ua.Gds.Server { if (builder.Length > 0) { - builder.Append(","); + builder.Append(','); } if (field.StartsWith("CN=", StringComparison.Ordinal)) diff --git a/Stack/Opc.Ua.Bindings.Https/Stack/Https/HttpsTransportListener.cs b/Stack/Opc.Ua.Bindings.Https/Stack/Https/HttpsTransportListener.cs index 12e6a9920c..153f35a01e 100644 --- a/Stack/Opc.Ua.Bindings.Https/Stack/Https/HttpsTransportListener.cs +++ b/Stack/Opc.Ua.Bindings.Https/Stack/Https/HttpsTransportListener.cs @@ -234,7 +234,7 @@ namespace Opc.Ua.Bindings httpsOptions.CheckCertificateRevocation = false; httpsOptions.ClientCertificateMode = ClientCertificateMode.NoCertificate; httpsOptions.ServerCertificate = m_serverCert; - httpsOptions.SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12; + httpsOptions.SslProtocols = SslProtocols.None; m_hostBuilder.UseKestrel(options => { options.Listen(IPAddress.Any, m_uri.Port, listenOptions => { // listenOptions.NoDelay = true; @@ -342,7 +342,11 @@ namespace Opc.Ua.Bindings context.Response.ContentLength = response.Length; context.Response.ContentType = context.Request.ContentType; context.Response.StatusCode = (int)HttpStatusCode.OK; +#if NETSTANDARD2_1 + await context.Response.Body.WriteAsync(response.AsMemory(0, response.Length)).ConfigureAwait(false); +#else await context.Response.Body.WriteAsync(response, 0, response.Length).ConfigureAwait(false); +#endif } catch (Exception e) { diff --git a/Tests/Opc.Ua.Core.Tests/Security/Certificates/CertificateValidatorTest.cs b/Tests/Opc.Ua.Core.Tests/Security/Certificates/CertificateValidatorTest.cs index 8c4ac0ceba..8632110829 100644 --- a/Tests/Opc.Ua.Core.Tests/Security/Certificates/CertificateValidatorTest.cs +++ b/Tests/Opc.Ua.Core.Tests/Security/Certificates/CertificateValidatorTest.cs @@ -1179,7 +1179,7 @@ namespace Opc.Ua.Core.Tests.Security.Certificates // override the autoaccept flag, but do not approve certValidator = validator.Update(); certValidator.AutoAcceptUntrustedCertificates = autoAccept; - approver = new CertValidationApprover(new StatusCode[] { }); + approver = new CertValidationApprover(Array.Empty()); certValidator.CertificateValidation += approver.OnCertificateValidation; if (trusted) { diff --git a/Tests/Opc.Ua.Core.Tests/Types/Utils/UtilTests.cs b/Tests/Opc.Ua.Core.Tests/Types/Utils/UtilTests.cs index 9dbbb1b4a0..7fed0b5d03 100644 --- a/Tests/Opc.Ua.Core.Tests/Types/Utils/UtilTests.cs +++ b/Tests/Opc.Ua.Core.Tests/Types/Utils/UtilTests.cs @@ -165,6 +165,10 @@ namespace Opc.Ua.Core.Tests.Types.UtilsTests /// exponential entity expansion in this version of .NET. /// [Test] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Security", "CA3075:Insecure DTD processing in XML", + Justification = + "Validate that XmlDocument DtdProcessing is protected against" + + "exponential entity expansion in this version of .NET.")] public void ExponentialEntityExpansionProcessing() { StringBuilder xmlEEXX = new StringBuilder(); diff --git a/Tests/Opc.Ua.PubSub.Tests/Transport/UdpClientCreatorTests.cs b/Tests/Opc.Ua.PubSub.Tests/Transport/UdpClientCreatorTests.cs index 1971d65169..29a9e67e26 100644 --- a/Tests/Opc.Ua.PubSub.Tests/Transport/UdpClientCreatorTests.cs +++ b/Tests/Opc.Ua.PubSub.Tests/Transport/UdpClientCreatorTests.cs @@ -203,7 +203,7 @@ namespace Opc.Ua.PubSub.Tests.Transport if (isValidIP) { byte[] ipAddressBytes = validIp.GetAddressBytes(); - for (int pos = 0; pos < ipAddressBytes.Count() - 1; pos++) + for (int pos = 0; pos < ipAddressBytes.Length - 1; pos++) { newIPAddress += string.Format("{0}.", ipAddressBytes[pos]); } diff --git a/Tests/Opc.Ua.PubSub.Tests/Transport/UdpPubSubConnectionTests.cs b/Tests/Opc.Ua.PubSub.Tests/Transport/UdpPubSubConnectionTests.cs index 8b92470f6d..3876dc75db 100644 --- a/Tests/Opc.Ua.PubSub.Tests/Transport/UdpPubSubConnectionTests.cs +++ b/Tests/Opc.Ua.PubSub.Tests/Transport/UdpPubSubConnectionTests.cs @@ -246,7 +246,7 @@ namespace Opc.Ua.PubSub.Tests.Transport if (isValidIP) { byte[] ipAddressBytes = validIp.GetAddressBytes(); - ipAddressBytes[ipAddressBytes.Count() - 1] = lastIpByte; + ipAddressBytes[ipAddressBytes.Length - 1] = lastIpByte; return new IPAddress(ipAddressBytes); } } diff --git a/UA Core Library.sln b/UA Core Library.sln index 3ef5cc1b7a..170346c77e 100644 --- a/UA Core Library.sln +++ b/UA Core Library.sln @@ -28,6 +28,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .editorconfig = .editorconfig azure-pipelines-preview.yml = azure-pipelines-preview.yml azure-pipelines.yml = azure-pipelines.yml + Tests\codecoverage.cmd = Tests\codecoverage.cmd common.props = common.props Directory.Build.props = Directory.Build.props lgtm.yml = lgtm.yml diff --git a/common.props b/common.props index 1a4550106b..483a7850b1 100644 --- a/common.props +++ b/common.props @@ -11,6 +11,7 @@ en-US true false + true true