-
Notifications
You must be signed in to change notification settings - Fork 1.1k
WIP: APIcompat 3.1 #2112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: APIcompat 3.1 #2112
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <Project> | ||
|
|
||
| <!-- | ||
| This file is intended to be used in combination with DesktopApiCompat.targets, | ||
| ResolveMetchingContract.targets, and DesktopAttributeTypeExclusion.txt to check | ||
| implementation against Classic Desktop reference assemblies excluding known | ||
| changes notated in DesktopAPICompatBaseline files. | ||
|
|
||
| You can use the /p:BaselineAllAPICompatError=true flag to regenerate baseline files. | ||
| --> | ||
|
|
||
| <PropertyGroup> | ||
| <RunApiCompat>true</RunApiCompat> | ||
| <!-- only validate that the current implementation is compatible | ||
| with the old one, not vice-versa (since latest may have new | ||
| API missing from old) --> | ||
| <RunApiCompatForSrc>true</RunApiCompatForSrc> | ||
| <RunMatchingRefApiCompat>false</RunMatchingRefApiCompat> | ||
| <DesktopAPICompatLeftOperand>".NET 4.7.2 implementation"</DesktopAPICompatLeftOperand> | ||
| <DesktopAPICompatRightOperand>".NET Core 3.1 implementation"</DesktopAPICompatRightOperand> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .NETCore implementation |
||
| <ApiCompatArgs>$(ApiCompatArgs) --left-operand $(DesktopAPICompatLeftOperand) --right-operand $(DesktopAPICompatRightOperand)</ApiCompatArgs> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <ApiCompatExcludeAttributeList>$(RepositoryEngineeringDir)/ApiCompatability/DesktopAttributeTypeExclusions.txt</ApiCompatExcludeAttributeList> | ||
| </PropertyGroup> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <Project> | ||
| <ItemGroup Condition="'$(RunApiCompat)' == 'true'"> | ||
| <PackageReference Include="Microsoft.DotNet.ApiCompat" | ||
| Version="$(MicrosoftDotNetApiCompatPackageVersion)" | ||
| PrivateAssets="All" /> | ||
| </ItemGroup> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| T:System.Security.SecurityCriticalAttribute |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||
| <Project> | ||||||
| <PropertyGroup> | ||||||
| <RunPreviousReleaseApiCompat>true</RunPreviousReleaseApiCompat> | ||||||
| <!-- only validate that the current implementation is compatible | ||||||
| with the old one, not vice-versa (since latest may have new | ||||||
| API missing from old) --> | ||||||
| <RunPreviousReleaseApiCompatForSrc>true</RunPreviousReleaseApiCompatForSrc> | ||||||
| <RunPreviousReleaseMatchingRefApiCompat>false</RunPreviousReleaseMatchingRefApiCompat> | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary |
||||||
| <PreviousReleaseAPICompatLeftOperand>".NET Core 3.0 reference"</PreviousReleaseAPICompatLeftOperand> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In other places we use "implementation"
Suggested change
or we need to change in other places to use "reference" for the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above try to use more generic names so you don't need to version these. |
||||||
| <PreviousReleaseAPICompatRightOperand>".NET Core 3.1 implementation"</PreviousReleaseAPICompatRightOperand> | ||||||
| <PreviousReleaseApiCompatBaseline>"PreviousReleaseApiCompatBaseline.txt"</PreviousReleaseApiCompatBaseline> | ||||||
| </PropertyGroup> | ||||||
| </Project> | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| <Project> | ||
|
|
||
| <PropertyGroup> | ||
| <!-- If DotNetTool is undefined, we default to assuming 'dotnet' is on the path --> | ||
| <DotNetTool Condition="'$(DotNetTool)' == ''">dotnet</DotNetTool> | ||
| <_ApiCompatPath>$(MSBuildThisFileDirectory)\..\tools\netcoreapp2.1\Microsoft.DotNet.ApiCompat.dll</_ApiCompatPath> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ericstj this path doesn't appear exist locally, and it gets resolved to: Through binlog I found that there is a variable diff --git a/eng/ApiCompatability/PreviousReleaseApiCompat.targets b/eng/ApiCompatability/PreviousReleaseApiCompat.targets
index 1efc4fe4..4899064a 100644
--- a/eng/ApiCompatability/PreviousReleaseApiCompat.targets
+++ b/eng/ApiCompatability/PreviousReleaseApiCompat.targets
@@ -3,7 +3,7 @@
<!-- If DotNetTool is undefined, we default to assuming 'dotnet' is on the path -->
<DotNetTool Condition="'$(DotNetTool)' == ''">dotnet</DotNetTool>
- <_ApiCompatPath>$(MSBuildThisFileDirectory)\..\tools\netcoreapp2.1\Microsoft.DotNet.ApiCompat.dll</_ApiCompatPath>
+ <_ApiCompatPath>$(PkgMicrosoft_DotNet_ApiCompat)\tools\netcoreapp2.1\Microsoft.DotNet.ApiCompat.dll</_ApiCompatPath>I presume it was copied from https://github.com/dotnet/arcade/blob/master/src/Microsoft.DotNet.ApiCompat/build/Microsoft.DotNet.ApiCompat.targets#L9
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a correct way to do it. To ensure that property is generated you can add
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be clear, this should be updated to use |
||
| <_ApiCompatCommand>"$(DotNetTool)" "$(_ApiCompatPath)"</_ApiCompatCommand> | ||
|
|
||
| </PropertyGroup> | ||
|
|
||
| <!-- ApiCompat for Implementation Assemblies --> | ||
| <Target Name="ValidateApiCompatAgainstPreviousRelease" | ||
| Condition="'$(RunApiCompatAgainstPreviousReleaseForSrc)' == 'true' and '$(RunApiCompat)' == 'true'"> | ||
|
|
||
| <Error Condition="'@(ResolvedMatchingPreviousReleaseContract)' == ''" | ||
| Text="ResolvedMatchingPreviousReleaseContract item must be specified to run API compat." /> | ||
| <Error Condition="!Exists('%(ResolvedMatchingPreviousReleaseContract.FullPath)')" | ||
| Text="ResolvedMatchingPreviousReleaseContract '%(ResolvedMatchingPreviousReleaseContract.FullPath)' did not exist." /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ericstj I'm not sure what
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's being defined here and fed into APICompat, it represents the last version of the project it's running against as a basis for comparison. I wouldn't expect it to be defined for |
||
|
|
||
| <ItemGroup> | ||
| <_DependencyDirectoriesTemp Include="@(ReferencePath -> '%(RootDir)%(Directory)')" /> | ||
| <!-- Remove duplicate directories by batching over them --> | ||
| <!-- Add project references first to give precedence to project-specific files --> | ||
| <_DependencyDirectories Condition="'%(_DependencyDirectoriesTemp.ReferenceSourceTarget)' == 'ProjectReference'" Include="%(_DependencyDirectoriesTemp.Identity)" /> | ||
| <_DependencyDirectories Condition="'%(_DependencyDirectoriesTemp.ReferenceSourceTarget)' != 'ProjectReference'" Include="%(_DependencyDirectoriesTemp.Identity)" /> | ||
RussKie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <_ContractDependencyDirectories Include="@(ResolvedMatchingPreviousReleaseContract -> '%(RootDir)%(Directory)')" /> | ||
| <_ContractDependencyDirectories Include="@(ResolvedMatchingPreviousReleaseContract -> '%(DependencyPaths)')" /> | ||
| <_ContractDependencyDirectories Include="$(ContractDependencyPaths)" /> | ||
| </ItemGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <PreviousReleaseApiCompatArgs>$(PreviousReleaseApiCompatArgs) --left-operand $(PreviousReleaseAPICompatLeftOperand) --right-operand $(PreviousReleaseAPICompatRightOperand)</PreviousReleaseApiCompatArgs> | ||
| <PreviousReleaseApiCompatArgs>$(PreviousReleaseApiCompatArgs) "@(ResolvedMatchingPreviousReleaseContract)"</PreviousReleaseApiCompatArgs> | ||
| <PreviousReleaseApiCompatArgs>$(PreviousReleaseApiCompatArgs) --contract-depends "@(_ContractDependencyDirectories, ','),"</PreviousReleaseApiCompatArgs> | ||
| <PreviousReleaseApiCompatArgs Condition="'$(PreviousReleaseApiCompatExcludeAttributeList)' != ''">$(PreviousReleaseApiCompatArgs) --exclude-attributes "$(PreviousReleaseApiCompatExcludeAttributeList)"</PreviousReleaseApiCompatArgs> | ||
| <PreviousReleaseApiCompatArgs Condition="'$(PreviousReleaseApiCompatEnforceOptionalRules)' == 'true'">$(PreviousReleaseApiCompatArgs) --enforce-optional-rules</PreviousReleaseApiCompatArgs> | ||
| <PreviousReleaseApiCompatArgs Condition="'$(BaselineAllAPICompatError)' != 'true' and Exists('$(PreviousReleaseApiCompatBaseline)')">$(PreviousReleaseApiCompatArgs) --baseline "$(PreviousReleaseApiCompatBaseline)"</PreviousReleaseApiCompatArgs> | ||
| <!-- Must be last option. --> | ||
| <PreviousReleaseApiCompatArgs>$(PreviousReleaseApiCompatArgs) --impl-dirs "$(IntermediateOutputPath),@(_DependencyDirectories, ','),"</PreviousReleaseApiCompatArgs> | ||
| <PreviousReleaseApiCompatBaselineAll Condition="'$(BaselineAllAPICompatError)' == 'true'">> $(PreviousReleaseApiCompatBaseline)</PreviousReleaseApiCompatBaselineAll> | ||
| <ApiCompatExitCode>0</ApiCompatExitCode> | ||
|
|
||
| <PreviousReleaseApiCompatResponseFile>$(IntermediateOutputPath)apicompat.rsp</PreviousReleaseApiCompatResponseFile> | ||
| </PropertyGroup> | ||
|
|
||
| <MakeDir Directories="$(IntermediateOutputPath)" /> | ||
| <WriteLinesToFile File="$(PreviousReleaseApiCompatResponseFile)" Lines="$(PreviousReleaseApiCompatArgs)" Overwrite="true" /> | ||
|
|
||
| <Exec Command="$(_ApiCompatCommand) @"$(PreviousReleaseApiCompatResponseFile)" $(PreviousReleaseApiCompatBaselineAll)" | ||
| CustomErrorRegularExpression="^[a-zA-Z]+ :" | ||
| StandardOutputImportance="Low" | ||
| IgnoreExitCode="true"> | ||
| <Output TaskParameter="ExitCode" PropertyName="ApiCompatExitCode" /> | ||
| </Exec> | ||
|
|
||
| <!-- | ||
| To force incremental builds to show failures again we are invalidating | ||
| one compile input. | ||
| --> | ||
| <Touch Condition="'$(ApiCompatExitCode)' != '0'" Files="$(IntermediateOutputPath)$(_ApiCompatSemaphoreFile)" AlwaysCreate="true"> | ||
| <Output TaskParameter="TouchedFiles" ItemName="FileWrites" /> | ||
| </Touch> | ||
| <Error Condition="'$(ApiCompatExitCode)' != '0'" Text="ApiCompat failed for '$(TargetPath)'" /> | ||
| </Target> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project> | ||
| <Target Name="ResolveMatchingPreviousReleaseContract" BeforeTargets="ResolveAssemblyReferences" Condition="'$(AvoidRunningResolveMatchingPreviousReleaseContract)' == 'false'"> | ||
| <Error Condition="!Exists('$(PreviousReleaseStableApiProject)')" Text="Error, failed to locate '$(PreviousReleaseStableApiProject)'" /> | ||
| <MSBuild Projects="$(PreviousReleaseStableApiProject)" | ||
| Targets="GetPreviousReleaseContract" | ||
| Properties="ContractName=$(AssemblyName);TargetFramework=$(TargetFramework)"> | ||
| <Output TaskParameter="TargetOutputs" ItemName="ResolveMatchingPreviousReleaseContract"/> | ||
| </MSBuild> | ||
| <PropertyGroup> | ||
| <ResolvedMatchingPreviousReleaseContract>%(ResolveMatchingPreviousReleaseContract.DependencyPaths)</ResolvedMatchingPreviousReleaseContract> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <RunPreviousReleaseApiCompatForSrc Condition="!Exists('@(ResolvedMatchingPreviousReleaseContract)')">false</RunPreviousReleaseApiCompatForSrc> | ||
| </PropertyGroup> | ||
| </Target> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | ||
| <PropertyGroup> | ||
| <TargetFramework>netcoreapp3.1</TargetFramework> | ||
| <UseWindowsForms>true</UseWindowsForms> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <AvoidRunningResolveMatchingPreviousReleaseContract>true</AvoidRunningResolveMatchingPreviousReleaseContract> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <!-- You should simply be able to change this in order to witness another version --> | ||
| <StableVersionToWitness>3.0.0</StableVersionToWitness> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <!-- Control the version of the Ref Pack used via the WindowsDesktop SDK --> | ||
| <FrameworkReference | ||
| Update="Microsoft.NETCore.App" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should have been WindowsDesktop?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be better to simplify this to look like a customer project from previous release with no CS / references. |
||
| TargetingPackVersion="$(StableVersionToWitness)" | ||
| RuntimeFrameworkVersion="$(StableVersionToWitness)" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- The purpose of this target is to return a path from a referenced package / project --> | ||
| <Target Name="GetPreviousReleaseContract" DependsOnTargets="ResolveReferences" Returns="@(_contractReferencePath)"> | ||
| <Error Condition="'$(ContractName)' == ''" Text="ContractName must be specified" /> | ||
| <ItemGroup> | ||
| <_contractReferencePath Include="@(ReferencePath)" Condition="'%(FileName)' == '$(ContractName)'" /> | ||
| <_allReferenceDirectories Include="%(ReferencePath.RootDir)%(ReferencePath.Directory)" /> | ||
| <_contractReferencePath DependencyPaths="@(_allReferenceDirectories)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| <Target Name="Build"> | ||
| <!-- This will override the default Build target. --> | ||
| </Target> | ||
| <Target Name="Rebuild"> | ||
| <!-- This will override the default Rebuild target. --> | ||
| </Target> | ||
| <Target Name="BuildAndTest"> | ||
| <!-- This will override the default BuildAndTest target. --> | ||
| </Target> | ||
| <Target Name="RebuildAndTest"> | ||
| <!-- This will override the default RebuildAndTest target. --> | ||
| </Target> | ||
|
|
||
| </Project> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.NETFramework reference assembly