Skip to content

Move hardcoded error string in PrepareAbiItems.cs to Resources.resx - #11574

Merged
jonathanpeppers merged 4 commits into
mainfrom
copilot/fix-finder-move-hardcoded-error-string
Jun 4, 2026
Merged

Move hardcoded error string in PrepareAbiItems.cs to Resources.resx#11574
jonathanpeppers merged 4 commits into
mainfrom
copilot/fix-finder-move-hardcoded-error-string

Conversation

Copilot AI commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

PrepareAbiItems.cs uses Log.LogError with a hardcoded string literal, bypassing the localization pipeline and lacking a proper XA#### error code.

Changes

  • Properties/Resources.resx: Add XA0037 resource string (Unknown mode: {0})
  • Properties/Resources.Designer.cs: Add corresponding generated property
  • Tasks/PrepareAbiItems.cs: Replace Log.LogError with Log.LogCodedError
  • Documentation/docs-mobile/messages/xa0037.md and index.md: Add documentation for the new XA0037 error code
// Before
Log.LogError ($"Unknown mode: {Mode}");

// After
Log.LogCodedError ("XA0037", Properties.Resources.XA0037, Mode);

Uses a dedicated, previously-unused error code XA0037 (the next free code after XA0036 in the XA0xxx range) rather than the generic XA0000. No existing localized coded message matched this internal "unknown mode" error, so a new code and resource string were added.

Copilot AI and others added 2 commits June 4, 2026 02:50
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Add XA0000_PrepareAbiItems_UnknownMode resource string and replace
Log.LogError with Log.LogCodedError using the XA0000 error code.

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix hardcoded error string in PrepareAbiItems.cs Move hardcoded error string in PrepareAbiItems.cs to Resources.resx Jun 4, 2026
Copilot AI requested a review from jonathanpeppers June 4, 2026 02:51
@jonathanpeppers

Copy link
Copy Markdown
Member

@copilot the error code XA0000 is wrong, you should pick an unused code!

also verify there isn't an existing message we could use for this that is already localized and has a code.

Pick an unused error code (XA0037) for the PrepareAbiItems unknown-mode
error rather than reusing the generic XA0000. Add documentation for the
new code.

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>

Copilot AI commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the error code XA0000 is wrong, you should pick an unused code!

also verify there isn't an existing message we could use for this that is already localized and has a code...

Switched to the dedicated unused code XA0037 (next free code after XA0036 in the XA0xxx range; XA0100 is the next existing one). I checked Resources.resx for an existing localized message to reuse and there isn't one that fits — this is an internal "should never happen" error specific to the PrepareAbiItems task's Mode, so no existing coded message matched. Added xa0037.md docs and an index entry as well.

@jonathanpeppers
jonathanpeppers marked this pull request as ready for review June 4, 2026 14:35
Copilot AI review requested due to automatic review settings June 4, 2026 14:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR localizes a previously hardcoded error message in the PrepareAbiItems MSBuild task by introducing a new XA#### coded error (XA0037) backed by Resources.resx, and adds corresponding documentation for the new error code.

Changes:

  • Added localized resource string XA0037 (“Unknown mode: {0}”) and the corresponding generated designer accessor.
  • Updated PrepareAbiItems to log XA0037 via Log.LogCodedError instead of a hardcoded string.
  • Added a new docs page for XA0037 and linked it from the messages index.

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Tasks/PrepareAbiItems.cs Switches from hardcoded Log.LogError to Log.LogCodedError using XA0037.
src/Xamarin.Android.Build.Tasks/Properties/Resources.resx Adds the localized XA0037 message text and placeholder comment.
src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs Adds the generated XA0037 property accessor.
Documentation/docs-mobile/messages/xa0037.md Documents the new XA0037 error code and user guidance.
Documentation/docs-mobile/messages/index.md Adds XA0037 to the error/warning reference index.
build-tools/banned-apis/banned-apis.targets Reformatting/line-ending-only change (unrelated to XA0037 localization).
Files not reviewed (1)
  • src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Language not supported

Comment on lines +1 to +4
<Project>
<PropertyGroup>
<WarningsAsErrors>RS0030</WarningsAsErrors>
</PropertyGroup>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is breaking CI in other places, so I'm inclined to merge this, it's causing weird things!

@jonathanpeppers
jonathanpeppers merged commit 2447b6a into main Jun 4, 2026
3 of 4 checks passed
@jonathanpeppers
jonathanpeppers deleted the copilot/fix-finder-move-hardcoded-error-string branch June 4, 2026 16:10
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants