All Projects → Suchiman → Seriloganalyzer

Suchiman / Seriloganalyzer

Licence: apache-2.0
Roslyn-based analysis for code using the Serilog logging library. Checks for common mistakes and usage problems.

Projects that are alternatives of or similar to Seriloganalyzer

Security Code Scan
Vulnerability Patterns Detector for C# and VB.NET
Stars: ✭ 550 (+157.01%)
Mutual labels:  analysis, roslyn, analyzer
Sonar Java
☕️ SonarSource Static Analyzer for Java Code Quality and Security
Stars: ✭ 745 (+248.13%)
Mutual labels:  analysis, analyzer
Cortex
Cortex: a Powerful Observable Analysis and Active Response Engine
Stars: ✭ 676 (+215.89%)
Mutual labels:  analysis, analyzer
Social Analyzer
API, CLI & Web App for analyzing & finding a person's profile across +1000 social media \ websites (Detections are updated regularly by automated systems)
Stars: ✭ 8,449 (+3848.13%)
Mutual labels:  analyzer, analysis
Codeconverter
Convert code from C# to VB.NET and vice versa using Roslyn
Stars: ✭ 432 (+101.87%)
Mutual labels:  roslyn, visual-studio
Phan
Phan is a static analyzer for PHP. Phan prefers to avoid false-positives and attempts to prove incorrectness rather than correctness.
Stars: ✭ 5,194 (+2327.1%)
Mutual labels:  analysis, analyzer
Meziantou.analyzer
A Roslyn analyzer to enforce some good practices in C#.
Stars: ✭ 189 (-11.68%)
Mutual labels:  roslyn, analyzer
pingnoo
An open-source cross-platform traceroute/ping analyser.
Stars: ✭ 149 (-30.37%)
Mutual labels:  analysis, analyzer
Uno.sourcegeneration
A Roslyn based C# source generation framework
Stars: ✭ 99 (-53.74%)
Mutual labels:  roslyn, visual-studio
Stack Trace Explorer
Stack Trace Explorer is a Visual Studio plug-in that pretty prints a stack trace by turning types, methods, and paths into hyper links
Stars: ✭ 100 (-53.27%)
Mutual labels:  roslyn, visual-studio
Bridge
♠️ C# to JavaScript compiler. Write modern mobile and web apps in C#. Run anywhere with Bridge.NET.
Stars: ✭ 2,216 (+935.51%)
Mutual labels:  roslyn, visual-studio
fsharp-linting-for-vs
Visual Studio Linter for F#
Stars: ✭ 33 (-84.58%)
Mutual labels:  visual-studio, analyzer
Ref12
Sends F12 in Visual Studio to the new .Net Reference Source Browser
Stars: ✭ 76 (-64.49%)
Mutual labels:  visual-studio, roslyn
Codist
A visual studio extension which enhances syntax highlighting, quick info (tooltip), navigation bar, scrollbar, display quality and brings smart tool bar to code editor.
Stars: ✭ 134 (-37.38%)
Mutual labels:  visual-studio, roslyn
Dotnetomdgenerator
A Roslyn-based cross-platform tool that generates an object model diagram from a set of C# source files or assemblies
Stars: ✭ 160 (-25.23%)
Mutual labels:  roslyn, analyzer
Mappinggenerator
🔄 "AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time.
Stars: ✭ 831 (+288.32%)
Mutual labels:  roslyn, visual-studio
spring-startup-analysis
Simple module to analyse bean construction in Java Spring
Stars: ✭ 76 (-64.49%)
Mutual labels:  analysis, analyzer
custom-bytecode-analyzer
Java bytecode analyzer customizable via JSON rules
Stars: ✭ 66 (-69.16%)
Mutual labels:  analysis, analyzer
Dart Code Metrics
Software analytics tool that helps developers analyse and improve software quality.
Stars: ✭ 96 (-55.14%)
Mutual labels:  analysis, analyzer
Analyzer
🔍 Offline Analyzer for extracting features, artifacts and IoCs from Windows, Linux, Android, iPhone, Blackberry, macOS binaries, emails and more
Stars: ✭ 108 (-49.53%)
Mutual labels:  analysis, analyzer

SerilogAnalyzer

Roslyn-based analysis for code using the Serilog logging library. Checks for common mistakes and usage problems.

SerilogAnalyzer

Installing (Visual Studio)

You can get the SerilogAnalyzer from various sources:

Analyses

Serilog001: Exception Usage

Checks that exceptions are passed to the exception argument, and not as a normal property, with a code fix to correct it.

Detected incorrect usage:

catch (Exception ex)
{
   Log.Error("Could not save {File}: {Error}", file, ex);
}

The ex parameter is an exception, which Serilog has special handling for if passed as the first argument.

Correct usage:

catch (Exception ex)
{
   Log.Error(ex, "Could not save {File}", file);
}

Serilog002: Message Template Syntax Verifier

Checks message templates for correct syntax and emits an error if there's a violation of the templating syntax.

Detected incorrect usage:

Log.Information("Saving {File to {Directory}", file, directory);

The first property token in the message template, File, is malformed.

Correct usage:

Log.Information("Saving {File} to {Directory}", file, directory);

Serilog003: Property Binding Verifier

Checks coherence between the message template tokens and the supplied arguments.

Detected incorrect usage:

Log.Information("Saving {File} to {Directory}", file);

Here the number of arguments passed to the method (1) is less than the number of tokens in the message template (2), so the second token in the message template, {Directory}, will have no value.

Correct usage:

Log.Information("Saving {File} to {Directory}", file, directory);

Each property named in the message template needs to correspond to exactly one argument.

Serilog004: Constant Message Template Verifier

Checks that message templates are constant strings. This ensures that events with different data/format arguments can still be detected as instances of the same event.

Detected incorrect usage:

var errorMessage = TryToCheckOutOrder(...); // etc.
Log.Error(errorMessage);

Because errorMessage generally contains failure-specific text ("Couldn't find order 123" ... then 124, then 125) the group of occurrences can't be located using the message template/event type.

This also degrades Serilog performance by filling its internal message template cache.

Correct usage:

Log.Error("Order handler failed with {HandlerError}", errorMessage);

Correct usage is to always pass any variable data as a property to a message template. A CodeFix is provided that converts string interpolation ($"{...}"), String.Format(...) and string concat ("value: " + value) to a message template

Serilog005: Unique Property Name Verifier

Checks that all property names in a message template are unique.

Detected incorrect usage:

Log.Information("Saving {Path} to {Path}", file, directory); 

In this example, because both properties in the message template have the same name, Serilog can only record one of them.

Correct usage:

Log.Information("Saving {File} to {Directory}", file, directory); 

Each property in a message template must have a unique name.

Serilog006: Pascal Cased Property Verifier

Checks that all property names in a message template are PascalCased.

Detected incorrect usage:

Log.Information("Saving {file} to {directory}", file, directory); 

A CodeFix is provided, that applies pascal casing.

Correct usage:

Log.Information("Saving {File} to {Directory}", file, directory); 

Serilog007: Anonymous objects use destructuring Verifier

Checks that all anonymous objects passed to the logger are destructured.

Detected incorrect usage:

Log.Information("Saving {File} to {Directory}", new { Name = name, Size = size }, directory); 

A CodeFix is provided, that applies the destructuring hint.

Correct usage:

Log.Information("Saving {@File} to {Directory}", new { Name = name, Size = size }, directory); 

Serilog008: Correct contextual Logger Verifier

Checks that contextual loggers are constructed with the correct type.

Detected incorrect usage:

class A
{
    private static readonly ILogger Logger = Logger.ForContext<B>();
}

class B {}

A CodeFix is provided, that uses the correct type.

Correct usage:

class A
{
    private static readonly ILogger Logger = Logger.ForContext<A>();
}

class B {} 

Refactors

Performs static analysis on a fluent LoggerConfiguration call to generate configuration for use with either <appSettings> or appSettings.json

Serilog Configuration Refactoring

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].