Skip to content

Commit a070f40

Browse files
committed
Adding documentation comments to EF extensions and utilities projects.
1 parent e475e22 commit a070f40

File tree

7 files changed

+190
-5
lines changed

7 files changed

+190
-5
lines changed

src/DDDToolkit.EntityFramework.Extensions/DDDToolkit.EntityFramework.Extensions.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1717
</PropertyGroup>
1818

19+
<PropertyGroup>
20+
<DocumentationFile>C:\Users\paulj\source\repos\DDDToolkit\src\DDDToolkit.EntityFramework.Extensions\DDDToolkit.EntityFramework.Extensions.xml</DocumentationFile>
21+
</PropertyGroup>
22+
1923
<ItemGroup>
20-
<None Include="..\..\LICENSE" Pack="true" PackagePath=""/>
24+
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
2125
</ItemGroup>
2226

2327
<ItemGroup>

src/DDDToolkit.EntityFramework.Extensions/DDDToolkit.EntityFramework.Extensions.xml

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/DDDToolkit.EntityFramework.Extensions/IncludeExtensions.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
using DDDToolkit.Core;
22
using DDDToolkit.Core.Interfaces;
33
using Microsoft.EntityFrameworkCore;
4-
using Microsoft.EntityFrameworkCore.Query;
54
using System;
65
using System.Collections.Generic;
76
using System.Linq;
87
using System.Reflection;
98

109
namespace DDDToolkit.EntityFramework.Extensions
1110
{
11+
/// <summary>
12+
/// Extensions to include properties in Entity Framework.
13+
/// </summary>
1214
public static class IncludeExtensions
1315
{
16+
/// <summary>
17+
/// <para>
18+
/// Include every navigation property on the entity.
19+
/// Navigate through every property that can be included, includes it,
20+
/// then recursively repeats the operation for all children until the
21+
/// whole property tree is included.
22+
/// </para>
23+
/// <para>
24+
/// Note: do not use this if there are any cyclical references. Due to
25+
/// the recursive nature, this will cause a stack overflow.
26+
/// </para>
27+
/// </summary>
28+
/// <typeparam name="T">The type of entity.</typeparam>
29+
/// <param name="source">The Queryable to operate on.</param>
30+
/// <returns>A new Queryable with all child properties included in the Entity Framework query.</returns>
31+
/// <exception cref="StackOverflowException">Thrown when there is a cyclic reference on the
32+
/// entity, or any child entity.</exception>
1433
public static IQueryable<T> IncludeEverything<T>(this IQueryable<T> source) where T : class
1534
{
1635
var type = source.GetType();

src/DDDToolkit.EntityFramework.Extensions/QueryableExtensions.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
using DDDToolkit.Utilities.Extensions;
22
using Microsoft.EntityFrameworkCore;
3-
using System;
43
using System.Collections.Generic;
54
using System.Linq;
6-
using System.Text;
75
using System.Threading;
86
using System.Threading.Tasks;
97

108
namespace DDDToolkit.EntityFramework.Extensions
119
{
10+
/// <summary>
11+
/// Extensions on Queryables
12+
/// </summary>
1213
public static class QueryableExtensions
1314
{
15+
/// <summary>
16+
/// Converts a Queryable to a <see cref="IReadOnlyCollection{T}"/>.
17+
/// </summary>
18+
/// <typeparam name="T">The type of entity for the IQueryable.</typeparam>
19+
/// <param name="queryable">The IQueryable to convert.</param>
20+
/// <param name="cancellationToken">A cancellation token to use for the operation.</param>
21+
/// <returns>A Task returning a <see cref="IReadOnlyCollection{T}"/> from the IQueryable.</returns>
1422
public static Task<IReadOnlyCollection<T>> ToReadOnlyCollectionAsync<T>(this IQueryable<T> queryable, CancellationToken cancellationToken = default(CancellationToken))
1523
=> queryable.ToListAsync(cancellationToken).ToReadOnlyCollection();
1624
}

src/DDDToolkit.Utilities/DDDToolkit.Utilities.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1717
</PropertyGroup>
1818

19+
<PropertyGroup>
20+
<DocumentationFile>C:\Users\paulj\source\repos\DDDToolkit\src\DDDToolkit.Utilities\DDDToolkit.Utilities.xml</DocumentationFile>
21+
</PropertyGroup>
22+
1923
<ItemGroup>
20-
<None Include="..\..\LICENSE" Pack="true" PackagePath=""/>
24+
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
2125
</ItemGroup>
2226

2327
</Project>

src/DDDToolkit.Utilities/DDDToolkit.Utilities.xml

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/DDDToolkit.Utilities/Extensions/TaskExtensions.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,55 @@
44

55
namespace DDDToolkit.Utilities.Extensions
66
{
7+
/// <summary>
8+
/// Extensions to Tasks.
9+
/// </summary>
710
public static class TaskExtensions
811
{
12+
/// <summary>
13+
/// Coverts a Task of a <see cref="List{T}"/> to a Task of a <see cref="IReadOnlyCollection{T}"/>.
14+
/// </summary>
15+
/// <typeparam name="T">The type of entity in the List.</typeparam>
16+
/// <param name="task">The tssk to convert.</param>
17+
/// <returns>The Task of a List converted to a Task of a IReadOnlyCollection.</returns>
918
public static Task<IReadOnlyCollection<T>> ToReadOnlyCollection<T>(this Task<List<T>> task)
1019
=> task.ContinueWith(t => t.Result.AsReadOnly()).ConvertTask().ToTaskOf<IReadOnlyCollection<T>>();
1120

21+
/// <summary>
22+
/// Begin converting a Task of a type to a Task of a compatiable type.
23+
/// </summary>
24+
/// <typeparam name="T">The current type of the Task.</typeparam>
25+
/// <param name="task">The Task to convert.</param>
26+
/// <returns>A <see cref="TaskConverter{T}"/> which enables selecting a Task to convert to.</returns>
1227
public static TaskConverter<T> ConvertTask<T>(this Task<T> task)
1328
{
1429
return new TaskConverter<T>(task);
1530
}
1631

32+
/// <summary>
33+
/// A class that can convert a Task of one type, to a Task of a compatible type.
34+
/// </summary>
35+
/// <typeparam name="T">The current type of the Task.</typeparam>
1736
public class TaskConverter<T>
1837
{
1938
private Task<T> _task;
2039

40+
/// <summary>
41+
/// Initialises a Task converter that will be able to convert
42+
/// the supplied Task to a Task of a compatible type.
43+
/// </summary>
44+
/// <param name="task">The Task to convert.</param>
2145
public TaskConverter(Task<T> task)
2246
{
2347
_task = task;
2448
}
2549

50+
/// <summary>
51+
/// Creates and returns a new Task of the type specified from the
52+
/// Task that was supplied to the class.
53+
/// </summary>
54+
/// <typeparam name="TResult">The type to convert the Task to.</typeparam>
55+
/// <returns>A new Task of the type supplied.</returns>
2656
public Task<TResult> ToTaskOf<TResult>()
2757
where TResult : class
2858
{
@@ -33,6 +63,17 @@ public Task<TResult> ToTaskOf<TResult>()
3363
return _task.ContinueWith(t => t.Result as TResult);
3464
}
3565

66+
/// <summary>
67+
/// <para>
68+
/// Creates and returns a new Task of the type specified from the
69+
/// Task that was supplied to the class.
70+
/// </para>
71+
/// <para>
72+
/// An alias for <see cref="ToTaskOf{TResult}"/>
73+
/// </para>
74+
/// </summary>
75+
/// <typeparam name="TResult">The type to convert the Task to.</typeparam>
76+
/// <returns>A new Task of the type supplied.</returns>
3677
public Task<TResult> To<TResult>()
3778
where TResult : class
3879
=> ToTaskOf<TResult>();

0 commit comments

Comments
 (0)