-
Notifications
You must be signed in to change notification settings - Fork 0
Add comprehensive documentation files for IComparable Extensions #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,191 @@ | ||||||||||||||||||||
| # Getting Started | ||||||||||||||||||||
|
|
||||||||||||||||||||
| This guide will help you quickly start using Wolfgang.Extensions.IComparable in your .NET projects. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Prerequisites | ||||||||||||||||||||
|
|
||||||||||||||||||||
| - .NET 8.0 or later | ||||||||||||||||||||
| - A C# project (any project type: console, web, library, etc.) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ## Installation | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### Using NuGet Package Manager | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```bash | ||||||||||||||||||||
| dotnet add package Wolfgang.Extensions.IComparable | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### Using Package Manager Console (Visual Studio) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```powershell | ||||||||||||||||||||
| Install-Package Wolfgang.Extensions.IComparable | ||||||||||||||||||||
| ``` | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ### Using .csproj File | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Add the following package reference to your `.csproj` file: | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ```xml | ||||||||||||||||||||
| <ItemGroup> | ||||||||||||||||||||
| <PackageReference Include="Wolfgang.Extensions.IComparable" Version="1.*" /> | ||||||||||||||||||||
|
||||||||||||||||||||
| <PackageReference Include="Wolfgang.Extensions.IComparable" Version="1.*" /> | |
| <PackageReference Include="Wolfgang.Extensions.IComparable" Version="1.0.0" /> |
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This IComparable<Employee> example won’t match the .NET IComparable<T> signature under nullable reference types (CompareTo(T? other)), which can produce warnings (and may fail builds if warnings are treated as errors). Consider changing the signature to CompareTo(Employee? other) and handling null explicitly.
| public int CompareTo(Employee other) | |
| { | |
| public int CompareTo(Employee? other) | |
| { | |
| if (other is null) | |
| { | |
| // By convention, any instance is greater than null | |
| return 1; | |
| } |
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The quick reference table has an extra leading | on each row (e.g., starts with || Method ...). This renders as an empty first column in Markdown. Remove the extra leading pipe so the table is formatted correctly.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,82 @@ | ||||||
| # Introduction | ||||||
|
|
||||||
| ## Overview | ||||||
|
|
||||||
| **Wolfgang.Extensions.IComparable** is a lightweight .NET library that provides powerful extension methods for types implementing the `IComparable<T>` interface. This library simplifies common comparison operations, making your code more readable and expressive. | ||||||
|
|
||||||
| ## What is IComparable? | ||||||
|
|
||||||
| The `IComparable<T>` interface is a fundamental part of .NET that allows objects to be compared for ordering purposes. Types that implement this interface can be sorted and compared using standardized methods. | ||||||
|
|
||||||
| ## Why Use This Library? | ||||||
|
|
||||||
| When working with comparable types in C#, you often need to check if a value falls within a specific range. Without this library, such checks can be verbose and error-prone: | ||||||
|
|
||||||
| ```csharp | ||||||
| // Without Wolfgang.Extensions.IComparable | ||||||
| if (value.CompareTo(min) >= 0 && value.CompareTo(max) <= 0) | ||||||
| { | ||||||
| // Value is in range | ||||||
| } | ||||||
|
|
||||||
| // With Wolfgang.Extensions.IComparable | ||||||
| if (value.IsInRange(min, max)) | ||||||
| { | ||||||
| // Value is in range - much clearer! | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ## Key Features | ||||||
|
|
||||||
| - **Intuitive API**: Extension methods that read like natural language | ||||||
| - **Type-Safe**: Works with any type that implements `IComparable<T>` | ||||||
| - **Zero Dependencies**: Lightweight library with no external dependencies | ||||||
| - **Well-Tested**: Comprehensive test coverage to ensure reliability | ||||||
| - **Performance-Optimized**: Minimal overhead compared to manual comparison operations | ||||||
|
|
||||||
| ## Available Extension Methods | ||||||
|
|
||||||
| ### IsBetween | ||||||
|
|
||||||
| Determines if a value is **strictly between** two bounds (exclusive comparison): | ||||||
|
|
||||||
| ```csharp | ||||||
| int value = 5; | ||||||
| bool result = value.IsBetween(1, 10); // true (5 > 1 AND 5 < 10) | ||||||
| ``` | ||||||
|
|
||||||
| ### IsInRange | ||||||
|
|
||||||
| Determines if a value is **within the range** of two bounds (inclusive comparison): | ||||||
|
|
||||||
| ```csharp | ||||||
| int value = 5; | ||||||
| bool result = value.IsInRange(5, 10); // true (5 >= 5 AND 5 <= 10) | ||||||
| ``` | ||||||
|
|
||||||
| ## Use Cases | ||||||
|
|
||||||
| This library is particularly useful in scenarios such as: | ||||||
|
|
||||||
| - **Validation**: Checking if user input falls within acceptable ranges | ||||||
| - **Business Logic**: Implementing rules that depend on value ranges | ||||||
| - **Data Processing**: Filtering or categorizing data based on value ranges | ||||||
| - **Game Development**: Checking bounds for positions, scores, or other metrics | ||||||
| - **Financial Applications**: Validating amounts, dates, or other comparable values | ||||||
|
|
||||||
| ## Supported Types | ||||||
|
|
||||||
| Any type that implements `IComparable<T>` can use these extension methods, including: | ||||||
|
|
||||||
| - Numeric types: `int`, `double`, `decimal`, `float`, etc. | ||||||
| - Date and time types: `DateTime`, `DateTimeOffset`, `TimeSpan` | ||||||
| - String comparisons | ||||||
| - Custom types that implement `IComparable<T>` | ||||||
|
|
||||||
| ## License | ||||||
|
|
||||||
| This project is licensed under the Mozilla Public License 2.0. See the [LICENSE](../LICENSE) file for details. | ||||||
|
||||||
| This project is licensed under the Mozilla Public License 2.0. See the [LICENSE](../LICENSE) file for details. | |
| This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prerequisites claim “.NET 8.0 or later”, but the library multi-targets net462 and netstandard2.0 (see src/Wolfgang.Extensions.IComparable/Wolfgang.Extensions.IComparable.csproj). Consider updating this to reflect the actual supported target frameworks (e.g., “any TFMs compatible with netstandard2.0 / net462”).