Skip to content

Commit 0e7244a

Browse files
committed
WAF: TraceSourceExtensions: Enable AggressiveInlining for better performance
1 parent 71be805 commit 0e7244a

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/System.Waf/System.Waf/System.Waf.Core/Foundation/TraceSourceExtensions.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.ComponentModel;
22
using System.Diagnostics;
3+
using System.Runtime.CompilerServices;
34

45
namespace System.Waf.Foundation
56
{
@@ -9,6 +10,7 @@ public static class TraceSourceExtensions
910
/// <summary>Indicates, if a log message of type Trace (Verbose) will be processed.</summary>
1011
/// <param name="traceSource">The trace source.</param>
1112
/// <returns>Indicates, if a log message of type Trace (Verbose) will be processed.</returns>
13+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1214
public static bool IsTraceEnabled(this TraceSource traceSource)
1315
{
1416
if (traceSource is null) throw new ArgumentNullException(nameof(traceSource));
@@ -18,6 +20,7 @@ public static bool IsTraceEnabled(this TraceSource traceSource)
1820
/// <summary>Indicates, if a log message of type Information will be processed.</summary>
1921
/// <param name="traceSource">The trace source.</param>
2022
/// <returns>Indicates, if a log message of type Information will be processed.</returns>
23+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2124
public static bool IsInfoEnabled(this TraceSource traceSource)
2225
{
2326
if (traceSource is null) throw new ArgumentNullException(nameof(traceSource));
@@ -27,6 +30,7 @@ public static bool IsInfoEnabled(this TraceSource traceSource)
2730
/// <summary>Indicates, if a log message of type Warning will be processed.</summary>
2831
/// <param name="traceSource">The trace source.</param>
2932
/// <returns>Indicates, if a log message of type Warning will be processed.</returns>
33+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3034
public static bool IsWarnEnabled(this TraceSource traceSource)
3135
{
3236
if (traceSource is null) throw new ArgumentNullException(nameof(traceSource));
@@ -36,6 +40,7 @@ public static bool IsWarnEnabled(this TraceSource traceSource)
3640
/// <summary>Indicates, if a log message of type Error will be processed.</summary>
3741
/// <param name="traceSource">The trace source.</param>
3842
/// <returns>Indicates, if a log message of type Error will be processed.</returns>
43+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3944
public static bool IsErrorEnabled(this TraceSource traceSource)
4045
{
4146
if (traceSource is null) throw new ArgumentNullException(nameof(traceSource));
@@ -45,6 +50,7 @@ public static bool IsErrorEnabled(this TraceSource traceSource)
4550
/// <summary>Log a message of type Trace (Verbose).</summary>
4651
/// <param name="traceSource">The trace source.</param>
4752
/// <param name="message">The log message.</param>
53+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
4854
public static void Trace(this TraceSource traceSource, [Localizable(false)] string message)
4955
{
5056
if (IsTraceEnabled(traceSource)) traceSource.TraceEvent(TraceEventType.Verbose, 0, message);
@@ -54,6 +60,7 @@ public static void Trace(this TraceSource traceSource, [Localizable(false)] stri
5460
/// <param name="traceSource">The trace source.</param>
5561
/// <param name="format">A composite format string.</param>
5662
/// <param name="arguments">An object array that contains zero or more objects to format.</param>
63+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
5764
public static void Trace(this TraceSource traceSource, [Localizable(false)] string format, params object?[] arguments)
5865
{
5966
if (IsTraceEnabled(traceSource)) traceSource.TraceEvent(TraceEventType.Verbose, 0, format, arguments);
@@ -62,6 +69,7 @@ public static void Trace(this TraceSource traceSource, [Localizable(false)] stri
6269
/// <summary>Log a message of type Information.</summary>
6370
/// <param name="traceSource">The trace source.</param>
6471
/// <param name="message">The log message.</param>
72+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
6573
public static void Info(this TraceSource traceSource, [Localizable(false)] string message)
6674
{
6775
if (IsInfoEnabled(traceSource)) traceSource.TraceEvent(TraceEventType.Information, 0, message);
@@ -71,6 +79,7 @@ public static void Info(this TraceSource traceSource, [Localizable(false)] strin
7179
/// <param name="traceSource">The trace source.</param>
7280
/// <param name="format">A composite format string.</param>
7381
/// <param name="arguments">An object array that contains zero or more objects to format.</param>
82+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
7483
public static void Info(this TraceSource traceSource, [Localizable(false)] string format, params object?[] arguments)
7584
{
7685
if (IsInfoEnabled(traceSource)) traceSource.TraceEvent(TraceEventType.Information, 0, format, arguments);
@@ -79,6 +88,7 @@ public static void Info(this TraceSource traceSource, [Localizable(false)] strin
7988
/// <summary>Log a message of type Warning.</summary>
8089
/// <param name="traceSource">The trace source.</param>
8190
/// <param name="message">The log message.</param>
91+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
8292
public static void Warn(this TraceSource traceSource, [Localizable(false)] string message)
8393
{
8494
if (IsWarnEnabled(traceSource)) traceSource.TraceEvent(TraceEventType.Warning, 0, message);
@@ -88,6 +98,7 @@ public static void Warn(this TraceSource traceSource, [Localizable(false)] strin
8898
/// <param name="traceSource">The trace source.</param>
8999
/// <param name="format">A composite format string.</param>
90100
/// <param name="arguments">An object array that contains zero or more objects to format.</param>
101+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
91102
public static void Warn(this TraceSource traceSource, [Localizable(false)] string format, params object?[] arguments)
92103
{
93104
if (IsWarnEnabled(traceSource)) traceSource.TraceEvent(TraceEventType.Warning, 0, format, arguments);
@@ -96,6 +107,7 @@ public static void Warn(this TraceSource traceSource, [Localizable(false)] strin
96107
/// <summary>Log a message of type Error.</summary>
97108
/// <param name="traceSource">The trace source.</param>
98109
/// <param name="message">The log message.</param>
110+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
99111
public static void Error(this TraceSource traceSource, [Localizable(false)] string message)
100112
{
101113
if (IsErrorEnabled(traceSource)) traceSource.TraceEvent(TraceEventType.Error, 0, message);
@@ -105,6 +117,7 @@ public static void Error(this TraceSource traceSource, [Localizable(false)] stri
105117
/// <param name="traceSource">The trace source.</param>
106118
/// <param name="format">A composite format string.</param>
107119
/// <param name="arguments">An object array that contains zero or more objects to format.</param>
120+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
108121
public static void Error(this TraceSource traceSource, [Localizable(false)] string format, params object?[] arguments)
109122
{
110123
if (IsErrorEnabled(traceSource)) traceSource.TraceEvent(TraceEventType.Error, 0, format, arguments);

0 commit comments

Comments
 (0)