Skip to content

Commit 0caf999

Browse files
committed
Add public API approval test
1 parent 8e76d03 commit 0caf999

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[assembly: System.CLSCompliant(true)]
2+
[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/0xced/serilog-formatting-log4net.git")]
3+
[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName="")]
4+
namespace Serilog.Formatting.Log4Net
5+
{
6+
public enum CDataMode
7+
{
8+
Always = 0,
9+
Never = 1,
10+
IfNeeded = 2,
11+
}
12+
public delegate string ExceptionFormatter(System.Exception exception);
13+
public enum Indentation
14+
{
15+
Space = 0,
16+
Tab = 1,
17+
}
18+
public class IndentationSettings
19+
{
20+
public IndentationSettings(Serilog.Formatting.Log4Net.Indentation indentation, byte size) { }
21+
public override string ToString() { }
22+
}
23+
[System.Flags]
24+
public enum LineEnding
25+
{
26+
None = 0,
27+
LineFeed = 1,
28+
CarriageReturn = 2,
29+
}
30+
public static class LineEndingExtensions
31+
{
32+
public static string ToCharacters(this Serilog.Formatting.Log4Net.LineEnding lineEnding) { }
33+
}
34+
public class Log4NetTextFormatter : Serilog.Formatting.ITextFormatter
35+
{
36+
public Log4NetTextFormatter() { }
37+
public Log4NetTextFormatter(System.Action<Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder>? configureOptions) { }
38+
public void Format(Serilog.Events.LogEvent logEvent, System.IO.TextWriter output) { }
39+
}
40+
public class Log4NetTextFormatterOptionsBuilder
41+
{
42+
public Log4NetTextFormatterOptionsBuilder() { }
43+
public Serilog.Formatting.Log4Net.CDataMode CDataMode { get; }
44+
public Serilog.Formatting.Log4Net.PropertyFilter FilterProperty { get; }
45+
public Serilog.Formatting.Log4Net.ExceptionFormatter FormatException { get; }
46+
public System.IFormatProvider? FormatProvider { get; }
47+
public Serilog.Formatting.Log4Net.IndentationSettings? IndentationSettings { get; }
48+
public Serilog.Formatting.Log4Net.LineEnding LineEnding { get; }
49+
public System.Xml.XmlQualifiedName? Log4NetXmlNamespace { get; }
50+
public Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder UseCDataMode(Serilog.Formatting.Log4Net.CDataMode cDataMode) { }
51+
public Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder UseExceptionFormatter(Serilog.Formatting.Log4Net.ExceptionFormatter formatException) { }
52+
public Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder UseFormatProvider(System.IFormatProvider? formatProvider) { }
53+
public Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder UseIndentationSettings(Serilog.Formatting.Log4Net.IndentationSettings indentationSettings) { }
54+
public Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder UseLineEnding(Serilog.Formatting.Log4Net.LineEnding lineEnding) { }
55+
public void UseLog4JCompatibility() { }
56+
public Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder UseLog4NetXmlNamespace(System.Xml.XmlQualifiedName? log4NetXmlNamespace) { }
57+
public Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder UseNoIndentation() { }
58+
public Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder UsePropertyFilter(Serilog.Formatting.Log4Net.PropertyFilter filterProperty) { }
59+
}
60+
public delegate bool PropertyFilter(Serilog.Events.LogEvent logEvent, string propertyName);
61+
}

tests/PublicApi.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.IO;
2+
using System.Reflection;
3+
using ApprovalTests;
4+
using ApprovalTests.Namers;
5+
using ApprovalTests.Reporters;
6+
using PublicApiGenerator;
7+
using Xunit;
8+
9+
namespace Serilog.Formatting.Log4Net.Tests
10+
{
11+
public class PublicApi
12+
{
13+
[Fact]
14+
public void ApprovePublicApi()
15+
{
16+
var assembly = typeof(Log4NetTextFormatter).Assembly;
17+
var publicApi = assembly.GeneratePublicApi();
18+
var writer = new ApprovalTextWriter(publicApi);
19+
Approvals.Verify(writer, new AssemblyNamer(assembly), new DiffReporter());
20+
}
21+
22+
private class AssemblyNamer : UnitTestFrameworkNamer
23+
{
24+
private readonly Assembly _assembly;
25+
26+
public AssemblyNamer(Assembly assembly) => _assembly = assembly;
27+
28+
public override string Name => nameof(PublicApi) + "." + Path.GetFileNameWithoutExtension(_assembly.Location);
29+
}
30+
}
31+
}

tests/Serilog.Formatting.Log4Net.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<PackageReference Include="FluentAssertions" Version="5.10.3" />
1515
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
1616
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
17+
<PackageReference Include="PublicApiGenerator" Version="10.2.0" />
1718
<PackageReference Include="ReportGenerator" Version="4.8.6" />
1819
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
1920
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />

0 commit comments

Comments
 (0)