When im trying to use constants in this C# application. When i run through the debugger, the constants come up as an "unknown identifier" Heres the code
public static class ConstsConfig
{
public static string BASE_URL_FORMAT = "%s://%s%s";
}
public static class NetworkConfig
{
public static string PROTOCOL = "http";
public static string HOST = "www.example.com";
public static string BASE_URL = "/test";
}
This is the line of code where its not evaluating it seems like
Uri uri = new Uri(String.Format(ConstsConfig.BASE_URL_FORMAT, NetworkConfig.PROTOCOL, NetworkConfig.HOST, NetworkConfig.BASE_URL)));
So when i step through the debugger and break on this line. If you hoever over one of the constants. It just says "Unknown identifier ConstsConfig" or "Uknown identifier NetworkConfig"
I would imagine its something small. Thanks for the help in advance.
There is a long-standing debugging issue in Xamarin.Android with Visual Studio related to inspecting values in static classes. Specifically, if you set a breakpoint on a line referencing a static class (or a non-static class with static members), Visual Studio may show the inspection value as "Unknown identifier: [ClassName]".
From my analysis, it turns out that the locations of class files in the project determine whether or not you'll have that issue.
The upshot for me is that, until Xamarin fixes the bug, all static classes, and classes with static members, should be placed in the root folder of the project. There are other file placement options, but some flat out don't work, and one requires fully qualifying your static class call with the namespace--even when not required by the compiler.
See comments in code below for full details.
MainActivity.cs
MyClass.cs
On 4/3/2016, I updated the associated Xamarin Bugzilla ticket with this information. Hopefully they get this resolved soon.