Bug 6256 - Stylable resource ids gets messed up in Resource.Designer file
Summary: Stylable resource ids gets messed up in Resource.Designer file
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.2.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-07-24 12:08 UTC by André Ingar Sørensen
Modified: 2012-07-26 03:02 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 FIXED

Description André Ingar Sørensen 2012-07-24 12:08:08 UTC
I have created a custom ui object that displays different content depending on user interaction. I have made it stylable, but something is wrong with the values in the Resource.Designer file, thus making the instantiation of the object defined in axml different than one should expect.

from Attrs.xml: 

<resources>
  <attr name="headerTextAppearance" format="reference" />
  <attr name="labelTextAppearance" format="reference" />
  <attr name="contentTextAppearance" format="reference" />
  <attr name="headerText" format="string" />
  <attr name="labelText" format="string" />

  <declare-styleable name="MainContentElement">
    <attr name="descText1" format="string" />
    <attr name="descText2" format="string" />
    <attr name="img1Disabled" format="reference" />
    <attr name="img1Enabled" format="reference" />
    <attr name="img2Disabled" format="reference" />
    <attr name="img2Enabled" format="reference" />
    <attr name="content" format="integer" />
    <attr name="invert" format="boolean" />
    <attr name="headerTextAppearance" />
    <attr name="contentTextAppearance" />
    <attr name="labelTextAppearance" />
    <attr name="headerText" />
  </declare-styleable>
.
.
.
</resources>

From Resource.Designer.cs:

			// aapt resource value: 10
			public const int MainContentElement_content = 16;
			
			// aapt resource value: 2
			public const int MainContentElement_contentTextAppearance = 2;
			
			// aapt resource value: 4
			public const int MainContentElement_descText1 = 4;
			
			// aapt resource value: 5
			public const int MainContentElement_descText2 = 5;
			
			// aapt resource value: 3
			public const int MainContentElement_headerText = 3;
			
			// aapt resource value: 0
			public const int MainContentElement_headerTextAppearance = 0;
			
			// aapt resource value: 6
			public const int MainContentElement_img1Disabled = 6;
			
			// aapt resource value: 7
			public const int MainContentElement_img1Enabled = 7;
			
			// aapt resource value: 8
			public const int MainContentElement_img2Disabled = 8;
			
			// aapt resource value: 9
			public const int MainContentElement_img2Enabled = 9;
			
			// aapt resource value: 11
			public const int MainContentElement_invert = 17;
			
			// aapt resource value: 1
			public const int MainContentElement_labelTextAppearance = 1;
---
Pay attention to the Ids for invert and content. The aapt resource values in comment differs from actual value. 
During debug the Ids for invert, 17, will not retrive anything. Same thing for content, 16. 
However if I replace it with the values in the comment, I get the expected values.
Comment 1 Paul Stevens 2012-07-25 07:00:58 UTC
I've encountered the exact same bug, it seems that whenever the aapt resource value >9 i.e 10+ it adds 6 to the resource cons value. i.e an aapt value of 10 becomes 16, 11 -> 17 etc.


Resources File:

<resources>
  <declare-styleable name="EditTextValidated">
    <attr name="ValidationType" format="string"/>
    <attr name="ValidationExpression" format="string"/>
    <attr name="ValidationParameter1" format="string"/>
    <attr name="ValidationParameter2" format="string"/>
    <attr name="ValidationParameter3" format="string"/>
    <attr name="GroupID" format="string"/>
    <attr name="GroupMax" format="string"/>
    <attr name="GroupMin" format="string"/>
    <attr name="TableName" format="string"/>
    <attr name="MaxLength" format="string"/>
    <attr name="MinLength" format="string"/>
    <attr name="MaxNumber" format="string"/>
    <attr name="MinNumber" format="string"/>
    <attr name="FailNotification" format="string"/>
    <attr name="Required" format="boolean"/>
    <attr name="UniqueField" format="boolean"/>
    <attr name="AttributeName" format="string"/>
    
  </declare-styleable>
</resources>

Resource.Designer.cs:

// aapt resource value: 16
			public const int EditTextValidated_AttributeName = 22;
			
			// aapt resource value: 13
			public const int EditTextValidated_FailNotification = 19;
			
			// aapt resource value: 5
			public const int EditTextValidated_GroupID = 5;
			
			// aapt resource value: 6
			public const int EditTextValidated_GroupMax = 6;
			
			// aapt resource value: 7
			public const int EditTextValidated_GroupMin = 7;
			
			// aapt resource value: 9
			public const int EditTextValidated_MaxLength = 9;
			
			// aapt resource value: 11
			public const int EditTextValidated_MaxNumber = 17;
			
			// aapt resource value: 10
			public const int EditTextValidated_MinLength = 16;
			
			// aapt resource value: 12
			public const int EditTextValidated_MinNumber = 18;
			
			// aapt resource value: 14
			public const int EditTextValidated_Required = 20;
			
			// aapt resource value: 8
			public const int EditTextValidated_TableName = 8;
			
			// aapt resource value: 15
			public const int EditTextValidated_UniqueField = 21;
			
			// aapt resource value: 1
			public const int EditTextValidated_ValidationExpression = 1;
			
			// aapt resource value: 2
			public const int EditTextValidated_ValidationParameter1 = 2;
			
			// aapt resource value: 3
			public const int EditTextValidated_ValidationParameter2 = 3;
			
			// aapt resource value: 4
			public const int EditTextValidated_ValidationParameter3 = 4;
			
			// aapt resource value: 0
			public const int EditTextValidated_ValidationType = 0;


As you can see in the example every value above 9 has a Resource id of it's value + 6
Comment 2 André Ingar Sørensen 2012-07-25 07:15:43 UTC
Yes,
I guess that there is some hex<->dec issue here since 10 hex = 16 dec.
Comment 3 Atsushi Eno 2012-07-26 03:02:52 UTC
Thanks for the report. This is fixed in our code base. Hopefully it will get in time to be included in 4.2.5 release.