Skip to content

Commit 0647d98

Browse files
committed
introduce API Compat tool in ML.NET
1 parent 4e2dba7 commit 0647d98

File tree

17 files changed

+98
-8
lines changed

17 files changed

+98
-8
lines changed

Directory.Build.props

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,14 @@
124124
<PropertyGroup>
125125
<CustomAfterMicrosoftCommonTargets>$(RepoRoot)build\AfterCommonTargets.targets</CustomAfterMicrosoftCommonTargets>
126126
</PropertyGroup>
127+
128+
<!-- API Compat -->
129+
<PropertyGroup>
130+
<!-- only validate that the current implementation is compatible
131+
with the old one, not vice-versa (since latest may have new
132+
API missing from old) -->
133+
<RunApiCompatForSrc>true</RunApiCompatForSrc>
134+
<RunMatchingRefApiCompat>false</RunMatchingRefApiCompat>
135+
<MicrosoftDotNetApiCompatPackageVersion>1.0.0-beta.19225.5</MicrosoftDotNetApiCompatPackageVersion>
136+
</PropertyGroup>
127137
</Project>

Microsoft.ML.sln

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio 15
2+
# Visual Studio Version 15
33
VisualStudioVersion = 15.0.27130.2026
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.Core", "src\Microsoft.ML.Core\Microsoft.ML.Core.csproj", "{A6CA6CC6-5D7C-4D7F-A0F5-35E14B383B0A}"
@@ -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", "{C1884169-7330-42DF-B401-9427C6EFB092}"
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+
{C1884169-7330-42DF-B401-9427C6EFB092}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
974+
{C1884169-7330-42DF-B401-9427C6EFB092}.Debug|Any CPU.Build.0 = Debug|Any CPU
975+
{C1884169-7330-42DF-B401-9427C6EFB092}.Debug-Intrinsics|Any CPU.ActiveCfg = Debug-Intrinsics|Any CPU
976+
{C1884169-7330-42DF-B401-9427C6EFB092}.Debug-Intrinsics|Any CPU.Build.0 = Debug-Intrinsics|Any CPU
977+
{C1884169-7330-42DF-B401-9427C6EFB092}.Debug-netfx|Any CPU.ActiveCfg = Debug-netfx|Any CPU
978+
{C1884169-7330-42DF-B401-9427C6EFB092}.Debug-netfx|Any CPU.Build.0 = Debug-netfx|Any CPU
979+
{C1884169-7330-42DF-B401-9427C6EFB092}.Release|Any CPU.ActiveCfg = Release|Any CPU
980+
{C1884169-7330-42DF-B401-9427C6EFB092}.Release|Any CPU.Build.0 = Release|Any CPU
981+
{C1884169-7330-42DF-B401-9427C6EFB092}.Release-Intrinsics|Any CPU.ActiveCfg = Release-Intrinsics|Any CPU
982+
{C1884169-7330-42DF-B401-9427C6EFB092}.Release-Intrinsics|Any CPU.Build.0 = Release-Intrinsics|Any CPU
983+
{C1884169-7330-42DF-B401-9427C6EFB092}.Release-netfx|Any CPU.ActiveCfg = Release-netfx|Any CPU
984+
{C1884169-7330-42DF-B401-9427C6EFB092}.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+
{C1884169-7330-42DF-B401-9427C6EFB092} = {7F13E156-3EBA-4021-84A5-CD56BA72F99E}
10581073
EndGlobalSection
10591074
GlobalSection(ExtensibilityGlobals) = postSolution
10601075
SolutionGuid = {41165AF1-35BB-4832-A189-73060F82B01D}

src/Directory.Build.targets

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,29 @@
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+
<StabelApiProject>$(RepoRoot)tools-local\Microsoft.ML.StableApi\Microsoft.ML.StableApi.csproj</StabelApiProject>
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="$(StabelApiProject)"
48+
Targets="GetContract"
49+
Properties="ContractName=$(AssemblyName);TargetFramework=$(TargetFramework)">
50+
<Output TaskParameter="TargetOutputs" ItemName="ResolvedMatchingContract"/>
51+
</MSBuild>
52+
</Target>
53+
2954
</Project>

src/Microsoft.ML.Analyzer/Microsoft.ML.Analyzer.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard1.3</TargetFramework>
4+
<TargetFramework>netstandard2.0</TargetFramework>
55
<IncludeAnalyzerInPackage>Microsoft.ML</IncludeAnalyzerInPackage>
6+
<RunApiCompat>true</RunApiCompat>
67
</PropertyGroup>
78

89
<ItemGroup>

src/Microsoft.ML.Core/Microsoft.ML.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<DefineConstants>CORECLR</DefineConstants>
88
<RootNamespace>Microsoft.ML</RootNamespace>
9+
<RunApiCompat>true</RunApiCompat>
910
</PropertyGroup>
1011

1112
<ItemGroup>
1213
<ProjectReference Include="..\Microsoft.ML.DataView\Microsoft.ML.DataView.csproj" />
13-
1414
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" />
1515
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
1616
</ItemGroup>

src/Microsoft.ML.CpuMath/Microsoft.ML.CpuMath.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<DefineConstants>$(DefineConstants);CPUMATH_INFRASTRUCTURE</DefineConstants>
99
<LangVersion>7.3</LangVersion>
10+
<RunApiCompat>true</RunApiCompat>
1011
</PropertyGroup>
1112

1213
<ItemGroup>

src/Microsoft.ML.Data/Microsoft.ML.Data.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<IncludeInPackage>Microsoft.ML</IncludeInPackage>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<DefineConstants>CORECLR</DefineConstants>
8+
<RunApiCompat>true</RunApiCompat>
89
</PropertyGroup>
910

1011
<ItemGroup>

src/Microsoft.ML.DataView/Microsoft.ML.DataView.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<IncludeInPackage>Microsoft.ML.DataView</IncludeInPackage>
6+
<RunApiCompat>true</RunApiCompat>
67
</PropertyGroup>
78

89
<ItemGroup>
@@ -13,5 +14,4 @@
1314
<ItemGroup>
1415
<Compile Include="..\Microsoft.ML.Core\Utilities\ArrayUtils.cs" />
1516
</ItemGroup>
16-
1717
</Project>

src/Microsoft.ML.FastTree/Microsoft.ML.FastTree.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<IncludeInPackage>Microsoft.ML.FastTree</IncludeInPackage>
66
<DefineConstants>$(DefineConstants);USE_FASTTREENATIVE;NO_STORE;CORECLR</DefineConstants>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
8+
<RunApiCompat>true</RunApiCompat>
89
</PropertyGroup>
910

1011
<ItemGroup>

src/Microsoft.ML.ImageAnalytics/Microsoft.ML.ImageAnalytics.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<IncludeInPackage>Microsoft.ML.ImageAnalytics</IncludeInPackage>
6+
<RunApiCompat>true</RunApiCompat>
67
</PropertyGroup>
78

89
<ItemGroup>

src/Microsoft.ML.KMeansClustering/Microsoft.ML.KMeansClustering.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<IncludeInPackage>Microsoft.ML</IncludeInPackage>
6+
<RunApiCompat>true</RunApiCompat>
67
</PropertyGroup>
78

89
<ItemGroup>

src/Microsoft.ML.LightGbm/Microsoft.ML.LightGbm.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<IncludeInPackage>Microsoft.ML.LightGbm</IncludeInPackage>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7+
<RunApiCompat>true</RunApiCompat>
78
</PropertyGroup>
8-
99
<ItemGroup>
1010
<ProjectReference Include="..\Microsoft.ML.Core\Microsoft.ML.Core.csproj" />
1111
<ProjectReference Include="..\Microsoft.ML.Data\Microsoft.ML.Data.csproj" />

src/Microsoft.ML.Mkl.Components/Microsoft.ML.Mkl.Components.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<IncludeInPackage>Microsoft.ML.Mkl.Components</IncludeInPackage>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7+
<RunApiCompat>true</RunApiCompat>
78
</PropertyGroup>
8-
99
<ItemGroup>
1010
<ProjectReference Include="..\Microsoft.ML.Core\Microsoft.ML.Core.csproj" />
1111
<ProjectReference Include="..\Microsoft.ML.Data\Microsoft.ML.Data.csproj" />

src/Microsoft.ML.PCA/Microsoft.ML.PCA.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<IncludeInPackage>Microsoft.ML</IncludeInPackage>
6+
<RunApiCompat>true</RunApiCompat>
67
</PropertyGroup>
78

89
<ItemGroup>

src/Microsoft.ML.StandardTrainers/Microsoft.ML.StandardTrainers.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<IncludeInPackage>Microsoft.ML</IncludeInPackage>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7+
<RunApiCompat>true</RunApiCompat>
78
</PropertyGroup>
89

910
<ItemGroup>

src/Microsoft.ML.Transforms/Microsoft.ML.Transforms.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<IncludeInPackage>Microsoft.ML</IncludeInPackage>
66
<DefineConstants>CORECLR</DefineConstants>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
8+
<RunApiCompat>true</RunApiCompat>
89
</PropertyGroup>
910

1011
<ItemGroup>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<!-- needs to contain all frameworks which src projects wish to restore -->
5+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Microsoft.ML" Version="1.0.0-preview-27625-16"/>
10+
<PackageReference Include="Microsoft.ML.DataView" Version="1.0.0-preview-27625-16"/>
11+
<PackageReference Include="Microsoft.ML.CpuMath" Version="1.0.0-preview-27625-16"/>
12+
<PackageReference Include="Microsoft.ML.FastTree" Version="1.0.0-preview-27625-16"/>
13+
<PackageReference Include="Microsoft.ML.LightGbm" Version="1.0.0-preview-27625-16"/>
14+
<PackageReference Include="Microsoft.ML.ImageAnalytics" Version="1.0.0-preview-27625-16"/>
15+
<PackageReference Include="Microsoft.ML.Mkl.Components" Version="1.0.0-preview-27625-16"/>
16+
<PackageReference Include="Microsoft.ML.Mkl.Redist" Version="1.0.0-preview-27625-16"/>
17+
</ItemGroup>
18+
19+
<!-- The purpose of this target is to return a path from a referenced
20+
package / project -->
21+
<Target Name="GetContract"
22+
DependsOnTargets="ResolveReferences"
23+
Returns="@(_contractReferencePath)">
24+
<Error Condition="'$(ContractName)' == ''" Text="ContractName must be specified" />
25+
<ItemGroup>
26+
<_contractReferencePath Include="@(ReferencePath)" Condition="'%(FileName)' == '$(ContractName)'" />
27+
</ItemGroup>
28+
<Error Condition="'$(ContractName)' == ''" Text="Could not locate $(ContractName)" />
29+
</Target>
30+
31+
</Project>

0 commit comments

Comments
 (0)