Skip to content

Commit 0d4b3b5

Browse files
committed
Validate API compatibility with Microsoft.DotNet.ApiCompat
1 parent b0a81df commit 0d4b3b5

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

NuGet.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<!-- For Microsoft.DotNet.ApiCompat -->
5+
<add key=".NET Core Tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
6+
</packageSources>
7+
</configuration>

packages.lock.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
"version": 1,
33
"dependencies": {
44
".NETStandard,Version=v2.0": {
5+
"Microsoft.DotNet.ApiCompat": {
6+
"type": "Direct",
7+
"requested": "[7.0.0-*, )",
8+
"resolved": "7.0.0-beta.21463.4",
9+
"contentHash": "TbIGBfVrAqVDA3a8H2V7RtLFJg5AWhIHL3DHFO4SWAAzEhNwUdTqk0j6etl2nKaY5jalC3xk90DuRME/NG6FOw=="
10+
},
511
"Microsoft.SourceLink.GitHub": {
612
"type": "Direct",
713
"requested": "[1.0.0, )",

src/ApiCompatBaseline.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Compat issues with assembly Serilog.Formatting.Log4Net:
2+
TypesMustExist : Type 'Serilog.Formatting.Log4Net.LineEndingExtensions' does not exist in the implementation but it does exist in the contract.
3+
MembersMustExist : Member 'public Serilog.Formatting.Log4Net.CDataMode Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder.CDataMode.get()' does not exist in the implementation but it does exist in the contract.
4+
MembersMustExist : Member 'public Serilog.Formatting.Log4Net.PropertyFilter Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder.FilterProperty.get()' does not exist in the implementation but it does exist in the contract.
5+
MembersMustExist : Member 'public Serilog.Formatting.Log4Net.ExceptionFormatter Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder.FormatException.get()' does not exist in the implementation but it does exist in the contract.
6+
MembersMustExist : Member 'public System.IFormatProvider Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder.FormatProvider.get()' does not exist in the implementation but it does exist in the contract.
7+
MembersMustExist : Member 'public Serilog.Formatting.Log4Net.IndentationSettings Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder.IndentationSettings.get()' does not exist in the implementation but it does exist in the contract.
8+
MembersMustExist : Member 'public Serilog.Formatting.Log4Net.LineEnding Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder.LineEnding.get()' does not exist in the implementation but it does exist in the contract.
9+
MembersMustExist : Member 'public System.Xml.XmlQualifiedName Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder.Log4NetXmlNamespace.get()' does not exist in the implementation but it does exist in the contract.
10+
MembersMustExist : Member 'public Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder Serilog.Formatting.Log4Net.Log4NetTextFormatterOptionsBuilder.UseLog4NetXmlNamespace(System.Xml.XmlQualifiedName)' does not exist in the implementation but it does exist in the contract.
11+
Total Issues: 9

src/Serilog.Formatting.Log4Net.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,27 @@
4949
</PropertyGroup>
5050

5151
<ItemGroup>
52+
<PackageReference Include="Microsoft.DotNet.ApiCompat" Version="7.0.0-*" PrivateAssets="all" />
5253
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
5354
<PackageReference Include="MinVer" Version="2.5.0" PrivateAssets="all" />
5455
<PackageReference Include="Serilog" Version="2.0.0" />
5556
</ItemGroup>
5657

58+
<!-- Run `dotnet build -p:BaselineAllAPICompatError=true` to accept breaking changes
59+
See https://stu.dev/check-for-breaking-changes-with-apicompat/ for more information -->
60+
<Target Name="SetupResolvedMatchingContract" BeforeTargets="ValidateApiCompatForSrc">
61+
<PropertyGroup>
62+
<ContractVersion>1.0.0-rc.2</ContractVersion>
63+
<ContractFilePath>$([System.IO.Path]::Combine($(NuGetPackageRoot),$(PackageId.ToLowerInvariant()),$(ContractVersion),'lib',$(TargetFramework),$(TargetFileName)))</ContractFilePath>
64+
</PropertyGroup>
65+
<ItemGroup>
66+
<ResolvedMatchingContract Include="$(ContractFilePath)" />
67+
</ItemGroup>
68+
<!-- We don't really want to validate the package here but `dotnet validate package remote ...` downloads and extract the NuGet package into the NuGet package root -->
69+
<Exec Command="dotnet tool restore" Condition="!Exists($(ContractFilePath))" />
70+
<Exec Command="dotnet validate package remote $(PackageId) --version $(ContractVersion)" StandardOutputImportance="low" IgnoreExitCode="true" Condition="!Exists($(ContractFilePath))" />
71+
</Target>
72+
5773
<Target Name="ValidateNuGetPackage" AfterTargets="Pack">
5874
<!-- For reference: the file `.config/dotnet-tools.json` was created by running `dotnet new tool-manifest && dotnet tool install dotnet-validate` -->
5975
<Exec Command="dotnet tool restore" />

0 commit comments

Comments
 (0)