Skip to content

Commit 8c14bc0

Browse files
refactor: 🔨 optimize logging and add XML documentation
- Remove excessive debug logging across all components for better performance - Add minimal XML documentation comments for all public APIs (resolves CS1591 warnings) - Streamline logging to essential information only (errors, warnings, key operations) - Improve code clarity by reducing log noise while maintaining debuggability - Clean up debugging guide to focus on practical troubleshooting
1 parent 7824da9 commit 8c14bc0

46 files changed

Lines changed: 398 additions & 1995 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎JsonApiToolkit/Attributes/AllowedIncludesAttribute.cs‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,24 @@
99
namespace JsonApiToolkit.Attributes;
1010

1111
/// <summary>
12-
/// Action filter attribute that restricts which relationships can be included in JSON:API responses.
12+
/// Restricts which relationships can be included in responses.
13+
/// Returns 403 Forbidden if requested includes don't match the whitelist.
1314
/// </summary>
14-
/// <remarks>
15-
/// This attribute validates the 'include' query parameter against a whitelist of allowed includes.
16-
/// If a client requests an include that is not in the whitelist, a 403 Forbidden error is returned.
17-
/// </remarks>
1815
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
1916
public class AllowedIncludesAttribute : ActionFilterAttribute
2017
{
2118
private readonly string[] _allowedIncludes;
2219
private readonly Dictionary<string, IncludePattern> _compiledPatterns;
2320

2421
/// <summary>
25-
/// Gets the list of allowed include patterns.
22+
/// Gets the allowed include patterns.
2623
/// </summary>
2724
public string[] AllowedIncludes => _allowedIncludes;
2825

2926
/// <summary>
30-
/// Initializes a new instance of the <see cref="AllowedIncludesAttribute"/> class.
27+
/// Initializes a new instance with the specified allowed include patterns.
3128
/// </summary>
32-
/// <param name="allowedIncludes">The list of allowed include patterns. If empty, no includes are allowed.</param>
29+
/// <param name="allowedIncludes">Include patterns to allow (supports wildcards).</param>
3330
public AllowedIncludesAttribute(params string[] allowedIncludes)
3431
{
3532
_allowedIncludes = allowedIncludes ?? [];
@@ -44,9 +41,8 @@ public AllowedIncludesAttribute(params string[] allowedIncludes)
4441
}
4542

4643
/// <summary>
47-
/// Validates the include query parameters before the action executes.
44+
/// Validates requested includes against the allowed patterns.
4845
/// </summary>
49-
/// <param name="context">The action executing context.</param>
5046
public override void OnActionExecuting(ActionExecutingContext context)
5147
{
5248
// Skip validation for JsonApiCreated methods

‎JsonApiToolkit/Controllers/JsonApiController.cs‎

Lines changed: 49 additions & 221 deletions
Large diffs are not rendered by default.

‎JsonApiToolkit/Extensions/QueryableExtensions.cs‎

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,13 @@
66
namespace JsonApiToolkit.Extensions;
77

88
/// <summary>
9-
/// Provides extension methods for applying JSON:API query parameters to IQueryable data sources.
9+
/// Extension methods for applying JSON:API query parameters to IQueryable.
1010
/// </summary>
11-
/// <remarks>
12-
/// Consolidates the application of filtering, sorting, and pagination in a single convenient extension method.
13-
/// </remarks>
1411
public static class QueryableExtensions
1512
{
1613
/// <summary>
17-
/// Applies all JSON:API query parameters to an IQueryable data source in the correct order.
14+
/// Applies all JSON:API parameters: filters → sort (defaults to Id) → pagination.
1815
/// </summary>
19-
/// <typeparam name="T">The entity type of the queryable</typeparam>
20-
/// <param name="query">The source IQueryable to apply parameters to</param>
21-
/// <param name="parameters">The complete set of JSON:API query parameters</param>
22-
/// <returns>A new IQueryable with all query parameters applied</returns>
23-
/// <remarks>
24-
/// Applies parameters in the following order:
25-
/// <list type="number">
26-
/// <item>
27-
/// <description>Filtering - narrows the result set based on field conditions</description>
28-
/// </item>
29-
/// <item>
30-
/// <description>Sorting - orders the results (defaults to Id ascending if not specified)</description>
31-
/// </item>
32-
/// <item>
33-
/// <description>Pagination - limits the number of results and supports paging</description>
34-
/// </item>
35-
/// </list>
36-
/// This is the recommended method for applying all JSON:API query parameters in a single operation.
37-
/// </remarks>
3816
public static IQueryable<T> ApplyJsonApiParameters<T>(
3917
this IQueryable<T> query,
4018
QueryParameters parameters
@@ -58,12 +36,8 @@ QueryParameters parameters
5836
}
5937

6038
/// <summary>
61-
/// Dynamically applies EF Core Include() calls for each include path (dot notation supported).
39+
/// Applies EF Core Include() for each path (supports dot notation).
6240
/// </summary>
63-
/// <typeparam name="T">The entity type.</typeparam>
64-
/// <param name="query">The source queryable.</param>
65-
/// <param name="includePaths">A list of include paths (e.g. "todo", "todo.category").</param>
66-
/// <returns>The queryable with all includes applied.</returns>
6741
public static IQueryable<T> ApplyIncludes<T>(
6842
this IQueryable<T> query,
6943
List<string>? includePaths
@@ -81,17 +55,9 @@ public static IQueryable<T> ApplyIncludes<T>(
8155
}
8256

8357
/// <summary>
84-
/// Dynamically applies EF Core Include() calls using AsSingleQuery() to prevent split query issues.
58+
/// Applies EF Core Include() using AsSingleQuery() to prevent split query issues with pagination.
59+
/// Forces single query with JOINs instead of separate queries.
8560
/// </summary>
86-
/// <typeparam name="T">The entity type.</typeparam>
87-
/// <param name="query">The source queryable.</param>
88-
/// <param name="includePaths">A list of include paths (e.g. "todo", "todo.category").</param>
89-
/// <returns>The queryable with all includes applied using single query mode.</returns>
90-
/// <remarks>
91-
/// Use this method when pagination is present to avoid EF Core split query optimization issues
92-
/// that can cause includes to load data for wrong entities or no entities at all.
93-
/// Forces EF Core to use a single query with JOINs instead of separate queries.
94-
/// </remarks>
9561
public static IQueryable<T> ApplyIncludesSingleQuery<T>(
9662
this IQueryable<T> query,
9763
List<string>? includePaths
@@ -101,7 +67,6 @@ public static IQueryable<T> ApplyIncludesSingleQuery<T>(
10167
if (includePaths == null || includePaths.Count == 0)
10268
return query;
10369

104-
// Force single query to prevent EF Core split query issues with pagination
10570
query = query.AsSingleQuery();
10671

10772
foreach (string path in includePaths)

0 commit comments

Comments
 (0)