BugReporting 0.1.7

dotnet add package BugReporting --version 0.1.7                
NuGet\Install-Package BugReporting -Version 0.1.7                
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="BugReporting" Version="0.1.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BugReporting --version 0.1.7                
#r "nuget: BugReporting, 0.1.7"                
#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.
// Install BugReporting as a Cake Addin
#addin nuget:?package=BugReporting&version=0.1.7

// Install BugReporting as a Cake Tool
#tool nuget:?package=BugReporting&version=0.1.7                

BugReporting

A library that allows for reporting of bugs to an external source and includes customizable data to better explain what is going on.

Important: This library is still in a beta stage, which means changes will be frequent and sudden, and may break files created with previous versions of the library. DO NOT rely on this library to be stable.

Submitting Feedback

If you have feedback on this library, or want to help contribute, please click here and fill out the form. We will try to respond to all requests, but it may take a while before we are able to respond. Please be patient.

Version History

Current version: 0.1.7.0 (BETA RELEASE)

Version 0.1.7.0 (BETA RELEASE - CURRENT)

  • Added ability to customize the Valsom logging formats and themes for both FileLogger and PrettyConsoleLogger

Version 0.1.6.0 (BETA RELEASE)

  • Added Id field to SerializableException so you can track exceptions by ID
  • Added ability to submit a bug report as a file only - the file will be created as normal but the webhooks / email triggers will not be fired
  • Added EventId struct to the Logging system

Version 0.1.5.0 (BETA RELEASE)

  • Updated dependent libraries and added validity check to SerializableVersion.

Version 0.1.4.0 (BETA RELEASE)

  • Fixed a bug with the DefaultContactInfoNative property that caused it to not be cloned properly when cloning an object.
  • Changed the default value for DefaultContactInfoNative property to an empty string so it automatically replaces itself with DefaultContactInfoText unless otherwise assigned.

Version 0.1.3.0 (BETA RELEASE)

  • Fixed the replacement of the {DEFAULT_CONTACT_INFO} token
  • Added a new version parameter: ReportVersion. Now the 'Version' parameter refers to the version of the application that is submitting the bug report, not the bug reporting library. ReportVersion is used for the version of the bug reporting library.
  • Added a new DefaultContactInfo type: Native. This type is used for Webhook / API submissions. By default, it will use DefaultContactInfoText unless you explicitly set it to something.
  • Changed nullability of ReadBug<> method so that if the bug fails to parse correctly NULL will be returned. It also handles the exception and logs it so it doesn't blow up.
  • BREAKING CHANGE: The schema for the bug report file has been altered to include an additional Version parameter. Files created with previous versions of this library ARE NOT COMPATIBLE and cannot be loaded with this version or any future version of this library.

Version 0.1.2.0 (BETA RELEASE)

  • Corrected the namespaces within the library - they were set to an invalid namespace from a previous project

Version 0.1.1.0 (BETA RELEASE)

  • Added support for custom properties on the SettingsFile object - now you can utilize the built-in settings engine to store your own values in addition to the ones needed by the bug reporting engine.

Version 0.1.0.0 (BETA RELEASE)

This was the initial release. It did not support the CustomProperties on SettingsFile objects.

Using the library

At a minimum, you must provide an concrete implementation of the BaseApplicationHostingConfiguration class and an implementation of ICreateSettings:

Example:

public class ApplicationConfig : BaseApplicationHostingConfiguration<SettingsCreator>
{
	protected override void Initialize()
	{
		//These services are ABSOLUTELY REQUIRED:
		DependencyResolver.ServiceCollection.AddScoped<ILoggingSystem, T1>(); //T1 must be an implementation of ILoggingSystem, such as DefaultLoggingSystem for example
		DependencyResolver.ServiceCollection.AddScoped<IBugReportingService, T2>(); //T2 must be an implementation of IBugReportingService, such as DefaultBugReportingService for example.  In 99% of cases, this is the implementation you will want to use.  The reason you have to specify it here is in case you wanted to use your own implementation for some reason.
        DependencyResolver.ServiceCollection.AddScoped<IBugReportRegistrationService, T3>(); //T3 must be an implementation of IBugReportRegistrationService, such as DefaultBugReportRegistrationService for example.  In 99% of cases, this is the implementation you will want to use.  The reason you have to specify it here is in case you wanted to use your own implementation for some reason.
		
		//If you want email sending to work, you must include this:
		DependencyResolver.ServiceCollection.AddScoped<IEmailService, T4>(); //T4 must be an implementation of IEmailService, such as DefaultEmailService for example
		DependencyResolver.ServiceCollection.AddScoped<IEmailTextParser, T5>(); //T5 must be an implementation of IEmailTextParser, such as DefaultEmailTextParser for example
		//If you do not provide an IEmailService or IEmailTextParser implementation, email sending will be disabled automatically.
		
		//If you want API submissions to work, you must include this:
		DependencyResolver.ServiceCollection.AddScoped<IWebhookService, T6>(); //T6 must be an implementation of IWebhookService, such as DefaultWebhookService for example
	}
	
	protected override bool VerifyRequiredServices()
	{
		//Check to make sure all required services you added above are present and accounted for
		//You do not have to check for the services mentioned in the example method above because those are automatically verified for you
	}
}

public class SettingsCreator : ICreateSettings 
{
	public SettingsFile CreateNewSettingsFile()
	{
		//code to create a new SettingsFile goes here.  Maybe you want to display a form and let the user enter values, or maybe you want to set some default values for them.
	}
}

Once you have these two classes defined, in your Program.cs class you need the following code:

public static void Main(string[] args)
{
	try
	{
		//other code
		
		var ac = new ApplicationConfig();
		ac.InitializeDependencyInjection();
		DependencyResolver.BugReportTypeRegistration?.RegisterBugReportType(typeof(YourBugReportSubclass)); //You need to put the name of the class you write to implement the abstract members of BugReport here so it can properly deserialize them.
		
		//more code
	}
	catch (Exception ex)
	{
		//deal with the exception if you wish - keep in mind, you cannot rely on DependencyResolver.LoggingSystem because it may not be initialized!
		//maybe display a message to the user
	}
}

If you want to define your own email sending method that is not supported by the default email service, you can do so by extending the DefaultEmailService class and overriding the HandleOtherEmailSendMethods method and setting the EmailSendMethod in your settings configuration to EmailSendMethod.Other. Here is an example:

Set the default EmailSendMethod and ExternalEmailSendingMethod:

DependencyResolver.SettingsService.Settings.EmailSendingMethod = EmailSendMethod.Other;
DependencyResolver.SettingsService.Settings.ExternalEmailSendingMethod = "use whatever string you want to represent the sending type you want to support";

Note: You can implement more than one external sending type, but only one can be enabled at a time. So when setting the 'ExternalEmailSendingMethod' property, only enter the string that represents the sending method you want to actually use.

Define a custom Email service by extending the default one:


public class MyEmailServiceExample : DefaultEmailService 
{
	protected override bool HandleOtherEmailSendMethods(BugReport bugReport, string? sendMethod,
    EmailSendFormat format, EmailConfiguration configuration, params string[] fileAttachments)
	{
		//Check to see if sendMethod is null - if so, set it to an invalid string so the fall back clause is invoked and an error is logged
		if (sendMethod == null)
		{
			sendMethod = "NO SEND METHOD DEFINED";
		}
		
		// Your code goes here- you could use a switch statmeent for example to check for whatever send method strings you have defined in your code
		
		//Fall back in case whatever method was provided is not supported:
		DependencyResolver.LoggingSystem?.Log($"Warning: email send method {sendMethod} is not implemented!",
			LogLevel.Warning);
		return false;
	}
}

In your BaseApplicationHostingConfiguration implementation, you will need to register your email service:

protected override void Initialize()
	{
		//....other code....
		
		//If you want email sending to work, you must include this:
		ServiceCollection.AddScoped<IEmailService, MyEmailServiceExample>();
		
		//....other code....
	}
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. 
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
0.1.7 56 12/18/2024

Added ability to customize the Valsom logging formats and themes for both FileLogger and PrettyConsoleLogger