Xamarin.forms: Breaking Xaml changes on XF 3.1

Created on 24 Jun 2018  ·  3Comments  ·  Source: xamarin/Xamarin.Forms

I just wanted to inform you that if you upgrade on XF 3.1 version, you may get xaml errors telling that "member names cannot be the same as their enclosing type". this is a well known C# error if parent and child types have same name

reason for that is code below works in versions before XF 3.1 but returns error on XF 3.1 ... I am not sure if that is supposed to be a bug or a fix of a bug all the time?

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

             x:Class="myApp.TestPage"  x:Name="TestPage" > 

  <ContentPage.Content>

            <c:cwTest x:Name="cwTest"  VerticalOptions="FillAndExpand"  HorizontalOptions="FillAndExpand"/>

  </ContentPage.Content>
</ContentPage>
Xaml </> invalid bug

Most helpful comment

@EmilAlipiev @StephaneDelcroix yes, would have been helpful to be forewarned. This is a breaking change and your sort of apology/excuse is unhelpful.

All 3 comments

The only thing that changed is that we now creates a field for x:Name defined at the top-level XAML element, so it can be accessed from code-behind eventually, and we weren't before.

You could reproduce that behavior with any previous version of XF by having a Label or any element in your xaml with a `x:Name="TestPage"' attribute.

We're sorry if it breaks some of your code. After careful consideration, this is not considered a bug or a regression. Your code used to rely on a missing validation, but you can't exploit this failure anymore.

The workaround for this is trivial, straightforward, and very simple to put in place.

@StephaneDelcroix I agree with that. I only brought to your attention because you should have highlighted it. VS2017 doesnt give me enough information, rather it throws 100s of errors for a single file. once i restore back to 3.0, all works fine. just for anybody else having this error to reference this issue.

@EmilAlipiev @StephaneDelcroix yes, would have been helpful to be forewarned. This is a breaking change and your sort of apology/excuse is unhelpful.

Was this page helpful?
0 / 5 - 0 ratings