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
-
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)
-
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);
-
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).
-
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
Generated by Nightly Fix Finder for issue #11425 · ● 12.5M · ◷
Problem
JCWGenerator.cshas severalLogErrorcalls using hardcoded interpolated strings instead of localized resource strings with properXA####error codes. This makes error messages non-localizable and inconsistent with the rest of the build task infrastructure.Location
src/Xamarin.Android.Build.Tasks/Utilities/JCWGenerator.csCurrent Code
Line 110 — JCW code changed unexpectedly:
Line 191 — Architecture type mismatch:
Line 196 — Individual mismatched type (logged in a loop):
Line 271 — Marshal method mismatch:
Suggested Fix
Add three new resource strings to
src/Xamarin.Android.Build.Tasks/Properties/Resources.resx(andResources.Designer.cs) using available error codes:"Generated Java callable wrapper code changed: '{0}'"(for line 110)"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)"Architecture '{0}' doesn't match all marshal methods in architecture '{1}'. Please see detailed MSBuild logs for more information."(for line 271)Replace the
LogErrorcalls withLogCodedErrorusing the resource strings:Create documentation files for the new error codes:
Documentation/docs-mobile/messages/xa4212.mdDocumentation/docs-mobile/messages/xa4217.mdDocumentation/docs-mobile/messages/xa4227.mdFollow the existing format (frontmatter with title/description/date/f1_keywords, then sections: Example messages, Issue explanation, Solution).
Add the new codes to the table of contents in
Documentation/docs-mobile/messages/index.md.Guidelines
LogCodedErrorinstead ofLogErrorwith theXA####code as the first argument{0},{1}, etc. for format parametersResources.resx— never modify localized.resxor.lclfilesAcceptance Criteria
XA4212,XA4217,XA4227entries added toProperties/Resources.resxandResources.Designer.csLogErrorcalls inJCWGenerator.csreplaced withLogCodedErrorusing resource stringsDocumentation/docs-mobile/messages/index.md