-
Notifications
You must be signed in to change notification settings - Fork 2k
Add support for background images with ImageBrush #36329
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
base: net11.0
Are you sure you want to change the base?
Changes from all commits
4bdfb26
5d2064d
d0c2d3b
3a9a9ef
9fe161b
ab22ef3
a4b0446
c74f498
2da2b8b
376d288
64fc60b
31bde87
96b03c0
2590981
bf19dd9
3b8027b
42ddce2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| namespace Microsoft.Maui.Controls | ||
| { | ||
| [ContentProperty(nameof(ImageSource))] | ||
| class ImageBrush : Brush | ||
| public class ImageBrush : Brush | ||
|
HarishwaranVijayakumar marked this conversation as resolved.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
[major] Public API Surface — Making |
||
| { | ||
| public ImageBrush() | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue12928" | ||
| Title="ImageBrush Background"> | ||
|
|
||
| <Grid RowDefinitions="Auto, *, *, Auto, *, *, Auto" | ||
| Padding="15" | ||
| RowSpacing="8"> | ||
|
|
||
| <Label x:Name="Control1Label" | ||
| Text="Label" | ||
| FontAttributes="Bold" | ||
| AutomationId="Control1Label"/> | ||
|
|
||
| <ContentView x:Name="Control1ColorContainer" | ||
| Grid.Row="1" | ||
| AutomationId="Control1ColorContainer"/> | ||
|
|
||
| <ContentView x:Name="Control1ImageContainer" | ||
| Grid.Row="2" | ||
| AutomationId="Control1Container"/> | ||
|
|
||
| <Label x:Name="Control2Label" | ||
| Grid.Row="3" | ||
| Text="Button" | ||
| FontAttributes="Bold" | ||
| AutomationId="Control2Label"/> | ||
|
|
||
| <ContentView x:Name="Control2ColorContainer" | ||
| Grid.Row="4" | ||
| AutomationId="Control2ColorContainer"/> | ||
|
|
||
| <ContentView x:Name="Control2ImageContainer" | ||
| Grid.Row="5" | ||
| AutomationId="Control2Container"/> | ||
|
|
||
| <Button Grid.Row="6" | ||
| Text="Select Controls" | ||
| Clicked="OnOptionsClicked" | ||
| AutomationId="OptionsButton"/> | ||
| </Grid> | ||
| </ContentPage> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[moderate] Public API Surface Design / Logic and Correctness — This line makes
ImageBrushpublic (previouslyinternal), and the accompanyingPublicAPI.Unshipped.txtentries in this PR shipEquals/GetHashCodeas public API.Equals(line 28-29) performs value comparison onImageSource, whileGetHashCode()(line 31) returnsbase.GetHashCode()— reference-identity, since neitherBrushnorElementoverrides it. This violates the .NET contract that equal objects must produce equal hash codes: two distinctImageBrushinstances referencing the sameImageSourcecompareEqualbut hash differently, breaking correctness forDictionary<ImageBrush,_>/HashSet<ImageBrush>usage. Since this is now public/shipped API, the defect can no longer be fixed without a breaking change.