-
-
Notifications
You must be signed in to change notification settings - Fork 362
feat(OpcDa): bump version 9.0.3 #6600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis PR upgrades the OpcDa sample to v9.0.3 by removing obsolete imports/constants, refactoring read and update logic to lookup by tag name, correcting subscription and browsing initializations, updating UI labels to use the primary tags, and bumping the project version. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ArgoZhang - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor.Server/Components/Samples/OpcDa.razor.cs:47` </location>
<code_context>
private void OnRead()
{
- var values = OpcDaServer.Read(Tag1, Tag2);
</code_context>
<issue_to_address>
Consider using dictionaries and TryGetValue to simplify tag lookups and reduce code nesting.
Here’s a way to keep exactly the same behavior but reduce both LOC and nesting by:
1. Turning your read/update lists into a `Dictionary<string, object?>` (via `ToDictionary`)
2. Looking up each tag just once with `TryGetValue`
3. Reverting the browse method back to a simple `ToList()` instead of the range‐operator hack.
---
**OnRead →**
```csharp
private void OnRead()
{
var values = OpcDaServer
.Read(Tag1, Tag2)
.ToDictionary(item => item.Name, item => item.Value);
if (values.TryGetValue(Tag1, out var raw1) && raw1 != null)
_tagValue1 = raw1.ToString();
if (values.TryGetValue(Tag2, out var raw2)
&& raw2 is int i2)
{
_tagValue2 = (i2 / 100d).ToString(CultureInfo.InvariantCulture);
}
}
```
**UpdateValues →**
```csharp
private void UpdateValues(List<OpcReadItem> items)
{
var values = items.ToDictionary(item => item.Name, item => item.Value);
if (values.TryGetValue(Tag3, out var raw3) && raw3 != null)
_tagValue3 = raw3.ToString();
if (values.TryGetValue(Tag4, out var raw4)
&& raw4 is int i4)
{
_tagValue4 = (i4 / 100d).ToString(CultureInfo.InvariantCulture);
}
InvokeAsync(StateHasChanged);
}
```
**OnBrowse →**
```csharp
private void OnBrowse()
{
_roots = OpcDaServer
.Browse("", new OpcBrowseFilters(), out _)
.Select(e => new TreeViewItem<OpcBrowseElement>(e)
{
Text = e.Name,
HasChildren = e.HasChildren,
Icon = "fa-solid fa-fw fa-cubes"
})
.ToList();
}
```
This keeps all behavior (including your `/100d` scaling) but avoids repeated LINQ searches, null‐check pods and the confusing new range operator.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6600 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 739 739
Lines 31669 31669
Branches 4458 4458
=========================================
Hits 31669 31669
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6599
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Bump OpcDa package to v9.0.3 and refactor the sample component to simplify tag handling and value retrieval
Enhancements:
Build: