Skip to content

[Client encryption]: Fixes failing contract tests on .NET 8#5373

Closed
adamnova wants to merge 31 commits intoAzure:masterfrom
adamnova:bug/fixes-contract-tests
Closed

[Client encryption]: Fixes failing contract tests on .NET 8#5373
adamnova wants to merge 31 commits intoAzure:masterfrom
adamnova:bug/fixes-contract-tests

Conversation

@adamnova
Copy link
Copy Markdown
Contributor

Pull Request Template

#4678

Description

The contracts test is failing due to incorrectly used templates and the contracts being different between .net 6 and .net 8

Introduces .NET 8-specific contract baseline files for Cosmos Encryption and updates contract enforcement tests to select the correct baseline per target framework. Also updates contract JSONs and the UpdateContracts.ps1 script to support these changes.
@adamnova adamnova changed the title Fixes failing contract tests on .NET 8 [Client encryption]: Fixes failing contract tests on .NET 8 Aug 26, 2025
adamnova and others added 5 commits August 26, 2025 09:38
Eliminated the candidate file name using the full TFM in ContractEnforcementTests for both Encryption and Encryption.Custom test projects, simplifying the candidate list to only use the major TFM version and the default file name.
@NaluTripician
Copy link
Copy Markdown
Contributor

\azp run

kirankumarkolli
kirankumarkolli previously approved these changes Oct 7, 2025
@kirankumarkolli
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

NaluTripician
NaluTripician previously approved these changes Oct 7, 2025
Updated contract enforcement logic to use '.net{majorVersion}' file naming. Added new region fields and AvailabilityStrategy property to DotNetPreviewSDKAPI contract. Enhanced baseline XMLs with additional activity and event data, and improved formatting in query plan and trace writer baselines.
Changed the file include pattern in the test project to match all DotNetSDKEncryptionCustomAPI*.json files, ensuring all relevant contract files are copied to the output directory.
@kirankumarkolli
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@kirankumarkolli
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@kirankumarkolli
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@juraj-blazek
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 5373 in repo Azure/azure-cosmos-dotnet-v3

Deleted several obsolete region fields and the AvailabilityStrategy property/methods from DotNetSDKAPI.json to reflect recent API changes and cleanup unused contract members.
@adamnova
Copy link
Copy Markdown
Contributor Author

adamnova commented Oct 9, 2025

/azp run

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 5373 in repo Azure/azure-cosmos-dotnet-v3

… frameworks

- Enhanced GetAssemblyLocally() to detect and prefer assemblies matching the test's target framework
- Added IsCompatibleFramework() helper to handle .NETStandard/.NETCoreApp compatibility
- Prevents non-deterministic behavior when multiple TFMs (net6.0, net8.0) are loaded
- Resolves flakiness where FirstOrDefault() could pick wrong assembly version

Addresses issue where contract tests would fail inconsistently depending on which
assembly version was arbitrarily selected from AppDomain.
…ts.ps1

- Added explicit '-f net6.0' flag to all dotnet test commands
- Ensures consistent framework selection regardless of environment defaults
- Prevents implicit TFM selection which varies by SDK version and project configuration
- Complements existing net8.0 commands which already use '-f net8.0'

This eliminates environment-dependent behavior where the default TFM could be
net6.0 or net8.0 depending on SDK installation or project TargetFrameworks order.
- Added baseline file existence check before running contract validation
- Provides clear error message indicating which TFM baseline is missing
- Added comprehensive XML documentation explaining multi-target contract pattern
- Directs developers to run UpdateContracts.ps1 when baselines are missing

Prevents cryptic 'contract changed' errors when the actual issue is a missing
baseline file for the current target framework (net6.0 or net8.0).

Improves developer experience by providing actionable error messages instead of
confusing diffs between current API and non-existent baseline.
}
},
"Members": {
"Microsoft.Azure.Cosmos.AvailabilityStrategy AvailabilityStrategy": {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This seems odd

Reorders the arguments in Newtonsoft.Json.JsonPropertyAttribute from (NullValueHandling, PropertyName) to (PropertyName, NullValueHandling) for consistency and clarity in DotNetSDKEncryptionCustomAPI.json test contract.
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.

4 participants