Skip to content

Commit 4bcc94c

Browse files
authored
API Compat tool in ML.NET (#3623)
1 parent 6ebfeb3 commit 4bcc94c

File tree

5 files changed

+102
-1
lines changed

5 files changed

+102
-1
lines changed

Microsoft.ML.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Microsoft.ML.FastTree", "Mi
274274
pkg\Microsoft.ML.FastTree\Microsoft.ML.FastTree.symbols.nupkgproj = pkg\Microsoft.ML.FastTree\Microsoft.ML.FastTree.symbols.nupkgproj
275275
EndProjectSection
276276
EndProject
277+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.StableApi", "tools-local\Microsoft.ML.StableApi\Microsoft.ML.StableApi.csproj", "{F308DC6B-7E59-40D7-A581-834E8CD99CFE}"
278+
EndProject
277279
Global
278280
GlobalSection(SolutionConfigurationPlatforms) = preSolution
279281
Debug|Any CPU = Debug|Any CPU
@@ -968,6 +970,18 @@ Global
968970
{E02DA82D-3FEE-4C60-BD80-9EC3C3448DFC}.Release-Intrinsics|Any CPU.Build.0 = Release-Intrinsics|Any CPU
969971
{E02DA82D-3FEE-4C60-BD80-9EC3C3448DFC}.Release-netfx|Any CPU.ActiveCfg = Release-netfx|Any CPU
970972
{E02DA82D-3FEE-4C60-BD80-9EC3C3448DFC}.Release-netfx|Any CPU.Build.0 = Release-netfx|Any CPU
973+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
974+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
975+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE}.Debug-Intrinsics|Any CPU.ActiveCfg = Debug-Intrinsics|Any CPU
976+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE}.Debug-Intrinsics|Any CPU.Build.0 = Debug-Intrinsics|Any CPU
977+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE}.Debug-netfx|Any CPU.ActiveCfg = Debug-netfx|Any CPU
978+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE}.Debug-netfx|Any CPU.Build.0 = Debug-netfx|Any CPU
979+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
980+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE}.Release|Any CPU.Build.0 = Release|Any CPU
981+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE}.Release-Intrinsics|Any CPU.ActiveCfg = Release-Intrinsics|Any CPU
982+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE}.Release-Intrinsics|Any CPU.Build.0 = Release-Intrinsics|Any CPU
983+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE}.Release-netfx|Any CPU.ActiveCfg = Release-netfx|Any CPU
984+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE}.Release-netfx|Any CPU.Build.0 = Release-netfx|Any CPU
971985
EndGlobalSection
972986
GlobalSection(SolutionProperties) = preSolution
973987
HideSolutionNode = FALSE
@@ -1055,6 +1069,7 @@ Global
10551069
{AD7058C9-5608-49A8-BE23-58C33A74EE91} = {D3D38B03-B557-484D-8348-8BADEE4DF592}
10561070
{E02DA82D-3FEE-4C60-BD80-9EC3C3448DFC} = {09EADF06-BE25-4228-AB53-95AE3E15B530}
10571071
{B1B3F284-FA3D-4D76-A712-FF04495D244B} = {D3D38B03-B557-484D-8348-8BADEE4DF592}
1072+
{F308DC6B-7E59-40D7-A581-834E8CD99CFE} = {7F13E156-3EBA-4021-84A5-CD56BA72F99E}
10581073
EndGlobalSection
10591074
GlobalSection(ExtensibilityGlobals) = postSolution
10601075
SolutionGuid = {41165AF1-35BB-4832-A189-73060F82B01D}

build/Dependencies.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<CodecovVersion>1.1.1</CodecovVersion>
3737
<CoverletVersion>2.6.0</CoverletVersion>
3838
<ReportGeneratorVersion>4.0.9</ReportGeneratorVersion>
39+
<MicrosoftDotNetApiCompatPackageVersion>1.0.0-beta.19225.5</MicrosoftDotNetApiCompatPackageVersion>
3940
</PropertyGroup>
4041

4142
<!-- Test-only Dependencies -->

src/Directory.Build.props

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@
2121
<PackageRid>$(PackageRid)-$(TargetArchitecture)</PackageRid>
2222
</PropertyGroup>
2323

24+
<!-- API Compat -->
25+
<PropertyGroup>
26+
<RunApiCompat Condition="'$(RunApiCompat)' == ''">$(IsStableProject)</RunApiCompat>
27+
<ToolHostCmd Condition="'$(OS)' != 'Windows_NT'">$(ToolsDir)dotnetcli/dotnet</ToolHostCmd>
28+
29+
30+
<!-- only validate that the current implementation is compatible
31+
with the old one, not vice-versa (since latest may have new
32+
API missing from old) -->
33+
<RunApiCompatForSrc>true</RunApiCompatForSrc>
34+
<RunMatchingRefApiCompat>false</RunMatchingRefApiCompat>
35+
</PropertyGroup>
36+
2437
<ItemGroup>
2538
<ProjectReference
2639
Condition="'$(UseMLCodeAnalyzer)' != 'false' and '$(MSBuildProjectExtension)' == '.csproj'"
@@ -37,5 +50,4 @@
3750
<Link>stylecop.json</Link>
3851
</AdditionalFiles>
3952
</ItemGroup>
40-
4153
</Project>

src/Directory.Build.targets

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,32 @@
2626

2727
</Target>
2828

29+
<!-- API Compat -->
30+
<PropertyGroup Condition="'$(RunApiCompat)' == 'true'">
31+
<!-- resolve contract for APICompat as part of resolve references -->
32+
<ResolveReferencesDependsOn>
33+
$(ResolveReferencesDependsOn);
34+
ResolveMatchingContract
35+
</ResolveReferencesDependsOn>
36+
37+
<StableApiProject>$(RepoRoot)tools-local\Microsoft.ML.StableApi\Microsoft.ML.StableApi.csproj</StableApiProject>
38+
</PropertyGroup>
39+
40+
<ItemGroup Condition="'$(RunApiCompat)' == 'true'">
41+
<PackageReference Include="Microsoft.DotNet.ApiCompat"
42+
Version="$(MicrosoftDotNetApiCompatPackageVersion)"
43+
PrivateAssets="All" />
44+
</ItemGroup>
45+
46+
<Target Name="ResolveMatchingContract">
47+
<MSBuild Projects="$(StableApiProject)"
48+
Targets="GetContract"
49+
Properties="ContractName=$(AssemblyName);TargetFramework=$(TargetFramework)">
50+
<Output TaskParameter="TargetOutputs" ItemName="ResolvedMatchingContract"/>
51+
</MSBuild>
52+
<PropertyGroup>
53+
<ContractOutputPath>%(ResolvedMatchingContract.DependencyPaths)</ContractOutputPath>
54+
</PropertyGroup>
55+
</Target>
56+
2957
</Project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<!-- needs to contain all frameworks which src projects wish to restore -->
5+
<TargetFramework Condition="'$(UseIntrinsics)' != 'true'">netstandard2.0</TargetFramework>
6+
<TargetFrameworks Condition="'$(UseIntrinsics)' == 'true'">netstandard2.0;netcoreapp3.0</TargetFrameworks>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.ML" Version="1.0.0" />
11+
<PackageReference Include="Microsoft.ML.DataView" Version="1.0.0" />
12+
<PackageReference Include="Microsoft.ML.CpuMath" Version="1.0.0" />
13+
<PackageReference Include="Microsoft.ML.FastTree" Version="1.0.0" />
14+
<PackageReference Include="Microsoft.ML.LightGbm" Version="1.0.0" />
15+
<PackageReference Include="Microsoft.ML.ImageAnalytics" Version="1.0.0" />
16+
<PackageReference Include="Microsoft.ML.Mkl.Components" Version="1.0.0" />
17+
</ItemGroup>
18+
19+
<!-- The purpose of this target is to return a path from a referenced
20+
package / project -->
21+
<Target Name="GetContract" DependsOnTargets="ResolveReferences" Returns="@(_contractReferencePath)">
22+
<Error Condition="'$(ContractName)' == ''" Text="ContractName must be specified" />
23+
<ItemGroup>
24+
<_contractReferencePath Include="@(ReferencePath)" Condition="'%(FileName)' == '$(ContractName)'" />
25+
<_allReferenceDirectories Include="%(ReferencePath.RootDir)%(ReferencePath.Directory)" />
26+
<_contractReferencePath Include="@(ReferencePath)" Condition="'%(FileName)' == '$(ContractName)'" />
27+
<_contractReferencePath DependencyPaths="@(_allReferenceDirectories)" />
28+
</ItemGroup>
29+
<Error Condition="'@(_contractReferencePath)' == ''" Text="Could not locate $(ContractName)" />
30+
</Target>
31+
32+
<Target Name="Build">
33+
<!-- This will override the default Build target. -->
34+
</Target>
35+
<Target Name="Rebuild">
36+
<!-- This will override the default Rebuild target. -->
37+
</Target>
38+
<Target Name="BuildAndTest">
39+
<!-- This will override the default BuildAndTest target. -->
40+
</Target>
41+
<Target Name="RebuildAndTest">
42+
<!-- This will override the default RebuildAndTest target. -->
43+
</Target>
44+
45+
</Project>

0 commit comments

Comments
 (0)