dotnet / dotnet/wpf

.net 8: Crash in ItemsControlAutomationPeer using recycling

Open
#8,528 6 comments 1 reaction 1 assignee Claimed by @harshit7962 View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

last line below: recyclableWrapper.**Peer** is null

```
protected override string GetNameCore()
{
AutomationPeer wrapperPeer = GetWrapperPeer();
string text = null;
object item = Item;
if (wrapperPeer != null)
{
text = wrapperPeer.GetName();
}
else if (item != null)
{
ItemsControlAutomationPeer itemsControlAutomationPeer = ItemsControlAutomationPeer;
if (itemsControlAutomationPeer != null)
{
using RecyclableWrapper recyclableWrapper = itemsControlAutomationPeer.GetRecyclableWrapperPeer(item);
text = recyclableWrapper.Peer.GetName();
}
}
```

this issue looks similar:
https://github.com/dotnet/wpf/pull/7115

### Reproduction Steps

Create an ItemsControl utilizing Groups with Recycling






















### Expected behavior

Need a null check

### Actual behavior

Debugger reports exception

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.