Skip to content

[fix-finder] Use thread-safe LogMessage() helper instead of obsolete Log property in GetMicrosoftNuGetPackagesMap #11947

Description

@github-actions

Problem

GetMicrosoftNuGetPackagesMap derives from AsyncTask, so its RunTaskAsync () body executes on a background thread. Line 49 logs through the [Obsolete] Log property (Log.LogMessage). Calling Log.* from a background thread can hang Visual Studio, which is exactly why AsyncTask exposes thread-safe logging helpers that should be used instead.

Location

  • File(s): src/Xamarin.Android.Build.Tasks/Tasks/GetMicrosoftNuGetPackagesMap.cs
  • Line(s): 49

Current Code

} catch (Exception ex) {
	Log.LogMessage ("Could not download microsoft-packages.json: {0}", ex.Message);
}

Suggested Fix

Call the inherited thread-safe LogMessage helper directly by dropping the Log. prefix:

} catch (Exception ex) {
	LogMessage ("Could not download microsoft-packages.json: {0}", ex.Message);
}

This is the same helper already used throughout the project. For example, src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs calls LogMessage ("[aot-compiler stdout] {0}", e.Data); with the identical (string format, params object[] args) signature, so no new API is introduced and it compiles cleanly against the project's netstandard2.0 target.

Guidelines

  • In AsyncTask-derived tasks, use the thread-safe helpers (LogMessage(), LogDebugMessage(), LogCodedWarning(), LogCodedError()) instead of Log.*, because the Log property is marked [Obsolete] on AsyncTask.
  • C# formatting: use tabs and a space before (.
  • This is the only direct Log.* call in the file; no other lines need to change.

Acceptance Criteria

  • Log.LogMessage on line 49 is replaced with the inherited LogMessage helper.
  • No other Log.* calls remain in GetMicrosoftNuGetPackagesMap.cs.
  • All tests pass.
  • No new warnings introduced.

Fix-finder metadata

  • Script: 07-asynctask-log-property
  • Score: 30/30 (actionability: 10, safety: 10, scope: 10)

Generated by Nightly Fix Finder · 128.7 AIC · ⌖ 30.4 AIC · ⊞ 9.3K ·

  • expires on Jul 9, 2026, 2:33 AM UTC

Metadata

Metadata

Type

No type

Fields

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