Skip to content

Commit d09cb50

Browse files
committed
Add code documentation to all types and methods (excluded tests)
1 parent 5858521 commit d09cb50

9 files changed

Lines changed: 86 additions & 13 deletions

File tree

src/UnityContainerAttributeRegistration/Adapter/AppDomainAdapter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55

66
namespace UnityContainerAttributeRegistration.Adapter
77
{
8+
/// <inheritdoc cref="IAppDomainAdapter"/>
89
internal class AppDomainAdapter : IAppDomainAdapter
910
{
11+
/// <inheritdoc cref="IAppDomainAdapter.GetAssemblies"/>
1012
public IList<Assembly> GetAssemblies()
1113
{
1214
return AppDomain.CurrentDomain.GetAssemblies();

src/UnityContainerAttributeRegistration/Adapter/IAppDomainAdapter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
namespace UnityContainerAttributeRegistration.Adapter
66
{
77
/// <summary>
8-
/// Wrapper to provide <see cref="IList{Assembly}"/> instead of using <see cref="System.AppDomain"/>
8+
/// Wrapper to provide <see cref="IList{Assembly}"/> instead of using <see cref="System.AppDomain"/>.
99
/// </summary>
1010
public interface IAppDomainAdapter
1111
{
1212
/// <summary>
13-
/// Provice <see cref="Assembly"/>s of an AppDomain
13+
/// Provide <see cref="Assembly"/>s of an AppDomain.
1414
/// </summary>
15-
/// <returns><see cref="Assembly"/>s which are used to populate </returns>
15+
/// <returns><see cref="Assembly"/>s which are used to populate.</returns>
1616
public IList<Assembly> GetAssemblies();
1717
}
1818
}

src/UnityContainerAttributeRegistration/Attribute/RegisterTypeAttribute.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ namespace UnityContainerAttributeRegistration.Attribute
1111
[AttributeUsage(AttributeTargets.Class)]
1212
public class RegisterTypeAttribute : System.Attribute
1313
{
14+
/// <summary>
15+
/// Candidate class for registration to <see cref="Unity"/>.
16+
/// </summary>
1417
/// <param name="from"><see cref="Type"/> that will be requested.</param>
1518
/// <param name="lifetimeManager">The <see cref="Unity.Lifetime.ITypeLifetimeManager"/> that controls the lifetime of the returned instance.</param>
1619
public RegisterTypeAttribute([CanBeNull] Type from = null,
@@ -20,9 +23,16 @@ public RegisterTypeAttribute([CanBeNull] Type from = null,
2023
LifetimeManager = lifetimeManager;
2124
}
2225

26+
/// <summary>
27+
/// <see cref="Type"/> that will be requested.
28+
/// </summary>
2329
[CanBeNull]
2430
internal Type From { get; }
2531

32+
/// <summary>
33+
/// The <see cref="LifetimeManager"/> that controls the lifetime
34+
/// of the returned instance.
35+
/// </summary>
2636
[CanBeNull]
2737
internal Type LifetimeManager { get; }
2838
}

src/UnityContainerAttributeRegistration/Exention/TypeExtension.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33

44
namespace UnityContainerAttributeRegistration.Exention
55
{
6+
/// <summary>
7+
/// Extensions for <see cref="Type"/>.
8+
/// </summary>
69
internal static class TypeExtension
710
{
11+
/// <summary>
12+
/// Checks if a type is static.
13+
/// </summary>
14+
/// <param name="self"><see cref="Type"/> to be checked.</param>
15+
/// <returns>whether a type is static or not.</returns>
816
public static bool IsStatic(this Type self)
917
{
1018
return self.IsAbstract && self.IsSealed;

src/UnityContainerAttributeRegistration/Populator/IPopulator.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33

44
namespace UnityContainerAttributeRegistration.Populator
55
{
6-
public interface IPopulator
6+
/// <summary>
7+
/// Interface for internal populators.
8+
/// </summary>
9+
internal interface IPopulator
710
{
11+
/// <summary>
12+
/// Populate the passed <paramref name="container"/>.
13+
/// </summary>
14+
/// <param name="container"><see cref="IUnityContainer"/> to populate.</param>
15+
/// <returns>Passed <paramref name="container"/>.</returns>
816
public IUnityContainer Populate(IUnityContainer container);
917
}
1018
}

src/UnityContainerAttributeRegistration/Populator/Populator.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,31 @@
99

1010
namespace UnityContainerAttributeRegistration.Populator
1111
{
12+
/// <summary>
13+
/// <see cref="IPopulator"/> providing some basic functionality for reflection.
14+
/// </summary>
1215
internal abstract class Populator : IPopulator
1316
{
1417
private readonly IAppDomainAdapter appDomain;
1518

16-
public Populator(IAppDomainAdapter appDomain)
19+
/// <summary>
20+
/// ctor
21+
/// </summary>
22+
/// <param name="appDomain">Used <see cref="IAppDomainAdapter"/> for searching for candidates.</param>
23+
protected Populator(IAppDomainAdapter appDomain)
1724
{
1825
this.appDomain = appDomain;
1926
}
2027

28+
/// <inheritdoc cref="IPopulator.Populate"/>
2129
public abstract IUnityContainer Populate(IUnityContainer container);
2230

31+
/// <summary>
32+
/// Find all types using <typeparamref name="TAttribute"/>.
33+
/// </summary>
34+
/// <param name="typeDefined">Using inheritance or not.</param>
35+
/// <typeparam name="TAttribute"><see cref="System.Attribute"/> used by searched <see cref="Type"/>s.</typeparam>
36+
/// <returns>List of all <see cref="Type"/>s in an <see cref="IAppDomainAdapter"/> using <typeparamref name="TAttribute"/>.</returns>
2337
protected IEnumerable<Type> GetTypesWith<TAttribute>(TypeDefined typeDefined) where TAttribute : System.Attribute
2438
{
2539
return appDomain.GetAssemblies()

src/UnityContainerAttributeRegistration/Populator/TypePopulator.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,27 @@
1515

1616
namespace UnityContainerAttributeRegistration.Populator
1717
{
18+
/// <summary>
19+
/// Populator for the <see cref="UnityContainerAttributeRegistration.Attribute.RegisterTypeAttribute"/>.
20+
/// </summary>
1821
internal class TypePopulator : Populator
1922
{
20-
23+
/// <summary>
24+
/// ctor
25+
/// </summary>
26+
/// <param name="appDomain">
27+
/// Used <see cref="IAppDomainAdapter"/> to find all candidates using <see cref="RegisterTypeAttribute"/>
28+
/// </param>
2129
public TypePopulator(IAppDomainAdapter appDomain) : base(appDomain)
2230
{
2331
}
2432

33+
/// <summary>
34+
/// Populate the passed <paramref name="container"/>.
35+
/// </summary>
36+
/// <param name="container"><see cref="IUnityContainer"/> to populate.</param>
37+
/// <returns>Passed <paramref name="container"/>.</returns>
38+
/// <exception cref="InvalidOperationException">Class type must not be static or abstract.</exception>
2539
public override IUnityContainer Populate(IUnityContainer container)
2640
{
2741
IList<Type> typesWithAttribute = GetTypesWith<RegisterTypeAttribute>(TypeDefined.Inherit)
@@ -31,7 +45,7 @@ public override IUnityContainer Populate(IUnityContainer container)
3145
{
3246
if(to.IsStatic() || to.IsAbstract)
3347
{
34-
throw new InvalidOperationException($"Type must not be static or abstract to be used with RegisterTypeAttribute: {to.FullName}");
48+
throw new InvalidOperationException($"Class type must not be static or abstract to be used with RegisterTypeAttribute: {to.FullName}");
3549
}
3650

3751
RegisterTypeAttribute attribute = to.GetCustomAttribute<RegisterTypeAttribute>();
@@ -45,6 +59,13 @@ public override IUnityContainer Populate(IUnityContainer container)
4559
return container;
4660
}
4761

62+
/// <summary>
63+
/// Create an instance for <paramref name="objectType"/>.
64+
/// </summary>
65+
/// <param name="objectType"><see cref="Type"/> used to create an instance.</param>
66+
/// <typeparam name="T"><paramref name="objectType"/> must be type-equal to, inherit or implement <typeparamref name="T"/>.</typeparam>
67+
/// <returns>New instance of <paramref name="objectType"/> as <typeparamref name="T"/>.</returns>
68+
/// <exception cref="InvalidOperationException">Cannot create an instance of <paramref name="objectType" />. Whether <paramref name="objectType"/> is not type-equal, does not inherit or implement <typeparamref name="T"/> or has no default constructor.</exception>
4869
[NotNull]
4970
private T GetInstanceByType<T>([NotNull] Type objectType)
5071
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
namespace UnityContainerAttributeRegistration
22
{
3+
/// <summary>
4+
/// Enum to avoid booleans.
5+
/// </summary>
36
internal enum TypeDefined
47
{
8+
/// <summary>
9+
/// Include inheritance.
10+
/// </summary>
511
Inherit,
12+
/// <summary>
13+
/// Not include inheritance.
14+
/// </summary>
615
NotInherit
716
}
817
}

src/UnityContainerAttributeRegistration/UnityContainerAttributeRegistration.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@
1919
<RepositoryUrl>https://github.com/ManticSic/UnityContainerAttributeRegistration</RepositoryUrl>
2020
<RepositoryType>git</RepositoryType>
2121
</PropertyGroup>
22+
23+
<PropertyGroup>
24+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
25+
<WarningsAsErrors />
26+
<NoWarn />
27+
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
28+
</PropertyGroup>
2229

2330
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
24-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
25-
<WarningsAsErrors />
26-
<NoWarn />
2731
</PropertyGroup>
2832

2933
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
30-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
31-
<WarningsAsErrors />
32-
<NoWarn />
3334
</PropertyGroup>
3435

3536
<ItemGroup>

0 commit comments

Comments
 (0)