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

Bug: CollectionViewSource crash in PublishAoT mode when using IEnumerable #1869

Open
dotMorten opened this issue Nov 13, 2024 · 1 comment
Open
Labels

Comments

@dotMorten
Copy link
Contributor

dotMorten commented Nov 13, 2024

Description

Binding this with PublishAoT causes a runtime crash:

    {
        get
        {
            var groups = (from item in Samples
                         orderby item.Category
                         group item by item.Category into g
                         select new SampleGroup(g) { Key = g.Key ?? "Misc" });
            return groups; // If you add .ToList() here no crash
        }
    }
    CollectionViewSource m_CollectionViewSource;
    public CollectionViewSource CollectionViewSource
    {
        get
        {
            if(m_CollectionViewSource == null)
            {
                m_CollectionViewSource = new CollectionViewSource()
                {
                    IsSourceGrouped = true,
                    Source = SamplesByCategory,
                    ItemsPath = new PropertyPath("Items")
                };
            }
            return m_CollectionViewSource;
        }
    }
}

Steps To Reproduce

  1. Run the attached project: App17.zip
  2. Observe the crash:
    Image
  3. Remove PublishAoT=true and sample runs
  4. Add ToList() to the SamplesByCategory return value, and problem goes away

Expected Behavior

No crash ;-)

Version Info

<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.241106002" />

Additional Context

No response

@dongle-the-gadget
Copy link
Contributor

This is a known issue, as LINQ uses internal enumerable types, which cannot be detected by the CsWinRT AOT optimizer.

@manodasanW manodasanW added the AOT label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants