Closed RussKie closed 3 years ago
not creating an instance of accessibility object until its owner is fully materialised and has a valid Handle,
Should the AccessibilityObject
return null or throw in this case? (I don't have a particular opinion just wanted to bring up this option.)
This is a good question, thank you! My initial feeling was to return null
, but since it would be a breaking change throwing would be equally appropriate.
I expect we will discuss this internally, and welcome external thoughts and opinions as well.
I have made a primary investigation, if we can set AccessibleObject as null.
Why do we need it:
Issues:
control.AccessibleObject.Name = "Some text";
Castomers may have something like that somewhere in their code before creating controls and a form, our changes make them to find and resolve them, and if customers don't catch all of them, their users may have errorsConclusion: I don't like this change. I see only negative effects. There are more disadvantages then advantages. My opinion - don't touch that is working. We will bring many problems to customers for the sake of the code clean up and the performance micro improvement.
My proposal: Keep it as is. Add more "IsHandleCreated" checks, that are missed for new implementations made after #3432
//cc: @merriemcgaw
Thank you.
Is your feature request related to a problem? Please describe.
Currently an accessibility object can be created before its owning control is materialised (i.e. have a valid
Handle
):Such design places a lot of responsibility on SDK to constantly check and guard against accessing an owner control and its handle before their are fully created and live.
A lot of work has been done in response to https://github.com/dotnet/winforms/issues/3062, which added a lot of code (e.g. https://github.com/dotnet/winforms/pull/3432), and has a perf impact (as negligible as it may be). However with the steady stream of accessibility-related work there is a significant overhead in implementing guards and rails against accidental handle access.
Describe the solution you'd like and alternatives you've considered
It makes no sense to access an accessibility object before its owner is materialised, i.e. a non existent control can't be navigated to or inspected in any accessibility tools (e.g. Inspect or AI4Win).
We should consider the following:
Handle
,ControlAccessibleObject
and its descendants