Skip to content

[fix-finder] NativeLinker.cs: LogFailure drops format arguments and lacks error code #11376

@github-actions

Description

@github-actions

Problem

In NativeLinker.ExtractDebugSymbols, the LogFailure local function calls log.LogError with a format string that has no placeholders, so the library filename and command output are silently dropped. Users see only "Failed to extract debug info" with zero context. Additionally, the message lacks an XA#### error code and is hardcoded instead of using Properties.Resources. Two inline TODO comments explicitly ask for this to be fixed.

Location

  • File: src/Xamarin.Android.Build.Tasks/Utilities/NativeLinker.cs
  • Lines: 402–408

Current Code

void LogFailure ()
{
    var sb = MonoAndroidHelper.MergeStdoutAndStderrMessages (stdoutLines, stderrLines);
    // TODO: consider making it a warning
    // TODO: make it a coded message
    log.LogError ("Failed to extract debug info", Path.GetFileName (sourceLib), sb.ToString ());
}

Bug: TaskLoggingHelper.LogError(string message, params object[] messageArgs) calls string.Format(message, messageArgs). Since the message "Failed to extract debug info" contains no {0} or {1} placeholders, the library filename and the command output are silently ignored.

Suggested Fix

  1. Add a new resource string XA3008 to src/Xamarin.Android.Build.Tasks/Properties/Resources.resx:
<data name="XA3008" xml:space="preserve">
    <value>Failed to extract debug info from '{0}': {1}</value>
    <comment>'{0}' is the native shared library filename. '{1}' is the full output of the failed command, starting and ending with a newline.</comment>
</data>
  1. Update Resources.Designer.cs to add the corresponding property (run the designer generator, or add manually following the pattern of XA3007).

  2. Replace the LogFailure method with:

void LogFailure ()
{
    var sb = MonoAndroidHelper.MergeStdoutAndStderrMessages (stdoutLines, stderrLines);
    log.LogCodedWarning ("XA3008", Properties.Resources.XA3008, Path.GetFileName (sourceLib), sb.ToString ());
}

Note: This changes from LogError to LogCodedWarning as the first TODO suggests. Debug symbol extraction failing is non-fatal — by this point the shared library has already been linked successfully (line 267). Failing the entire build over debug symbols is unnecessarily harsh.

  1. Remove both TODO comments (lines 405–406) since they will be resolved.

  2. Create documentation at Documentation/docs-mobile/messages/xa3008.md following the existing format:

---
title: .NET for Android warning XA3008
description: XA3008 warning code
ms.date: 05/15/2026
f1_keywords:
  - "XA3008"
---

# .NET for Android warning XA3008

## Issue

This warning is emitted when the build system fails to extract debug symbols from
a native shared library using `objcopy`. The shared library itself was linked
successfully, but separate debug symbol files (`.dbg.so`) could not be created.

## Solution

This warning is non-fatal and the app will still work correctly. Debug symbols
are used for native crash diagnostics. If you need native debug symbols, check
that the NDK `objcopy` tool is installed and functioning correctly.

## Example messages

> warning XA3008: Failed to extract debug info from 'libmonodroid.so':
> objcopy: error: ...
```

6. **Add the new code to the index** in `Documentation/docs-mobile/messages/index.md` after the XA3007 line:

```
+ XA3008: Failed to extract debug info from '{library}'

Guidelines

  • Only modify the English Resources.resx file (not localized .resx files)
  • Use LogCodedWarning (not LogCodedError) since debug symbol extraction is non-fatal
  • Follow the existing pattern of XA3007 for the resource entry format and Designer.cs property
  • Use tabs for indentation (Mono code style)

Acceptance Criteria

  • New XA3008 resource string added to Resources.resx and Resources.Designer.cs
  • LogFailure uses log.LogCodedWarning("XA3008", ...) with proper format placeholders
  • Both TODO comments removed
  • Library filename and command output are included in the warning message
  • Documentation file created at Documentation/docs-mobile/messages/xa3008.md
  • XA3008 added to Documentation/docs-mobile/messages/index.md
  • All tests pass
  • No new warnings introduced

Generated by Nightly Fix Finder for issue #11352 · ● 4M ·

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