Bug 21340 - Ids of strings in strings.xml invoked with Resource.String.string_name point to incorrect string
Summary: Ids of strings in strings.xml invoked with Resource.String.string_name point ...
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler (show other bugs)
Version: 4.14.0
Hardware: PC Mac OS
: Highest normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-07-15 13:52 UTC by Sean Pearl
Modified: 2017-03-28 10:48 UTC (History)
3 users (show)

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


Attachments

Description Sean Pearl 2014-07-15 13:52:26 UTC
# Overview
In a sample I'm working on, Resources/values/strings.xml contains lines like the following:

>    <string name="app_name">CardReader</string>
>    <string name="sample_show_log">Show Log</string>
>    <string name="sample_hide_log">Hide Log</string>

In the main activity class, MainActivity.cs, I invoke them with the following code:

>    logToggle.SetTitle(mLogShown ? Resource.String.sample_hide_log : Resource.String.sample_show_log);

Where logToggle is an IMenuItem object. 

# Expected results
Invoking the strings sample_hide_log and and sample_show_log should produce the literal strings "Hide Log" and "Show Log", respectively. This goes for any other string invoked with this method.

# Actual results
When the application is run, the value of the string app_name are produced when the contents of sample_show_log should be displayed, and the contents of sample_show_log instead of sample_hide_log. 

If I add a breakpoint anywhere in the code and add a watch with the target Resources.GetString(Resource.String.sample_show_log), the result of that statement is "CardReader", the value of app_name.

Referencing them in a layout file using "@string/sample_show_log" produces correct values.

This affects the following Xamarin.Android sample in every version of XS and X.A I've tried, which includes 4.14 builds of X.A.

https://github.com/xamarin/monodroid-samples/tree/master/CardReader 
This project has a reference to the project CommonSampleLibrary in the monodroid-samples repo.

https://github.com/xamarin/monodroid-samples/tree/master/CardEmulation may also be affected.

# Steps to reproduce:
Open CardReader.sln in XS 
Build in Debug or Release and deploy to device or emulator
Optionally add a breakpoint and watch invoking Resource.String

# Tried steps:
Cleaning and rebuilding the solution
Updating Xamarin.Android

# System info
Xamarin Studio
Version 5.3 (build 291)
Installation UUID: 47444c7f-ce4e-4ab9-a7c0-0e3b40968ddf
Runtime:
	Mono 3.4.0 ((no/954ed3c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 304000214

Xamarin.Android
Version: 4.15.0 (Business Edition)
Java SDK: /usr
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)

Operating System
Mac OS X 10.9.4
Comment 1 Saurabh 2014-07-25 07:51:26 UTC
I have also checked this issue with the steps provide in this issue. I am also getting value CardReader for added watch "Resources.GetString(Resource.String.sample_show_log". This is the screencast for the same: http://www.screencast.com/t/OUuSfpavDMO

=== Xamarin Studio ===

Version 5.2 (build 384)
Installation UUID: 2591d519-875d-4afe-a3d9-5fcf391bbd2d
Runtime:
	Mono 3.4.0 ((no/954ed3c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 304000214

=== Apple Developer Tools ===

Xcode 4.6.3 (2068)
Build 4H1503

=== Xamarin.Android ===

Version: 4.14.0 (Enterprise Edition)
Android SDK: /Users/nischal/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)

=== Xamarin.iOS ===

Version: 7.2.5.5 (Enterprise Edition)
Hash: 87026b6
Branch: 
Build date: 2014-07-02 19:39:08-0400

=== Xamarin.Mac ===

Version: 1.8.0.8

=== Build Information ===

Release ID: 502000384
Git revision: 09e06441e39ea272ddda63758fd53013157f7e45
Build date: 2014-07-16 11:15:54-04
Xamarin addins: 2d11dd4dad5b35ca83f24d70e965792a47be8291

=== Operating System ===

Mac OS X 10.7.4
Darwin nischals-Mac-mini.local 11.4.0 Darwin Kernel Version 11.4.0
    Mon Apr  9 19:32:15 PDT 2012
    root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64
Comment 2 jaygreyman 2017-03-28 10:48:26 UTC
nice report. very informative. The steps of the representation are well-described. 

Regards,
http://writemypersonalstatement.net/

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