Skip to content

Commit

Permalink
Bump BenchmarkDotNet from 0.13.12 to 0.14.0 and fix some build issues…
Browse files Browse the repository at this point in the history
… for legacy platforms (#2707)

* Bump BenchmarkDotNet from 0.13.12 to 0.14.0
* Fix NetStandard2.0 and Netstandard2.1 ci builds

Bumps [BenchmarkDotNet](https://github.com/dotnet/BenchmarkDotNet) from 0.13.12 to 0.14.0.
- [Release notes](https://github.com/dotnet/BenchmarkDotNet/releases)
- [Commits](dotnet/BenchmarkDotNet@v0.13.12...v0.14.0)

---
updated-dependencies:
- dependency-name: BenchmarkDotNet
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Martin Regen <[email protected]>
  • Loading branch information
dependabot[bot] and mregen authored Aug 13, 2024
1 parent aaf6f7d commit 4b822fc
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SharpFuzz" Version="2.1.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 10 additions & 8 deletions Libraries/Opc.Ua.Client/Subscription/Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -869,12 +869,13 @@ public bool Transfer(ISession session, uint id, UInt32Collection availableSequen
return false;
}

if (serverHandles.Count != m_monitoredItems.Count ||
clientHandles.Count != m_monitoredItems.Count)
int monitoredItemsCount = m_monitoredItems.Count;
if (serverHandles.Count != monitoredItemsCount ||
clientHandles.Count != monitoredItemsCount)
{
// invalid state
Utils.LogError("SubscriptionId {0}: Number of Monitored Items on client and server do not match after transfer {1}!={2}",
Id, serverHandles.Count, m_monitoredItems.Count);
Id, serverHandles.Count, monitoredItemsCount);
return false;
}

Expand Down Expand Up @@ -947,12 +948,13 @@ public async Task<bool> TransferAsync(ISession session, uint id, UInt32Collectio
return false;
}

if (serverHandles.Count != m_monitoredItems.Count ||
clientHandles.Count != m_monitoredItems.Count)
int monitoredItemsCount = m_monitoredItems.Count;
if (serverHandles.Count != monitoredItemsCount ||
clientHandles.Count != monitoredItemsCount)
{
// invalid state
Utils.LogError("SubscriptionId {0}: Number of Monitored Items on client and server do not match after transfer {1}!={2}",
Id, serverHandles.Count, m_monitoredItems.Count);
Id, serverHandles.Count, monitoredItemsCount);
return false;
}

Expand Down Expand Up @@ -1531,7 +1533,7 @@ public void AddItem(MonitoredItem monitoredItem)
}

/// <summary>
/// Adds an item to the subscription.
/// Adds items to the subscription.
/// </summary>
public void AddItems(IEnumerable<MonitoredItem> monitoredItems)
{
Expand Down Expand Up @@ -1586,7 +1588,7 @@ public void RemoveItem(MonitoredItem monitoredItem)
}

/// <summary>
/// Removes an item from the subscription.
/// Removes items from the subscription.
/// </summary>
public void RemoveItems(IEnumerable<MonitoredItem> monitoredItems)
{
Expand Down
69 changes: 17 additions & 52 deletions Libraries/Opc.Ua.Server/Session/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,60 +103,25 @@ public Session(
m_identity = new UserIdentity();

// initialize diagnostics.
m_diagnostics = new SessionDiagnosticsDataType();

m_diagnostics.SessionId = null;
m_diagnostics.SessionName = sessionName;
m_diagnostics.ClientDescription = clientDescription;
m_diagnostics.ServerUri = null;
m_diagnostics.EndpointUrl = endpointUrl;
m_diagnostics.LocaleIds = new StringCollection();
m_diagnostics.ActualSessionTimeout = sessionTimeout;
m_diagnostics.ClientConnectionTime = DateTime.UtcNow;
m_diagnostics.ClientLastContactTime = DateTime.UtcNow;
m_diagnostics.CurrentSubscriptionsCount = 0;
m_diagnostics.CurrentMonitoredItemsCount = 0;
m_diagnostics.CurrentPublishRequestsInQueue = 0;
m_diagnostics.TotalRequestCount = new ServiceCounterDataType();
m_diagnostics.UnauthorizedRequestCount = 0;
m_diagnostics.ReadCount = new ServiceCounterDataType();
m_diagnostics.HistoryReadCount = new ServiceCounterDataType();
m_diagnostics.WriteCount = new ServiceCounterDataType();
m_diagnostics.HistoryUpdateCount = new ServiceCounterDataType();
m_diagnostics.CallCount = new ServiceCounterDataType();
m_diagnostics.CreateMonitoredItemsCount = new ServiceCounterDataType();
m_diagnostics.ModifyMonitoredItemsCount = new ServiceCounterDataType();
m_diagnostics.SetMonitoringModeCount = new ServiceCounterDataType();
m_diagnostics.SetTriggeringCount = new ServiceCounterDataType();
m_diagnostics.DeleteMonitoredItemsCount = new ServiceCounterDataType();
m_diagnostics.CreateSubscriptionCount = new ServiceCounterDataType();
m_diagnostics.ModifySubscriptionCount = new ServiceCounterDataType();
m_diagnostics.SetPublishingModeCount = new ServiceCounterDataType();
m_diagnostics.PublishCount = new ServiceCounterDataType();
m_diagnostics.RepublishCount = new ServiceCounterDataType();
m_diagnostics.TransferSubscriptionsCount = new ServiceCounterDataType();
m_diagnostics.DeleteSubscriptionsCount = new ServiceCounterDataType();
m_diagnostics.AddNodesCount = new ServiceCounterDataType();
m_diagnostics.AddReferencesCount = new ServiceCounterDataType();
m_diagnostics.DeleteNodesCount = new ServiceCounterDataType();
m_diagnostics.DeleteReferencesCount = new ServiceCounterDataType();
m_diagnostics.BrowseCount = new ServiceCounterDataType();
m_diagnostics.BrowseNextCount = new ServiceCounterDataType();
m_diagnostics.TranslateBrowsePathsToNodeIdsCount = new ServiceCounterDataType();
m_diagnostics.QueryFirstCount = new ServiceCounterDataType();
m_diagnostics.QueryNextCount = new ServiceCounterDataType();
m_diagnostics.RegisterNodesCount = new ServiceCounterDataType();
m_diagnostics.UnregisterNodesCount = new ServiceCounterDataType();
DateTime now = DateTime.UtcNow;
m_diagnostics = new SessionDiagnosticsDataType {
SessionId = null,
SessionName = sessionName,
ClientDescription = clientDescription,
ServerUri = null,
EndpointUrl = endpointUrl,
ActualSessionTimeout = sessionTimeout,
ClientConnectionTime = now,
ClientLastContactTime = now,
};

// initialize security diagnostics.
m_securityDiagnostics = new SessionSecurityDiagnosticsDataType();

m_securityDiagnostics.SessionId = m_sessionId;
m_securityDiagnostics.ClientUserIdOfSession = m_identity.DisplayName;
m_securityDiagnostics.AuthenticationMechanism = m_identity.TokenType.ToString();
m_securityDiagnostics.Encoding = context.ChannelContext.MessageEncoding.ToString();

m_securityDiagnostics.ClientUserIdHistory = new StringCollection();
m_securityDiagnostics = new SessionSecurityDiagnosticsDataType {
SessionId = m_sessionId,
ClientUserIdOfSession = m_identity.DisplayName,
AuthenticationMechanism = m_identity.TokenType.ToString(),
Encoding = context.ChannelContext.MessageEncoding.ToString(),
};
m_securityDiagnostics.ClientUserIdHistory.Add(m_identity.DisplayName);

EndpointDescription description = context.ChannelContext.EndpointDescription;
Expand Down
8 changes: 6 additions & 2 deletions Stack/Opc.Ua.Core/Types/Encoders/BinaryDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,12 @@ public XmlElement ReadXmlElement(string fieldName)

try
{
// If 0 terminated, decrease length by one before converting to string
var utf8StringLength = bytes[bytes.Length - 1] == 0 ? bytes.Length - 1 : bytes.Length;
// If 0 terminated, decrease length before converting to string
int utf8StringLength = bytes.Length;
while (utf8StringLength > 0 && bytes[utf8StringLength - 1] == 0)
{
utf8StringLength--;
}
string xmlString = Encoding.UTF8.GetString(bytes, 0, utf8StringLength);
using (StringReader stream = new StringReader(xmlString))
using (XmlReader reader = XmlReader.Create(stream, Utils.DefaultXmlReaderSettings()))
Expand Down
3 changes: 2 additions & 1 deletion Stack/Opc.Ua.Core/Types/Encoders/BinaryEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,9 @@ public void WriteString(string fieldName, string value)
int count = Encoding.UTF8.GetBytes(value, encodedBytes);
WriteByteString(null, encodedBytes.Slice(0, count));
}
else
#if NET5_0_OR_GREATER
else if (maxByteCount > maxByteCountPerBuffer)
if (maxByteCount > maxByteCountPerBuffer)
{
using (var bufferWriter = new ArrayPoolBufferWriter<byte>(minByteCountPerBuffer, maxByteCountPerBuffer))
{
Expand Down
4 changes: 2 additions & 2 deletions Stack/Opc.Ua.Core/Types/Utils/OpcUaCoreEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ internal void WriteFormattedMessage(int id, int eventId, string EventName, strin
{
if (IsEnabled())
{
EventName = EventName ?? "";
FormattedMessage = FormattedMessage ?? "";
EventName = EventName ?? string.Empty;
FormattedMessage = FormattedMessage ?? string.Empty;
WriteEvent(id, eventId, EventName, FormattedMessage);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
</ItemGroup>
Expand Down
17 changes: 10 additions & 7 deletions Tests/Opc.Ua.Core.Tests/Types/Encoders/EncoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/

#if ECC_SUPPORT && !NETFRAMEWORK
#define SPAN_SUPPORT
#endif

using System;
using System.IO;
using System.Text;
Expand Down Expand Up @@ -300,7 +304,7 @@ public void BinaryEncoder_WriteByteString()
using (IEncoder encoder = new BinaryEncoder(stream, new ServiceMessageContext(), true))
{
encoder.WriteByteString("ByteString1", new byte[] { 0, 1, 2, 3, 4, 5 }, 1, 3);
#if NET5_0_OR_GREATER
#if SPAN_SUPPORT
var span = new ReadOnlySpan<byte>(new byte[] { 0, 1, 2, 3, 4, 5 }, 1, 3);
var nullspan = new ReadOnlySpan<byte>(null);
encoder.WriteByteString("ByteString2", span);
Expand All @@ -314,7 +318,7 @@ public void BinaryEncoder_WriteByteString()
{
var result = decoder.ReadByteString("ByteString1");
Assert.AreEqual(new byte[] { 1, 2, 3 }, result);
#if NET5_0_OR_GREATER
#if SPAN_SUPPORT
result = decoder.ReadByteString("ByteString2");
Assert.AreEqual(new byte[] { 1, 2, 3 }, result);
result = decoder.ReadByteString("ByteString3");
Expand All @@ -339,7 +343,7 @@ public void XmlEncoder_WriteByteString()
using (IEncoder encoder = new XmlEncoder(new XmlQualifiedName("ByteStrings", Namespaces.OpcUaXsd), writer, new ServiceMessageContext()))
{
encoder.WriteByteString("ByteString1", new byte[] { 0, 1, 2, 3, 4, 5 }, 1, 3);
#if NET5_0_OR_GREATER
#if SPAN_SUPPORT
var span = new ReadOnlySpan<byte>(new byte[] { 0, 1, 2, 3, 4, 5 }, 1, 3);
var nullspan = new ReadOnlySpan<byte>(null);
encoder.WriteByteString("ByteString2", span);
Expand All @@ -354,7 +358,7 @@ public void XmlEncoder_WriteByteString()
{
var result = decoder.ReadByteString("ByteString1");
Assert.AreEqual(new byte[] { 1, 2, 3 }, result);
#if NET5_0_OR_GREATER
#if SPAN_SUPPORT
result = decoder.ReadByteString("ByteString2");
Assert.AreEqual(new byte[] { 1, 2, 3 }, result);
result = decoder.ReadByteString("ByteString3");
Expand All @@ -377,7 +381,7 @@ public void JsonEncoder_WriteByteString()
using (IEncoder encoder = new JsonEncoder(new ServiceMessageContext(), true, false, stream, true))
{
encoder.WriteByteString("ByteString1", new byte[] { 0, 1, 2, 3, 4, 5 }, 1, 3);
#if NET5_0_OR_GREATER
#if SPAN_SUPPORT
var span = new ReadOnlySpan<byte>(new byte[] { 0, 1, 2, 3, 4, 5 }, 1, 3);
var nullspan = new ReadOnlySpan<byte>(null);
encoder.WriteByteString("ByteString2", span);
Expand All @@ -392,7 +396,7 @@ public void JsonEncoder_WriteByteString()
{
var result = decoder.ReadByteString("ByteString1");
Assert.AreEqual(new byte[] { 1, 2, 3 }, result);
#if NET5_0_OR_GREATER
#if SPAN_SUPPORT
result = decoder.ReadByteString("ByteString2");
Assert.AreEqual(new byte[] { 1, 2, 3 }, result);
result = decoder.ReadByteString("ByteString3");
Expand Down Expand Up @@ -807,5 +811,4 @@ BuiltInType builtInType
#region Private Fields
#endregion
}

}
2 changes: 1 addition & 1 deletion Tests/Opc.Ua.PubSub.Tests/Opc.Ua.PubSub.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Tests/Opc.Ua.Server.Tests/Opc.Ua.Server.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Tests/customtest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
setlocal enabledelayedexpansion

echo This script is used to run custom platform tests for the UA Core Library
echo Supported parameters: net462, netstandard2.0, netstandard2.1, net48, net6.0, net8.0
echo Supported parameters: net462, netstandard2.0, netstandard2.1, net472, net48, net6.0, net8.0

REM Check if the target framework parameter is provided
if "%1"=="" (
echo Usage: %0 [TargetFramework]
echo Allowed values for TargetFramework: net462, netstandard2.0, netstandard2.1, net48, net6.0, net8.0, default
echo Allowed values for TargetFramework: net462, netstandard2.0, netstandard2.1, net472, net48, net6.0, net8.0, default
goto :eof
)

Expand Down
17 changes: 8 additions & 9 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,28 @@ stages:
framework: net6.0
agents: '@{ windows = "windows-2022"; linux="ubuntu-22.04"; mac = "macOS-12"}'
jobnamesuffix: net60
customtestarget: net6.0
- stage: testreleasepr
dependsOn: []
displayName: 'Fast .NET 6.0 PR Test'
displayName: 'Fast .NET 8.0 PR Test'
condition: and(eq(variables.FullBuild, 'False'), eq(variables.ScheduledBuild, 'False'))
jobs:
- template: .azurepipelines/test.yml
parameters:
configuration: Release
framework: net6.0
framework: net8.0
agents: '@{ windows = "windows-2022"; linux="ubuntu-20.04"}'
jobnamesuffix: net60pr
jobnamesuffix: net80pr
- stage: testdebug
dependsOn: [build]
displayName: 'Test .NET 6.0 Debug'
displayName: 'Test .NET 8.0 Debug'
condition: and(succeeded(), ne(variables.ScheduledBuild, 'False'))
jobs:
- template: .azurepipelines/test.yml
parameters:
framework: net6.0
framework: net8.0
configuration: Debug
jobnamesuffix: net60debug
jobnamesuffix: net80debug
- stage: testnet80
dependsOn: [build]
displayName: 'Test .NET 8.0'
Expand All @@ -101,7 +102,6 @@ stages:
framework: net8.0
configuration: Release
jobnamesuffix: net80
customtestarget: net8.0
- stage: testnet462
dependsOn: [build]
displayName: 'Test .NET 4.6.2'
Expand Down Expand Up @@ -159,5 +159,4 @@ stages:
configuration: Release
poolImage: 'ubuntu-22.04'
framework: net8.0
jobnamesuffix: net60cc
customtestarget: net8.0
jobnamesuffix: net80cc

0 comments on commit 4b822fc

Please sign in to comment.