Skip to content

[fix-finder] Move hardcoded error string in PrepareAbiItems.cs to Resources.resx #11573

Description

@github-actions

Problem

PrepareAbiItems.cs line 64 uses Log.LogError with a hardcoded string literal instead of using a coded error from Properties.Resources. This means the error message is not localizable and lacks a proper XA#### error code for documentation and troubleshooting.

Location

  • File(s): src/Xamarin.Android.Build.Tasks/Tasks/PrepareAbiItems.cs
  • Line(s): 64

Current Code

Log.LogError ($"Unknown mode: {Mode}");

Suggested Fix

  1. Add a new resource string to the English src/Xamarin.Android.Build.Tasks/Properties/Resources.resx:
<data name="XA0000_PrepareAbiItems_UnknownMode" xml:space="preserve">
  <value>Unknown mode: {0}</value>
</data>
  1. Regenerate Resources.Designer.cs (or add the corresponding property manually).

  2. Replace the hardcoded Log.LogError call in PrepareAbiItems.cs line 64 with:

Log.LogCodedError ("XA0000", Properties.Resources.XA0000_PrepareAbiItems_UnknownMode, Mode);

This reuses the existing generic XA0000 error code, so no new documentation file is needed.

Important: The owning project (Xamarin.Android.Build.Tasks.csproj) targets netstandard2.0. The suggested fix only uses Log.LogCodedError and Properties.Resources, both of which are available on netstandard2.0. Do not use any APIs that require net6.0+ (e.g. ArgumentNullException.ThrowIfNull).

Guidelines

  • Only modify the English Resources.resx — never modify non-English *.resx or *.lcl files
  • Follow Mono formatting style (tabs, space before ()
  • Use string.Format-style {0} placeholders in resource strings

Acceptance Criteria

  • Log.LogError on line 64 of PrepareAbiItems.cs is replaced with Log.LogCodedError using a resource string
  • The new resource string is added to src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
  • Resources.Designer.cs is updated with the new property
  • All tests pass
  • No new warnings introduced

Fix-finder metadata

  • Script: 08-string-literal-error-messages
  • Score: 25/30 (actionability: 9, safety: 8, scope: 8)

Generated by Nightly Fix Finder · ● 10.4M ·

  • expires on Jun 11, 2026, 2:29 AM UTC

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions