Skip to content

Conversation

@romanett
Copy link
Contributor

Proposed changes

  • Obsolete all sync methods in the server
  • Update SubscriptionManager to use SemaphoreSlim
  • Remove Sync overloads from MasterNodeManager
  • Fix SessionPublishQueue to allow publishing Custom Status Messages for Good Status Codes

Related Issues

  • Fixes #

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

@codecov
Copy link

codecov bot commented Nov 21, 2025

Codecov Report

❌ Patch coverage is 84.05797% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.00%. Comparing base (d25caff) to head (ee83d91).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
Libraries/Opc.Ua.Server/Server/StandardServer.cs 84.87% 18 Missing ⚠️
.../Opc.Ua.Server/Subscription/SubscriptionManager.cs 88.88% 6 Missing and 1 partial ⚠️
...braries/Opc.Ua.Server/Subscription/Subscription.cs 70.00% 6 Missing ⚠️
.../Opc.Ua.Server/Subscription/SessionPublishQueue.cs 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3350      +/-   ##
==========================================
+ Coverage   51.86%   60.00%   +8.14%     
==========================================
  Files         370      371       +1     
  Lines       78618    78217     -401     
  Branches    13650    13600      -50     
==========================================
+ Hits        40779    46938    +6159     
+ Misses      33705    26976    -6729     
- Partials     4134     4303     +169     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@romanett romanett requested a review from Copilot November 21, 2025 06:56
@romanett romanett marked this pull request as ready for review November 21, 2025 06:56
@romanett romanett requested a review from marcschier November 21, 2025 06:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes the OPC UA .NET Standard Server subscription management by converting synchronous methods to async/await patterns and replacing Lock with SemaphoreSlim for better async compatibility. The changes enable proper async operation throughout the subscription lifecycle while fixing a bug that prevented publishing Good status codes for subscription transfer notifications.

Key Changes:

  • Replaced Lock with SemaphoreSlim in SubscriptionManager for async-compatible synchronization
  • Converted subscription lifecycle methods (StartupAsync, ShutdownAsync, RestoreSubscriptionsAsync, etc.) to async
  • Removed synchronous wrapper methods from MasterNodeManager that used blocking calls on async methods
  • Fixed SessionPublishQueue.TryPublishCustomStatus to properly handle Good status codes by returning null subscription instead of throwing an exception

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
Stack/Opc.Ua.Core/Opc.Ua.Core.csproj Removed OPCUA_EXCLUDE flags to enable async methods for subscription-related operations
Tests/Opc.Ua.Server.Tests/ServerTestServices.cs Updated test service methods to call async server methods directly instead of using sync wrappers
Libraries/Opc.Ua.Server/Subscription/SubscriptionManager.cs Replaced Lock with SemaphoreSlim; converted lifecycle methods to async; updated synchronization patterns
Libraries/Opc.Ua.Server/Subscription/Subscription.cs Added RestoreAsync factory method; converted ConditionRefresh and SetMonitoringMode methods to async
Libraries/Opc.Ua.Server/Subscription/SessionPublishQueue.cs Fixed TryPublishCustomStatus to handle Good status codes by returning null instead of throwing
Libraries/Opc.Ua.Server/Subscription/ISubscriptionManager.cs Updated interface signatures to async methods
Libraries/Opc.Ua.Server/Subscription/ISubscription.cs Updated interface signatures to async methods
Libraries/Opc.Ua.Server/Server/StandardServer.cs Converted subscription and node management methods to async; updated to return response objects directly
Libraries/Opc.Ua.Server/NodeManager/MasterNodeManager.cs Removed sync wrapper methods; added cancellation token parameter to ShutdownAsync

romanett and others added 3 commits November 21, 2025 13:46
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants