Repository navigation
Make APICompat friendlier #2297
Copy link
Copy link
Closed
Labels
area-Infrastructure-librariesArea maintained by .NET libraries team: APICompat, AsmDiff, GenAPI, GenFacades, PkgProj, etcArea maintained by .NET libraries team: APICompat, AsmDiff, GenAPI, GenFacades, PkgProj, etc
Description
Today I had to do the following to demonstrate API Compat usage.
<PropertyGroup>
<RunApiCompat>true</RunApiCompat>
<RunApiCompatForSrc>true</RunApiCompatForSrc>
<RunMatchingRefApiCompat>false</RunMatchingRefApiCompat>
</PropertyGroup>
<ItemGroup>
<ResolvedMatchingContract Include="..\old\apiCompat.dll" />
<PackageReference Include="Microsoft.DotNet.ApiCompat" Version="1.0.0-beta.19170.2" PrivateAssets="All" />
</ItemGroup>
<Target Name="defineContractOutputPath" BeforeTargets="RunMatchingRefApiCompat">
<ItemGroup>
<_ContractDependencyDirectoriesTemp Include="@(ReferencePath -> '%(RootDir)%(Directory)')" />
<_ContractDependencyDirectories Condition="'%(_ContractDependencyDirectoriesTemp.ReferenceSourceTarget)' == 'ProjectReference'" Include="%(_ContractDependencyDirectories.Identity)" />
<_ContractDependencyDirectories Condition="'%(_ContractDependencyDirectoriesTemp.ReferenceSourceTarget)' != 'ProjectReference'" Include="%(_ContractDependencyDirectories.Identity)" />
</ItemGroup>
</Target>
Some notes.
- By default we should run normal API compat, and not reverse API compat. Properties should only be required to turn it off, or to enable reverse compat.
-
ResolvedMatchingContract is a terrible name. We should rename it.I've convinced myself I'm OK with this name: contract is good enough and is more appropriate than "reference assembly" since we use API compat for past versions as well. - We should also have some options for how to define it. Once NuGet download-only packages are available this might be an interesting use-case. In the meantime we should have an example for how to create a project to do this.
- Sample underway: API Compat tool in ML.NET machinelearning#3623
-
When ContractOutputPath isn't defined we should reuse ReferencePath directories as contract dependencies. This should be suppressible with a property.I don't think this is a good idea as it could lead to missed issues in cases where dependencies are also things that might be under test. Instead I've made it easier to pass contract dependencies.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-Infrastructure-librariesArea maintained by .NET libraries team: APICompat, AsmDiff, GenAPI, GenFacades, PkgProj, etcArea maintained by .NET libraries team: APICompat, AsmDiff, GenAPI, GenFacades, PkgProj, etc
Activity
ericstj commentedon May 1, 2019
Taking a look at fixing these as I ran into them again when helping out on dotnet/machinelearning#3623