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

fix!: Make SolidColorBrushHelper internal #11168

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build/PackageDiffIgnore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9133,13 +9133,13 @@
<Member fullName="Microsoft.UI.Xaml.Automation.Peers.ScrollPresenterAutomationPeer" reason="Not present in WinAppSDK 1.2" />
<Member fullName="Microsoft.UI.Xaml.Media.RevealBrushState" reason="Not present in WinAppSDK 1.2" />
<Member fullName="Windows.Foundation.IClosable" reason="Shouldn't be visible in .NET and shows as IDisposable instead." />
<Member fullName="Windows.Storage.Streams.InMemoryBuffer reason="Windows.Storage.Streams.Buffer should be used." />
Youssef1313 marked this conversation as resolved.
Show resolved Hide resolved
<Member fullName="Windows.Foundation.HResult" reason="Type is hidden in .NET and shouldn't be used" />
<Member fullName="Windows.Storage.Streams.InMemoryBuffer" reason="Windows.Storage.Streams.Buffer should be used." />
<Member fullName="Uno.Extensions.JavaObjectExtensions" reason="Only needed internally" />
<Member fullName="Uno.Client.ICommandExtensions" reason="Only needed internally" />
<Member fullName="Uno.Extensions.UriExtensions" reason="Not needed publicly" />
<Member fullName="Windows.UI.Xaml.FontFamilyHelper" reason="Only needed internally. The public facing type is Uno.UI.Xaml.Media.FontFamilyHelper" />
<Member fullName="Windows.UI.Xaml.SolidColorBrushHelper" reason="Not needed publicly and not present in Windows." />
</Types>
<Events>
<Member fullName="Windows.Foundation.TypedEventHandler`2&lt;Microsoft.UI.Xaml.Controls.IInputValidationControl,Microsoft.UI.Xaml.Controls.HasValidationErrorsChangedEventArgs&gt; Microsoft.UI.Xaml.Controls.AutoSuggestBox::HasValidationErrorsChanged" reason="Not present in WinAppSDK 1.2" />
Expand Down Expand Up @@ -9401,8 +9401,8 @@
<Member fullName="System.Void Windows.ApplicationModel.SuspendingDeferral..ctor(System.Action deferralDone)" reason="This constructor does not exist in Windows" />
<Member fullName="System.Void Windows.UI.Xaml.Controls.CalendarDatePicker.add__dateChanged(Windows.Foundation.TypedEventHandler`2&lt;Windows.UI.Xaml.Controls.CalendarDatePicker,Windows.UI.Xaml.Controls.CalendarDatePickerDateChangedEventArgs&gt; value)" reason="Not in Windows" />
<Member fullName="System.Void Windows.UI.Xaml.Controls.CalendarDatePicker.remove__dateChanged(Windows.Foundation.TypedEventHandler`2&lt;Windows.UI.Xaml.Controls.CalendarDatePicker,Windows.UI.Xaml.Controls.CalendarDatePickerDateChangedEventArgs&gt; value)" reason="Not in Windows" />
<Member fullName="System.Threading.Tasks.Task`1&lgt;System.Collections.Generic.IList`1&lt;Windows.Devices.Geolocation.Geoposition&gt;&gt; Windows.Devices.Geolocation.Geolocator.GetGeopositionHistoryAsync(System.DateTime startTime)" reason="Not in Windows and not implemented properly" />
<Member fullName="System.Threading.Tasks.Task`1&lgt;System.Collections.Generic.IList`1&lt;Windows.Devices.Geolocation.Geoposition&gt;&gt; Windows.Devices.Geolocation.Geolocator.GetGeopositionHistoryAsync(System.DateTime startTime, System.TimeSpan duration)" reason="Not in Windows and not implemented properly" />
<Member fullName="System.Threading.Tasks.Task`1&lt;System.Collections.Generic.IList`1&lt;Windows.Devices.Geolocation.Geoposition&gt;&gt; Windows.Devices.Geolocation.Geolocator.GetGeopositionHistoryAsync(System.DateTime startTime)" reason="Not in Windows and not implemented properly" />
<Member fullName="System.Threading.Tasks.Task`1&lt;System.Collections.Generic.IList`1&lt;Windows.Devices.Geolocation.Geoposition&gt;&gt; Windows.Devices.Geolocation.Geolocator.GetGeopositionHistoryAsync(System.DateTime startTime, System.TimeSpan duration)" reason="Not in Windows and not implemented properly" />
<Member fullName="System.Void Uno.UI.Controls.Window.SetNeedsKeyboard(AppKit.NSView view, System.Boolean needsKeyboard)" reason="Not needed and doesn't do something useful" />
<Member fullName="System.Threading.Tasks.Task`1&lt;System.Collections.Generic.IList`1&lt;Windows.Devices.Geolocation.Geoposition&gt;&gt; Windows.Devices.Geolocation.Geolocator.GetGeopositionHistoryAsync(System.DateTime startTime)" reason="Not in Windows and not implemented properly" />
<Member fullName="System.Threading.Tasks.Task`1&lt;System.Collections.Generic.IList`1&lt;Windows.Devices.Geolocation.Geoposition&gt;&gt; Windows.Devices.Geolocation.Geolocator.GetGeopositionHistoryAsync(System.DateTime startTime, System.TimeSpan duration)" reason="Not in Windows and not implemented properly" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public static class Types
// Misc
public const string Setter = BaseXamlNamespace + ".Setter";
public const string CornerRadius = BaseXamlNamespace + ".CornerRadius";
public const string SolidColorBrushHelper = BaseXamlNamespace + ".SolidColorBrushHelper";
public const string GridLength = BaseXamlNamespace + ".GridLength";
public const string GridUnitType = BaseXamlNamespace + ".GridUnitType";
public const string Color = RootWUINamespace + ".Color";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5317,19 +5317,18 @@ private string BuildFontWeight(string memberValue)

private string BuildBrush(string memberValue)
{
var colorHelper = (INamedTypeSymbol)_metadataHelper.GetTypeByFullName(XamlConstants.Types.SolidColorBrushHelper);
var colors = (INamedTypeSymbol)_metadataHelper.GetTypeByFullName(XamlConstants.Types.Colors);

// This ensures that a memberValue "DarkGoldenRod" gets converted to colorName "DarkGoldenrod" (notice the lowercase 'r')
var colorName = colorHelper.GetProperties().FirstOrDefault(m => m.Name.Equals(memberValue, StringComparison.OrdinalIgnoreCase))?.Name;
var colorName = colors.GetProperties().FirstOrDefault(m => m.Name.Equals(memberValue, StringComparison.OrdinalIgnoreCase))?.Name;
if (colorName != null)
{
return "SolidColorBrushHelper." + colorName;
return $"new global::{XamlConstants.Types.SolidColorBrush}(global::{XamlConstants.Types.Colors}.{colorName})";
jeromelaban marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
memberValue = ColorCodeParser.ParseColorCode(memberValue);

return "SolidColorBrushHelper.FromARGB({0})".InvariantCultureFormat(memberValue);
return $"new global::{XamlConstants.Types.SolidColorBrush}(global::{XamlConstants.Types.Color}.FromArgb({{0}}))".InvariantCultureFormat(memberValue);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/Media/Brush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public Brush()
InitializeBinder();
}

public static implicit operator Brush(Color uiColor) => SolidColorBrushHelper.FromARGB(uiColor.A, uiColor.R, uiColor.G, uiColor.B);
public static implicit operator Brush(Color uiColor) => new SolidColorBrush(uiColor);

public static implicit operator Brush(string colorCode) => SolidColorBrushHelper.Parse(colorCode);

Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/Media/BrushConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c
switch (value)
{
case string color:
return SolidColorBrushHelper.FromARGB(color);
return SolidColorBrushHelper.Parse(color);

case Color color:
return new SolidColorBrush(color);
Expand Down
Loading