Maui.Markup
Maui.Markup copied to clipboard
[Bug] TextAlignmentExtensions does not work with inherited controls of Label, Picker, etc.
Description
TextAlignmentExtensions does not work with inherited controls of Label, Picker, etc. Previously this worked because the type parameter of the extension method was ITextAlignment, instead of a concrete class.
Steps to Reproduce
- In a new class inherit Label
- Try to use .TextCenter()
- Explicit casting required error
Expected Behavior
Actual Behavior
Basic Information
- Version with issue: 1.1.1
- Last known good version:1.0.1
- IDE:
- Platform Target Frameworks:
- iOS:
- Android:
- UWP:
- Android Support Library Version:
- Nuget Packages:
- Affected Devices:
Workaround
Reproduction imagery
Thanks Daniel! Good catch - yup, this is because we didn't extend the source generator for user code; it currently only generates the extension methods for the ITextAlignment
controls included in .NET MAUI.
I'll fix this for our next release 👍
This bug still exists in a different form. Since TextAlignment extension methods return Label
, I get this error
Cannot implicitly convert type 'Microsoft.Maui.Controls.Label' to 'MyProject.CustomLabel'. An explicit conversion exists (are you missing a cast?)
Thanks for the heads up!
Could you open a new Issue and include a reproduction sample?