Skip to content
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

Some .NET 9 maintenance and JSON encoder improvements #2922

Open
wants to merge 12 commits into
base: develop/main374
Choose a base branch
from

Conversation

mregen
Copy link
Contributor

@mregen mregen commented Jan 3, 2025

Proposed changes

This pull request includes various updates and improvements across multiple files. The changes focus on updating package references, enhancing debugging capabilities, and improving code efficiency and readability.

  • Reduce memory allocations in JSON encoder by using stackalloc/ArrayPool
  • Fix some new warnings in .NET9 code analyzers
  • Fix fuzzing error in JsonDecoder
  • do not use .NET9 libraries with .NET8 LTS builds

Fixes #2940
Fixes #2931

Package Reference Updates:

  • Updated NUnit to version 4.3.2 and NUnit.Console to version 3.19.0 in Fuzzing/Encoders/Fuzz.Tests/Opc.Ua.Encoders.Fuzz.Tests.csproj.
  • Updated System.Diagnostics.DiagnosticSource to version 6.0.2 in Stack/Opc.Ua.Core/Opc.Ua.Core.csproj.
  • Added conditional package references for System.Formats.Asn1 and Microsoft.Bcl.Cryptography in Libraries/Opc.Ua.Security.Certificates/Opc.Ua.Security.Certificates.csproj. [1] [2]

Debugging Enhancements:

  • Added #if DEBUG directive to validate publish time and reject old values in Session.cs.

Code Efficiency and Readability:

  • Simplified SaveMessageInCache method by removing redundant parameters and using object initializers in Subscription.cs. [1] [2]
  • Replaced string interpolation with ServiceResultException.Create for consistency in error messages in NodeId.cs. [1] [2] [3]

New Features:

  • Added MoreNotifications property to NotificationMessage and NotificationData classes to indicate if more notifications are expected. [1] [2]

Miscellaneous:

  • Removed unnecessary package reference conditions in Opc.Ua.Client.csproj.
  • Added support for stack allocation and array pooling in ReadString method for performance improvement in BinaryDecoder.cs.

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

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 59.37500% with 39 lines in your changes missing coverage. Please review.

Project coverage is 46.39%. Comparing base (a0b12d7) to head (dd1e3fe).

Files with missing lines Patch % Lines
Stack/Opc.Ua.Core/Types/Encoders/BinaryDecoder.cs 26.31% 11 Missing and 3 partials ⚠️
Stack/Opc.Ua.Core/Types/BuiltIn/NodeId.cs 35.29% 6 Missing and 5 partials ⚠️
...braries/Opc.Ua.Client/Subscription/Subscription.cs 0.00% 5 Missing ⚠️
Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs 90.00% 2 Missing and 3 partials ⚠️
Libraries/Opc.Ua.Client/Session/Session.cs 0.00% 3 Missing ⚠️
...ack/Opc.Ua.Core/Stack/Types/NotificationMessage.cs 50.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (a0b12d7) and HEAD (dd1e3fe). Click for more details.

HEAD has 18 uploads less than BASE
Flag BASE (a0b12d7) HEAD (dd1e3fe)
33 15
Additional details and impacted files
@@                 Coverage Diff                 @@
##           develop/main374    #2922      +/-   ##
===================================================
- Coverage            54.89%   46.39%   -8.51%     
===================================================
  Files                  349      349              
  Lines                66377    66396      +19     
  Branches             13624    13624              
===================================================
- Hits                 36437    30802    -5635     
- Misses               25957    31878    +5921     
+ Partials              3983     3716     -267     

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

@mregen mregen requested a review from Copilot January 3, 2025 10:03

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 12 changed files in this pull request and generated no comments.

Files not reviewed (7)
  • Libraries/Opc.Ua.Security.Certificates/Opc.Ua.Security.Certificates.csproj: Language not supported
  • targets.props: Language not supported
  • Libraries/Opc.Ua.Security.Certificates/X509Certificate/X509CertificateLoader.cs: Evaluated as low risk
  • Tests/Opc.Ua.Core.Tests/Types/Encoders/JsonEncoderEscapeStringBenchmarks.cs: Evaluated as low risk
  • Tests/Opc.Ua.Gds.Tests/Common.cs: Evaluated as low risk
  • Tests/Opc.Ua.Client.Tests/SubscriptionTest.cs: Evaluated as low risk
  • Tests/Opc.Ua.Core.Tests/Security/Certificates/ApplicationTestDataGenerator.cs: Evaluated as low risk
Comments suppressed due to low confidence (1)

Tests/Opc.Ua.Core.Tests/Types/Encoders/EncoderTests.cs:497

  • The assertion Assert.IsTrue(nullspan == null) is incorrect because ReadOnlySpan cannot be null.
Assert.IsTrue(nullspan == null);
@mregen mregen added this to the 1.5.374 Januar update milestone Jan 7, 2025
@mregen mregen requested a review from Copilot January 16, 2025 22:11
@mregen mregen marked this pull request as ready for review January 16, 2025 22:12

Choose a reason for hiding this comment

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

Copilot reviewed 22 out of 35 changed files in this pull request and generated no comments.

Files not reviewed (13)
  • Fuzzing/Encoders/Fuzz.Tests/Opc.Ua.Encoders.Fuzz.Tests.csproj: Language not supported
  • Libraries/Opc.Ua.Client/Opc.Ua.Client.csproj: Language not supported
  • Libraries/Opc.Ua.Security.Certificates/Opc.Ua.Security.Certificates.csproj: Language not supported
  • Stack/Opc.Ua.Core/Opc.Ua.Core.csproj: Language not supported
  • Tests/Opc.Ua.Client.ComplexTypes.Tests/Opc.Ua.Client.ComplexTypes.Tests.csproj: Language not supported
  • Tests/Opc.Ua.Client.Tests/Opc.Ua.Client.Tests.csproj: Language not supported
  • Tests/Opc.Ua.Configuration.Tests/Opc.Ua.Configuration.Tests.csproj: Language not supported
  • Tests/Opc.Ua.Core.Tests/Opc.Ua.Core.Tests.csproj: Language not supported
  • Libraries/Opc.Ua.Client/Session/Session.cs: Evaluated as low risk
  • Libraries/Opc.Ua.Client/Subscription/Subscription.cs: Evaluated as low risk
  • Stack/Opc.Ua.Core/Types/Encoders/IEncoder.cs: Evaluated as low risk
  • Libraries/Opc.Ua.Security.Certificates/X509Certificate/X509CertificateLoader.cs: Evaluated as low risk
  • Stack/Opc.Ua.Core/Stack/Types/NotificationMessage.cs: Evaluated as low risk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant