Bug 45261 - [XamlC] Accessing Class Enum Causes Build Error
Summary: [XamlC] Accessing Class Enum Causes Build Error
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.3
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-10-10 23:03 UTC by Jimmy [MSFT]
Modified: 2017-01-18 09:42 UTC (History)
5 users (show)

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

sample project (259.56 KB, application/zip)
2016-10-10 23:03 UTC, Jimmy [MSFT]

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:

Description Jimmy [MSFT] 2016-10-10 23:03:35 UTC
Created attachment 17971 [details]
sample project

### Overview
When XamlC is enabled, trying to access a nested enum in Xaml

> BackgroundColor="{x:Static local:TestViewModel+MyColors.Hazel}"

 will throw a build error

> Type TestViewModel+MyColors not found in xmlns clr-namespace:XamlC_Issues

This worked prior to Forms 2.3.3-pre2 and the repro project compiles successfully with Forms 2.3.2 stable.

### Steps to Reproduce]
1. Open the attached sample project
2. Build the PCL project

### Expected Results
The project will compile.

### Actual Results
A build error is thrown.

### Testing Info
Tested with Forms 2.3.3-pre2.
Comment 1 Nestor 2016-12-02 21:17:56 UTC
I'm having the same issue, if I remove 
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
from my Application it compiles just fine

************ XAML file ************

<Style x:Key="BtnStyle" TargetType="Button">
 <Setter Property="BorderColor" Value="{x:Static local:Helpers.AppConstants.PrimaryButtonColor}"/>

************  Helpers/AppConstants.cs  ****************

public static class AppConstants{
public static Color PrimaryButtonColor = Color.FromHex("38455E");
Comment 2 Nestor 2016-12-02 21:28:52 UTC
### Testing Info   "stable"
Comment 3 Nestor 2016-12-08 20:48:27 UTC
dup of  https://bugzilla.xamarin.com/show_bug.cgi?id=47950   ?
Comment 4 Nestor 2016-12-19 19:08:15 UTC


<Label TextColor="{x:Static local:Helpers.AppConstants.TextColor}" />


<Label TextColor="{x:Static helpers:AppConstants.PrimaryTextColor}" />

now it compiles.
Comment 5 Stephane Delcroix 2017-01-18 09:42:18 UTC
see https://msdn.microsoft.com/en-us/library/ms742135(v=vs.110).aspx for additional info.

the syntax for `{x:Static}` is:

  <object property="{x:Static prefix:typeName.staticMemberName}" .../>

where "typeName you specify is actually a XAML type name, not a CLR type name"

Xaml typeName DO NOT support declaring namespaces (the '.' is reserved for properties assignment) and do not support nested classes (the '+' is not allowed in XML element names)