Skip to content

[fix-finder] Move hardcoded error strings in GenerateJniRemappingNativeCode to Properties.Resources with XA error codes #11365

@github-actions

Description

@github-actions

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

  1. Add three new error messages to src/Xamarin.Android.Build.Tasks/Properties/Resources.resx using the next available XA1045XA1047 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 XA1045XA1047 are already taken by the time this is implemented, pick the next available codes in the XA1xxx range.

  2. 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>
  1. Regenerate Resources.Designer.cs (run ResGen or build the project).

  2. 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

  • Three new XA1045XA1047 entries added to src/Xamarin.Android.Build.Tasks/Properties/Resources.resx (or next available codes)
  • All three Log.LogError calls in GenerateJniRemappingNativeCode.cs replaced with Log.LogCodedError using the new codes and Properties.Resources messages
  • Resources.Designer.cs is regenerated and included in the PR
  • The project builds without errors or new warnings
  • No non-English .resx or .lcl files are modified

Generated by Nightly Fix Finder for issue #11352 · ● 4M ·

  • expires on May 21, 2026, 10:25 PM UTC

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions