Skip to content

Commit

Permalink
Enable the option to invoke APICompat in strict mode for ref-pack ser…
Browse files Browse the repository at this point in the history
…vicing (dotnet#88707)

* Fixes dotnet#42961

Enable strict mode comparison during servicing when
`ApiCompatNetCoreAppBaselineVersion` is the current .NET version. When
the GA targeting pack is released, that property should be updated which
will turn on strict mode comparison and prohibits the addition of new
API.

Suppressing one error in the baseline file that showed-up because
out-of-band assemblies now being passed in as assembly references.

While at it I also cleaned-up how private assemblies are handled during
the build.

* PR feedback
  • Loading branch information
ViktorHofer committed Jul 13, 2023
1 parent 7bcc4ef commit b9c9964
Show file tree
Hide file tree
Showing 23 changed files with 116 additions and 73 deletions.
12 changes: 11 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
<NetCoreAppPreviousVersion>7.0</NetCoreAppPreviousVersion>
<NetCoreAppPrevious>net$(NetCoreAppPreviousVersion)</NetCoreAppPrevious>
<NetCoreAppPrevious Condition="'$(DotNetBuildFromSource)' == 'true'">$(NetCoreAppCurrent)</NetCoreAppPrevious>
<NetCoreAppPreviousPackageBaselineVersion>$(NetCoreAppPreviousVersion).0</NetCoreAppPreviousPackageBaselineVersion>

<!-- The minimum supported .NET version. -->
<NetCoreAppMinimum>net6.0</NetCoreAppMinimum>
Expand All @@ -113,6 +112,10 @@
<NetFrameworkToolCurrent Condition="'$(DotNetBuildFromSource)' == 'true'" />
<NetFrameworkCurrent Condition="'$(DotNetBuildFromSource)' == 'true'" />

<!-- Important: Set this to the GA version (or a close approximation) during servicing and adjust the TFM property below. -->
<ApiCompatNetCoreAppBaselineVersion>7.0.0</ApiCompatNetCoreAppBaselineVersion>
<ApiCompatNetCoreAppBaselineTFM>net7.0</ApiCompatNetCoreAppBaselineTFM>

<TargetFrameworkForNETFrameworkTasks>$(NetFrameworkToolCurrent)</TargetFrameworkForNETFrameworkTasks>
<!-- Don't build for NETFramework during source-build. -->
<TargetFrameworkForNETFrameworkTasks Condition="'$(DotNetBuildFromSource)' == 'true'" />
Expand Down Expand Up @@ -349,6 +352,13 @@
<PlaceholderFile>$(RepositoryEngineeringDir)_._</PlaceholderFile>
</PropertyGroup>

<!-- Flow these properties to consuming projects. -->
<ItemDefinitionGroup>
<TargetPathWithTargetPlatformMoniker>
<IsPrivateAssembly>$(IsPrivateAssembly.ToLowerInvariant())</IsPrivateAssembly>
</TargetPathWithTargetPlatformMoniker>
</ItemDefinitionGroup>

<!-- Language configuration -->
<PropertyGroup>
<!-- default to allowing all language features -->
Expand Down
2 changes: 1 addition & 1 deletion eng/packaging.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<DisablePackageBaselineValidation Condition="'$(IsShipping)' == 'false' or
'$(SuppressFinalPackageVersion)' == 'true' or
'$(DotNetBuildFromSource)' == 'true'">true</DisablePackageBaselineValidation>
<PackageValidationBaselineVersion Condition="'$(PackageValidationBaselineVersion)' == ''">$(NetCoreAppPreviousPackageBaselineVersion)</PackageValidationBaselineVersion>
<PackageValidationBaselineVersion Condition="'$(PackageValidationBaselineVersion)' == ''">$(ApiCompatNetCoreAppBaselineVersion)</PackageValidationBaselineVersion>
<BeforePack>$(BeforePack);IncludeAnalyzersInPackage;AddNETStandardCompatErrorFileForPackaging</BeforePack>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);AddRuntimeSpecificFilesToPackage;IncludeProjectReferencesWithPackAttributeInPackage</TargetsForTfmSpecificContentInPackage>
<!-- Don't include target platform specific dependencies, since we use the target platform to represent RIDs instead -->
Expand Down
10 changes: 0 additions & 10 deletions eng/references.targets
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@
</ItemGroup>
</Target>

<!-- An opt-in target to trim out private assemblies from the ref assembly ReferencePath. -->
<Target Name="TrimOutPrivateAssembliesFromReferencePath"
Condition="'$(CompileUsingReferenceAssemblies)' == 'true' and '$(TrimOutPrivateAssembliesFromReferencePath)' == 'true'"
AfterTargets="FindReferenceAssembliesForReferences">
<ItemGroup>
<ReferencePathWithRefAssemblies Remove="@(ReferencePathWithRefAssemblies)"
Condition="$(NetCoreAppLibraryNoReference.Contains('%(Filename);'))" />
</ItemGroup>
</Target>

<Target Name="ReplaceCoreLibSrcWithRefAssemblyForCompilation"
AfterTargets="FindReferenceAssembliesForReferences"
Condition="'$(CompileUsingReferenceAssemblies)' != 'true' and '@(_coreLibProjectReference)' != ''">
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
$(NetCoreAppLibrary.Contains('$(AssemblyName);'))">true</IsNETCoreAppSrc>
<IsNETCoreAppRef Condition="('$(IsReferenceAssemblyProject)' == 'true' or '$(IsRuntimeAndReferenceAssembly)' == 'true') and
$(NetCoreAppLibrary.Contains('$(AssemblyName);')) and
!$(NetCoreAppLibraryNoReference.Contains('$(AssemblyName);'))">true</IsNETCoreAppRef>
'$(IsPrivateAssembly)' != 'true'">true</IsNETCoreAppRef>
<IsNETCoreAppAnalyzer Condition="'$(IsGeneratorProject)' == 'true' and
$(NetCoreAppLibraryGenerator.Contains('$(MSBuildProjectName);'))">true</IsNETCoreAppAnalyzer>
<!-- Inbox analyzers shouldn't use the live targeting / runtime pack. They better depend on an LKG to avoid layering concerns. -->
Expand Down
8 changes: 0 additions & 8 deletions src/libraries/NetCoreAppLibrary.props
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,6 @@
System.Xml.XPath;
System.Xml.XPath.XDocument;
</NetCoreAppLibrary>
<NetCoreAppLibraryNoReference>
System.Private.CoreLib;
System.Private.DataContractSerialization;
System.Private.Uri;
System.Private.Xml;
System.Private.Xml.Linq;
</NetCoreAppLibraryNoReference>
<!-- List .NETCoreApp shared framework generator project names below. -->
<NetCoreAppLibraryGenerator>
ComInterfaceGenerator;
Expand Down Expand Up @@ -252,7 +245,6 @@
<ItemGroup>
<NetFxReference Include="$(NetFxReference)" />
<NetCoreAppLibrary Include="$(NetCoreAppLibrary)" />
<NetCoreAppLibraryNoReference Include="$(NetCoreAppLibraryNoReference)" />
<NetCoreAppLibraryGenerator Include="$(NetCoreAppLibraryGenerator)" />
<AspNetCoreAppLibrary Include="$(AspNetCoreAppLibrary)" />
<WindowsDesktopCoreAppLibrary Include="$(WindowsDesktopCoreAppLibrary)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
<ProjectReference Include="..\..\System.Collections.NonGeneric\src\System.Collections.NonGeneric.csproj" />
<ProjectReference Include="..\..\System.ComponentModel.TypeConverter\src\System.ComponentModel.TypeConverter.csproj" />
<ProjectReference Include="..\..\System.Runtime\src\System.Runtime.csproj" />
<ProjectReference Include="..\..\System.Private.Uri\src\System.Private.Uri.csproj" />
<ProjectReference Include="..\..\System.Private.Uri\src\System.Private.Uri.csproj" PrivateAssets="all" />
<Reference Include="System.Collections.Concurrent" />
<Reference Include="System.ComponentModel" />
<Reference Include="System.ComponentModel.Primitives" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<RootNamespace>System.Xml</RootNamespace>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<RootNamespace>System.Xml</RootNamespace>
</PropertyGroup>

<ItemGroup>
<Compile Include="$(CommonPath)System\Collections\Generic\EnumerableHelpers.cs"
Link="Common\System\Collections\Generic\EnumerableHelpers.cs" />
Expand Down Expand Up @@ -40,14 +42,16 @@
<Compile Include="System\Xml\XPath\XNodeNavigator.cs" />
<Compile Include="System\Xml\XPath\XObjectExtensions.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" PrivateAssets="all" />
<Reference Include="System.Collections" />
<Reference Include="System.Linq" />
<Reference Include="System.Memory" />
<Reference Include="System.ObjectModel" />
<Reference Include="System.Runtime" />
<Reference Include="System.Threading" />
<Reference Include="System.Threading.Thread" />
<Reference Include="System.Memory" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(CoreLibProject)" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Uri\src\System.Private.Uri.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Uri\src\System.Private.Uri.csproj" PrivateAssets="all" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime\src\System.Runtime.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.DataContractSerialization\src\System.Private.DataContractSerialization.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.DataContractSerialization\src\System.Private.DataContractSerialization.csproj" PrivateAssets="all"/>
<Reference Include="System.Runtime" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.DataContractSerialization\src\System.Private.DataContractSerialization.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.DataContractSerialization\src\System.Private.DataContractSerialization.csproj" PrivateAssets="all"/>
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Serialization.Primitives" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<RootNamespace>System.Xml</RootNamespace>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" PrivateAssets="all" />
<Reference Include="System.Runtime" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<RootNamespace>System.Xml</RootNamespace>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml.Linq\src\System.Private.Xml.Linq.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml.Linq\src\System.Private.Xml.Linq.csproj" PrivateAssets="all" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" PrivateAssets="all"/>
<Reference Include="System.Runtime" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="System\Xml\XPath\XDocumentExtensions.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml.Linq\src\System.Private.Xml.Linq.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" PrivateAssets="all" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml.Linq\src\System.Private.Xml.Linq.csproj" PrivateAssets="all" />
<Reference Include="System.Runtime" />
</ItemGroup>

</Project>
7 changes: 5 additions & 2 deletions src/libraries/System.Xml.XPath/src/System.Xml.XPath.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" PrivateAssets="all" />
<Reference Include="System.Runtime" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" PrivateAssets="all" />
<Reference Include="System.Runtime" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.Xml\src\System.Private.Xml.csproj" PrivateAssets="all"/>
<Reference Include="System.Runtime" />
</ItemGroup>

</Project>
Loading

0 comments on commit b9c9964

Please sign in to comment.