MyClassLibrary027.Utilities 1.0.11

dotnet add package MyClassLibrary027.Utilities --version 1.0.11
                    
NuGet\Install-Package MyClassLibrary027.Utilities -Version 1.0.11
                    
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="MyClassLibrary027.Utilities" Version="1.0.11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MyClassLibrary027.Utilities" Version="1.0.11" />
                    
Directory.Packages.props
<PackageReference Include="MyClassLibrary027.Utilities" />
                    
Project file
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 MyClassLibrary027.Utilities --version 1.0.11
                    
#r "nuget: MyClassLibrary027.Utilities, 1.0.11"
                    
#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 MyClassLibrary027.Utilities@1.0.11
                    
#: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=MyClassLibrary027.Utilities&version=1.0.11
                    
Install as a Cake Addin
#tool nuget:?package=MyClassLibrary027.Utilities&version=1.0.11
                    
Install as a Cake Tool

MyClassLibrary027.Utilities

Utility functions for common tasks like prime checking and file splitting, plus a custom Swagger attribute to enhance API documentation by adding descriptive info to Swagger UI summaries and descriptions.

Installation

You can install the package from NuGet.org:

dotnet add package MyClassLibrary027.Utilities

Or, if you're using Visual Studio, you can search for the package in the NuGet Package Manager and install it from there.

Functions

CheckPrime(int prime)

Checks if a number is prime.

Utilities.CheckPrime(5);  // Output: Prime Number
Utilities.CheckPrime(10); // Output: Not Prime Number

SplitFile(string filePath, int n = 10000)

Splits a large file into smaller chunks, each with a maximum size of n characters. The default value of n is 10,000 characters.

  • filePath (string): The path to the file to be split.
  • n (int, optional): The maximum size of each chunk (default is 10,000 characters).
Utilities.SplitFile("path/to/largefile.txt", 5000);

This will split the file into chunks of 5,000 characters each and save them as separate files in the same directory.

SwaggerInfoAttribute

Use SwaggerInfoAttribute on API methods to add custom info in Swagger UI. Register the filter:

services.AddSwaggerGen(c =>
{
    // Other Swagger configuration...

    c.OperationFilter<SwaggerInfoOperationFilter>();
});

Example:

[ApiController]
[Route("api/[controller]")]
public class SampleController : ControllerBase
{
    [HttpGet("data")]
    [SwaggerInfo("Requires Admin", Description = "Requires admin privileges.")]
    public IActionResult GetSensitiveData() => Ok(new { Message = "Secret data" });

    [HttpGet("public")]
    [SwaggerInfo("Public Access")]
    public IActionResult GetPublicData() => Ok(new { Message = "Public data" });
    
    [HttpGet("status")]
    [SwaggerInfo()]
    public IActionResult GetStatus() => Ok(new { Message = "All systems operational" });
}

What happens:

  • For the GetSensitiveData endpoint, Swagger UI summary will start with [Requires Admin] and the description panel will include your info text:

    🔹 Info: This endpoint requires admin privileges and returns sensitive data.
    
  • For the GetPublicData endpoint, summary will start with [Public Access] and description stays unchanged (since Description was not provided).

  • For the GetStatus endpoint, the summary will display [Additional endpoint info] (the default), and the description will remain unchanged because no Description was provided.

Product 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 was computed.  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 was computed.  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.

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.11 210 6/2/2025