Bug 55027 - Xaml compilation can't handle folders in namespaces
Summary: Xaml compilation can't handle folders in namespaces
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Stephane Delcroix
Depends on:
Reported: 2017-04-11 15:13 UTC by Charles Petzold
Modified: 2017-07-19 07:47 UTC (History)
6 users (show)

See Also:
Is this bug a regression?: Yes
Last known good build:


Description Charles Petzold 2017-04-11 15:13:19 UTC
The following program has a MainPage that navigates to AnotherPage:


The navigation is initiated with a Button press. The Button's Command property is set to a little function in the code-behind file that does the navigation; the CommandParameter is set (in MainPage.xaml) to the type of AnotherPage.

AnotherPage is in a folder named OrganizationalFolder. Thus, its fully qualified named is XamlCompilationIssue.NavigationalFolder.AnotherPage. It appears in MainPage.xaml as local:OrganizationalFolder.AnotherPage.

The program has XAML compilation enabled for the assembly (in App.xaml.cs) but XAML compilation for MainPage is disabled. The program works as is.

However, if the [XamlCompilation(XamlCompilationOptions.Skip)] attribute in MainPage is commented out, the compilation fails with the error message that OrganizationalFolder.AnotherPage cannot be found.
Comment 2 Stephane Delcroix 2017-04-13 07:05:43 UTC
The folder part of this was confusing at first. after downloading that multi-gig repo it was a bit clearer. This has nothing to do with folders at all, but with compound namespaces (VS, or r#, generates a namespace per folder, but that's all).

Usually, Xaml DO NOT supports compound namespaces, or nested classes because the syntax

  <local:OrganizationalFolder.AnotherPage />

could then mean
- instantiate an object of type whateverNamespaceDeclaredInTheLocalXmlns.OrganizationFolder.AnotherPage or
- assign the AnotherPage property (or Bindable, or attached) to the object

From looking at your reproduction, it looks like your issue is that the x:Type markup extension doesn't allow compound namespaces, and enabling that is harmless as there's no confusion possible.

  CommandParameter="{x:Type local:OrganizationalFolder.AnotherPage}"

Or at least, that the behavior should be coherent with XamlC or on off.

I'll investigate some more as soon as I finish downloading your multi-gigabytes repository...
Comment 3 Stephane Delcroix 2017-04-13 11:56:54 UTC
Comment 4 Jimmy [MSFT] 2017-06-16 22:15:57 UTC
The pull request in comment 3 should fix this issue. It has been merged and will be available in a future release.
Comment 5 Pratik Lad 2017-07-04 07:14:16 UTC
Hi ,

Could you please provide me fixed version to verify this bug. Any steps to reproduce bug would be great.
Comment 6 Gaurav Ganorkar 2017-07-19 07:47:29 UTC

I have verified this bug on latest xamarin.forms version - .

Followed following steps:

1.open https://github.com/xamarin/private-samples/tree/master/XamlCompilationIssue
2.set properties build as none for mainpage.xaml.cs where it was enabled for app.xaml.cs

3.Commented [XamlCompilation(XamlCompilationOptions.Skip)] attribute in MainPage.
4.Clean & build project.

Didn't received any error as given in description where as error received on earlier forms version(2.3.4).

Link of screen cast- https://www.screencast.com/t/8A7Pfq4Kr

Gist version link- https://gist.github.com/nehaKh/b23c6bcb1d8fcc706ead38984057bbb8

Note You need to log in before you can comment on or make changes to this bug.