Skip to content

Commit

Permalink
Fixed up all missing code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jezzsantos committed Oct 1, 2023
1 parent 600ca3a commit 11b2291
Show file tree
Hide file tree
Showing 18 changed files with 103 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/decisions/0045-modularization.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The options are:

- At the start of building a SaaS product, the bounded contexts of the software are largely unknown, but what is known are the use cases being designed for in the early days. Subdomains will naturally evolve from grouping those use cases around specific aggregates/resources, as they are explored and built out.

- > Bounded contexts, at the beginning of a software build, pretty much represent a whole subdomain itself. More sophisticated definitions of bounded contexts be derived far later in the journey, when more about the domain is learned.
- > Bounded contexts, at the beginning of a software build, pretty much represent a whole subdomain itself. More sophisticated definitions of bounded contexts be derived far later in the journey, when more about the domain is learned.
- REST resources are designed to expose a remote HTTP API to remote consumers. It is not the only way to interop with a SaaS product. Service buses, event hubs, queues, IoT, and other infrastructure are also interop mechanisms. REST resources are designed around real-world processes and use cases, so the overlap is close to aggregates and subdomains, but not precisely the same.

Expand Down
3 changes: 3 additions & 0 deletions src/Application.Common/Caller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public static ICallerContext CreateAsServiceClient()
return new ServiceClientAccountCaller();
}

/// <summary>
/// Returns a newly generated ID for the call
/// </summary>
public static string GenerateCallId()
{
return $"{Guid.NewGuid():N}";
Expand Down
6 changes: 6 additions & 0 deletions src/Application.Interfaces/GetOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Application.Interfaces;

/// <summary>
/// Defines options for embedding resources in GET REST API calls
/// </summary>
public class GetOptions
{
public const string EmbedRequestParamDelimiter = ",";
Expand Down Expand Up @@ -50,6 +53,9 @@ public static GetOptions Custom<TResource>(params Expression<Func<TResource, obj
}
}

/// <summary>
/// Defines the options for expanding child resources in REST responses
/// </summary>
public enum ExpandOptions
{
None = 0,
Expand Down
3 changes: 3 additions & 0 deletions src/Application.Interfaces/GetOptionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace Application.Interfaces;

public static class GetOptionsExtensions
{
/// <summary>
/// Converts the <see cref="propertyReferences" /> expressions to names of the properties
/// </summary>
internal static List<string> ReferencesToNames<TResource>(
this Expression<Func<TResource, object?>>[] propertyReferences)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Application.Interfaces/SearchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,18 @@ public Sorting(string by, SortDirection direction = SortDirection.Ascending)

public SortDirection Direction { get; }

/// <summary>
/// Creates a new <see cref="Sorting" /> for the <see cref="field" /> and <see cref="direction" />
/// </summary>
public static Sorting ByField(string field, SortDirection direction = SortDirection.Ascending)
{
return new Sorting(field, direction);
}
}

/// <summary>
/// Defines the sorting direction
/// </summary>
public enum SortDirection
{
Ascending = 0,
Expand Down
30 changes: 30 additions & 0 deletions src/Common/Error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,81 @@ private Error(ErrorCode code, string? message = null)

public ErrorCode Code { get; }

/// <summary>
/// Creates a <see cref="ErrorCode.Validation" /> error
/// </summary>
public static Error Validation(string? message = null)
{
return new Error(ErrorCode.Validation, message);
}

/// <summary>
/// Creates a <see cref="ErrorCode.RuleViolation" /> error
/// </summary>
public static Error RuleViolation(string? message = null)
{
return new Error(ErrorCode.RuleViolation, message);
}

/// <summary>
/// Creates a <see cref="ErrorCode.RoleViolation" /> error
/// </summary>
public static Error RoleViolation(string? message = null)
{
return new Error(ErrorCode.RoleViolation, message);
}

/// <summary>
/// Creates a <see cref="ErrorCode.PreconditionViolation" /> error
/// </summary>
public static Error PreconditionViolation(string? message = null)
{
return new Error(ErrorCode.PreconditionViolation, message);
}

/// <summary>
/// Creates a <see cref="ErrorCode.EntityNotFound" /> error
/// </summary>
public static Error EntityNotFound(string? message = null)
{
return new Error(ErrorCode.EntityNotFound, message);
}

/// <summary>
/// Creates a <see cref="ErrorCode.EntityExists" /> error
/// </summary>
public static Error EntityExists(string? message = null)
{
return new Error(ErrorCode.EntityExists, message);
}

/// <summary>
/// Creates a <see cref="ErrorCode.NotAuthenticated" /> error
/// </summary>
public static Error NotAuthenticated(string? message = null)
{
return new Error(ErrorCode.NotAuthenticated, message);
}

/// <summary>
/// Creates a <see cref="ErrorCode.ForbiddenAccess" /> error
/// </summary>
public static Error ForbiddenAccess(string? message = null)
{
return new Error(ErrorCode.ForbiddenAccess, message);
}

/// <summary>
/// Creates a <see cref="ErrorCode.NotSubscribed" /> error
/// </summary>
public static Error NotSubscribed(string? message = null)
{
return new Error(ErrorCode.NotSubscribed, message);
}

/// <summary>
/// Creates a <see cref="ErrorCode.Unexpected" /> error
/// </summary>
public static Error Unexpected(string? message = null)
{
return new Error(ErrorCode.Unexpected, message);
Expand Down
3 changes: 3 additions & 0 deletions src/Domain.Common/UserRoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public static class UserRoles
#endif
};

/// <summary>
/// Whether the <see cref="role" /> is an assignable role
/// </summary>
public static bool IsUserAssignableRole(string role)
{
return UserAssignableRoles.ContainsIgnoreCase(role);
Expand Down
6 changes: 6 additions & 0 deletions src/Domain.Interfaces/CallerConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ public const string
ExternalWebhookAccountUserId
};

/// <summary>
/// Whether the user is the <see cref="AnonymousUserId" />
/// </summary>
public static bool IsAnonymousUser(string userId)
{
return userId == AnonymousUserId;
}

/// <summary>
/// Whether the user is one of the <see cref="ServiceAccounts" />
/// </summary>
public static bool IsServiceAccount(string userId)
{
return ServiceAccounts.Contains(userId);
Expand Down
3 changes: 3 additions & 0 deletions src/Infrastructure.WebApi.Common/HasGetOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public class HasGetOptions : IHasGetOptions

public string? Embed { get; set; }

/// <summary>
/// Converts the <see cref="resourceProperties" /> to a <see cref="HasGetOptions" />
/// </summary>
public static HasGetOptions Custom<TResource>(params Expression<Func<TResource, object?>>[] resourceProperties)
{
return GetOptions.Custom(resourceProperties)
Expand Down
3 changes: 3 additions & 0 deletions src/Infrastructure.WebApi.Common/JsonDateTimeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ private static void WriteIso8601(Utf8JsonWriter writer, DateTime value)
}
}

/// <summary>
/// Defines the formats for JSON timestamps
/// </summary>
public enum DateFormat
{
UnixTimestamp,
Expand Down
6 changes: 6 additions & 0 deletions src/Infrastructure.WebApi.Common/XmlHttpResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,17 @@ public static async Task SerializeAsync(Stream responseBody, object? value, Type
}
}

/// <summary>
/// Defines the options for the <see cref="System.Xml.Serialization.XmlSerializer" />
/// </summary>
public class XmlSerializerOptions
{
public bool WriteIndented { get; set; }
}

/// <summary>
/// Defines the configurable options for XML serialization
/// </summary>
public class XmlOptions
{
public static readonly XmlSerializerOptions DefaultSerializerOptions = new()
Expand Down
3 changes: 3 additions & 0 deletions src/Infrastructure.WebApi.Interfaces/EmptyResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Infrastructure.WebApi.Interfaces;

/// <summary>
/// Defines an empty response, for use in empty responses
/// </summary>
[UsedImplicitly]
public class EmptyResponse : IWebResponse
{
Expand Down
25 changes: 17 additions & 8 deletions src/Infrastructure.WebApi.Interfaces/HttpError.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
using System.Net;
using Common;

namespace Infrastructure.WebApi.Interfaces;

/// <summary>
/// Defines an error for using in <see cref="Result{TError}" /> return types
/// </summary>
public struct HttpError
{
public HttpError(HttpErrorCode code, string? message)
Expand All @@ -13,14 +19,17 @@ public HttpError(HttpErrorCode code, string? message)
public string? Message { get; }
}

/// <summary>
/// Defines the commonly used HTTP StatusCodes
/// </summary>
public enum HttpErrorCode
{
BadRequest = 400,
Unauthorized = 401,
PaymentRequired = 402,
Forbidden = 403,
NotFound = 404,
MethodNotAllowed = 405,
Conflict = 409,
InternalServerError = 500
BadRequest = HttpStatusCode.BadRequest,
Unauthorized = HttpStatusCode.Unauthorized,
PaymentRequired = HttpStatusCode.PaymentRequired,
Forbidden = HttpStatusCode.Forbidden,
NotFound = HttpStatusCode.NotFound,
MethodNotAllowed = HttpStatusCode.MethodNotAllowed,
Conflict = HttpStatusCode.Conflict,
InternalServerError = HttpStatusCode.InternalServerError
}
3 changes: 3 additions & 0 deletions src/Infrastructure.WebApi.Interfaces/IWebSearchRequest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace Infrastructure.WebApi.Interfaces;

/// <summary>
/// Defines the request of a SEARCH API
/// </summary>
public interface IWebSearchRequest<TResponse> : IWebRequest<TResponse>, IHasSearchOptions
where TResponse : IWebResponse
{
Expand Down
3 changes: 3 additions & 0 deletions src/Infrastructure.WebApi.Interfaces/IWebSearchResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Infrastructure.WebApi.Interfaces;

/// <summary>
/// Defines a response from a SEARCH API
/// </summary>
public interface IWebSearchResponse : IWebResponse
{
SearchResultMetadata? Metadata { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions src/Infrastructure.WebApi.Interfaces/SearchRequest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace Infrastructure.WebApi.Interfaces;

/// <summary>
/// Defines the request of a SEARCH API
/// </summary>
public class SearchRequest<TResponse> : IWebSearchRequest<TResponse>
where TResponse : IWebResponse
{
Expand Down
3 changes: 3 additions & 0 deletions src/Infrastructure.WebApi.Interfaces/SearchResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Infrastructure.WebApi.Interfaces;

/// <summary>
/// Defines a response from a SEARCH API
/// </summary>
public class SearchResponse : IWebSearchResponse
{
public SearchResultMetadata? Metadata { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/Tools.Analyzers.Core/MissingDocsAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ private static bool IsNotPublicOrInternalStaticMethod(MethodDeclarationSyntax me
return false;
}

// ReSharper disable once UnusedMember.Local
private static bool IsPublicOrInternalExtensionMethod(MethodDeclarationSyntax methodDeclarationSyntax)
{
var isNotPublicOrInternal = IsNotPublicOrInternalStaticMethod(methodDeclarationSyntax);
Expand Down

0 comments on commit 11b2291

Please sign in to comment.