Skip to content

Conversation

@marcschier
Copy link
Collaborator

@marcschier marcschier commented Oct 7, 2025

Proposed changes

This PR introduces immutable encodeable factory with lookup performance improvements. The changes replace the existing mutable EncodeableFactory implementation with an immutable design that uses FrozenDictionary for optimized lookups and thread safety.

Key changes:

  • Refactored EncodeableFactory to be immutable with a builder pattern for modifications
  • Replaced ConcurrentDictionary with FrozenDictionary for 15-20% performance improvements in lookups
  • Updated interfaces to separate factory creation from type lookup responsibilities

Related Issues

  • Fixes #

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply. You can also fill these out after creating the PR.

  • 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

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • 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.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@marcschier marcschier requested a review from Copilot October 7, 2025 08:55
@marcschier marcschier self-assigned this Oct 7, 2025
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 introduces immutable encodeable factory with lookup performance improvements. The changes replace the existing mutable EncodeableFactory implementation with an immutable design that uses FrozenDictionary for optimized lookups and thread safety.

Key changes:

  • Refactored EncodeableFactory to be immutable with a builder pattern for modifications
  • Replaced ConcurrentDictionary with FrozenDictionary for 15-20% performance improvements in lookups
  • Updated interfaces to separate factory creation from type lookup responsibilities

Reviewed Changes

Copilot reviewed 33 out of 34 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Stack/Opc.Ua.Core/Types/Encoders/EncodeableFactory.cs Complete rewrite to immutable factory with FrozenDictionary and builder pattern
Stack/Opc.Ua.Core/Types/Encoders/IEncodeableFactory.cs New interface design separating factory, builder, and lookup responsibilities
Stack/Opc.Ua.Core/Types/Utils/TypeInfo.cs Added XML name utility methods moved from EncodeableFactory
Tests/Opc.Ua.Core.Tests/Types/Encoders/EncodeableFactoryTests.cs Comprehensive test suite for new factory implementation
Multiple other files Updates to use new factory interfaces and remove telemetry parameters
Comments suppressed due to low confidence (1)

Stack/Opc.Ua.Core/Types/Utils/Utils.cs:1

  • Unused imports should be removed. The removed using statements for System.Diagnostics.CodeAnalysis and Microsoft.Extensions.Logging are no longer needed.
/* Copyright (c) 1996-2022 The OPC Foundation. All rights reserved.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 81.65138% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.53%. Comparing base (845c31d) to head (a15720c).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...ck/Opc.Ua.Core/Types/Encoders/EncodeableFactory.cs 87.96% 12 Missing and 4 partials ⚠️
Stack/Opc.Ua.Core/Types/Utils/TypeInfo.cs 70.96% 5 Missing and 4 partials ⚠️
...k/Opc.Ua.Core/Types/Encoders/IEncodeableFactory.cs 70.58% 4 Missing and 1 partial ⚠️
Stack/Opc.Ua.Core/Types/Utils/DataComparer.cs 0.00% 4 Missing ⚠️
Stack/Opc.Ua.Core/Stack/Client/DiscoveryClient.cs 50.00% 2 Missing ⚠️
Stack/Opc.Ua.Core/Types/Encoders/XmlDecoder.cs 60.00% 2 Missing ⚠️
...es/Opc.Ua.Client.ComplexTypes/ComplexTypeSystem.cs 83.33% 1 Missing ⚠️
...Ua.Gds.Client.Common/LocalDiscoveryServerClient.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3241      +/-   ##
==========================================
+ Coverage   57.50%   57.53%   +0.03%     
==========================================
  Files         361      362       +1     
  Lines       79163    79215      +52     
  Branches    13821    13835      +14     
==========================================
+ Hits        45521    45575      +54     
- Misses      29404    29411       +7     
+ Partials     4238     4229       -9     

☔ 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.

@marcschier marcschier marked this pull request as draft October 7, 2025 09:01
@marcschier marcschier marked this pull request as ready for review October 7, 2025 13:03
@marcschier marcschier merged commit 01ffcee into OPCFoundation:master Oct 8, 2025
77 checks passed
@marcschier marcschier deleted the immutablemsgctx branch October 8, 2025 07:45
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