-
Notifications
You must be signed in to change notification settings - Fork 422
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
Ensure IdentityComparer.AreEqual Usage is Properly Asserted #3151
base: dev
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree |
@microsoft-github-policy-service agree |
Thanks for the contribution @omidmloo |
Thanks for the review, @jennyf19 ! During the fix for issue #3130, I encountered a failing test due to incorrect test data in To ensure this gets addressed properly, I have raised issue #3159 to track and resolve the test data mismatch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -92,13 +92,13 @@ public async Task ConfigurationManagerUsingCustomClass() | |||
configManager.RequestRefresh(); | |||
configuration2 = await configManager.GetConfigurationAsync(); | |||
|
|||
if (IdentityComparer.AreEqual(configuration.Issuer, configuration2.Issuer)) | |||
if (IdentityComparer.AreEqual(configuration.Issuer, configuration2.Issuer, CompareContext.Default)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, but elsewhere as well, what is the thinking of using CompareContext.Default when there is a compare context available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, the for
loop ensures the configuration refresh has taken effect before validation. Since updates may be delayed due to caching or async behavior, it retries up to 5 times, waiting 1 second between attempts until a change in Issuer
is detected. Using context
here might falsely impact the test result.
The next use of CompareContext.Default
is to verify a negative test case, ensuring the values are different. While this aligns with the current test structure, the test could be improved by adding TestUtilities.AssertFailIfNoErrors
to enforce proper assertions.
Fixes: #3130
This PR addresses issue #3130 by ensuring that IdentityComparer.AreEqual(object object1, object object2) is used correctly across the codebase.
Changes Made:
✅ Replaced usages of IdentityComparer.AreEqual(object, object) with the overload that accepts CompareContext, ensuring proper validation.
✅ Removed the parameterless overload where possible to enforce assertion of the comparison result.
✅ In cases where removal wasn’t possible, I explicitly added CompareContext.Default.
✅ Verified and updated all affected test methods to ensure correctness.
Testing & Validation:
I ran all relevant unit tests to confirm that there were no regressions.
Verified that all assertions are now explicitly checked.