Skip to content

[fix-finder] Remove obsolete AndroidToolsPath pragma suppressions in AndroidSdk.cs #11627

@github-actions

Description

@github-actions

Problem

Three internal methods in AndroidSdk.cs use #pragma warning disable CS0618 to suppress obsolete-usage warnings when accessing the AndroidToolsPath property. The property is marked [Obsolete("Use GetCommandLineToolsPaths().")], but these callsites only need the underlying path value (<sdk>/tools), which can be computed directly via Path.Combine(AndroidSdkPath, "tools") — eliminating the need for the pragma suppressions entirely.

Location

  • File: src/Xamarin.AndroidTools/AndroidSdk.cs
  • Lines: 558–560, 581–583, 609–611

Current Code

GetZipAlignPath() (lines 558–560):

#pragma warning disable CS0618 // Type or member is obsolete
			var old = Path.Combine (GetShortPathName (AndroidToolsPath), zipAlign);
#pragma warning restore CS0618

GetApkSignerPath() (lines 581–583):

#pragma warning disable CS0618 // Type or member is obsolete
			var old = Path.Combine (GetShortPathName (AndroidToolsPath), apkSigner);
#pragma warning restore CS0618

GetFallbackApkAnalyzerPath() (lines 609–611):

#pragma warning disable CS0618 // Type or member is obsolete
			var apkanalyzerPath = Path.Combine (AndroidSdk.AndroidToolsPath, "bin", apkanalyzer);
#pragma warning restore CS0618

Suggested Fix

Replace each usage of the obsolete AndroidToolsPath property with direct path construction using Path.Combine (AndroidSdkPath, "tools"). The AndroidToolsPath property is set to exactly Path.Combine (AndroidSdkPath, "tools") in Refresh() (line 69), so this is a semantically identical substitution.

GetZipAlignPath():

			var old = Path.Combine (GetShortPathName (Path.Combine (AndroidSdkPath, "tools")), zipAlign);

GetApkSignerPath():

			var old = Path.Combine (GetShortPathName (Path.Combine (AndroidSdkPath, "tools")), apkSigner);

GetFallbackApkAnalyzerPath():

			var apkanalyzerPath = Path.Combine (AndroidSdkPath, "tools", "bin", apkanalyzer);

Guidelines

  • The project targets netstandard2.0 with LangVersion 12 — all APIs used above (Path.Combine with 3–4 args) are available on netstandard2.0
  • Do not modify the [Obsolete] declarations themselves or the Refresh() method pragma block (lines 58–96) — those serve different purposes
  • Do not remove or change the fallback logic (the File.Exists checks) — only change how the path string is obtained
  • Follow Mono formatting style: space before (, tabs for indentation

Acceptance Criteria

  • All three #pragma warning disable/restore CS0618 pairs around AndroidToolsPath usage (lines 558–560, 581–583, 609–611) are removed
  • Each callsite uses Path.Combine (AndroidSdkPath, "tools") instead of AndroidToolsPath
  • No other changes to the file
  • All tests pass
  • No new warnings introduced

Fix-finder metadata

  • Script: 02-obsolete-api-usage
  • Score: 27/30 (actionability: 9, safety: 9, scope: 9)

Generated by Nightly Fix Finder · ● 18.6M ·

  • expires on Jun 18, 2026, 2:35 AM 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