Skip to content
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

Refactor DesignerHost to replace ArrayList with List<T> #8672

Merged
merged 2 commits into from
Feb 23, 2023

Conversation

elachlan
Copy link
Contributor

@elachlan elachlan commented Feb 21, 2023

Related: #8143, #8357

Microsoft Reviewers: Open in CodeFlow

@elachlan elachlan requested a review from a team as a code owner February 21, 2023 23:31
@ghost ghost assigned elachlan Feb 21, 2023
@lonitra lonitra added the 📭 waiting-author-feedback The team requires more information from the author label Feb 22, 2023
@ghost ghost removed the 📭 waiting-author-feedback The team requires more information from the author label Feb 22, 2023
@elachlan
Copy link
Contributor Author

I made some more changes designed to avoid problems when an array is passed in and not a list/arraylist. Also fixed a caller to the method which was passing in an arraylist.

@elachlan
Copy link
Contributor Author

@dreddy-work is the test failure a flaky test?

@dreddy-work
Copy link
Member

Error message
System.NullReferenceException : Object reference not set to an instance of an object.

Stack trace
   at System.Windows.Forms.Tests.ListViewLabelEditAccessibleObjectTests.ListViewLabelEditAccessibleObject_IsPatternSupported_ReturnsExpected() in /_/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewLabelEditAccessibleObjectTests.cs:line 67
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

@dreddy-work
Copy link
Member

@dreddy-work is the test failure a flaky test?

Only on ARM suggests so. @dmitrii-drobotov can you check why accessible object is disposed in this case?

@dmitrii-drobotov
Copy link
Contributor

@dreddy-work is the test failure a flaky test?

Only on ARM suggests so. @dmitrii-drobotov can you check why accessible object is disposed in this case?

The exception actually looks like that _labelEdit was null here for some reason:

ListViewLabelEditNativeWindow labelEdit = listView.TestAccessor().Dynamic._labelEdit;
ListViewLabelEditAccessibleObject accessibilityObject = (ListViewLabelEditAccessibleObject)labelEdit.AccessibilityObject;

There is a condition when it may not be created, I assume cancelEdit was true, but it's hard to tell why:

case (int)LVN.BEGINLABELEDITW:
{
Debug.Assert(_labelEdit is null,
"A new label editing shouldn't start before the previous one ended");
if (_labelEdit is not null)
{
_labelEdit.ReleaseHandle();
_labelEdit = null;
}
bool cancelEdit;
if (_blockLabelEdit)
{
cancelEdit = true;
}
else
{
NMLVDISPINFO* dispInfo = (NMLVDISPINFO*)(nint)m.LParamInternal;
LabelEditEventArgs e = new(dispInfo->item.iItem);
OnBeforeLabelEdit(e);
cancelEdit = e.CancelEdit;
}
m.ResultInternal = (LRESULT)(nint)(BOOL)cancelEdit;
_listViewState[LISTVIEWSTATE_inLabelEdit] = !cancelEdit;
if (!cancelEdit)
{
_labelEdit = new ListViewLabelEditNativeWindow(this);
_labelEdit.AssignHandle(PInvoke.SendMessage(this, (User32.WM)PInvoke.LVM_GETEDITCONTROL));
}
break;
}

Should we create a new issue for it through Runfo? https://runfo.azurewebsites.net/search/tests/?q=started%3A%7E100+definition%3A76+name%3A%22system.windows.forms.tests.listviewlabeleditaccessibleobjecttests.listviewlabeleditaccessibleobject_ispatternsupported_returnsexpected%22

@lonitra lonitra added the ready-to-merge PRs that are ready to merge but worth notifying the internal team. label Feb 23, 2023
@dreddy-work
Copy link
Member

#8682

@dreddy-work dreddy-work enabled auto-merge (squash) February 23, 2023 21:41
@dreddy-work dreddy-work merged commit 9879536 into dotnet:main Feb 23, 2023
@ghost ghost added this to the 8.0 Preview2 milestone Feb 23, 2023
@ghost ghost removed the ready-to-merge PRs that are ready to merge but worth notifying the internal team. label Feb 23, 2023
@elachlan elachlan deleted the DesignerHost-ArrayList branch February 23, 2023 22:09
@ghost ghost locked as resolved and limited conversation to collaborators Mar 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants