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

There isn't a null check before calling **DataContextChanged** in .g.cs file for .xaml #9551

Closed
ishimada opened this issue Apr 16, 2024 · 1 comment
Labels
area-Binding bug Something isn't working closed-Fixed Described behavior has been fixed. team-Markup Issue for the Markup team
Milestone

Comments

@ishimada
Copy link

Describe the bug

There isn't a null check before calling DataContextChanged in .g.cs file for .xaml:

` // IDataTemplateComponent

        public void ProcessBindings(global::System.Object item, int itemIndex, int phase, out int nextPhase)
        {
            nextPhase = -1;
            switch(phase)
            {
                case 0:
                    nextPhase = -1;
                    this.SetDataRoot(item);
                    if (!removedDataContextHandler)
                    {
                        removedDataContextHandler = true;
                        (this.obj3.Target as global::Microsoft.UI.Xaml.Controls.StackPanel).DataContextChanged -= this.DataContextChangedHandler;

`
A static code analyzer reports this issue.

Is it guaranteed to be a nonnull value?

Steps to reproduce the bug

  1. Create a ,NET app with Windows App SDK using the code from https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.datatemplate?view=windows-app-sdk-1.5
  2. Build it.
  3. Find .g.cs for the XAML file under "bin" folder.

Expected behavior

If it is not guaranteed to be a nonnull value, there should be a null check before calling DataContextChanged.

Screenshots

No response

NuGet package version

None

Windows version

No response

Additional context

No response

@ishimada ishimada added the bug Something isn't working label Apr 16, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Apr 16, 2024
@bpulliam bpulliam added area-Binding team-Markup Issue for the Markup team and removed needs-triage Issue needs to be triaged by the area owners labels Apr 18, 2024
@llongley llongley added this to the WinAppSDK 1.6 milestone May 7, 2024
@llongley llongley closed this as completed May 7, 2024
@llongley llongley added the closed-Fixed Described behavior has been fixed. label May 7, 2024
@codendone
Copy link
Contributor

The fix is now also in Version 1.5.4 (1.5.240607001).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Binding bug Something isn't working closed-Fixed Described behavior has been fixed. team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

4 participants