Skip to content

[fix-finder] Add XML documentation to ITaskItemExtensions public methods #11355

@github-actions

Description

@github-actions

Problem

The ITaskItemExtensions class contains 5 public extension methods used across 18+ MSBuild task files, but none of them have XML documentation comments. This makes it harder for contributors to understand the behavior differences between similar methods (e.g., GetRequiredMetadata vs TryGetRequiredMetadata).

Location

  • File: src/Xamarin.Android.Build.Tasks/Utilities/ITaskItemExtensions.cs

Current Code

All 5 public methods lack <summary>, <param>, <returns>, and <remarks> documentation:

public static IEnumerable<XElement> ToXElements (this ICollection<ITaskItem> items, string itemName, string[] knownMetadata)

public static T? GetMetadataOrDefault<T> (this ITaskItem item, string name, T? defaultValue)

public static string? GetRequiredMetadata (this ITaskItem item, string itemName, string name, TaskLoggingHelper log)

public static bool TryGetRequiredMetadata (this ITaskItem item, string itemName, string name, TaskLoggingHelper log, out string value)

public static bool HasMetadata (this ITaskItem item, string name)

Suggested Fix

Add XML documentation comments to each public method. Key behaviors to document:

  1. ToXElements — Converts a collection of ITaskItems into XElements, using ItemSpec as the element value and known metadata as attributes. Only non-empty metadata values are included.

  2. GetMetadataOrDefault<T> — Retrieves metadata by name and converts it to type T using Convert.ChangeType. Returns defaultValue if the metadata is null or whitespace. Note the [NotNullIfNotNull] contract.

  3. GetRequiredMetadata — Retrieves metadata by name, logging error XA4234 and returning null if the metadata is missing or whitespace. The itemName parameter is used in the error message to identify which MSBuild item group the item belongs to.

  4. TryGetRequiredMetadata — Same validation as GetRequiredMetadata but uses the try-pattern: returns bool and outputs the value via out parameter. Logs error XA4234 on failure.

  5. HasMetadata — Checks whether the item has metadata with the given name using case-insensitive comparison.

Guidelines

  • Follow the repo's C# formatting: tabs, space before (, Mono style
  • Use <summary>, <param>, and <returns> tags
  • Add <remarks> only when the method has non-obvious behavior (e.g., the error logging in GetRequiredMetadata)
  • Keep documentation concise and focused on what each method does, its parameters, and return values

Acceptance Criteria

  • All 5 public methods in ITaskItemExtensions have XML documentation comments
  • Documentation accurately describes behavior, parameters, and return values
  • GetRequiredMetadata and TryGetRequiredMetadata docs mention the XA4234 error logging
  • No code logic changes — documentation only
  • All tests pass
  • No new warnings introduced

Generated by Nightly Fix Finder for issue #11352 · ● 4.2M ·

  • expires on May 21, 2026, 9:33 PM UTC

Metadata

Metadata

Assignees

No one assigned

    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