Skip to content

[fix-finder] Move hardcoded error strings in RemoveRegisterAttribute.cs and GenerateCompressedAssembliesNativeSourceFiles.cs to Properties.Re [Content truncated due to length] #11469

@github-actions

Description

@github-actions

Problem

Two MSBuild tasks use Log.LogError with hardcoded, non-localized strings and no XA error codes. These should use Properties.Resources entries with proper XA#### codes for consistency and localizability.

Location

  • File 1: src/Xamarin.Android.Build.Tasks/Tasks/RemoveRegisterAttribute.cs
    • Line 34: Log.LogError ($"Unable to load assembly '{mono_android}'")
  • File 2: src/Xamarin.Android.Build.Tasks/Tasks/GenerateCompressedAssembliesNativeSourceFiles.cs
    • Line 76: Log.LogError ($"Assembly {assembly.ItemSpec} does not exist")

Current Code

RemoveRegisterAttribute.cs:34

Log.LogError ($"Unable to load assembly '{mono_android}'");

GenerateCompressedAssembliesNativeSourceFiles.cs:76

Log.LogError ($"Assembly {assembly.ItemSpec} does not exist");

Suggested Fix

  1. Add two new resource strings to src/Xamarin.Android.Build.Tasks/Properties/Resources.resx (and Resources.Designer.cs). Use available error codes XA2024 and XA2025:

    • XA2024: "Unable to load assembly '{0}'."
    • XA2025: "Assembly {0} does not exist."
  2. Replace the hardcoded strings with coded errors:

    // RemoveRegisterAttribute.cs
    Log.LogCodedError ("XA2024", Properties.Resources.XA2024, mono_android);
    
    // GenerateCompressedAssembliesNativeSourceFiles.cs
    Log.LogCodedError ("XA2025", Properties.Resources.XA2025, assembly.ItemSpec);
  3. Create documentation files for the new error codes:

    • Documentation/docs-mobile/messages/xa2024.md
    • Documentation/docs-mobile/messages/xa2025.md

    Follow the existing format (frontmatter with title/description/date/f1_keywords, then sections for Example messages, Issue explanation, and Solution).

  4. Add the new codes to the table of contents in Documentation/docs-mobile/messages/index.md.

Guidelines

  • Follow the existing pattern for LogCodedError calls in the codebase
  • Use Properties.Resources.XA#### for the message format string
  • Only modify the main English Resources.resx file (not localized versions)
  • The Resources.Designer.cs file should be regenerated (or manually updated to match)
  • Check that error codes XA2024 and XA2025 are not already in use before committing — if they are, pick the next available codes

Acceptance Criteria

  • Hardcoded error strings in both files are replaced with Log.LogCodedError using Properties.Resources
  • New entries added to Resources.resx and Resources.Designer.cs
  • Documentation markdown files created for each new error code
  • New codes added to Documentation/docs-mobile/messages/index.md
  • All tests pass
  • No new warnings introduced

Generated by Nightly Fix Finder · ● 17M ·

  • expires on May 31, 2026, 2:34 AM 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