docs: added performance warnings to find methods

This commit is contained in:
Syntriax 2025-05-25 13:56:59 +03:00
parent 2df41e1881
commit 8f8558a262
2 changed files with 14 additions and 2 deletions

View File

@ -8,7 +8,7 @@ public static class UniverseExtensions
=> universe.InstantiateUniverseObject<UniverseObject>(args);
/// <summary>
/// Searches through all<see cref="IUniverseObject"/>s to find the specified instance of the type.
/// Searches through all <see cref="IUniverseObject"/>s to find the specified instance of the type.
/// </summary>
/// <typeparam name="T">Type to be searched through the <see cref="IUniverse"/>.</typeparam>
/// <returns>The specified type if found; otherwise, throws <see cref="UniverseObjectNotFoundException"/>.</returns>
@ -16,7 +16,7 @@ public static class UniverseExtensions
=> universe.GetUniverseObject<T>() ?? throw new UniverseObjectNotFoundException($"{universe.GetType().FullName}({universe.Id}) does not contain any {nameof(IUniverseObject)} object of type {typeof(T).FullName}");
/// <summary>
/// Searches through all<see cref="IBehaviours"/>s to find the specified instance of the type.
/// Searches through all <see cref="IBehaviours"/>s to find the specified instance of the type.
/// </summary>
/// <typeparam name="T">Type to be searched through the <see cref="IUniverse"/>.</typeparam>
/// <returns>The specified type if found; otherwise, throws <see cref="BehaviourNotFoundException"/>.</returns>
@ -26,6 +26,9 @@ public static class UniverseExtensions
/// <summary>
/// Searches through all <see cref="IUniverseObject"/>s and <see cref="IBehaviours"/>s to find the specified instance of the type.
/// </summary>
/// <remarks>
/// WARNING: This is more expensive compared to <see cref="GetRequiredUniverseObject{T}(IUniverse)"/> or <see cref="FindRequiredBehaviour{T}(IUniverse)"/> as it combines the two. If you know whether the type is either a type that gets implemented on an <see cref="IBehaviour"/> or <see cref="IUniverseObject"/> use the method appropriate for it for performance.
/// </remarks>
/// <typeparam name="T">Type to be searched through the <see cref="IUniverse"/>.</typeparam>
/// <returns>The specified type if found; otherwise, throws <see cref="NotFoundException"/>.</returns>
public static T FindRequired<T>(this IUniverse universe) where T : class

View File

@ -199,6 +199,9 @@ public static class UniverseObjectExtensions
/// <summary>
/// Finds an object of the specified type in the provided <see cref="IUniverseObject"/>s and their <see cref="IBehaviour"/>s.
/// </summary>
/// <remarks>
/// WARNING: This is more expensive compared to <see cref="GetUniverseObject{T}(IEnumerable{IUniverseObject})"/> or <see cref="FindBehaviour{T}(IEnumerable{IUniverseObject})"/> as it combines the two. If you know whether the type is either a type that gets implemented on an <see cref="IBehaviour"/> or <see cref="IUniverseObject"/> use the method appropriate for it for performance.
/// </remarks>
/// <typeparam name="T">The type of <see cref="IBehaviour"/> to find.</typeparam>
/// <returns>The first found instance of the specified type; otherwise, null.</returns>
public static T? Find<T>(this IEnumerable<IUniverseObject> universeObjects) where T : class
@ -215,6 +218,9 @@ public static class UniverseObjectExtensions
/// <summary>
/// Tries to find an object of the specified type in the provided <see cref="IUniverseObject"/>s and their <see cref="IBehaviour"/>s.
/// </summary>
/// <remarks>
/// WARNING: This is more expensive compared to <see cref="TryGetUniverseObject{T}(IEnumerable{IUniverseObject}, out T?)"/> or <see cref="TryFindBehaviour{T}(IEnumerable{IUniverseObject}, out T?)"/> as it combines the two. If you know whether the type is either a type that gets implemented on an <see cref="IBehaviour"/> or <see cref="IUniverseObject"/> use the method appropriate for it for performance.
/// </remarks>
/// <typeparam name="T">The type of <see cref="IBehaviour"/> to find.</typeparam>
/// <param name="behaviour">When this method returns, contains the <see cref="IUniverseObject"/> of the specified type, if found; otherwise, null.</param>
/// <returns><see cref="true"/> if an object of the specified type was found in the provided <see cref="IUniverseObject"/>s; otherwise, <see cref="false"/>.</returns>
@ -227,6 +233,9 @@ public static class UniverseObjectExtensions
/// <summary>
/// Searches through the provided <see cref="IUniverseObject"/>s and their <see cref="IBehaviour"/>s to collect a list of the specified type.
/// </summary>
/// <remarks>
/// WARNING: This is more expensive compared to <see cref="GetUniverseObjects{T}(IEnumerable{IUniverseObject}, IList{T})"/> or <see cref="FindBehaviours{T}(IEnumerable{IUniverseObject}, IList{T})"/> as it combines the two. If you know whether the type is either a type that gets implemented on an <see cref="IBehaviour"/> or <see cref="IUniverseObject"/> use the method appropriate for it for performance.
/// </remarks>
/// <typeparam name="T">The type of <see cref="IBehaviour"/> to get.</typeparam>
/// <param name="instances">List of objects found wit the specified type.</param>
/// <param name="universeObjects">The <see cref="IUniverseObject"/>s to search.</param>