HuntGlitch C# Project
HuntGlitch is a C# library built on .NET Core 2.1 designed to detect and analyze visual glitches within applications or graphical outputs. This package provides tools to identify potential rendering issues, screen tearing, and other visual anomalies.
Installation
To use HuntGlitch in your .NET Core 2.1 project, you can install it via NuGet Package Manager.
Using NuGet Package Manager Console:
Install-Package HuntGlitch
Using .NET CLI:
dotnet add package HuntGlitch
Prerequisites:
- .NET Core 2.1 SDK or later installed
- A compatible IDE (e.g., Visual Studio) or a text editor
Usage
To run the application, execute the following command:
dotnet run
Configuration
To use HuntGlitch, you need to configure it properly. Follow these steps to set up your account and integrate HuntGlitch into your project.
Step 1: Register a New Account
- 1. Go to app.huntglitch.com/register and create a new account.
- 2. Login at app.huntglitch.com/login.
Step 2: Create a New Project
- 1. Once logged in, navigate to the "All Projects" page at app.huntglitch.com/project/list.
- 2. Click on the "Add Project" button.
- 3. Enter the Project Name and Deliverables in the respective fields.
- 4. Click Save to create the project.
Step 3: View Your Project
1. Go back to the project list, and you will see your newly created project.

2. Click on your project to preview log information.

Step 4: Obtain Your Keys
- Project Key: This is your unique project identifier provided by HuntGlitch.
- Deliverable Key: This is your unique deliverable identifier associated with the project.
Step 5: Configure Your Application
Add the following in your appsettings.json
:
{
"HuntGlitchSettings": {
"ProjectKey": "YOUR_PROJECT_KEY",
"DeliverableKey": "YOUR_DELIVERABLE_KEY"
}
}
Step 6: Register HuntGlitch Services
To integrate HuntGlitch effectively, you need to register its services within your application's Startup.cs (or Program.cs in .NET 6+).
Add HuntGlitch services to the service collection:
// In Startup.cs (ConfigureServices method) or Program.cs (builder.Services)
// Bind app-settings to your AppSettings class (if applicable)
builder.Services.AddHuntGlitchForHttpServices(builder.Configuration);
// For API, MVC Applications where you want to log HTTP requests
builder.Services.AddHuntGlitchForBackgroundServices(builder.Configuration, <name-of-background-service> );
// For Background Services where you want to log background tasks
Usage
After installing and configuring the package, you can start using the HuntGlitch library in your C# code. Here's a basic example of how to use it:
Note: Some of the code is conceptual and may need to be adjusted to fit your project's structure.
Sample DI in Controller
//This is the sample data form which you can use in your controller file.
private readonly IHuntGlitchLog _huntGlitchLogs;
//Constructor
public TestController(IHuntGlitchLog huntGlitchLogs)
{
_huntGlitchLogs = huntGlitchLogs;
}
DebugAsync
//Log debug without additional data or tags
await _huntGlitchLogs.DebugAsync();
//Log debug with additional data
await _huntGlitchLogs.DebugAsync(additionalData);
//Log debug with tag data
await _huntGlitchLogs.DebugAsync(tagData);
//Log debug with additional data and tag data
await _huntGlitchLogs.DebugAsync(additionalData, tagData);
WarningAsync
//Log warning without additional data or tags
await _huntGlitchLogs.WarningAsync();
//Log warning with additional data
await _huntGlitchLogs.WarningAsync(additionalData);
//Log warning with tag data
await _huntGlitchLogs.WarningAsync(tagData);
//Log warning with additional data and tag data
await _huntGlitchLogs.WarningAsync(additionalData, tagData);
NoticeAsync
//Log notice without additional data or tags
await _huntGlitchLogs.NoticeAsync();
//Log notice with additional data
await _huntGlitchLogs.NoticeAsync(additionalData);
//Log notice with tag data
await _huntGlitchLogs.NoticeAsync(tagData);
//Log notice with additional data and tag data
await _huntGlitchLogs.NoticeAsync(additionalData, tagData);
InformationAsync
//Log information without additional data or tags
await _huntGlitchLogs.InfoAsync();
//Log information with additional data
await _huntGlitchLogs.InfoAsync(additionalData);
//Log information with tag data
await _huntGlitchLogs.InfoAsync(tagData);
//Log information with additional data and tag data
await _huntGlitchLogs.InfoAsync(additionalData, tagData);
ErrorAsync
//Log error with exception only
await _huntGlitchLogs.ErrorAsync(exception);
//Log error with exception and additional data
await _huntGlitchLogs.ErrorAsync(exception, additionalData);
//Log error with exception and tag data
await _huntGlitchLogs.ErrorAsync(exception, tagData);
//Log error with exception, additional data, and tag data
await _huntGlitchLogs.ErrorAsync(exception, additionalData, tagData);
Example of Additional and Tag Data
private static Dictionary<string, object> additionalData = new Dictionary<string, object>() {
{ "user_data", new { name = "John", id = 1 } },
{ "order_data", new { order_id = "001" } },
{ "error_data", new { eventId = "002" } }
};
private static Dictionary<string, string> tagData = new Dictionary<string, object>() {
{ "environment", "production" },
{ "module", "authentication" },
{ "feature", "login" },
{ "logger", "csharp" },
{ "csharp-version", Environment.Version.ToString() }
};
Extracted Information
HuntGlitch extracts various pieces of information from the HTTP context to provide detailed logs. This includes:
- Request Body
- Request Headers
- Request Method Type
- Request URL
Additionally, it extracts:
- Browser Name and Version (from the
User-Agent
header) - Operating System (from the
sec-ch-ua-platform
header)
Request Body Reading (Optional)
The RequestBufferingMiddleware is an optional middleware designed to allow reading the request body multiple times throughout the request lifecycle. This is especially useful for logging or debugging request payloads before they are processed by the controller.
Supported Content Types
This middleware only buffers and reads body data for the following content types:
- application/json – JSON payloads
- application/x-www-form-urlencoded – Standard form submissions
- multipart/form-data – Form submissions that may include file uploads
⚠️ Only non-binary fields (like text inputs) are parsed. Binary data such as images/videos will not be processed.
How to Use
Step 1: Add RequestBufferingMiddleware
Create a file named RequestBufferingMiddleware.cs in your project (e.g., under a Middlewares folder):
public class RequestBufferingMiddleware
{
private readonly RequestDelegate _next;
public RequestBufferingMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
var contentType = context.Request.ContentType;
if (!string.IsNullOrWhiteSpace(contentType) &&
(contentType.Contains("application/json", StringComparison.OrdinalIgnoreCase) ||
contentType.Contains("application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase) ||
contentType.Contains("multipart/form-data", StringComparison.OrdinalIgnoreCase)))
{
context.Request.EnableBuffering();
}
await _next(context);
}
}
Step 2: Register Middleware in Program.cs
Add the middleware before other middlewares that may read the request body (like logging):
app.UseMiddleware();
🎉 You're All Set! Your request body can now be safely read multiple times inside HuntGlitch, logging components, or other services.
Exception Handling
HuntGlitch provides detailed logging for exceptions. When an exception is logged, the following information is captured:
- Error Message
- File Name where the error occurred
- Line Number of the error
- Error Code (hash code of the exception)
- Exception Class and Method Name
This information helps in diagnosing and resolving issues effectively.
Important Notes
- Ensure your project targets .NET Core 2.1 or a compatible framework.
- Replace the conceptual code examples with actual implementation using the real HuntGlitch API.
Contact
For any questions or issues, please open an issue on the GitHub repository.