Skip to content

ResourceDictionary x KeyValuePair convert code generation  #14025

Closed

Description

@erikvilima

Current behavior

Works fine on UWP, but in other platforms (even WinUI) I'm getting a code generation error when trying to use a <ResourceDictionary> in a Dependency Property:

>C:\UnoPlatform\Uno.Themes\src\samples\UWP\Uno.Themes.Samples.Skia.Gtk\Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator\ButtonSamplePage_ffaf46608a7221259020a046294eeefc.cs(133,37,149,11): error CS1503: Argument 1: cannot convert from 'Windows.UI.Xaml.ResourceDictionary' to 'System.Collections.Generic.KeyValuePair<object, object>'

DP

public static DependencyProperty ColorPaletteProperty { [DynamicDependency(nameof(GetColorPalette))] get; } = DependencyProperty.RegisterAttached(
    "ColorPalette",
    typeof(ResourceDictionary),
    typeof(ThemeExtensions),
    new PropertyMetadata(default, OnColorPaletteChanged));

XAML

<Button Content="Outlined"
        Style="{StaticResource MaterialFilledButtonStyle}">
    <um:ThemeExtensions.ColorPalette>
        <ResourceDictionary>
            <Color x:Key="PrimaryColor">Yellow</Color>
            <Color x:Key="OnPrimaryBrush">Green</Color>
        </ResourceDictionary>
    </um:ThemeExtensions.ColorPalette>
</Button>

Expected behavior

No response

How to reproduce it (as minimally and precisely as possible)

Here's a dummy repro:
ResourceDict-Repro.zip

Workaround

No response

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

Activity

  1. added
    kind/bug
    triage/untriaged
    difficulty/tbd
    on Oct 19, 2023
  2. Youssef1313 commented on Oct 19, 2023

    @Youssef1313
    Member

    Works fine on UWP, but in other platforms (even WinUI) I'm getting a code generation

    @jeromelaban From the description it seems it's supported in UWP but not WinUI. We can't control what happens on WinUI anyway. So do we need to do anything here at all?

    cc @kazo0

  3. erikvilima commented on Oct 19, 2023

    @erikvilima
    ContributorAuthor

    I mean, you get the same error in a Uno App running on Windows (WinUI), the error is still in Uno.UI.SourceGenerators\Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator ...

    But you are able to do that in a WinUI App like:

    WinUI.zip

    cc @Youssef1313

  4. Youssef1313 commented on Oct 19, 2023

    @Youssef1313
    Member

    Then the error isn't really for WinUI. The Windows project doesn't use XamlCodeGenerator at all (it's all Microsoft things).

  5. changed the title [-]ResourceDictionary x KeyValuePair convert code generation [/-] [+]`ResourceDictionary` x `KeyValuePair` convert code generation [/+] on Oct 25, 2023
  6. added
    area/code-generation
    difficulty/medium 🤔
    and removed
    triage/untriaged
    difficulty/tbd
    on Oct 25, 2023
  7. jeromelaban commented on Oct 26, 2023

    @jeromelaban
    Member

    If it's not supported by WinUI, we can close. @eriklimakc @kazo0 do we need to track something here in toolkit for the scenario you were trying to reach?

  8. Youssef1313 commented on Oct 26, 2023

    @Youssef1313
    Member

    @jeromelaban I confirmed it's supported by WinUI. I think #14040 should be ready to merge (except for a runtime test that I forgot to add)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/code-generationdifficulty/medium 🤔kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions