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
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 · ◷
Problem
GetMicrosoftNuGetPackagesMapderives fromAsyncTask, so itsRunTaskAsync ()body executes on a background thread. Line 49 logs through the[Obsolete]Logproperty (Log.LogMessage). CallingLog.*from a background thread can hang Visual Studio, which is exactly whyAsyncTaskexposes thread-safe logging helpers that should be used instead.Location
src/Xamarin.Android.Build.Tasks/Tasks/GetMicrosoftNuGetPackagesMap.csCurrent Code
Suggested Fix
Call the inherited thread-safe
LogMessagehelper directly by dropping theLog.prefix:This is the same helper already used throughout the project. For example,
src/Xamarin.Android.Build.Tasks/Tasks/Aot.cscallsLogMessage ("[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'snetstandard2.0target.Guidelines
AsyncTask-derived tasks, use the thread-safe helpers (LogMessage(),LogDebugMessage(),LogCodedWarning(),LogCodedError()) instead ofLog.*, because theLogproperty is marked[Obsolete]onAsyncTask.(.Log.*call in the file; no other lines need to change.Acceptance Criteria
Log.LogMessageon line 49 is replaced with the inheritedLogMessagehelper.Log.*calls remain inGetMicrosoftNuGetPackagesMap.cs.Fix-finder metadata
07-asynctask-log-property30/30(actionability:10, safety:10, scope:10)