microsoft/Microsoft-UI-UIAutomation

UiaElement copy ctor and assignment operator do subtly different things

mlalic opened this issue · 1 comments

In the following snippet...

void Fn(UiaElement original)
{
  UiaElement newElement = original;
}

The newElement will end up aliasing the same remote object. More precisely, it'll refer to the same operand register as original (on the lowest-level of Remote Ops bytecode).

Meanwhile, in the following...

void Fn(UiaElement original)
{
  UiaElement newElement{ nullptr };
  newElement = original;
}

A Set instruction is emitted in the bytecode that assigns the original element to a new operand register in the bytecode.


This means that two things that typically should work the same (the copy ctor and assignment operator) end up with subtly different behavior.

This issue tracks making a decision about this -- whether to try to make any changes to make these two operations work the same way or whether to document this rough edge as expected/by design.

In a way this is related to #6 -- except for ints the current behavior seems obviously broken. Perhaps that should be an indication that we should make a fix across the board where copy ctors just do the same thing as assignment operators.