ProfileSharp.AspNetCore 7.0.0.2-prerelease

This is a prerelease version of ProfileSharp.AspNetCore.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package ProfileSharp.AspNetCore --version 7.0.0.2-prerelease                
NuGet\Install-Package ProfileSharp.AspNetCore -Version 7.0.0.2-prerelease                
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="ProfileSharp.AspNetCore" Version="7.0.0.2-prerelease" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ProfileSharp.AspNetCore --version 7.0.0.2-prerelease                
#r "nuget: ProfileSharp.AspNetCore, 7.0.0.2-prerelease"                
#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 ProfileSharp.AspNetCore as a Cake Addin
#addin nuget:?package=ProfileSharp.AspNetCore&version=7.0.0.2-prerelease&prerelease

// Install ProfileSharp.AspNetCore as a Cake Tool
#tool nuget:?package=ProfileSharp.AspNetCore&version=7.0.0.2-prerelease&prerelease                

ProfileSharp was built to allow developers to quickly test on their local machines and automate unit tests without manually generating a large amount of mock data. ProfileSharp provides an easy way to collect mock data and enable its use within your domain.

NOTE: This is an early proof of concept and could change as it matures.

Planned Features
  • Automatic Unit Test Generation and Execution at Runtime within your unit tests based on profiled data.
Drawbacks
  • Mock data can only be collected at runtime.
  • If the signature of a mocked method changes it will no longer be compatible with preivously profiled mocking data.
  • Random data is not supported in unit tests. (This may be resolved with an Attribute or alternative means in the future)
  • Mocking is currently only supported within an AspNet runtime.
  • Only methods and properties can profiled/mocked.

How?

Install the ProfileSharp.AspNetCore package from nuget.

In your Startup.cs call the following methods.

public void ConfigureServices(IServiceCollection services)
{
	services.AddProfileSharp(o =>
	{
		o.AddProfiling(o =>
		{
			o.UseFileStore(@"D:\#temp\ProfilingStore");
		});

		o.AddMocking(o =>
		{
			o.UseFileStore(@"D:\#temp\ProfilingStore");
		});
	});
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
	app.UseProfileSharp(config =>
	{
		if(env.IsDevelopment())
		{
			// Enable Mocking Mode, when this mode is set ProfileSharp will mock the
			// specified parts of your domain.
			config.EnableMocking();
		}
		else if(env.IsStaging())
		{
			// Enable Profiling Mode, when this mode is set ProfileSharp will profile the
			// specified parts of your domain.
			config.EnableProfiling();
		}
		else
		{
			// Disable ProfileSharp, Mocking and Profiling will not occur.
			config.Disable();
		}
	
	});
}

If your project is using NServiceBus

Install the ProfileSharp.NServiceBus package from nuget.

When configuration your EndpointConfiguration call the following methods

endpointConfiguration.UseProfileSharp();

ProfileSharp Attributes

For ProfileSharp to work, you must specify what parts of your domain will be intercepted. This is done using the EnableProfileSharpAttribute.

[EnableProfileSharp]
public interface IStudentRepository
{
	Task CreateAsync(StudentModel student);

	Task<StudentModel> GetAsync(Guid studentId);

	Task DeleteAsync(Guid studentId);
}

You can also only enable ProfileSharp for specific methods.

public interface IStudentRepository
{
	// This method will not intercepted.
	Task CreateAsync(StudentModel student);

	[EnableProfileSharp]
	Task<StudentModel> GetAsync(Guid studentId);

	// This method will not intercepted.
	Task DeleteAsync(Guid studentId);
}

Or disable ProfileSharp for specific methods.

[EnableProfileSharp]
public interface IStudentRepository
{
	Task CreateAsync(StudentModel student);
	
	Task<StudentModel> GetAsync(Guid studentId);

	// This method will not intercepted.
	[DisableProfileSharp]
	Task DeleteAsync(Guid studentId);
}

Releases

Package Downloads NuGet
ProfileSharp alternate text is missing from this package README image Nuget
ProfileSharp.AspNetCore alternate text is missing from this package README image Nuget
ProfileSharp.NServiceBus alternate text is missing from this package README image Nuget
ProfileSharp.Store.FileStore alternate text is missing from this package README image Nuget
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
7.0.0.3-prerelease 137 12/21/2022
7.0.0.2-prerelease 126 12/20/2022
7.0.0.1-prerelease 114 12/19/2022