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.
Description
Fixes the test failure seen in main currently. This was caused by the switch from xUnit test runner to VSTest test runner introduced in #10514 which changed the order in which test were ran and exposed an existing bug in the tests.
The problem is because the xUnit test runner ran the test
Register_InvokeStringTypeTypeValidateFail_ThrowsbeforeRegister_InvokeStringTypeType_Successand VSTest test runner runs them in inverse order. This causes problem because both test registers a dependency property for the same type with the same property name, the thing is thatRegister_InvokeStringTypeTypeValidateFail_Throwsexpects the registration to fail and not register the dependency property in the cache whileRegister_InvokeStringTypeType_Successexpects the registration to succeed and register the dependency property in the cache.When the order is
Register_InvokeStringTypeTypeValidateFail_Throws->Register_InvokeStringTypeType_Successit's fine because the dependency property is not in the cache for the second test.When the order is
Register_InvokeStringTypeType_Success->Register_InvokeStringTypeTypeValidateFail_Throwsit fails becauseRegister_InvokeStringTypeTypeValidateFail_Throwsfails early because the property is already registered for the second test.Here's the 2 conflicting dependency property name + type:
wpf/src/Microsoft.DotNet.Wpf/tests/UnitTests/WindowsBase.Tests/System/Windows/DependencyPropertyTests.cs
Line 19 in 009ae5a
wpf/src/Microsoft.DotNet.Wpf/tests/UnitTests/WindowsBase.Tests/System/Windows/DependencyPropertyTests.cs
Lines 299 to 300 in 009ae5a
Side note:
We should probably refactor how tests are done for DependencyProperty, this PR is just a patch to fix the current failure. IMO we should have 1 type per tests that register dependency properties, if we don't want to have a mess of types we could possibly create the types at runtime using IL emit.
Customer Impact
None, tests only.
Regression
WPF tests regression only.
Testing
Running the tests locally.
Risk
Low to none, tests only.
Microsoft Reviewers: Open in CodeFlow