generated from nventive/Template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use LoggerMessage to improve performance and reduce memory allo…
…cations.
- Loading branch information
1 parent
24e3883
commit ffc85e6
Showing
30 changed files
with
226 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/DynamicMvvm.Abstractions/LoggerMessages.Abstractions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Chinook.DynamicMvvm | ||
{ | ||
internal static partial class LoggerMessagesAbstractions | ||
{ | ||
[LoggerMessage(101, LogLevel.Warning, "Resolving property '{ViewModelTypeName}.{PropertyName}' using reflection on '{ViewModelName}'.")] | ||
public static partial void LogViewModelResolvingPropertyUsingReflection(this ILogger logger, string viewModelTypeName, string propertyName, string viewModelName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
using BenchmarkDotNet.Running; | ||
using DynamicMvvm.Benchmarks; | ||
using Chinook.DynamicMvvm; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
BenchmarkRunner.Run<Benchmark>(); | ||
|
||
// The following section is to profile manually using Visual Studio's debugger. | ||
|
||
//var serviceProvider = new HostBuilder() | ||
// .ConfigureServices(serviceCollection => serviceCollection | ||
// .AddSingleton<IDynamicCommandBuilderFactory, DynamicCommandBuilderFactory>() | ||
// .AddSingleton<IDynamicPropertyFactory, DynamicPropertyFactory>() | ||
// ) | ||
// .Build() | ||
// .Services; | ||
|
||
//var vm1 = new ViewModel("ViewModel", serviceProvider); | ||
//var vm2 = new ViewModel("ViewModel", serviceProvider); | ||
|
||
//Console.Read(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/DynamicMvvm.FluentValidation/LoggerMessages.FluentValidation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Chinook.DynamicMvvm | ||
{ | ||
internal static partial class LoggerMessages | ||
{ | ||
[LoggerMessage(201, LogLevel.Error, "Validation failed for property '{PropertyName}'.")] | ||
public static partial void LogValidationFailed(this ILogger logger, string propertyName, Exception exception); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Chinook.DynamicMvvm | ||
{ | ||
internal static partial class LoggerMessagesReactive | ||
{ | ||
[LoggerMessage(301, LogLevel.Debug, "Deactivated observable of type '{TypeName}'.")] | ||
public static partial void LogDeactivatedObservable(this ILogger logger, string typeName); | ||
|
||
[LoggerMessage(302, LogLevel.Debug, "Reactivated observable of type '{TypeName}'.")] | ||
public static partial void LogReactivatedObservable(this ILogger logger, string typeName); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Chinook.DynamicMvvm | ||
{ | ||
internal static partial class LoggerMessagesUnoWinUI | ||
{ | ||
[LoggerMessage(401, LogLevel.Debug, "Cancelled 'ExecuteOnDispatcher' because of the cancellation token.")] | ||
public static partial void LogCancelledExecuteOnDispatcherBecauseOfCancellationToken(this ILogger logger); | ||
|
||
[LoggerMessage(402, LogLevel.Debug, "Executed action immediately because already on dispatcher.")] | ||
public static partial void LogExecutedActionImmediatelyBecauseAlreadyOnDispatcher(this ILogger logger); | ||
|
||
[LoggerMessage(403, LogLevel.Debug, "Batched {RequestCount} dispatcher requests.")] | ||
public static partial void LogBatchedDispatcherRequests(this ILogger logger, int requestCount); | ||
|
||
[LoggerMessage(404, LogLevel.Error, "Failed 'ExecuteOnDispatcher'.")] | ||
public static partial void LogFailedExecuteOnDispatcher(this ILogger logger, Exception exception); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.