File tree Expand file tree Collapse file tree 3 files changed +21
-14
lines changed
Expand file tree Collapse file tree 3 files changed +21
-14
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 33// Licensed under the MIT license.
44//
55
6+ using System ;
7+
68namespace Ical . Net . Logging . Internal ;
79
810/// <summary>
911/// Provides a no-operation implementation of <see cref="ILoggerFactory"/> that produces <see cref="NullLogger"/>
1012/// instances. This factory is intended for scenarios where logging is not required or should be disabled.
1113/// </summary>
12- internal class NullLoggerFactory : ILoggerFactory
14+ internal sealed class NullLoggerFactory : ILoggerFactory
1315{
16+ private bool _disposed ;
17+
1418 /// <summary>
1519 /// Provides a singleton instance of a <see cref="NullLoggerFactory"/> that produces no-op loggers.
1620 /// </summary>
@@ -25,9 +29,22 @@ private NullLoggerFactory() { }
2529 /// <returns>A <see cref="NullLogger.Instance"/></returns>
2630 public ILogger CreateLogger ( string categoryName ) => NullLogger . Instance ;
2731
32+ private void Dispose ( bool _ ) //NOSONAR
33+ {
34+ if ( _disposed ) return ;
35+ // No resources to release, implement IDisposable pattern for consistency
36+ _disposed = true ;
37+ }
38+
2839 /// <inheritdoc/>
2940 public void Dispose ( )
3041 {
31- // no-op
42+ Dispose ( true ) ;
43+ GC . SuppressFinalize ( this ) ;
44+ }
45+
46+ ~ NullLoggerFactory ( )
47+ {
48+ Dispose ( false ) ;
3249 }
3350}
Original file line number Diff line number Diff line change @@ -53,11 +53,11 @@ internal static ILogger CreateLogger(string categoryName)
5353 => ( _loggerFactory . Value ?? NullLoggerFactory . Instance ) . CreateLogger ( categoryName ) ;
5454
5555 /// <summary>
56- /// Gets an <see cref="ILogger{T} "/> instance for the specified type.
56+ /// Gets an <see cref="ILogger"/> instance for the specified type.
5757 /// The category name will be the full name of the type T.
5858 /// </summary>
5959 /// <typeparam name="T">The type for which to create the logger.</typeparam>
60- /// <returns>An <see cref="ILogger{T} "/> instance.</returns>
60+ /// <returns>An <see cref="ILogger"/> instance.</returns>
6161 internal static ILogger CreateLogger < T > ( )
6262 => new Logger < T > ( _loggerFactory . Value ?? NullLoggerFactory . Instance ) ;
6363
You can’t perform that action at this time.
0 commit comments