Bug 18207 - Unable to have XML string resource where value begins with a question mark
Summary: Unable to have XML string resource where value begins with a question mark
Status: RESOLVED UPSTREAM
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.2.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-03-06 04:29 UTC by gserg.g
Modified: 2014-03-06 16:58 UTC (History)
3 users (show)

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

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 UPSTREAM

Description gserg.g 2014-03-06 04:29:56 UTC
If in Xamarin Studio you add a string resource to the 'values/strings.xml' file where the value of the resource begins with a question mark, optionally preceeded by white space, then you can't build the project.

The error: "No resource found that matches the givenname (at '<resource name>' with value '<resource value>')."
The error appears in the strings.xml editor.


Steps to reproduce:
1. Add this line to strings.xml:

<string name="bad_resource">???</string>

2. Build the project. Error: No resource found that matches the given name (at 'bad_resource' with value '???').


In order to work around this, you have to make the value begin with something else other that a question mark. As long as the value begins with something else, you can keep the rest '?'s.
Comment 1 Ram Chandra 2014-03-06 05:08:27 UTC
I tried to reproduce this issue as mentioned in bug description and I am able to reproduce this issue.

When I put a string which started with "?", I am getting build time error i.e. "No resource found that matches the given name (at 'bad_resources' with value '?tr')."  but when I added anything else except "?", I am not getting any build error.

Screencast: http://www.screencast.com/t/zq9Am1YaFrQa

Environment:

Windows 7
VS2013
xamarin.Android : 4.12.00028
Comment 2 Jonathan Pryor 2014-03-06 16:58:40 UTC
This is an Android "issue"/"bug"/"feature".

First of all, it bites Java users as well:

http://stackoverflow.com/questions/8074369/leading-question-mark-causes-eclipse-no-resource-found-that-matches-the-given-n

Second of all, the value of the <string/> element is not arbitrary text. It has rules:

http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling

For example, note that a single quote needs to be escaped. There are rules.

I suspect that as part of the (undocumented) rules, you can reference other resources, which means style references may be valid, and style references start with a '?':

http://developer.android.com/guide/topics/resources/accessing-resources.html#ReferencesToThemeAttributes

I would suggest trying to wrap the value in double-quotes, e.g.

    <string name="bad_resource">"???"</string>