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:
-
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.
-
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.
-
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.
-
TryGetRequiredMetadata — Same validation as GetRequiredMetadata but uses the try-pattern: returns bool and outputs the value via out parameter. Logs error XA4234 on failure.
-
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
Generated by Nightly Fix Finder for issue #11352 · ● 4.2M · ◷
Problem
The
ITaskItemExtensionsclass 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.,GetRequiredMetadatavsTryGetRequiredMetadata).Location
src/Xamarin.Android.Build.Tasks/Utilities/ITaskItemExtensions.csCurrent Code
All 5 public methods lack
<summary>,<param>,<returns>, and<remarks>documentation:Suggested Fix
Add XML documentation comments to each public method. Key behaviors to document:
ToXElements— Converts a collection ofITaskItems intoXElements, usingItemSpecas the element value and known metadata as attributes. Only non-empty metadata values are included.GetMetadataOrDefault<T>— Retrieves metadata by name and converts it to typeTusingConvert.ChangeType. ReturnsdefaultValueif the metadata is null or whitespace. Note the[NotNullIfNotNull]contract.GetRequiredMetadata— Retrieves metadata by name, logging errorXA4234and returningnullif the metadata is missing or whitespace. TheitemNameparameter is used in the error message to identify which MSBuild item group the item belongs to.TryGetRequiredMetadata— Same validation asGetRequiredMetadatabut uses the try-pattern: returnsbooland outputs the value viaoutparameter. Logs errorXA4234on failure.HasMetadata— Checks whether the item has metadata with the given name using case-insensitive comparison.Guidelines
(, Mono style<summary>,<param>, and<returns>tags<remarks>only when the method has non-obvious behavior (e.g., the error logging inGetRequiredMetadata)Acceptance Criteria
ITaskItemExtensionshave XML documentation commentsGetRequiredMetadataandTryGetRequiredMetadatadocs mention theXA4234error logging