ProfileSharp 7.0.0.2-prerelease
See the version list below for details.
dotnet add package ProfileSharp --version 7.0.0.2-prerelease
NuGet\Install-Package ProfileSharp -Version 7.0.0.2-prerelease
<PackageReference Include="ProfileSharp" Version="7.0.0.2-prerelease" />
paket add ProfileSharp --version 7.0.0.2-prerelease
#r "nuget: ProfileSharp, 7.0.0.2-prerelease"
// Install ProfileSharp as a Cake Addin #addin nuget:?package=ProfileSharp&version=7.0.0.2-prerelease&prerelease // Install ProfileSharp as a Cake Tool #tool nuget:?package=ProfileSharp&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 | ||
ProfileSharp.AspNetCore | ||
ProfileSharp.NServiceBus | ||
ProfileSharp.Store.FileStore |
Product | Versions 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. |
-
.NETStandard 2.1
- Castle.Core (>= 5.1.0)
- Microsoft.Extensions.DependencyInjection (>= 5.0.0)
- System.Text.Json (>= 5.0.0)
-
net5.0
- Castle.Core (>= 5.1.0)
- Microsoft.Extensions.DependencyInjection (>= 5.0.0)
- System.Text.Json (>= 5.0.0)
-
net6.0
- Castle.Core (>= 5.1.0)
- Microsoft.Extensions.DependencyInjection (>= 6.0.0)
- System.Text.Json (>= 6.0.0)
-
net7.0
- Castle.Core (>= 5.1.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
- System.Text.Json (>= 7.0.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on ProfileSharp:
Package | Downloads |
---|---|
ProfileSharp.AspNetCore
Automate the process of mocking, testing, and profiling your .Net application. |
|
ProfileSharp.Store.FileStore
Automate the process of mocking, testing, and profiling your .Net application. |
|
ProfileSharp.NServiceBus
Automate the process of mocking, testing, and profiling your .Net application. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
7.0.0.3-prerelease | 130 | 12/21/2022 |
7.0.0.2-prerelease | 119 | 12/20/2022 |
7.0.0.1-prerelease | 111 | 12/19/2022 |