Problem
GenerateJniRemappingNativeCode.cs has three Log.LogError() calls using hardcoded interpolated strings with no XA#### error codes. Per repo convention, all build errors should use Log.LogCodedError() with messages defined in Properties.Resources.resx so they are localizable and have stable, documentable error codes.
Location
- File:
src/Xamarin.Android.Build.Tasks/Tasks/GenerateJniRemappingNativeCode.cs
- Lines: 73, 134, 155
Current Code
Line 73:
Log.LogError ($"Input file `{remappingXmlFilePath}` does not start with `<replacements/>`");
Line 134:
Log.LogError ($"Attribute 'target-method-instance-to-static' in element '{reader.LocalName}' value '{targetIsStatic}' cannot be parsed as boolean; {remappingXmlFilePath} line {GetCurrentLineNumber ()}");
Line 155:
Log.LogError ($"Attribute '{attributeName}' missing from element '{reader.LocalName}'; {remappingXmlFilePath} line {GetCurrentLineNumber ()}");
Suggested Fix
-
Add three new error messages to src/Xamarin.Android.Build.Tasks/Properties/Resources.resx using the next available XA1045–XA1047 codes (verify these are unused first — XA1042/XA1043 exist in Resources.Designer.cs from localized files but are not in the main Resources.resx and are unused in code). If XA1045–XA1047 are already taken by the time this is implemented, pick the next available codes in the XA1xxx range.
-
Add format-string entries to Resources.resx:
<data name="XA1045" xml:space="preserve">
<value>Input file `{0}` does not start with `<replacements/>`.</value>
<comment>{0} - file path</comment>
</data>
<data name="XA1046" xml:space="preserve">
<value>Attribute '{0}' in element '{1}' has value '{2}' that cannot be parsed as boolean; {3} line {4}.</value>
<comment>{0} - attribute name; {1} - element name; {2} - attribute value; {3} - file path; {4} - line number</comment>
</data>
<data name="XA1047" xml:space="preserve">
<value>Required attribute '{0}' missing from element '{1}'; {2} line {3}.</value>
<comment>{0} - attribute name; {1} - element name; {2} - file path; {3} - line number</comment>
</data>
-
Regenerate Resources.Designer.cs (run ResGen or build the project).
-
Replace the Log.LogError calls with Log.LogCodedError:
Line 73 → :
Log.LogCodedError ("XA1045", Properties.Resources.XA1045, remappingXmlFilePath);
Line 134 → :
Log.LogCodedError ("XA1046", Properties.Resources.XA1046, "target-method-instance-to-static", reader.LocalName, targetIsStatic, remappingXmlFilePath, GetCurrentLineNumber ());
Line 155 → :
Log.LogCodedError ("XA1047", Properties.Resources.XA1047, attributeName, reader.LocalName, remappingXmlFilePath, GetCurrentLineNumber ());
Guidelines
- Only modify the main English
Resources.resx file — never modify *.lcl files in Localize/loc/ or non-English *.resx files (they are auto-generated)
- Follow the existing pattern:
Log.LogCodedError ("XA####", Properties.Resources.XA####, args...) — see examples in AndroidApkSigner.cs, Aapt2.cs
- The
Resources.Designer.cs file should be regenerated by building the project (do not hand-edit it)
- Use
string.Format-style placeholders ({0}, {1}, ...) in Resources.resx values
- Each
<data> element should have a <comment> describing the format arguments
- C# formatting: use tabs, space before
(, Mono style
Acceptance Criteria
Generated by Nightly Fix Finder for issue #11352 · ● 4M · ◷
Problem
GenerateJniRemappingNativeCode.cshas threeLog.LogError()calls using hardcoded interpolated strings with noXA####error codes. Per repo convention, all build errors should useLog.LogCodedError()with messages defined inProperties.Resources.resxso they are localizable and have stable, documentable error codes.Location
src/Xamarin.Android.Build.Tasks/Tasks/GenerateJniRemappingNativeCode.csCurrent Code
Line 73:
Line 134:
Line 155:
Suggested Fix
Add three new error messages to
src/Xamarin.Android.Build.Tasks/Properties/Resources.resxusing the next availableXA1045–XA1047codes (verify these are unused first —XA1042/XA1043exist inResources.Designer.csfrom localized files but are not in the mainResources.resxand are unused in code). IfXA1045–XA1047are already taken by the time this is implemented, pick the next available codes in theXA1xxxrange.Add format-string entries to
Resources.resx:Regenerate
Resources.Designer.cs(runResGenor build the project).Replace the
Log.LogErrorcalls withLog.LogCodedError:Line 73 → :
Line 134 → :
Line 155 → :
Guidelines
Resources.resxfile — never modify*.lclfiles inLocalize/loc/or non-English*.resxfiles (they are auto-generated)Log.LogCodedError ("XA####", Properties.Resources.XA####, args...)— see examples inAndroidApkSigner.cs,Aapt2.csResources.Designer.csfile should be regenerated by building the project (do not hand-edit it)string.Format-style placeholders ({0},{1}, ...) inResources.resxvalues<data>element should have a<comment>describing the format arguments(, Mono styleAcceptance Criteria
XA1045–XA1047entries added tosrc/Xamarin.Android.Build.Tasks/Properties/Resources.resx(or next available codes)Log.LogErrorcalls inGenerateJniRemappingNativeCode.csreplaced withLog.LogCodedErrorusing the new codes andProperties.ResourcesmessagesResources.Designer.csis regenerated and included in the PR.resxor.lclfiles are modified