AlbinAnthonyJohn.MyUtils
1.0.0
dotnet add package AlbinAnthonyJohn.MyUtils --version 1.0.0
NuGet\Install-Package AlbinAnthonyJohn.MyUtils -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AlbinAnthonyJohn.MyUtils" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AlbinAnthonyJohn.MyUtils" Version="1.0.0" />
<PackageReference Include="AlbinAnthonyJohn.MyUtils" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AlbinAnthonyJohn.MyUtils --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AlbinAnthonyJohn.MyUtils, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AlbinAnthonyJohn.MyUtils@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AlbinAnthonyJohn.MyUtils&version=1.0.0
#tool nuget:?package=AlbinAnthonyJohn.MyUtils&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MyUtils — Personal .NET Utility Library
A personal NuGet package with reusable helpers, extensions, validators, security tools, and more. Drop it into any project and skip the boilerplate.
📦 Installation
dotnet add package YourName.MyUtils
🗂️ Folder Structure
MyUtils/
├── Configuration/ AppSettings.cs — Strongly-typed settings (JWT, Email, Storage, OTP, Pagination)
├── Constants/ AppConstants.cs — Date formats, MIME types, HTTP codes, regex patterns
├── Converters/ Converters.cs — JSON, Unit (temp/distance/weight/data), Currency (INR/USD/GST)
├── Exceptions/ CustomExceptions.cs — NotFoundException, BusinessException, ValidationException, etc.
├── Extensions/
│ ├── StringExtensions.cs — Extension wrappers for all StringHelper methods + ToEnum, ToInt, etc.
│ ├── ListExtensions.cs — Paginate, Chunk, Shuffle, ForEach, DistinctBy, ToCsv, etc.
│ └── DateTimeExtensions.cs — ToIST, TimeAgo, IsWeekend, StartOfDay, ToUnixTimestamp, etc.
├── Helpers/
│ ├── StringHelper.cs — Truncate, ToSlug, ToCamelCase, Mask, Base64, GenerateRandom, etc.
│ ├── DateHelper.cs — NowIST, CalculateAge, TimeAgo, BusinessDaysBetween, etc.
│ ├── FileHelper.cs — FormatFileSize, IsImage, EnsureDirectory, GenerateUniqueFileName, etc.
│ └── NumberHelper.cs — ToOrdinal, ToWords (with Crore/Lakh), ToIndianFormat, Percentage, etc.
├── Models/
│ ├── ApiResponse.cs — ApiResponse<T> with factory methods (Ok, Fail, NotFound, Created, etc.)
│ └── CommonModels.cs — Result<T>, SelectItem, FileResult, AuditableEntity, BaseEntity<TKey>
├── Pagination/ PaginationHelper.cs — PagedResult<T>, PagedRequest, PaginationHelper factory methods
├── Security/ SecurityHelper.cs — BCrypt hashing, JWT generate/validate, OTP, SHA256/512, HMAC
├── Utilities/ Utilities.cs — RetryHelper, Guard clauses, EnvironmentHelper, MiscUtils
└── Validators/ CommonValidator.cs — Email, Indian Mobile, Aadhaar, PAN, GST, IFSC, PinCode, Password
✅ Usage Examples
ApiResponse
return ApiResponse<User>.Ok(user);
return ApiResponse<User>.NotFound("User not found");
return ApiResponse<User>.ValidationError(["Email is required", "Name too short"]);
Result Pattern (Service Layer)
public Result<User> GetUser(int id) {
if (user == null) return Result<User>.Failure("User not found");
return Result<User>.Success(user);
}
String Extensions
"hello world".ToSlug(); // "hello-world"
"ABCDE1234F".IsNullOrEmpty(); // false
"John Doe".ToCamelCase(); // "johnDoe"
"test@gmail.com".Mask(2, 9); // "te*********com"
DateTime Extensions
DateTime.UtcNow.ToIST();
birthDate.CalculateAge();
someDate.TimeAgo(); // "3 days ago"
someDate.StartOfMonth();
Pagination
var paged = PaginationHelper.Paginate(allUsers, page: 1, pageSize: 10);
// paged.Items, paged.TotalPages, paged.HasNextPage
Validators
CommonValidator.IsValidEmail("user@example.com"); // true
CommonValidator.IsValidPAN("ABCDE1234F"); // true
CommonValidator.IsValidIndianMobile("9876543210"); // true
CommonValidator.IsStrongPassword("P@ssword1"); // true
Security
string hash = SecurityHelper.HashPassword("mypassword");
bool valid = SecurityHelper.VerifyPassword("mypassword", hash);
string jwt = SecurityHelper.GenerateJwt(claims, secretKey, issuer, audience);
string otp = SecurityHelper.GenerateOtp(6); // "482931"
string token = SecurityHelper.GenerateSecureToken(); // hex string
Converters
JsonConverter.Serialize(myObject);
UnitConverter.CelsiusToFahrenheit(37); // 98.6
CurrencyConverter.ToINR(1234567.89m); // "₹12,34,567.89"
CurrencyConverter.CalculateGst(1000, 18); // (1000, 180, 1180)
Guard Clauses
Guard.NotNull(user, nameof(user));
Guard.NotNullOrEmpty(email, nameof(email));
Guard.Range(age, 18, 100, nameof(age));
Retry
await RetryHelper.ExecuteAsync(async () => {
await externalApi.CallAsync();
}, maxRetries: 3, delayMs: 300);
🚀 Publishing to NuGet
# 1. Update version in .csproj
# 2. Pack
dotnet pack -c Release
# 3. Push
dotnet nuget push ./bin/Release/YourName.MyUtils.1.0.0.nupkg \
--api-key YOUR_API_KEY \
--source https://api.nuget.org/v3/index.json
🔢 Versioning
| Change Type | Version Bump |
|---|---|
| Bug fix | 1.0.x Patch |
| New helper added | 1.x.0 Minor |
| Breaking change | x.0.0 Major |
📄 License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- BCrypt.Net-Next (>= 4.0.3)
- System.IdentityModel.Tokens.Jwt (>= 7.5.1)
-
net8.0
- BCrypt.Net-Next (>= 4.0.3)
- System.IdentityModel.Tokens.Jwt (>= 7.5.1)
-
net9.0
- BCrypt.Net-Next (>= 4.0.3)
- System.IdentityModel.Tokens.Jwt (>= 7.5.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 122 | 6/8/2026 |
Initial release containing helpers, validators, extensions, security utilities, and pagination helpers.