-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started adding documentation for classes and methods as well as creat…
…ing new validation and custom exceptions
- Loading branch information
Showing
33 changed files
with
2,848 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
```markdown | ||
# Documentation Process for AiDotNet | ||
|
||
This document outlines the process for systematically documenting all classes in the AiDotNet project. | ||
|
||
## Documentation Workflow | ||
|
||
1. **Prioritize Classes**: | ||
- Start with core classes that are most frequently used | ||
- Then move to supporting classes | ||
- Finally document utility and helper classes | ||
|
||
2. **Documentation Checklist for Each Class**: | ||
- [ ] Class-level documentation | ||
- [ ] Property documentation | ||
- [ ] Constructor documentation | ||
- [ ] Public method documentation | ||
- [ ] Protected/internal method documentation if relevant for extenders | ||
- [ ] Examples of usage in complex cases | ||
|
||
3. **Review Process**: | ||
- Self-review: Check for clarity, completeness, and accuracy | ||
- Peer review: Have another team member review the documentation | ||
- Beginner review (if possible): Have someone unfamiliar with the code read the documentation to verify clarity | ||
|
||
## Documentation Tools | ||
|
||
- Use Visual Studio's built-in XML documentation features | ||
- Consider using GhostDoc extension for Visual Studio to generate initial documentation templates | ||
- Use DocFX to generate documentation websites from XML comments | ||
|
||
## Tracking Progress | ||
|
||
Create a documentation tracking spreadsheet with the following columns: | ||
- Class name | ||
- Namespace | ||
- Documentation status (Not Started, In Progress, Complete) | ||
- Reviewer | ||
- Review status | ||
- Priority (High, Medium, Low) | ||
|
||
## Documentation Automation | ||
|
||
Consider creating a script to: | ||
1. Identify classes without proper documentation | ||
2. Generate basic documentation templates | ||
3. Report on documentation coverage | ||
|
||
Example PowerShell script to find classes with missing documentation: | ||
|
||
```powershell | ||
Get-ChildItem -Path "C:\Users\yolan\source\repos\AiDotNet\src" -Filter "*.cs" -Recurse | | ||
ForEach-Object { | ||
$content = Get-Content $_.FullName -Raw | ||
if ($content -match "public class" -and $content -notmatch "/// <summary>") { | ||
Write-Output "Missing documentation: $($_.FullName)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace AiDotNet.Exceptions; | ||
|
||
/// <summary> | ||
/// Base exception for all AiDotNet-specific exceptions. | ||
/// </summary> | ||
public class AiDotNetException : Exception | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AiDotNetException"/> class. | ||
/// </summary> | ||
public AiDotNetException() : base() { } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AiDotNetException"/> class with a specified error message. | ||
/// </summary> | ||
/// <param name="message">The message that describes the error.</param> | ||
public AiDotNetException(string message) : base(message) { } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AiDotNetException"/> class with a specified error message | ||
/// and a reference to the inner exception that is the cause of this exception. | ||
/// </summary> | ||
/// <param name="message">The message that describes the error.</param> | ||
/// <param name="innerException">The exception that is the cause of the current exception.</param> | ||
public AiDotNetException(string message, Exception innerException) : base(message, innerException) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
namespace AiDotNet.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception thrown when an operation is attempted before a required forward pass has been completed. | ||
/// </summary> | ||
public class ForwardPassRequiredException : AiDotNetException | ||
{ | ||
/// <summary> | ||
/// The name of the component where the exception occurred. | ||
/// </summary> | ||
public string ComponentName { get; } | ||
|
||
/// <summary> | ||
/// The type of the component where the exception occurred. | ||
/// </summary> | ||
public string ComponentType { get; } | ||
|
||
/// <summary> | ||
/// The operation that was attempted. | ||
/// </summary> | ||
public string Operation { get; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ForwardPassRequiredException"/> class for a layer. | ||
/// </summary> | ||
/// <param name="layerName">The name of the layer where the exception occurred.</param> | ||
/// <param name="layerType">The type of the layer where the exception occurred.</param> | ||
public ForwardPassRequiredException(string layerName, string layerType) | ||
: base($"Forward pass must be called before backward pass in layer '{layerName}' of type {layerType}.") | ||
{ | ||
ComponentName = layerName; | ||
ComponentType = layerType; | ||
Operation = "backward pass"; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ForwardPassRequiredException"/> class. | ||
/// </summary> | ||
/// <param name="componentName">The name of the component where the exception occurred.</param> | ||
/// <param name="componentType">The type of the component where the exception occurred.</param> | ||
/// <param name="operation">The operation that was attempted.</param> | ||
public ForwardPassRequiredException(string componentName, string componentType, string operation) | ||
: base($"Forward pass must be called before {operation} in {componentType} '{componentName}'.") | ||
{ | ||
ComponentName = componentName; | ||
ComponentType = componentType; | ||
Operation = operation; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
namespace AiDotNet.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception thrown when input data dimensions are invalid for a specific algorithm or operation. | ||
/// </summary> | ||
public class InvalidInputDimensionException : Exception | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of the InvalidInputDimensionException class. | ||
/// </summary> | ||
public InvalidInputDimensionException() : base() { } | ||
|
||
/// <summary> | ||
/// Creates a new instance of the InvalidInputDimensionException class with a specified error message. | ||
/// </summary> | ||
/// <param name="message">The message that describes the error.</param> | ||
public InvalidInputDimensionException(string message) : base(message) { } | ||
|
||
/// <summary> | ||
/// Creates a new instance of the InvalidInputDimensionException class with a specified error message | ||
/// and a reference to the inner exception that is the cause of this exception. | ||
/// </summary> | ||
/// <param name="message">The message that describes the error.</param> | ||
/// <param name="innerException">The exception that is the cause of the current exception.</param> | ||
public InvalidInputDimensionException(string message, Exception innerException) | ||
: base(message, innerException) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace AiDotNet.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception thrown when a neural network receives an input type that doesn't match its requirements. | ||
/// </summary> | ||
public class InvalidInputTypeException : AiDotNetException | ||
{ | ||
/// <summary> | ||
/// The expected input type for the neural network. | ||
/// </summary> | ||
public InputType ExpectedInputType { get; } | ||
|
||
/// <summary> | ||
/// The actual input type provided. | ||
/// </summary> | ||
public InputType ActualInputType { get; } | ||
|
||
/// <summary> | ||
/// The type of neural network that requires the specific input type. | ||
/// </summary> | ||
public string NetworkType { get; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="InvalidInputTypeException"/> class. | ||
/// </summary> | ||
/// <param name="expectedInputType">The expected input type for the neural network.</param> | ||
/// <param name="actualInputType">The actual input type provided.</param> | ||
/// <param name="networkType">The type of neural network that requires the specific input type.</param> | ||
public InvalidInputTypeException(InputType expectedInputType, InputType actualInputType, string networkType) | ||
: base(FormatMessage(expectedInputType, actualInputType, networkType)) | ||
{ | ||
ExpectedInputType = expectedInputType; | ||
ActualInputType = actualInputType; | ||
NetworkType = networkType; | ||
} | ||
|
||
private static string FormatMessage(InputType expectedInputType, InputType actualInputType, string networkType) | ||
{ | ||
return $"{networkType} requires {expectedInputType} input, but received {actualInputType} input."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
namespace AiDotNet.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception thrown when there's an error during serialization or deserialization of a neural network. | ||
/// </summary> | ||
public class SerializationException : AiDotNetException | ||
{ | ||
/// <summary> | ||
/// The component where the serialization error occurred. | ||
/// </summary> | ||
public string Component { get; } | ||
|
||
/// <summary> | ||
/// The operation being performed when the error was detected (e.g., "Serialize", "Deserialize"). | ||
/// </summary> | ||
public string Operation { get; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SerializationException"/> class. | ||
/// </summary> | ||
/// <param name="message">The error message.</param> | ||
/// <param name="component">The component where the serialization error occurred.</param> | ||
/// <param name="operation">The operation being performed when the error was detected.</param> | ||
public SerializationException(string message, string component, string operation) | ||
: base(FormatMessage(message, component, operation)) | ||
{ | ||
Component = component; | ||
Operation = operation; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SerializationException"/> class with an inner exception. | ||
/// </summary> | ||
/// <param name="message">The error message.</param> | ||
/// <param name="component">The component where the serialization error occurred.</param> | ||
/// <param name="operation">The operation being performed when the error was detected.</param> | ||
/// <param name="innerException">The inner exception that caused this exception.</param> | ||
public SerializationException(string message, string component, string operation, Exception innerException) | ||
: base(FormatMessage(message, component, operation), innerException) | ||
{ | ||
Component = component; | ||
Operation = operation; | ||
} | ||
|
||
private static string FormatMessage(string message, string component, string operation) | ||
{ | ||
return $"Serialization error in {component} during {operation}: {message}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
namespace AiDotNet.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception thrown when a tensor's dimension doesn't match the expected value. | ||
/// </summary> | ||
public class TensorDimensionException : AiDotNetException | ||
{ | ||
/// <summary> | ||
/// The index of the dimension that doesn't match. | ||
/// </summary> | ||
public int DimensionIndex { get; } | ||
|
||
/// <summary> | ||
/// The expected value of the dimension. | ||
/// </summary> | ||
public int ExpectedValue { get; } | ||
|
||
/// <summary> | ||
/// The actual value of the dimension. | ||
/// </summary> | ||
public int ActualValue { get; } | ||
|
||
/// <summary> | ||
/// The component where the dimension mismatch occurred. | ||
/// </summary> | ||
public string Component { get; } | ||
|
||
/// <summary> | ||
/// The operation being performed when the mismatch was detected. | ||
/// </summary> | ||
public string Operation { get; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="TensorDimensionException"/> class. | ||
/// </summary> | ||
/// <param name="dimensionIndex">The index of the dimension that doesn't match.</param> | ||
/// <param name="expectedValue">The expected value of the dimension.</param> | ||
/// <param name="actualValue">The actual value of the dimension.</param> | ||
/// <param name="component">The component where the dimension mismatch occurred.</param> | ||
/// <param name="operation">The operation being performed when the mismatch was detected.</param> | ||
public TensorDimensionException(int dimensionIndex, int expectedValue, int actualValue, string component, string operation) | ||
: base(FormatMessage(dimensionIndex, expectedValue, actualValue, component, operation)) | ||
{ | ||
DimensionIndex = dimensionIndex; | ||
ExpectedValue = expectedValue; | ||
ActualValue = actualValue; | ||
Component = component; | ||
Operation = operation; | ||
} | ||
|
||
private static string FormatMessage(int dimensionIndex, int expectedValue, int actualValue, string component, string operation) | ||
{ | ||
return $"Dimension mismatch in {component} during {operation}: " + | ||
$"Expected dimension {dimensionIndex} to be {expectedValue}, but got {actualValue}."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
namespace AiDotNet.Exceptions; | ||
|
||
/// <summary> | ||
/// Exception thrown when a tensor's rank doesn't match the expected rank. | ||
/// </summary> | ||
public class TensorRankException : AiDotNetException | ||
{ | ||
/// <summary> | ||
/// The expected rank of the tensor. | ||
/// </summary> | ||
public int ExpectedRank { get; } | ||
|
||
/// <summary> | ||
/// The actual rank of the tensor. | ||
/// </summary> | ||
public int ActualRank { get; } | ||
|
||
/// <summary> | ||
/// The component where the rank mismatch occurred. | ||
/// </summary> | ||
public string Component { get; } | ||
|
||
/// <summary> | ||
/// The operation being performed when the mismatch was detected. | ||
/// </summary> | ||
public string Operation { get; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="TensorRankException"/> class. | ||
/// </summary> | ||
/// <param name="expectedRank">The expected rank of the tensor.</param> | ||
/// <param name="actualRank">The actual rank of the tensor.</param> | ||
/// <param name="component">The component where the rank mismatch occurred.</param> | ||
/// <param name="operation">The operation being performed when the mismatch was detected.</param> | ||
public TensorRankException(int expectedRank, int actualRank, string component, string operation) | ||
: base(FormatMessage(expectedRank, actualRank, component, operation)) | ||
{ | ||
ExpectedRank = expectedRank; | ||
ActualRank = actualRank; | ||
Component = component; | ||
Operation = operation; | ||
} | ||
|
||
private static string FormatMessage(int expectedRank, int actualRank, string component, string operation) | ||
{ | ||
return $"Rank mismatch in {component} during {operation}: " + | ||
$"Expected rank {expectedRank}, but got {actualRank}."; | ||
} | ||
} |
Oops, something went wrong.