Skip to content

[fix-finder] Move hardcoded error strings in JCWGenerator.cs to Properties.Resources with XA error codes #11426

@github-actions

Description

@github-actions

Problem

JCWGenerator.cs has several LogError calls using hardcoded interpolated strings instead of localized resource strings with proper XA#### error codes. This makes error messages non-localizable and inconsistent with the rest of the build task infrastructure.

Location

  • File: src/Xamarin.Android.Build.Tasks/Utilities/JCWGenerator.cs
  • Lines: 110, 191, 196, 271

Current Code

Line 110 — JCW code changed unexpectedly:

log.LogError ($"Generated Java callable wrapper code changed: '{path}' ");

Line 191 — Architecture type mismatch:

logger.LogError ($"Architecture '{state.TargetArch}' has Java types which have no counterparts in template architecture '{templateState.TargetArch}':");

Line 196 — Individual mismatched type (logged in a loop):

logger.LogError ($"  {type}");

Line 271 — Marshal method mismatch:

logger.LogError ($"Architecture '{state.TargetArch}' doesn't match all marshal methods in architecture '{templateState.TargetArch}'. Please see detailed MSBuild logs for more information.");

Suggested Fix

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

    • XA4212: "Generated Java callable wrapper code changed: '{0}'" (for line 110)
    • XA4217: "Architecture '{0}' has Java types which have no counterparts in template architecture '{1}': {2}" (for lines 191+196, combine the type list into one message)
    • XA4227: "Architecture '{0}' doesn't match all marshal methods in architecture '{1}'. Please see detailed MSBuild logs for more information." (for line 271)
  2. Replace the LogError calls with LogCodedError using the resource strings:

    // Line 110
    log.LogCodedError ("XA4212", Properties.Resources.XA4212, path);
    
    // Lines 191-196: collect types, then log once
    typesSet.ExceptWith (templateSet);
    var typesList = string.Join (", ", typesSet);
    logger.LogCodedError ("XA4217", Properties.Resources.XA4217, state.TargetArch, templateState.TargetArch, typesList);
    
    // Line 271
    logger.LogCodedError ("XA4227", Properties.Resources.XA4227, state.TargetArch, templateState.TargetArch);
  3. Create documentation files for the new error codes:

    • Documentation/docs-mobile/messages/xa4212.md
    • Documentation/docs-mobile/messages/xa4217.md
    • Documentation/docs-mobile/messages/xa4227.md

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

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

Guidelines

  • Use LogCodedError instead of LogError with the XA#### code as the first argument
  • Resource string values use {0}, {1}, etc. for format parameters
  • Only modify the English Resources.resx — never modify localized .resx or .lcl files
  • Follow Mono formatting style (tabs, space before parentheses)
  • For the line 196 loop case, consider combining the mismatched types into a single error message rather than logging one error per type

Acceptance Criteria

  • Three new XA4212, XA4217, XA4227 entries added to Properties/Resources.resx and Resources.Designer.cs
  • All four LogError calls in JCWGenerator.cs replaced with LogCodedError using resource strings
  • Documentation 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 for issue #11425 · ● 12.5M ·

  • expires on May 27, 2026, 8:05 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