https://github.com/swisslife-oss/thor-analyzer
An ETW EventSource analyzer build on .Net Standard 2.0
https://github.com/swisslife-oss/thor-analyzer
analyzer c-sharp diagnostics dotnet etw eventsource eventsource-analyzer logging tracing
Last synced: 2 months ago
JSON representation
An ETW EventSource analyzer build on .Net Standard 2.0
- Host: GitHub
- URL: https://github.com/swisslife-oss/thor-analyzer
- Owner: SwissLife-OSS
- License: mit
- Created: 2017-07-05T08:50:39.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-10-20T07:17:41.000Z (over 4 years ago)
- Last Synced: 2025-07-12T03:31:34.368Z (12 months ago)
- Topics: analyzer, c-sharp, diagnostics, dotnet, etw, eventsource, eventsource-analyzer, logging, tracing
- Language: C#
- Homepage:
- Size: 229 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Thor Analyzer
[](https://github.com/ChilliCream/thor-analyzer/releases) [](https://www.nuget.org/packages/Thor.Analyzer) [](https://github.com/ChilliCream/thor-analyzer/blob/master/LICENSE) [](https://ci.appveyor.com/project/rstaib/thor-analyzer) [](https://ci.appveyor.com/project/rstaib/thor-analyzer) [](https://coveralls.io/github/ChilliCream/thor-analyzer?branch=master)
An analyzer for *ETW* (Event Tracing for Windows) event sources which helps reveal frequent mistakes and also guides in best practices rules.
## Getting Started
Getting started in two steps. Install the *NuGet* package and start writing code. That´s it.
### Install Package
Before we start we have to decide which package would be the right choice for our project. If we work with the `System.Diagnostics.Tracing` namespace in combination with *.Net* 4.6.1 or higher, we might be well adviced by using the `Thor.Analyzer` package. But if we use the `Microsoft.Diagnostics.Tracing` namespace in combination with *.Net* 4.5.1 or higher instead, we should choose the `Thor.Analyzer.Legacy` package.
In summary, can be stated that newer projects using the `System.Diagnostics.Tracing` namespace should install the `Thor.Analyzer` package. See the following Powershell script.
```powershell
Install-Package Thor.Analyzer
```
Therefore, older projects using the `Microsoft.Diagnostics.Tracing` namespace should install the `Thor.Analyzer.Legacy` package. See the following Powershell script.
```powershell
Install-Package Thor.Analyzer.Legacy
```
### Basic Example
This example shows a simple tercet.
```csharp
MyCustomEventSource eventSource = new MyCustomEventSource();
EventSourceAnalyzer analyzer = new EventSourceAnalyzer();
Report report = analyzer.Inspect(eventSource);
```
The report contains all the important information we need. If we want to know whether the event schema contains any errors, we can do so by checking the `HasErrors` property.
### Automated Test Example
This example shows how to automate the analysis of event sources. For this example we used *xUnit*, but any other test framework will work pretty much the same.
```csharp
[Fact(DisplayName = "Should not contain any error")]
public void Analyze()
{
// Arrange
MyCustomEventSource eventSource = MyCustomEventSource.Log;
EventSourceAnalyzer analyzer = new EventSourceAnalyzer();
// Act
Report report = analyzer.Inspect(eventSource);
// Assert
Assert.False(report.HasErrors);
}
```
## Documentation
Click [here](https://github.com/ChilliCream/thor-analyzer-docs) to get to the documentation home of *Thor Analyzer*.
## Checkout the Thor Generator
In most scenarios we recommend to use the *Thor Generator* to generate event sources automatically. Thus, the critical parts are generated in an efficient way by the generator. Click [here](https://github.com/ChilliCream/thor-generator) to get more information about the *Thor Generator*.