Skip to content

[fix-finder] Add XML documentation to generic FragmentManager helper methods #11962

Description

@github-actions

Problem

The three public generic helper methods in src/Mono.Android/Android.App/FragmentManager.csFindFragmentById<T>, FindFragmentByTag<T>, and GetFragment<T> — are shipped public API on Mono.Android.dll but have no /// XML documentation. As a result they surface with no IntelliSense summaries or [learn.microsoft.com]((learn.microsoft.com/redacted) content for consumers. Documenting all three fully documents this hand-written file.

Location

  • File(s): src/Mono.Android/Android.App/FragmentManager.cs
  • Line(s): 8–33 (the FindFragmentById<T>, FindFragmentByTag<T>, and GetFragment<T> methods)

Current Code

using Android.OS;
using Android.Runtime;
using System.Diagnostics.CodeAnalysis;

#if ANDROID_11
namespace Android.App {
	public partial class FragmentManager {
		public T? FindFragmentById<
				[DynamicallyAccessedMembers (Constructors)]
				T
		> (int id)
			where T : Fragment
		{
			return FindFragmentById (id).JavaCast<T> ();
		}

		public T? FindFragmentByTag<
				[DynamicallyAccessedMembers (Constructors)]
				T
		> (string tag)
			where T : Fragment
		{
			return FindFragmentByTag (tag).JavaCast<T> ();
		}

		public T? GetFragment<
				[DynamicallyAccessedMembers (Constructors)]
				T
		> (Bundle bundle, string key)
			where T : Fragment
		{
			return GetFragment (bundle, key).JavaCast<T> ();
		}
	}
}
#endif

Suggested Fix

Add a complete /// doc comment (<summary>, <typeparam>, <param>, <returns>) above each of the three methods. These are strongly-typed .NET-for-Android overloads that call the corresponding non-generic base method and cast the result to T via JavaCast<T> (returning null when nothing matches). Do not change any code — this is a comment-only change.

using Android.OS;
using Android.Runtime;
using System.Diagnostics.CodeAnalysis;

#if ANDROID_11
namespace Android.App {
	public partial class FragmentManager {
		/// <summary>
		/// Finds a <see cref="Fragment"/> that was identified by the given id, either when
		/// inflated from XML or as the container id when added in a transaction, and returns
		/// it cast to <typeparamref name="T"/>.
		/// </summary>
		/// <typeparam name="T">The <see cref="Fragment"/> type to cast the result to.</typeparam>
		/// <param name="id">The resource id or container id used to identify the fragment.</param>
		/// <returns>
		/// The matching fragment cast to <typeparamref name="T"/>, or <see langword="null"/>
		/// if no matching fragment exists.
		/// </returns>
		public T? FindFragmentById<
				[DynamicallyAccessedMembers (Constructors)]
				T
		> (int id)
			where T : Fragment
		{
			return FindFragmentById (id).JavaCast<T> ();
		}

		/// <summary>
		/// Finds a <see cref="Fragment"/> that was identified by the given tag, either when
		/// inflated from XML or as supplied when added in a transaction, and returns it cast
		/// to <typeparamref name="T"/>.
		/// </summary>
		/// <typeparam name="T">The <see cref="Fragment"/> type to cast the result to.</typeparam>
		/// <param name="tag">The tag used to identify the fragment.</param>
		/// <returns>
		/// The matching fragment cast to <typeparamref name="T"/>, or <see langword="null"/>
		/// if no matching fragment exists.
		/// </returns>
		public T? FindFragmentByTag<
				[DynamicallyAccessedMembers (Constructors)]
				T
		> (string tag)
			where T : Fragment
		{
			return FindFragmentByTag (tag).JavaCast<T> ();
		}

		/// <summary>
		/// Retrieves the current <see cref="Fragment"/> instance for a reference previously
		/// placed in <paramref name="bundle"/> with <c>PutFragment</c>, and returns it cast
		/// to <typeparamref name="T"/>.
		/// </summary>
		/// <typeparam name="T">The <see cref="Fragment"/> type to cast the result to.</typeparam>
		/// <param name="bundle">The bundle in which the fragment reference was stored.</param>
		/// <param name="key">The name of the entry in the bundle.</param>
		/// <returns>
		/// The referenced fragment cast to <typeparamref name="T"/>, or <see langword="null"/>
		/// if no fragment is associated with the given key.
		/// </returns>
		public T? GetFragment<
				[DynamicallyAccessedMembers (Constructors)]
				T
		> (Bundle bundle, string key)
			where T : Fragment
		{
			return GetFragment (bundle, key).JavaCast<T> ();
		}
	}
}
#endif

Guidelines

  • Follow dotnet/android formatting: tabs for indentation, a space before (.
  • This is a comment-only change — do not modify method signatures, bodies, the #if ANDROID_11 guard, the [DynamicallyAccessedMembers (Constructors)] annotations, or any other code.
  • Keep the wording aligned with the Android platform reference for [FragmentManager]((developer.android.com/redacted)
  • Every <typeparam>/<param> must be documented so no CS1573 is introduced (these are suppressed in Mono.Android.csproj, but keep the docs complete anyway).

Acceptance Criteria

  • All three generic methods (FindFragmentById<T>, FindFragmentByTag<T>, GetFragment<T>) have complete /// XML docs with <summary>, <typeparam>, <param> for every parameter, and <returns>.
  • No code changes other than the added doc comments.
  • Mono.Android builds successfully.
  • All tests pass
  • No new warnings introduced

Fix-finder metadata

  • Script: 04-missing-xml-docs
  • Score: 30/30 (actionability: 10, safety: 10, scope: 10)

Generated by Nightly Fix Finder · 169.8 AIC · ⌖ 30.7 AIC · ⊞ 9.3K ·

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