[BUG] Culture-sensitive ToLower() breaks generated code, GravatarImageSource and MathExpressionConverter under Turkish culture

Aperta
#3,369 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp

Direzione di ricerca

The issue identifies culture-sensitive casing in BindablePropertyAttributeSourceGenerator, AttachedBindablePropertyAttributeSourceGenerator, GravatarImageSource, and MathExpressionConverter. Start by reproducing the failures under tr-TR with the linked test project and inspect the reported casing calls. Done means generated accessibility and property-key names, the Gravatar identicon parameter, and the MIN expression behave as expected under Turkish culture; the issue author says a fix is ready to contribute.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Is there an existing issue for this?
  • I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior

Several places lower-case enum names or user input with the culture-sensitive ToLower(). Under tr-TR and az-AZ, "I".ToLower() is "ı" (dotless i), so on a machine with Turkish culture:

  • BindablePropertyAttributeSourceGenerator and AttachedBindablePropertyAttributeSourceGenerator emit ınternal partial class TestView for an internal class (DeclaredAccessibility.ToString().ToLower()). The generated file does not compile.
  • The generated BindablePropertyKey field of a read-only property named Icon becomes ıconPropertyKey (char.ToLower), so the generated code depends on the build machine.
  • GravatarImageSource with DefaultImage.Identicon requests d=ıdenticon, which Gravatar does not recognize.
  • MathExpressionConverter lower-cases the whole expression, so MIN(x, 3), IF(...) and PI become mın, ıf and pı and throw "Can't find operator or value".
Expected Behavior

Generated code and runtime results do not depend on the current culture: internal partial class TestView, iconPropertyKey, d=identicon, and MIN(x, 3) evaluates to 2 for x = 2.

Steps To Reproduce
  1. Use Turkish culture: build on a machine whose OS culture is tr-TR, or set CultureInfo.CurrentCulture = new CultureInfo("tr-TR") in a test.
  2. Declare internal partial class TestView : View { [BindableProperty] public partial string Text { get; set; } } and build. The generated file contains ınternal partial class TestView.
  3. Call new MathExpressionConverter().ConvertFrom(2d, "MIN(x, 3)"). It throws ArgumentException.
  4. Create a GravatarImageSource with Image = DefaultImage.Identicon. Its Uri ends with d=ıdenticon.
Link to public reproduction project repository

https://github.com/efeesrefinal/Maui/tree/repro/turkish-culture-casing
(unit tests only, on top of main: 5 tests that fail under tr-TR; run dotnet test in the two UnitTests projects)

Environment
* .NET MAUI CommunityToolkit: main (afa1d0dd)
* OS: Linux (unit tests); the generator issue applies to any build machine with Turkish culture
* .NET MAUI: 10.0 (.NET 10.0.403 SDK)
Anything else?

I have a fix ready: a small Accessibility.ToCSharpKeyword() helper for the generators and ToLowerInvariant in the other places. With it these tests pass, and so do the existing source generator tests (143) and the Gravatar and MathExpression tests (136). Happy to open a PR once this is approved.

Lingua principale
C#
Stelle
2.7k
Fork
502
Merge medio
11h 10m
PR unite (30g)
50

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CommunityToolkit/Maui

Tutte le issue di CommunityToolkit/Maui

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.