Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API approval test #361

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
Expand Down Expand Up @@ -200,7 +200,4 @@ FakesAssemblies/

project.lock.json

#Test files
*.txt

artifacts/
25 changes: 25 additions & 0 deletions test/Serilog.Settings.Configuration.Tests/ApiApprovalTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#if NET7_0

using PublicApiGenerator;
using Shouldly;

namespace Serilog.Settings.Configuration.Tests;

public class ApiApprovalTests
{
[Fact]
public void PublicApi_Should_Not_Change_Unintentionally()
{
var assembly = typeof(ConfigurationReaderOptions).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
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="17.5.0" />
<PackageReference Include="Serilog.Expressions" Version="3.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="Shouldly" Version="4.1.0" />
<PackageReference Include="PublicApiGenerator" Version="11.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
namespace Serilog
{
public static class ConfigurationLoggerConfigurationExtensions
{
public const string DefaultSectionName = "Serilog";
[System.Obsolete("Use ReadFrom.Configuration(IConfiguration configuration, ConfigurationReaderOptio" +
"ns readerOptions) instead.")]
public static Serilog.LoggerConfiguration Configuration(this Serilog.Configuration.LoggerSettingsConfiguration settingConfiguration, Microsoft.Extensions.Configuration.IConfiguration configuration, Microsoft.Extensions.DependencyModel.DependencyContext dependencyContext) { }
[System.Obsolete("Use ReadFrom.Configuration(IConfiguration configuration, ConfigurationReaderOptio" +
"ns readerOptions) instead.")]
public static Serilog.LoggerConfiguration Configuration(this Serilog.Configuration.LoggerSettingsConfiguration settingConfiguration, Microsoft.Extensions.Configuration.IConfiguration configuration, Serilog.Settings.Configuration.ConfigurationAssemblySource configurationAssemblySource) { }
public static Serilog.LoggerConfiguration Configuration(this Serilog.Configuration.LoggerSettingsConfiguration settingConfiguration, Microsoft.Extensions.Configuration.IConfiguration configuration, Serilog.Settings.Configuration.ConfigurationReaderOptions readerOptions = null) { }
[System.Obsolete("Use ReadFrom.Configuration(IConfiguration configuration, ConfigurationReaderOptio" +
"ns readerOptions) instead.")]
public static Serilog.LoggerConfiguration Configuration(this Serilog.Configuration.LoggerSettingsConfiguration settingConfiguration, Microsoft.Extensions.Configuration.IConfiguration configuration, params System.Reflection.Assembly[] assemblies) { }
[System.Obsolete("Use ReadFrom.Configuration(IConfiguration configuration, ConfigurationReaderOptio" +
"ns readerOptions) instead.")]
public static Serilog.LoggerConfiguration Configuration(this Serilog.Configuration.LoggerSettingsConfiguration settingConfiguration, Microsoft.Extensions.Configuration.IConfiguration configuration, string sectionName, Microsoft.Extensions.DependencyModel.DependencyContext dependencyContext = null) { }
[System.Obsolete("Use ReadFrom.Configuration(IConfiguration configuration, ConfigurationReaderOptio" +
"ns readerOptions) instead.")]
public static Serilog.LoggerConfiguration Configuration(this Serilog.Configuration.LoggerSettingsConfiguration settingConfiguration, Microsoft.Extensions.Configuration.IConfiguration configuration, string sectionName, Serilog.Settings.Configuration.ConfigurationAssemblySource configurationAssemblySource) { }
[System.Obsolete("Use ReadFrom.Configuration(IConfiguration configuration, ConfigurationReaderOptio" +
"ns readerOptions) instead.")]
public static Serilog.LoggerConfiguration Configuration(this Serilog.Configuration.LoggerSettingsConfiguration settingConfiguration, Microsoft.Extensions.Configuration.IConfiguration configuration, string sectionName, params System.Reflection.Assembly[] assemblies) { }
[System.Obsolete("Use ReadFrom.Configuration(IConfiguration configuration, string sectionName, Depe" +
"ndencyContext dependencyContext) instead.")]
public static Serilog.LoggerConfiguration ConfigurationSection(this Serilog.Configuration.LoggerSettingsConfiguration settingConfiguration, Microsoft.Extensions.Configuration.IConfigurationSection configSection, Microsoft.Extensions.DependencyModel.DependencyContext dependencyContext = null) { }
[System.Obsolete("Use ReadFrom.Configuration(IConfiguration configuration, string sectionName, Conf" +
"igurationAssemblySource configurationAssemblySource) instead.")]
public static Serilog.LoggerConfiguration ConfigurationSection(this Serilog.Configuration.LoggerSettingsConfiguration settingConfiguration, Microsoft.Extensions.Configuration.IConfigurationSection configSection, Serilog.Settings.Configuration.ConfigurationAssemblySource configurationAssemblySource) { }
}
}
namespace Serilog.Settings.Configuration
{
public enum ConfigurationAssemblySource
{
UseLoadedAssemblies = 0,
AlwaysScanDllFiles = 1,
}
public sealed class ConfigurationReaderOptions
{
public ConfigurationReaderOptions() { }
public ConfigurationReaderOptions(Microsoft.Extensions.DependencyModel.DependencyContext dependencyContext) { }
public ConfigurationReaderOptions(Serilog.Settings.Configuration.ConfigurationAssemblySource configurationAssemblySource) { }
public ConfigurationReaderOptions(params System.Reflection.Assembly[] assemblies) { }
public System.IFormatProvider FormatProvider { get; init; }
public System.Action<string, Serilog.Core.LoggingLevelSwitch> OnLevelSwitchCreated { get; init; }
public string SectionName { get; init; }
}
}