DEV Community

MHIZokuchi
MHIZokuchi

Posted on

ReferenceGenerator: A Lightweight C# Library for Generating Unique References

ReferenceGenerator: A Lightweight C# Library for Generating Unique References

Are you tired of writing custom code to generate reference numbers for your C# applications? Meet ReferenceGenerator, a flexible and lightweight library designed specifically for creating unique reference numbers in various formats.

🚀 Why You Need This Library

Whether you're working on an e-commerce platform that needs order numbers, a financial app requiring transaction IDs, or a document management system that needs reference codes - ReferenceGenerator has got you covered!

✨ Key Features

  • Numeric references - perfect for sequential identifiers
  • Alphabetic references (uppercase letters only) - great for category codes
  • Alphanumeric references - for maximum flexibility
  • GUID generation - when you need guaranteed uniqueness
  • Cryptographically secure references - for security-sensitive applications
  • Custom prefixes - easily add context to your references (e.g., "ORD-", "TXN-", "DOC-")

📦 Installation

Getting started is easy. Install via NuGet Package Manager:

Install-Package ReferenceGenerator
Enter fullscreen mode Exit fullscreen mode

Or via .NET CLI:

dotnet add package ReferenceGenerator
Enter fullscreen mode Exit fullscreen mode

💻 Usage Examples

The API is designed to be intuitive and straightforward:

using ReferenceGenerator;

// Generate a 10-digit numeric reference
string numericRef = ReferenceGenerator.GenerateNumeric(10);
// Example output: "1234567890"

// Generate an 8-character alphabetic reference
string alphabeticRef = ReferenceGenerator.GenerateAlphabetic(8);
// Example output: "ABCDEFGH"

// Generate a 12-character alphanumeric reference
string alphanumericRef = ReferenceGenerator.GenerateAlphanumeric(12);
// Example output: "A1B2C3D4E5F6"

// Generate a GUID
string guid = ReferenceGenerator.GenerateGuid();
// Example output: "550e8400-e29b-41d4-a716-446655440000"

// Generate references with prefixes
string orderRef = ReferenceGenerator.GenerateNumeric(6, "ORD-");
// Example output: "ORD-123456"

// Generate a cryptographically secure reference
string secureRef = ReferenceGenerator.GenerateSecure(10);
// Example output: "X7Y9Z2W4P5"
Enter fullscreen mode Exit fullscreen mode

🛠️ Contributing

We believe in the power of community! Contributions are welcome and appreciated. Before submitting pull requests, please:

  1. Clone the repository
  2. Open the solution in Visual Studio or your preferred IDE
  3. Run the tests to ensure everything is working correctly

Speaking of tests, you can run them easily:

dotnet test
Enter fullscreen mode Exit fullscreen mode

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🆘 Support

Encountered an issue or have questions? We're here to help:

  1. Check existing issues in the GitHub repository
  2. Create a new issue if your problem hasn't been reported
  3. Provide as much detail as possible when reporting issues

Have you used ReferenceGenerator in your projects? Share your experience in the comments below! And don't forget to ⭐ the GitHub repo if you find it useful!

Top comments (0)