Skip to content

fix: compare both exception data values in clone assertion - #5064

Open
unsafePtr wants to merge 2 commits into
dotnet:mainfrom
unsafePtr:dev/automation/fix-exception-data-assertion
Open

unsafePtr wants to merge 2 commits into
dotnet:mainfrom
unsafePtr:dev/automation/fix-exception-data-assertion

Conversation

@unsafePtr

@unsafePtr unsafePtr commented Nov 13, 2026 •

Copy link
Copy Markdown

Description

Correct the exception-clone assertion so it compares the dictionaries from both exceptions rather than comparing a value with itself. Match entries by key and compare values with null-safe value equality, without assuming matching dictionary enumeration order. Preserve the initial metadata and count checks instead of overwriting failed checks in the error-comparison loop.

This changes test validation only; there are no driver API or runtime behavior changes. The existing SQL-backed ExceptionTests test invokes this helper after repeated pooled connection failures.

Issues

Follow-up discussion: #5064

Testing

The five original database-free cases cover matching non-null and null values, different values, and both null/non-null mismatch directions. Seven additional cases cover separately boxed equal values, reordered entries with equal but distinct keys, count mismatches in both directions, and missing keys with null values.

Before the loop fix, the focused run passed eight cases and failed four; after the fix, all 12 passed with no skips.

  • dotnet test src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTests.csproj --framework net10.0 --list-tests --filter 'FullyQualifiedName~CheckThatExceptionsAreDistinctButHaveSameData' --verbosity quiet - passed; discovered all 12 cases.
  • dotnet test src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTests.csproj --framework net10.0 --no-restore --filter 'FullyQualifiedName~CheckThatExceptionsAreDistinctButHaveSameData' --verbosity quiet - passed; 12 passed, zero failed, zero skipped.
  • dotnet build src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTests.csproj --framework net462 --no-restore --verbosity quiet - passed; zero warnings and zero errors.
  • git diff --check - passed.

SQL-backed tests were not rerun for this follow-up. The original PR reported that a broader .NET 10 ExceptionTest run passed six cases, skipped two, and failed four database-dependent cases because the configured SQL Server was unavailable. .NET Framework execution was not performed on Linux.

Guidelines

Please review the contribution guidelines before submitting a pull request:

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@unsafePtr
unsafePtr marked this pull request as ready for review November 13, 2026 15:14
@unsafePtr
unsafePtr requested a review from a team as a code owner November 13, 2026 15:14
@paulmedynski

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.

Compare dictionary entries by key and value without depending on iteration order. Preserve initial equality checks and cover boxed values, missing keys, and mismatched counts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@paulmedynski

Copy link
Copy Markdown
Contributor

@unsafePtr - Thanks for noticing this TODO and addressing it. I noticed some additional weaknesses in the data comparison loop and have added another commit.

@paulmedynski paulmedynski added the Area\Tests Issues that are targeted to tests or test projects label Nov 13, 2026
@paulmedynski paulmedynski moved this from To triage to In review in SqlClient Board Nov 13, 2026
@paulmedynski paulmedynski added this to the 8.1.0-preview1 milestone Nov 13, 2026
@paulmedynski

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.

@paulmedynski
paulmedynski enabled auto-merge (squash) November 13, 2026 15:53

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area\Tests Issues that are targeted to tests or test projects

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants