Skip to content

Commit

Permalink
Merge pull request #1520 from nunit/inheritdoc
Browse files Browse the repository at this point in the history
Update IExtensionManager doc comments
  • Loading branch information
CharliePoole authored Dec 1, 2024
2 parents 01294c2 + 61113ff commit 97e76f9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 41 deletions.
48 changes: 17 additions & 31 deletions src/NUnitEngine/nunit.engine.core/Services/ExtensionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,19 @@ internal ExtensionManager(IFileSystem fileSystem, IDirectoryFinder directoryFind

#region IExtensionManager Implementation

/// <summary>
/// Gets an enumeration of all ExtensionPoints in the engine.
/// </summary>
/// <inheritdoc/>
public IEnumerable<IExtensionPoint> ExtensionPoints
{
get { return _extensionPoints.ToArray(); }
}

/// <summary>
/// Gets an enumeration of all installed Extensions.
/// </summary>
/// <inheritdoc/>
public IEnumerable<IExtensionNode> Extensions
{
get { return _extensions.ToArray(); }
}

/// <summary>
/// Find the extension points in a loaded assembly.
/// </summary>
/// <inheritdoc/>
public virtual void FindExtensionPoints(params Assembly[] targetAssemblies)
{
foreach (var assembly in targetAssemblies)
Expand Down Expand Up @@ -121,11 +115,7 @@ public virtual void FindExtensionPoints(params Assembly[] targetAssemblies)
}
}

/// <summary>
/// Find and install extensions starting from a given base directory,
/// and using the contained '.addins' files to direct the search.
/// </summary>
/// <param name="startDir"></param>
/// <inheritdoc/>
public void FindExtensions(string startDir)
{
// Create the list of possible extension assemblies,
Expand All @@ -137,11 +127,7 @@ public void FindExtensions(string startDir)
FindExtensionsInAssembly(candidate);
}

/// <summary>
/// Find and install standard extensions for a host assembly using
/// a built-in algorithm that searches in certain known locations.
/// </summary>
/// <param name="hostAssembly">An assembly that supports extensions.</param>
/// <inheritdoc/>
public void FindStandardExtensions(Assembly hostAssembly)
{
bool isChocolateyPackage = System.IO.File.Exists(Path.Combine(hostAssembly.Location, "VERIFICATION.txt"));
Expand All @@ -155,14 +141,20 @@ public void FindStandardExtensions(Assembly hostAssembly)
FindExtensionsInAssembly(candidate);
}

/// <summary>
/// Get an ExtensionPoint based on its unique identifying path.
/// </summary>
/// <inheritdoc/>
public IExtensionPoint GetExtensionPoint(string path)
{
return _pathIndex.ContainsKey(path) ? _pathIndex[path] : null;
}

/// <inheritdoc/>
public IEnumerable<T> GetExtensions<T>()
{
foreach (var node in GetExtensionNodes<T>())
yield return (T)((ExtensionNode)node).ExtensionObject; // HACK
}

/// <inheritdoc/>
public IEnumerable<IExtensionNode> GetExtensionNodes(string path)
{
var ep = GetExtensionPoint(path);
Expand All @@ -171,6 +163,7 @@ public IEnumerable<IExtensionNode> GetExtensionNodes(string path)
yield return node;
}

/// <inheritdoc/>
public IExtensionNode GetExtensionNode(string path)
{
// TODO: Remove need for the cast
Expand All @@ -179,6 +172,7 @@ public IExtensionNode GetExtensionNode(string path)
return ep != null && ep.Extensions.Count > 0 ? ep.Extensions[0] : null;
}

/// <inheritdoc/>
public IEnumerable<ExtensionNode> GetExtensionNodes<T>(bool includeDisabled = false)
{
var ep = GetExtensionPoint(typeof(T));
Expand All @@ -188,15 +182,7 @@ public IEnumerable<ExtensionNode> GetExtensionNodes<T>(bool includeDisabled = fa
yield return node;
}

public IEnumerable<T> GetExtensions<T>()
{
foreach (var node in GetExtensionNodes<T>())
yield return (T)((ExtensionNode)node).ExtensionObject; // HACK
}

/// <summary>
/// Enable or disable an extension
/// </summary>
/// <inheritdoc/>
public void EnableExtension(string typeName, bool enabled)
{
foreach (var node in _extensions)
Expand Down
40 changes: 30 additions & 10 deletions src/NUnitEngine/nunit.engine.core/Services/IExtensionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ namespace NUnit.Engine.Services
{
public interface IExtensionManager : IDisposable
{
/// <summary>
/// Gets an enumeration of all ExtensionPoints in the engine.
/// </summary>
IEnumerable<IExtensionPoint> ExtensionPoints { get; }

/// <summary>
/// Gets an enumeration of all installed Extensions.
/// </summary>
IEnumerable<IExtensionNode> Extensions { get; }

/// <summary>
/// Find the extension points in a loaded assembly.
/// </summary>
void FindExtensionPoints(params Assembly[] targetAssemblies);

/// <summary>
Expand All @@ -29,27 +39,37 @@ public interface IExtensionManager : IDisposable
/// <param name="hostAssembly">An assembly that supports NUnit extensions.</param>
void FindStandardExtensions(Assembly hostAssembly);

/// <summary>
/// Get an ExtensionPoint based on its unique identifying path.
/// </summary>
IExtensionPoint GetExtensionPoint(string path);

/// <summary>
/// Get extension objects for all nodes of a given type
/// </summary>
IEnumerable<T> GetExtensions<T>();

/// <summary>
/// Get all ExtensionNodes for a give path
/// </summary>
IEnumerable<IExtensionNode> GetExtensionNodes(string path);

/// <summary>
/// Get the first or only ExtensionNode for a given ExtensionPoint
/// </summary>
/// <param name="path">The identifying path for an ExtensionPoint</param>
/// <returns></returns>
IExtensionNode GetExtensionNode(string path);

/// <summary>
/// Returns all extension nodes for a given Type.
/// Get all extension nodes of a given Type.
/// </summary>
/// <typeparam name="T">The Type of the node</typeparam>
/// <param name="includeDisabled">If true, disabled nodes are included</param>
/// <returns>An enumeration of ExtensionNodes</returns>
/// <remarks>
/// Unlike other methods, this method returns an actual ExtensionNode rather
/// than an IExtensionNode. It is required in order for classes that support
/// extensions to create the actual extension object.
///
/// </remarks>
// NOTE:
IEnumerable<ExtensionNode> GetExtensionNodes<T>(bool includeDisabled = false);

/// <summary>
/// Enable or disable an extension
/// </summary>
void EnableExtension(string typeName, bool enabled);
}

Expand Down

0 comments on commit 97e76f9

Please sign in to comment.