Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] XF 4.8 pre2 - fix provided in #11187 - for RECT API throws error - System.InvalidOperationException Message=The BindableProperty "Width" is readonly. #11551

Closed
npagare opened this issue Jul 24, 2020 · 8 comments

Comments

@npagare
Copy link

npagare commented Jul 24, 2020

Description

Fix provided in #11187 throws error at runtime.

System.InvalidOperationException
Message=The BindableProperty "Width" is readonly.

Steps to Reproduce

  1. Upgrade to XF 4.8, pre2
  2. Define a style in a theme xaml file .. say myTheme.Xaml
  3. Define a <Rect x:Key="TemplateLayoutBounds" Height="22" Width="{x:Static AbsoluteLayout.AutoSize}" X="1" Y="0.5" />
  4. Create a XAML page with label element and assign a absoluteLayout.LayoutBounds using above style
    <Setter Property="AbsoluteLayout.LayoutBounds" Value="{DynamicResource TemplateLayoutBounds}" />

Please note this was working using struct API Rectangle - up until XF 4.7 pre3. It was broken in XF 4.7 pre4 until now.

Expected Behavior

Functionality of the Rectangle API up until 4.7 pre3 to be working in XF 4.8 pre2

Actual Behavior

Fix provided in #11187 is broken

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE: VS 16.6.5
  • Platform Target Frameworks:
    • iOS: 13.6
    • Android: 9, 10
    • UWP:
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices:
    Both Android and iOS

Reproduction Link

Workaround

VS bug #1162353

@npagare npagare added s/unverified New report that has yet to be verified t/bug 🐛 labels Jul 24, 2020
@hartez
Copy link
Contributor

hartez commented Jul 24, 2020

I believe this is addressed in #11548

@hartez hartez added a/Xaml </> external-hotreload Non-Forms bugs that affect Hot Reload and removed s/unverified New report that has yet to be verified labels Jul 24, 2020
@StephaneDelcroix StephaneDelcroix removed the external-hotreload Non-Forms bugs that affect Hot Reload label Jul 25, 2020
@StephaneDelcroix StephaneDelcroix marked this as a duplicate of #11541 Jul 25, 2020
@StephaneDelcroix
Copy link
Member

reopening for the issue outlined at #11541 (comment), and rephrasing the content. the original issue (invalid IL) has been fixed

@StephaneDelcroix StephaneDelcroix marked this as not a duplicate of #11541 Jul 25, 2020
@StephaneDelcroix
Copy link
Member

@IoTFier do you really mean <Rect x:Key="TemplateLayoutBounds" HeightRequest="22" WidthRequest="{x:Static AbsoluteLayout.AutoSize}" X="1" Y="0.5" /> or should it be <Rect x:Key="TemplateLayoutBounds" Height="22" Width="{x:Static AbsoluteLayout.AutoSize}" X="1" Y="0.5" /> ??

@StephaneDelcroix
Copy link
Member

LayoutBounds property type should probably be changed to Rect instead of Rectangle

@npagare
Copy link
Author

npagare commented Jul 25, 2020

LayoutBounds property type should probably be changed to Rect instead of Rectangle

I have updated step # 3 in the steps to reproduce. I had the WidthRequest and HeightRequest in place when I had tried to use it with 4.7 pre4 and 4.7 stable.

But now, I am back to using <Rect x:Key="TemplateLayoutBounds" Width="{x:Static AbsoluteLayout.AutoSize}" Height="22" X="0" Y="0.5" />

The Rectangle struct up until 4.7 pre3 allowed these bindable property to be editable. Now in the new Rect API it is not allowed.

I am going reiterate my request to all XF leadership panel to consider isolating Shapes API in its own namespace.
Who knows what other things may break out ?

@StephaneDelcroix
Copy link
Member

The Rectangle struct up until 4.7 pre3 allowed these bindable property to be editable. Now in the new Rect API it is not allowed.

they are no BP, but should be editable (they have a public setter)

I am going reiterate my request to all XF leadership panel to consider isolating Shapes API in its own namespace.

Thanks for the recommandation, but this ship has sailed (the API has been in a public release). We can still consider moving it out while moving to Maui

@StephaneDelcroix StephaneDelcroix changed the title [Bug] XF 4.8 pre2 - fix provided in #11187 - for RECT API throws error - Invalid IL code in InitializeComponent (): IL_0329: stloc.s 31 [Bug] XF 4.8 pre2 - fix provided in #11187 - for RECT API throws error - System.InvalidOperationException Message=The BindableProperty "Width" is readonly. Jul 27, 2020
@StephaneDelcroix StephaneDelcroix added 2.4.0 regression on 2.4.0 and removed 2.4.0 regression on 2.4.0 labels Jul 27, 2020
@StephaneDelcroix
Copy link
Member

I tried to reproduce your issue with the following XAML:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
	xmlns="http://xamarin.com/schemas/2014/forms"
	xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
	x:Class="Xamarin.Forms.Xaml.UnitTests.Gh11551">
    <ContentPage.Resources>
	<Rect x:Key="rect" Height="22" Width="{x:Static AbsoluteLayout.AutoSize}" X="1" Y="0.5"/>
    </ContentPage.Resources>
    <Label x:Name="label">
	<Label.Style>
	    <Style TargetType="Label">
		<Setter Property="AbsoluteLayout.LayoutBounds" Value="{DynamicResource rect}"/>
	    </Style>
	</Label.Style>
    </Label>
</ContentPage>

The message the BP Width is readonly would only happen if you're trying to assign the Width (vs WidthRequest) of a VisualElement (Shapes.Rectangle IS a VisualElement).

I suppose you still have some Rect/Rectangle mixups in your code. We understand this comes from a breaking change we introduced, and we're sorry for the inconvenience it causes to you and your project.

I'm going to:

  • commit the unit test to avoid reverting that behaviour
  • close this issue as I think it's solved.

If you think it's not fixed, please reopen the issue, and attach a reproduction sample we can run.

Thanks

StephaneDelcroix added a commit that referenced this issue Jul 27, 2020
@npagare
Copy link
Author

npagare commented Jul 28, 2020

Hi @StephaneDelcroix , I guess my bin/obj folders were corrupt.
Changing XAML similar to the one in your note above has worked for me.

Thank you all for helping me out.

Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants