Conversation
Reviewer's GuideThis PR standardizes OPC service terminology around clients across OpcDa and OpcUa, implements the new client-facing APIs and registrations, preserves OpcDa server-named consumers through obsolete compatibility types, updates bilingual documentation, bumps the OpcDa package version, and migrates the tests. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/extensions/BootstrapBlazor.OpcDa/OpcDaClient.cs" line_range="49-54" />
<code_context>
+ }
+
+ /// <inheritdoc/>
+ public void Disconnect()
+ {
+ ServerName = string.Empty;
+
+ if (_server is { IsConnected: true })
+ {
+ foreach (Subscription sub in _server.Subscriptions)
+ {
+ _server.CancelSubscription(sub);
+ }
+
+ _server.Disconnect();
+ _server = null;
+ }
+ }
+
+ /// <inheritdoc/>
+ public IOpcSubscription CreateSubscription(string name, int updateRate = 1000, bool active = true)
+ {
+ var server = GetOpcServer();
+ if (_subscriptions.TryGetValue(name, out var subscription))
+ {
+ // 已经存在该订阅
+ server.CancelSubscription(subscription);
+ }
+
+ subscription = server.CreateSubscription(name, updateRate, active);
+ _subscriptions.Add(name, subscription);
+ return subscription.ToOpcSubscription();
+ }
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Disconnect cancels the underlying subscriptions but never clears `_subscriptions`. After reconnecting, creating a subscription with a previously used name reuses the old server-bound subscription and then `_subscriptions.Add` throws because the name is still present, so subscription recreation fails.
**Triggers:** When a client disconnects, reconnects, and recreates a subscription with the same name.
**Suggested fix:** Clear `_subscriptions` after cancelling the subscriptions during `Disconnect`.
```suggestion
foreach (Subscription sub in _server.Subscriptions)
{
_server.CancelSubscription(sub);
}
_subscriptions.Clear();
_server.Disconnect();
```
</issue_to_address>
### Comment 2
<location path="src/extensions/BootstrapBlazor.OpcUa/Extensions/ServiceCollectionExtensions.cs" line_range="21" />
<code_context>
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
- public static IServiceCollection AddOpcUaServer(this IServiceCollection services)
+ public static IServiceCollection AddOpcUaClient(this IServiceCollection services)
{
- services.AddScoped<IOpcUaServer, OpcUaServer>();
</code_context>
<issue_to_address>
**issue (bug_risk):** The 10.0.1 OpcUa package removes the public `AddOpcUaServer` and `IOpcUaServer` symbols without obsolete aliases or a package-version bump. Existing OpcUa consumers therefore fail to compile when upgrading to this package version.
**Triggers:** When an existing consumer upgrades the OpcUa package and still uses the server-named registration or interface.
**Suggested fix:** Retain obsolete forwarding aliases for the old OpcUa API, or publish the breaking rename under a new major package version.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This was referenced Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link issues
fixes #1119
Summary By Copilot
IOpcDaClient,OpcDaClient, andAddOpcDaClientRegression?
Existing OpcDa consumers can continue using
IOpcDaServerandAddOpcDaServer, which now provide migration guidance throughObsoleteattributes.Risk
The change is primarily API naming and documentation. The OpcDa compatibility path resolves the same implementation behavior without compiler warnings inside the package.
Verification
Manual (required)
Automated
built BootstrapBlazor.OpcDa and UnitTestOpcDa for
net10.0with no warnings or errorsbuilt BootstrapBlazor.OpcUa for all target frameworks with no warnings or errors
passed all 5 UnitTestOpcUa tests on
net10.0Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Rename OPC DA and OPC UA service APIs from server to client terminology while preserving an obsolete OpcDa compatibility path for existing consumers.
New Features:
IOpcDaClient,OpcDaClient, andAddOpcDaClient.Enhancements:
Build:
Documentation:
Tests: