Problem
LinkNativeRuntime derives from AsyncTask, where the Log property is marked [Obsolete] because calling it from a background thread can hang Visual Studio. Line 87 calls Log.LogError (...) directly with a non-localized inline English string. This failure is already reported with a proper coded error (XA3007 / XA3008) inside NativeLinker.Link, so the direct Log.LogError call is both unsafe and redundant.
Location
- File(s):
src/Xamarin.Android.Build.Tasks/Tasks/LinkNativeRuntime.cs
- Line(s): 86-88
Current Code
if (!success) {
Log.LogError ($"Failed to link native runtime {outputRuntime}");
}
Suggested Fix
NativeLinker.Link already logs a coded, localized error on every failure path: RunLinker logs XA3007 (Properties.Resources.XA3007) and ExtractDebugSymbols logs XA3008 (Properties.Resources.XA3008). Because a logged error already causes the MSBuild task to fail, the redundant Log.LogError block should simply be removed:
List<ITaskItem> items = OrganizeCommandLineItemsCLR (abi);
linker.Link (
outputRuntime,
items,
GetAbiItems (NativeLinkStartFiles, "_NativeLinkStartFiles", abi),
GetAbiItems (NativeLinkEndFiles, "_NativeLinkEndFiles", abi),
GetAbiItems (NativeSymbolsToExport, "_NativeSymbolsToExport", abi)
);
The local bool success variable becomes unused and should be dropped as part of removing the block. Removing the redundant call eliminates the obsolete Log property usage without losing any diagnostic output, since XA3007/XA3008 are already surfaced to the user.
Guidelines
- Do NOT use the
[Obsolete] Log property on AsyncTask-derived tasks; use the thread-safe helpers (LogCodedError, LogMessage, LogDebugMessage, etc.).
- User-facing error messages must come from
Properties.Resources with a stable XA#### code, never a raw inline English string.
- Follow dotnet/android formatting (tabs, space before
().
Acceptance Criteria
Fix-finder metadata
- Script:
07-asynctask-log-property
- Score:
28/30 (actionability: 10, safety: 8, scope: 10)
Generated by Nightly Fix Finder · 85.5 AIC · ⌖ 17.4 AIC · ⊞ 9.4K · ◷
Problem
LinkNativeRuntimederives fromAsyncTask, where theLogproperty is marked[Obsolete]because calling it from a background thread can hang Visual Studio. Line 87 callsLog.LogError (...)directly with a non-localized inline English string. This failure is already reported with a proper coded error (XA3007/XA3008) insideNativeLinker.Link, so the directLog.LogErrorcall is both unsafe and redundant.Location
src/Xamarin.Android.Build.Tasks/Tasks/LinkNativeRuntime.csCurrent Code
Suggested Fix
NativeLinker.Linkalready logs a coded, localized error on every failure path:RunLinkerlogsXA3007(Properties.Resources.XA3007) andExtractDebugSymbolslogsXA3008(Properties.Resources.XA3008). Because a logged error already causes the MSBuild task to fail, the redundantLog.LogErrorblock should simply be removed:The local
bool successvariable becomes unused and should be dropped as part of removing the block. Removing the redundant call eliminates the obsoleteLogproperty usage without losing any diagnostic output, sinceXA3007/XA3008are already surfaced to the user.Guidelines
[Obsolete]Logproperty onAsyncTask-derived tasks; use the thread-safe helpers (LogCodedError,LogMessage,LogDebugMessage, etc.).Properties.Resourceswith a stableXA####code, never a raw inline English string.().Acceptance Criteria
Log.LogErrorcall inLinkRuntimeis removed.XA3007/XA3008coded errors inNativeLinker).Fix-finder metadata
07-asynctask-log-property28/30(actionability: 10, safety: 8, scope: 10)