Bug 36972 - Xamarin Studio does not recognise base class assignment in Forms' XAML files
Summary: Xamarin Studio does not recognise base class assignment in Forms' XAML files
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Xamarin.Forms Add-in ()
Version: 5.10 (C6SR3)
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: (C7)
Assignee: David Karlaš
URL:
Depends on:
Blocks:
 
Reported: 2015-12-14 10:26 UTC by Prashant Cholachagudda
Modified: 2015-12-14 20:35 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test case (80.50 KB, application/zip)
2015-12-14 10:27 UTC, Prashant Cholachagudda
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Prashant Cholachagudda 2015-12-14 10:26:50 UTC
Xamarin Studio does not recognise base class assignment in Forms' XAML files, and reports the code errors in the source files.
However projects continues to build and work

# Steps to reproduce
Customer has a XAML ContentPage, that derives from a base ContentPage.

<?xml version="1.0" encoding="utf-8" ?>
<base:BaseContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:base="clr-namespace:Client.XamForms.Views.Base;assembly=KorfballScout"
             x:Class="Client.XamForms.Views.TeamTypeGroups.TeamTypeGroupSearch">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <SearchBar x:Name="Search" Grid.Row="0"></SearchBar>
        <ListView x:Name="List" Grid.Row="1" CachingStrategy="RecycleElement">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Label Grid.Row="0" Grid.Column="0" Text="{Binding TranslatedName}" 
                                   HorizontalTextAlignment="Start" VerticalOptions="Center" VerticalTextAlignment="Center" HorizontalOptions="FillAndExpand" FontSize="14"></Label>

                        </Grid>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</base:BaseContentPage>  

My code behind cs file looks like this:

using System.Collections.Generic;
using ClientService;
using ClientService.NotificationHub;
using Shared.Model;
using Xamarin.Forms;

namespace Client.XamForms.Views.TeamTypeGroups
{
    public partial class TeamTypeGroupSearch : Base.BaseContentPage
    {
        private readonly Club _clubFilter;

        public TeamTypeGroupSearch (Club clubFilter)
        {
            _clubFilter = clubFilter;
            InitializeComponent ();

            Title = Shared.Resources.Screens.Choose () + " " + Shared.Resources.Screens.TeamTypeGroup ();

            Search.Placeholder = Shared.Resources.Screens.Search ();
            Search.TextChanged += (sender, args) => PerformSearch ();

            List.ItemSelected += ListOnItemSelected;

            PerformSearch ();
        }

        protected override void OnAppearing ()
        {
            base.OnAppearing ();
            Search.Focus ();
        }

        private async void ListOnItemSelected (object sender, SelectedItemChangedEventArgs selectedItemChangedEventArgs)
        {
            if (List.SelectedItem == null)
                return;

            SelectTeamTypeGroupMessage.Publish (this, (TeamTypeGroup)List.SelectedItem);
            ApplicationManager.CoreService.AddRecent ((TeamTypeGroup)List.SelectedItem);
            await Navigation.PopAsync ();
        }

        private void PerformSearch ()
        {
            var searchText = Search.Text ?? string.Empty;

            var result = new List<TeamTypeGroup> ();
            foreach (var teamTypeGroup in ApplicationManager.CoreService.TeamTypeGroupSelectionList(CoreService.SelectionListFilter.All, _clubFilter)) {
                if (teamTypeGroup.GetTranslatedName ().ToLower ().Contains (searchText.ToLower ()))
                    result.Add (teamTypeGroup);
            }
            List.ItemsSource = result;
        }
    }
}  


However,

when I remove the 

: Base.BaseContentPage

from the class declaration,

using System.Collections.Generic;
using ClientService;
using ClientService.NotificationHub;
using Shared.Model;
using Xamarin.Forms;

namespace Client.XamForms.Views.TeamTypeGroups
{
    public partial class TeamTypeGroupSearch
    {
        private readonly Club _clubFilter;

        public TeamTypeGroupSearch (Club clubFilter)
        {
            _clubFilter = clubFilter;
            InitializeComponent ();

            Title = Shared.Resources.Screens.Choose () + " " + Shared.Resources.Screens.TeamTypeGroup ();

            Search.Placeholder = Shared.Resources.Screens.Search ();
            Search.TextChanged += (sender, args) => PerformSearch ();

            List.ItemSelected += ListOnItemSelected;

            PerformSearch ();
        }

        protected override void OnAppearing ()
        {
            base.OnAppearing ();
            Search.Focus ();
        }

        private async void ListOnItemSelected (object sender, SelectedItemChangedEventArgs selectedItemChangedEventArgs)
        {
            if (List.SelectedItem == null)
                return;

            SelectTeamTypeGroupMessage.Publish (this, (TeamTypeGroup)List.SelectedItem);
            ApplicationManager.CoreService.AddRecent ((TeamTypeGroup)List.SelectedItem);
            await Navigation.PopAsync ();
        }

        private void PerformSearch ()
        {
            var searchText = Search.Text ?? string.Empty;

            var result = new List<TeamTypeGroup> ();
            foreach (var teamTypeGroup in ApplicationManager.CoreService.TeamTypeGroupSelectionList(CoreService.SelectionListFilter.All, _clubFilter)) {
                if (teamTypeGroup.GetTranslatedName ().ToLower ().Contains (searchText.ToLower ()))
                    result.Add (teamTypeGroup);
            }
            List.ItemsSource = result;
        }
    }
}  


# Expected behavior
Xamarin Studio should pick the base class assigned in the XAML file, and shouldn't report code errors

# Actual behaviour
Xamarin Studio does not know the base class assigned in the XAML file, and report code errors
Comment 1 Prashant Cholachagudda 2015-12-14 10:27:24 UTC
Created attachment 14278 [details]
Test case
Comment 3 xamarin-release-manager 2015-12-14 20:35:31 UTC
Fixed in version 6.0.0.2535 (master)

Author: David Karlas??
Commit: 6e12236962563f8cfeb7f734c370ffa909137d99 (xamarin/md-addins)
Included in Commit: 0a818f98bbea04e6cd3db6e90807889be38043d3 (mono/monodevelop)