WebVella.BlazorTrace
1.0.7
dotnet add package WebVella.BlazorTrace --version 1.0.7
NuGet\Install-Package WebVella.BlazorTrace -Version 1.0.7
<PackageReference Include="WebVella.BlazorTrace" Version="1.0.7" />
<PackageVersion Include="WebVella.BlazorTrace" Version="1.0.7" />
<PackageReference Include="WebVella.BlazorTrace" />
paket add WebVella.BlazorTrace --version 1.0.7
#r "nuget: WebVella.BlazorTrace, 1.0.7"
#addin nuget:?package=WebVella.BlazorTrace&version=1.0.7
#tool nuget:?package=WebVella.BlazorTrace&version=1.0.7
What is BlazorTrace?
An easy to add library that will enable you to get detailed information about your Blazor components rerenders and memory, as well as compare it with different snapshots that you created. It is targeting Blazor UI developers and presents the information in a simple and focused way. BlazorTrace will help you build better, faster and more consistent user experience with your Blazor applications.
About Us
We are a small team of early Blazor adopters that created several complex Blazor applications that work in production. We prefer working with WebAssembly deployments but SSR is getting a favorite fast. We have 15+ experience in creating .net projects. Here is some examples of our work
WebVella ERP | ||
Document Templates Library | ||
Tefter |
How to get it
You can either clone this repository or get the Nuget package
Please help by giving a star
GitHub stars guide developers toward great tools. If you find this project valuable, please give it a star – it helps the community and takes just a second!⭐
Documentation
You can find our documentation in the Wiki section of this repository
Get Started
To start using BlazorTrace you need to do the following simple steps:
- Add the latest version of the WebVella.BlazorTrace Nuget package to your component holding project
- Add the latest version of the MethodDecorator.Fody Nuget package to your component holding project
- Add the following lines in your
Program.cs
file. You can get more info about options to fine tune it in the wiki.
[module: WvBlazorTrace] //<-- This is important to be before the namespace declaration
namespace Your.Name.Space;
//code...
builder.Services.AddBlazorTrace();
#if DEBUG
//Snapshots require bigger hub message size
builder.Services.Configure<HubOptions>(options =>
{
options.MaximumReceiveMessageSize = 10 * 1024 * 1024; // 10MB
});
//To get the message size error if it got bigger than the above
builder.Services.AddSignalR(o =>
{
o.EnableDetailedErrors = true;
});
#endif
//code...
- Add
FodyWeavers.xml
file at the root of your component poject with the following content
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<MethodDecorator AsyncMethods="true" />
</Weavers>
- Add the BlazorTrace component at the end of your
App.razor
orRoutes.razor
component
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
</Router>
<WvBlazorTrace/> @* <-- INSERT HERE *@
- (BASIC) Add tracers in your components or methods. Decorate a method or a component class with the attribute
[WvBlazorTrace]
// if razor component without code behind
@attribute [WvBlazorTrace]
// if razor.cs code behind you can decorate the entire class
[WvBlazorTrace]
public partial class Test1 : ComponentBase
{
//code...
}
// if razor.cs code behind you can decorate only several methods you need traced
public partial class Test1 : ComponentBase
{
[WvBlazorTrace]
private void _countTest1(){}
}
- (ADVANCED) Add tracers with options that can be dynamically set. For all options, visit our wiki.
[Inject] public IWvBlazorTraceService WvBlazorTraceService { get; set; } = default!;
[Parameter] public string? InstanceTag { get; set; }
protected override void OnInitialized()
{
WvBlazorTraceService.OnEnter(component: this, instanceTag: InstanceTag);
base.OnInitialized();
//Do something
WvBlazorTraceService.OnExit(component: this, instanceTag: InstanceTag);
}
- Add signals in your methods. They are a way to track events in your components or look in details about what and how is going on. There are several arguments that you can call them with, but here is an example with the only required one (component):
[Inject] public IWvBlazorTraceService WvBlazorTraceService { get; set; } = default!;
private void _countTest()
{
_counter++;
WvBlazorTraceService.OnSignal(caller: this, signalName: "counter");
}
- Thats it. You can start reviewing the data. PRO TIP: Use the F1 (show) and Esc (hide) to save time.
Method OnEnter/OnExit call information
Log signals information
Trace calls detail information
Memory detail information
Limit hits
Snapshots
Muted traces
License
BlazorTrace is distributed under the MIT license.
Acknowledgments
BlazorTrace wouldn't be possible without the incredible encouragement and support of amazing people and communities. Thanks to all of you!
jhsheets
For being our fist contributor and thus boosting our motivation to make BlazorTrace better.
LlamaNL
He saved time to all of us, by finding a way how to create faster tracer intergation with an Attribute and FODY
Tension-Maleficent
For helping with the FODY implementation
/r/dotnet, /r/Blazor, /r/csharp
These Reddit communities are home to incredibly welcoming and knowledgeable people, always ready to offer help with questions, problems, or advice.
Product | Versions 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 is compatible. 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. |
-
net8.0
- Backport.System.Threading.Lock (>= 3.1.4)
- MethodDecorator.Fody (>= 1.1.1)
- Microsoft.AspNetCore.Components.Web (= 8.0.16)
-
net9.0
- Backport.System.Threading.Lock (>= 3.1.4)
- MethodDecorator.Fody (>= 1.1.1)
- Microsoft.AspNetCore.Components.Web (>= 9.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release