Skip to content

Commit 982a768

Browse files
committed
Merge branch 'master' of https://github.com/unitycontainer/container into v5.x
2 parents 16d50fe + 96e20f2 commit 982a768

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/Extensions/DiagnosticExtensions.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,52 @@ namespace Unity
55
{
66
public static class DiagnosticExtensions
77
{
8+
/// <summary>
9+
/// Enables diagnostic validations on the container built in DEBUG mode.
10+
/// </summary>
11+
/// <remarks>
12+
/// <para>This extension method adds <see cref="Diagnostic"/> extension to the
13+
/// container and enables extended validation for all container's operations.</para>
14+
/// <para>This method will only work if the calling code is built with DEBUG
15+
/// symbol defined. In other word in you building in Debug mode. Condigional
16+
/// methods can not return any values, so fluent notation can not be used with
17+
/// this method.</para>
18+
/// </remarks>
19+
/// <example>
20+
/// This is how you could call this method to enable diagnostics:
21+
/// <code>
22+
/// var container = new UnityContainer();
23+
/// container.EnableDebugDiagnostic();
24+
/// ...
25+
/// </code>
26+
/// </example>
27+
/// <param name="container">The Unity Container instance</param>
828
[Conditional("DEBUG")]
29+
public static void EnableDebugDiagnostic(this UnityContainer container)
30+
{
31+
if (null == container) throw new ArgumentNullException(nameof(container));
32+
33+
container.AddExtension(new Diagnostic());
34+
}
35+
36+
/// <summary>
37+
/// Enables diagnostic validations on the container.
38+
/// </summary>
39+
/// <remarks>
40+
/// <para>This extension method adds <see cref="Diagnostic"/> extension to the
41+
/// container and enables extended validation for all container's operations.</para>
42+
/// <para>This method works regardles of build mode. In other word, it will
43+
/// always enable validation. This method could be used with fluent notation.</para>
44+
/// </remarks>
45+
/// <example>
46+
/// This is how you could call this method to enable diagnostics:
47+
/// <code>
48+
/// var container = new UnityContainer().EnableDebugDiagnostic();
49+
/// ...
50+
/// </code>
51+
/// </example>
52+
/// <param name="container">The Unity Container instance</param>
53+
/// <returns></returns>
954
public static UnityContainer EnableDiagnostic(this UnityContainer container)
1055
{
1156
if (null == container) throw new ArgumentNullException(nameof(container));

0 commit comments

Comments
 (0)