Preserve nullable struct null-check semantics in UA0003#4039
Open
marcschier wants to merge 2 commits into
Open
Preserve nullable struct null-check semantics in UA0003#4039marcschier wants to merge 2 commits into
marcschier wants to merge 2 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
marcschier
marked this pull request as ready for review
July 19, 2026 10:43
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adjusts UA0003 to preserve C# nullable semantics by no longer unwrapping Nullable<T> before deciding whether a null-comparison should be reported/fixed.
Changes:
- Stop unwrapping
Nullable<T>in UA0003 analysis, returning early to keep== null/!= nullchecks intact. - Add tests to ensure UA0003 does not report null-comparisons for nullable
NodeIdandLocalizedText(including operand ordering).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tools/Opc.Ua.MigrationAnalyzer/Analyzers/UA0003NullCheckOnStructTypeAnalyzer.cs | Changes analysis to skip nullable types, preserving Nullable<T> null-check behavior. |
| tests/Opc.Ua.MigrationAnalyzer.Tests/Analyzers/UA0003Tests.cs | Adds regression coverage ensuring nullable UA structs are not flagged, including null != value ordering. |
marcschier
marked this pull request as draft
July 19, 2026 11:35
7 tasks
marcschier
marked this pull request as ready for review
July 19, 2026 11:54
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
marcschier
marked this pull request as draft
July 19, 2026 16:21
marcschier
marked this pull request as ready for review
July 19, 2026 16:24
marcschier
marked this pull request as draft
July 19, 2026 16:26
marcschier
marked this pull request as ready for review
July 19, 2026 16:30
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4039 +/- ##
==========================================
- Coverage 73.55% 73.54% -0.02%
==========================================
Files 1345 1345
Lines 180036 180037 +1
Branches 31677 31678 +1
==========================================
- Hits 132427 132404 -23
- Misses 36911 36922 +11
- Partials 10698 10711 +13
🚀 New features to boost your workflow:
|
Collaborator
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
romanett
approved these changes
Jul 21, 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.
Failure
UA0003 unwrapped
Nullable<T>before classifying OPC UA built-in structs. Thatreported valid nullable
== nulland!= nullchecks and offered fixes whose.IsNullsemantics differ from nullable-value absence.Fix
System.Nullable<T>comparisons unchanged.NodeIdandLocalizedTextoperand orderings.Reference
Tests
dotnet test tests\Opc.Ua.MigrationAnalyzer.Tests\Opc.Ua.MigrationAnalyzer.Tests.csproj -c Release -f net10.0 --nologo(121 passed)dotnet test tests\Opc.Ua.MigrationAnalyzer.Tests\Opc.Ua.MigrationAnalyzer.Tests.csproj -c Release -f net48 --nologo(121 passed)