Skip to content

[fix-finder] Remove unused using directives in Aapt2.cs #12042

Description

@github-actions

Problem

src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs declares 16 using directives, several of which are never referenced anywhere in the file. Removing them reduces clutter and avoids misleading readers about the file's dependencies.

Location

  • File(s): src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs
  • Line(s): 4-19 (the using block)

Current Code

using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Xml;
using System.Xml.Linq;
using System.Text;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Collections.Concurrent;
using Xamarin.Android.Tools;
using ThreadingTasks = System.Threading.Tasks;
using Microsoft.Android.Build.Tasks;

Suggested Fix

Remove the following directives, which are confirmed unused (no type, method, extension method, or alias from them is referenced in the file):

  • using System.Diagnostics; — only appears in a code comment, no type usage
  • using System.Linq; — no LINQ extension methods used
  • using System.Xml; — no System.Xml types used
  • using System.Xml.Linq; — no X* types used
  • using System.Text.RegularExpressions; — the Regex.Match call is on AndroidRunToolTask.AndroidErrorRegex; the result is stored in a var, so no RegularExpressions type is named
  • using ThreadingTasks = System.Threading.Tasks; — the alias is never referenced

Keep all other directives (System, System.IO, System.Threading, System.Text, Microsoft.Build.*, System.Collections.Generic, System.Collections.Concurrent, Xamarin.Android.Tools, Microsoft.Android.Build.Tasks), which are all in use.

Resulting block:

using System;
using System.IO;
using System.Threading;
using System.Text;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
using System.Collections.Generic;
using System.Collections.Concurrent;
using Xamarin.Android.Tools;
using Microsoft.Android.Build.Tasks;

Guidelines

  • Follow dotnet/android formatting conventions (tabs, Mono style)
  • Do not reorder the remaining directives
  • Verify the project still builds after removal

Acceptance Criteria

  • The six unused directives listed above are removed
  • Xamarin.Android.Build.Tasks compiles cleanly
  • All tests pass
  • No new warnings introduced

Fix-finder metadata

  • Script: 06-unused-using-directives
  • Score: 28/30 (actionability: 10, safety: 8, scope: 10)

Generated by Nightly Fix Finder · 73.4 AIC · ⌖ 17.5 AIC · ⊞ 9.3K ·

  • expires on Jul 19, 2026, 2:27 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