-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from sungam3r/api
Add API approval test
- Loading branch information
Showing
4 changed files
with
91 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#if NET7_0 | ||
|
||
using PublicApiGenerator; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace Serilog.Extensions.Logging.Tests; | ||
|
||
public class ApiApprovalTests | ||
{ | ||
[Fact] | ||
public void PublicApi_Should_Not_Change_Unintentionally() | ||
{ | ||
var assembly = typeof(LoggerSinkConfigurationExtensions).Assembly; | ||
var publicApi = assembly.GeneratePublicApi( | ||
new() | ||
{ | ||
IncludeAssemblyAttributes = false, | ||
ExcludeAttributes = new[] { "System.Diagnostics.DebuggerDisplayAttribute" }, | ||
}); | ||
|
||
publicApi.ShouldMatchApproved(options => options.WithFilenameGenerator((_, _, fileType, fileExtension) => $"{assembly.GetName().Name!}.{fileType}.{fileExtension}")); | ||
} | ||
} | ||
|
||
#endif |
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
46 changes: 46 additions & 0 deletions
46
test/Serilog.Extensions.Logging.Tests/Serilog.Extensions.Logging.approved.txt
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,46 @@ | ||
namespace Serilog.Extensions.Logging | ||
{ | ||
public static class LevelConvert | ||
{ | ||
public static Microsoft.Extensions.Logging.LogLevel ToExtensionsLevel(Serilog.Events.LogEventLevel logEventLevel) { } | ||
public static Serilog.Events.LogEventLevel ToSerilogLevel(Microsoft.Extensions.Logging.LogLevel logLevel) { } | ||
} | ||
public class LoggerProviderCollection : System.IDisposable | ||
{ | ||
public LoggerProviderCollection() { } | ||
public System.Collections.Generic.IEnumerable<Microsoft.Extensions.Logging.ILoggerProvider> Providers { get; } | ||
public void AddProvider(Microsoft.Extensions.Logging.ILoggerProvider provider) { } | ||
public void Dispose() { } | ||
} | ||
public class SerilogLoggerFactory : Microsoft.Extensions.Logging.ILoggerFactory, System.IDisposable | ||
{ | ||
public SerilogLoggerFactory(Serilog.ILogger? logger = null, bool dispose = false, Serilog.Extensions.Logging.LoggerProviderCollection? providerCollection = null) { } | ||
public void AddProvider(Microsoft.Extensions.Logging.ILoggerProvider provider) { } | ||
public Microsoft.Extensions.Logging.ILogger CreateLogger(string categoryName) { } | ||
public void Dispose() { } | ||
} | ||
[Microsoft.Extensions.Logging.ProviderAlias("Serilog")] | ||
public class SerilogLoggerProvider : Microsoft.Extensions.Logging.ILoggerProvider, Serilog.Core.ILogEventEnricher, System.IDisposable | ||
{ | ||
public SerilogLoggerProvider(Serilog.ILogger? logger = null, bool dispose = false) { } | ||
public System.IDisposable BeginScope<T>(T state) { } | ||
public Microsoft.Extensions.Logging.ILogger CreateLogger(string name) { } | ||
public void Dispose() { } | ||
public void Enrich(Serilog.Events.LogEvent logEvent, Serilog.Core.ILogEventPropertyFactory propertyFactory) { } | ||
} | ||
} | ||
namespace Serilog | ||
{ | ||
public static class LoggerSinkConfigurationExtensions | ||
{ | ||
public static Serilog.LoggerConfiguration Providers(this Serilog.Configuration.LoggerSinkConfiguration configuration, Serilog.Extensions.Logging.LoggerProviderCollection providers, Serilog.Events.LogEventLevel restrictedToMinimumLevel = 0, Serilog.Core.LoggingLevelSwitch? levelSwitch = null) { } | ||
} | ||
public static class SerilogLoggerFactoryExtensions | ||
{ | ||
public static Microsoft.Extensions.Logging.ILoggerFactory AddSerilog(this Microsoft.Extensions.Logging.ILoggerFactory factory, Serilog.ILogger? logger = null, bool dispose = false) { } | ||
} | ||
public static class SerilogLoggingBuilderExtensions | ||
{ | ||
public static Microsoft.Extensions.Logging.ILoggingBuilder AddSerilog(this Microsoft.Extensions.Logging.ILoggingBuilder builder, Serilog.ILogger? logger = null, bool dispose = false) { } | ||
} | ||
} |