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

Regression from MAUI 8: Picker entries blank in release mode (Android) #25935

Open
BioTurboNick opened this issue Nov 19, 2024 · 4 comments
Open
Labels
area-controls-picker Picker platform/android 🤖 potential-regression This issue described a possible regression on a currently supported version., verification pending s/needs-repro Attach a solution or code which reproduces the issue t/bug Something isn't working
Milestone

Comments

@BioTurboNick
Copy link
Contributor

Description

I have a Picker that is populated by an array of values. They are mapped to a localized string through a ValueConverter.

Since updating to MAUI 9, the picker is now full of blank entries in release mode.

Steps to Reproduce

XAML:

<ContentView.Resources>
    <ResourceDictionary>
        <vc:IntToPowerConverter x:Key="intToPower" />
    </ResourceDictionary>
</ContentView.Resources>

<Picker Grid.Column="2"
        FontSize="16"
        VerticalTextAlignment="End"
        ItemDisplayBinding="{Binding Converter={StaticResource intToPower}}">
    <Picker.ItemsSource>
        <x:Array Type="{x:Type x:Int32}">
            <x:Int32>0</x:Int32>
            <x:Int32>1</x:Int32>
            <x:Int32>2</x:Int32>
            <x:Int32>3</x:Int32>
            <x:Int32>4</x:Int32>
            <x:Int32>5</x:Int32>
            <x:Int32>6</x:Int32>
            <x:Int32>7</x:Int32>
            <x:Int32>8</x:Int32>
            <x:Int32>9</x:Int32>
        </x:Array>
    </Picker.ItemsSource>
</Picker>

C#:

static readonly char[] superscriptCharacters = ['⁰', '¹', '²', '³', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹', '⁻'];
static readonly char[] characters = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-'];
static readonly Dictionary<char, char> superscriptDictionary = new(superscriptCharacters.Length);
const char times = '×';

public static string GetSuperscript(int exponentValue, CultureInfo culture)
{
    string formatedValue = exponentValue.ToString("D", culture);

    string formattedSuperscripts = string.Empty;

    for (int i = 0; i < formatedValue.Length; i++)
        formattedSuperscripts += superscriptDictionary[formatedValue[i]];

    return formattedSuperscripts;
}

public static string ToPowerOfTen(int value, CultureInfo culture)
{
    string formattedValue = string.Empty;

    if (value == 0) return formattedValue;

    formattedValue += times + 10.ToString(culture);

    if (value == 1) return formattedValue;

    formattedValue += GetSuperscript(value, culture);

    return formattedValue;
}

public class IntToPowerConverter :
    IValueConverter
{
    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (targetType != typeof(string))
            return new object();

        return value switch
        {
            int intValue => FormatHelpers.ToPowerOfTen(intValue, culture),
            _            => string.Empty
        };
    }

    public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
        throw new NotImplementedException();
}

Link to public reproduction project repository

No response

Version with bug

9.0.10 SR1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.92 SR9.2

Affected platforms

Android

Affected platform versions

Android 14

Did you find any workaround?

No response

Relevant log output

@BioTurboNick BioTurboNick added the t/bug Something isn't working label Nov 19, 2024
@BioTurboNick BioTurboNick changed the title Regression from MAUI 8: Picker entries blank in release mode Regression from MAUI 8: Picker entries blank in release mode (Android) Nov 19, 2024
@mattleibow
Copy link
Member

@simonrozsival This is using ItemDisplayBinding and I know we touched that in .NET 9...

@mattleibow mattleibow added platform/android 🤖 area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) potential-regression This issue described a possible regression on a currently supported version., verification pending area-controls-picker Picker and removed area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) labels Nov 19, 2024
@mattleibow mattleibow added this to the .NET 9 SR1.1 milestone Nov 19, 2024
@BioTurboNick
Copy link
Contributor Author

FWIW I have confirmed that if I remove ItemDisplayBinding= the items show up.

@simonrozsival
Copy link
Member

@BioTurboNick I cannot reproduce the problem in .NET 9 in the example you provided with this change to how superscriptDictionary is initialized (I assume you're setting this up elsewhere in your original codebase):

-static readonly Dictionary<char, char> superscriptDictionary = new(superscriptCharacters.Length);
+static readonly Dictionary<char, char> superscriptDictionary = characters.Zip(superscriptCharacters).ToDictionary(x => x.First, x => x.Second);

Even without this change, the picker displays two values ("" and "x10") which is different from the behavior you described.

Could you please share a full sample app which demonstrates the bug? There might be something else that causes the issue outside of the code you shared.

@simonrozsival simonrozsival added the s/needs-repro Attach a solution or code which reproduces the issue label Nov 19, 2024
Copy link
Contributor

Hi @BioTurboNick. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-picker Picker platform/android 🤖 potential-regression This issue described a possible regression on a currently supported version., verification pending s/needs-repro Attach a solution or code which reproduces the issue t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants