Skip to content

Commit 34cbcf1

Browse files
[XSG] trim color (#32035)
Trim color names in ColorConverter - fixes #32034
1 parent 4ea1f02 commit 34cbcf1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Controls/src/SourceGen/TypeConverters/ColorConverter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ internal class ColorConverter : ISGTypeConverter
1717

1818
public string Convert(string value, BaseNode node, ITypeSymbol toType, SourceGenContext context, LocalVariable? parentVar = null)
1919
{
20+
value = value.Trim();
2021
if (ColorUtils.TryParse(value, out float red, out float green, out float blue, out float alpha))
2122
{
2223
var colorType = context.Compilation.GetTypeByMetadataName("Microsoft.Maui.Graphics.Color")!;

src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SimplifyOnPlatform.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void Test()
1919
x:Class="Test.TestPage">
2020
<ContentPage.Resources>
2121
<Style TargetType="Label" x:Key="style">
22-
<Setter Property="TextColor" Value="Pink" />
22+
<Setter Property="TextColor" Value="Pink " />
2323
<Setter Property="IsVisible" Value="{OnPlatform Android=True, iOS=False}" />
2424
</Style>
2525
</ContentPage.Resources>
@@ -120,7 +120,7 @@ private partial void InitializeComponent()
120120
setter.Property = ((global::Microsoft.Maui.Controls.IExtendedTypeConverter)new global::Microsoft.Maui.Controls.BindablePropertyConverter()).ConvertFromInvariantString("TextColor", xamlServiceProvider1) as global::Microsoft.Maui.Controls.BindableProperty;
121121
#line default
122122
#line 8 "{{testXamlFilePath}}"
123-
setter.Value = "Pink";
123+
setter.Value = "Pink ";
124124
#line default
125125
var setter2 = new global::Microsoft.Maui.Controls.Setter {Property = global::Microsoft.Maui.Controls.Label.TextColorProperty, Value = global::Microsoft.Maui.Graphics.Colors.Pink};
126126
if (global::Microsoft.Maui.VisualDiagnostics.GetSourceInfo(setter2!) == null)

0 commit comments

Comments
 (0)