Skip to content
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

Add ApiCompat run to repo #17959

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

<IsReferenceAssemblyProject>false</IsReferenceAssemblyProject>
<IsReferenceAssemblyProject Condition="$(MSBuildProjectDirectory.EndsWith('ref'))">true</IsReferenceAssemblyProject>
<OutDirName Condition="'$(IsReferenceAssemblyProject)' == 'true'">$(MSBuildProjectName)-ref</OutDirName>
<RefOutDirName>$(MSBuildProjectName)-ref</RefOutDirName>
<OutDirName Condition="'$(IsReferenceAssemblyProject)' == 'true'">$(RefOutDirName)</OutDirName>

<IsBenchmarkProject Condition="$(MSBuildProjectName.EndsWith('.Performance')) OR $(RepoRelativeProjectDir.Contains('perf'))">true</IsBenchmarkProject>
<IsSpecificationTestProject Condition="$(MSBuildProjectName.EndsWith('.Specification.Tests'))">true</IsSpecificationTestProject>
Expand Down
11 changes: 11 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@
<AssemblyVersion>$(AspNetCoreMajorVersion).$(AspNetCoreMinorVersion).0.0</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Label="APICompat settings">
<!-- Don't run APICompat on projects without ref assemblies -->
<RunApiCompat Condition="'$(HasReferenceAssembly)' == 'false'">false</RunApiCompat>
dougbu marked this conversation as resolved.
Show resolved Hide resolved
<ContractDir Condition="'$(HasReferenceAssembly)' == 'true'">$(OutputPath.Replace('$(OutDirName)','$(RefOutDirName)'))</ContractDir>
dougbu marked this conversation as resolved.
Show resolved Hide resolved
<BaselineAllAPICompatError Condition="'$(HasReferenceAssembly)' == 'true'">true</BaselineAllAPICompatError>
</PropertyGroup>

<ItemGroup Condition="'$(HasReferenceAssembly)' == 'true'">
<ResolvedMatchingContract Include="$(ContractDir)$(TargetFileName)" />
</ItemGroup>

<ItemGroup>
<KnownFrameworkReference Update="Microsoft.NETCore.App">
<!-- Always update the 'latest version', whether the repo is servicing or not. -->
Expand Down
1 change: 1 addition & 0 deletions eng/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and are generated based on the last package release.
<LatestPackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
<LatestPackageReference Include="Microsoft.CodeAnalysis.Razor" Version="$(MicrosoftCodeAnalysisRazorPackageVersion)" />
<LatestPackageReference Include="Microsoft.CSharp" Version="$(MicrosoftCSharpPackageVersion)" />
<LatestPackageReference Include="Microsoft.DotNet.APICompat" Version="$(MicrosoftDotNetAPICompatPackageVersion)" />
<LatestPackageReference Include="Microsoft.DotNet.GenAPI" Version="$(MicrosoftDotNetGenApiPackageVersion)" />
<LatestPackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(MicrosoftDotNetPlatformAbstractionsPackageVersion)" />
<LatestPackageReference Include="Microsoft.Extensions.ActivatorUtilities.Sources" Version="$(MicrosoftExtensionsActivatorUtilitiesSourcesPackageVersion)" />
Expand Down
4 changes: 4 additions & 0 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@
<Uri>https://github.com/aspnet/Extensions</Uri>
<Sha>d40e21ccc14908a054b2181b1d6aeb22c49c630d</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.APICompat" Version="1.0.0-beta.19607.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>4d80b9cfa53e309c8f685abff3512f60c3d8a3d1</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.GenAPI" Version="1.0.0-beta.19607.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>4d80b9cfa53e309c8f685abff3512f60c3d8a3d1</Sha>
Expand Down
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<PropertyGroup Label="Automated">
<!-- Packages from dotnet/arcade -->
<MicrosoftDotNetGenAPIPackageVersion>1.0.0-beta.19607.3</MicrosoftDotNetGenAPIPackageVersion>
<MicrosoftDotNetAPICompatPackageVersion>1.0.0-beta.19607.3</MicrosoftDotNetAPICompatPackageVersion>
<!-- Packages from dotnet/roslyn -->
<MicrosoftNetCompilersToolsetPackageVersion>3.4.0-beta4-19569-03</MicrosoftNetCompilersToolsetPackageVersion>
<!-- Packages from dotnet/core-setup -->
Expand Down
1 change: 1 addition & 0 deletions eng/targets/CSharp.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<PackageReference Include="MicroBuild.Core" Version="0.3.0" PrivateAssets="All" AllowExplicitReference="true" ExcludeAssets="All" />

<PackageReference Condition="'$(DotNetBuildFromSource)' != 'true'" Include="Microsoft.DotNet.GenAPI" PrivateAssets="All" Version="$(MicrosoftDotNetGenApiPackageVersion)" IsImplicitlyDefined="true" />
<PackageReference Condition="'$(DotNetBuildFromSource)' != 'true'" Include="Microsoft.DotNet.APICompat" PrivateAssets="All" Version="$(MicrosoftDotNetAPICompatPackageVersion)" IsImplicitlyDefined="true" />
</ItemGroup>

<ItemGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
Expand Down
1 change: 1 addition & 0 deletions src/Antiforgery/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid checking in all of these tiny files? E.g. include one Total Issues: 0 default file plus those containing issues we actually want to ignore.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just exclude these files if there are no issues
https://github.com/dotnet/arcade/blob/767154ac5bb8715ab1357c63f346244de6d4aa6b/src/Microsoft.DotNet.ApiCompat/build/Microsoft.DotNet.ApiCompat.targets#L56
It seems like if a baseline does not exist, it will simply not be passed to apicompat.

Note that there's no corresponding option to output a file only when there are errors since when the option is set, the baseline file is always written: https://github.com/dotnet/arcade/blob/767154ac5bb8715ab1357c63f346244de6d4aa6b/src/Microsoft.DotNet.ApiCompat/build/Microsoft.DotNet.ApiCompat.targets#L108

1 change: 1 addition & 0 deletions src/Components/Authorization/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
10 changes: 10 additions & 0 deletions src/Components/Components/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Compat issues with assembly Microsoft.AspNetCore.Components:
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Microsoft.AspNetCore.Components.BindElementAttribute' changed from '[AttributeUsageAttribute(4, AllowMultiple=true, Inherited=true)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=true, Inherited=true)]' in the implementation.
dougbu marked this conversation as resolved.
Show resolved Hide resolved
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Microsoft.AspNetCore.Components.CascadingParameterAttribute' changed from '[AttributeUsageAttribute(128, AllowMultiple=false, Inherited=true)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Property, AllowMultiple=false, Inherited=true)]' in the implementation.
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Microsoft.AspNetCore.Components.EventHandlerAttribute' changed from '[AttributeUsageAttribute(4, AllowMultiple=true, Inherited=true)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=true, Inherited=true)]' in the implementation.
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Microsoft.AspNetCore.Components.InjectAttribute' changed from '[AttributeUsageAttribute(128, AllowMultiple=false, Inherited=true)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Property, AllowMultiple=false, Inherited=true)]' in the implementation.
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Microsoft.AspNetCore.Components.LayoutAttribute' changed from '[AttributeUsageAttribute(4, AllowMultiple=false, Inherited=true)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=false, Inherited=true)]' in the implementation.
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Microsoft.AspNetCore.Components.ParameterAttribute' changed from '[AttributeUsageAttribute(128, AllowMultiple=false, Inherited=true)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Property, AllowMultiple=false, Inherited=true)]' in the implementation.
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Microsoft.AspNetCore.Components.RouteAttribute' changed from '[AttributeUsageAttribute(4, AllowMultiple=true, Inherited=false)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=true, Inherited=false)]' in the implementation.
ParameterModifiersCannotChange : Custom modifiers on parameter 'renderBatch' on method 'Microsoft.AspNetCore.Components.RenderTree.Renderer.UpdateDisplayAsync(Microsoft.AspNetCore.Components.RenderTree.RenderBatch)' are 'System.Runtime.InteropServices.InAttribute' in the implementation but 'System.Runtime.InteropServices.InAttribute' in the contract.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a bug in the tool

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[In] is defined in a number of different assemblies. Perhaps something in how we build ref/ projects is very slightly different?

In any case, suggest a centralized exclusion for the [In] != [In] case.

Total Issues: 8
1 change: 1 addition & 0 deletions src/Components/Forms/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Components/Server/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
3 changes: 3 additions & 0 deletions src/Components/Web/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Compat issues with assembly Microsoft.AspNetCore.Components.Web:
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Microsoft.AspNetCore.Components.BindInputElementAttribute' changed from '[AttributeUsageAttribute(4, AllowMultiple=true, Inherited=true)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple=true, Inherited=true)]' in the implementation.
Total Issues: 1
3 changes: 3 additions & 0 deletions src/DataProtection/Abstractions/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Compat issues with assembly Microsoft.AspNetCore.DataProtection.Abstractions:
CannotChangeAttribute : Attribute 'System.ComponentModel.EditorBrowsableAttribute' on 'Microsoft.AspNetCore.DataProtection.Infrastructure.IApplicationDiscriminator' changed from '[EditorBrowsableAttribute(1)]' in the contract to '[EditorBrowsableAttribute(EditorBrowsableState.Never)]' in the implementation.
Total Issues: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/DataProtection/Extensions/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/DefaultBuilder/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
3 changes: 3 additions & 0 deletions src/Hosting/Abstractions/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Compat issues with assembly Microsoft.AspNetCore.Hosting.Abstractions:
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Microsoft.AspNetCore.Hosting.HostingStartupAttribute' changed from '[AttributeUsageAttribute(1, Inherited=false, AllowMultiple=true)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Assembly, Inherited=false, AllowMultiple=true)]' in the implementation.
Total Issues: 1
1 change: 1 addition & 0 deletions src/Hosting/Hosting/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Html/Abstractions/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Http/Authentication.Core/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Http/Headers/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Http/Http.Abstractions/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Http/Http.Extensions/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Http/Http.Features/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Http/Http/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Http/Metadata/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Http/Routing.Abstractions/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
5 changes: 5 additions & 0 deletions src/Http/Routing/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Compat issues with assembly Microsoft.AspNetCore.Routing:
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Microsoft.AspNetCore.Routing.HostAttribute' changed from '[AttributeUsageAttribute(68, AllowMultiple=false, Inherited=false)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple=false, Inherited=false)]' in the implementation.
MembersMustExist : Member 'Microsoft.AspNetCore.Routing.Matching.CandidateState.Values.set(Microsoft.AspNetCore.Routing.RouteValueDictionary)' does not exist in the implementation but it does exist in the contract.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should look into this one

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pilchie does this example refer to your question? The tool picked up a diff between the src file and the corresponding manual.cs file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not conclusive, since it was public on at least one side. I'd want to see a case where it reports a mismatch in something that is internal on both sides.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's entirely possible we messed a few things up when creating and updating *.Manual.cs files e.g. did the all-important internal keyword get deleted accidentally? Suggest checking GenAPI output w/ --all because that tool uses the same base infrastructure as ApiCompat.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we just messed up when updating Manual.cs files.

CannotChangeAttribute : Attribute 'System.Diagnostics.DebuggerDisplayAttribute' on 'Microsoft.AspNetCore.Routing.Patterns.RoutePatternPathSegment' changed from '[DebuggerDisplayAttribute("{DebuggerToString()}")]' in the contract to '[DebuggerDisplayAttribute("{DebuggerToString()}")]' in the implementation.
Total Issues: 3
1 change: 1 addition & 0 deletions src/Http/WebUtilities/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Identity/Core/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Identity/Extensions.Core/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Identity/Extensions.Stores/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
4 changes: 4 additions & 0 deletions src/Middleware/CORS/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Compat issues with assembly Microsoft.AspNetCore.Cors:
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Microsoft.AspNetCore.Cors.DisableCorsAttribute' changed from '[AttributeUsageAttribute(68, AllowMultiple=false, Inherited=false)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple=false, Inherited=false)]' in the implementation.
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Microsoft.AspNetCore.Cors.EnableCorsAttribute' changed from '[AttributeUsageAttribute(68, AllowMultiple=false, Inherited=true)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple=false, Inherited=true)]' in the implementation.
Total Issues: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Middleware/Diagnostics/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Middleware/HealthChecks/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Middleware/HostFiltering/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Middleware/HttpOverrides/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Middleware/HttpsPolicy/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Middleware/Localization/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Middleware/ResponseCaching/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Middleware/Rewrite/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Middleware/Session/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Middleware/StaticFiles/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Middleware/WebSockets/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Mvc/Mvc.Abstractions/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
1 change: 1 addition & 0 deletions src/Mvc/Mvc.ApiExplorer/src/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Issues: 0
Loading