Fixing bug of searching for heading level throwing exception #5003
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.
Fixes Issue #4935
Main PR
Description
The type of the heading level property declaration in UIAutomationClient in the class Schema.cs was using a different type of what it is in PresentationCore. When creating a property condition, the exception is thrown because the one type is no assignable by the other.
The fact is the the AutomationElement stores the value of the ID of the property, starting at 80050. So, when we create the condition, we can't convert AutomationHeadingLevel to HeadingLevel. To solve this, we created a converter in the Schema, to convert from HeadingLevel to AutomationHeadingLevel, and set in the schema the type of the property to AutomationHeadingLevel for the info. Also, in the PropertyCondition.cs, we convert back from AutomationHeadingLevel (that is what the developer inputs to the class) to HeadingLevel (that is what is actually stored in the AutomationElement).
Customer Impact
Regression
Testing
To test this fix, a sample app was created, declaring an element with a HeadingLevel. And another app, a console application, was created to get the proccess of the first app, and find the element with the given AutomationHeadingLevel.
Risk