From c8503d39053f9e0d94716a23c406b66f126ca259 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Tue, 22 Nov 2022 20:01:29 +0100 Subject: [PATCH] Cleanup GenFacades logic and don't bind against non-shipping contract assemblies (#78703) * Clean-up the ApiCompat and GenAPI logic * Fix System.DirectoryServices.AccountManagement build System.DirectoryServices.AccountManagement now builds against src/System.DirectoryServices instead of ref/System.DirectoryServices (because the package doesn't contain the ref assembly). Because of that, the compiler now gets confused because of the System.DirectoryServices.Interop namespace and the global Interop class. This happens even though the DirectoryServices.Interop namespace doesn't include any public types. That results in the following erros: src\libraries\System.DirectoryServices.AccountManagement\src\System\DirectoryServices\AccountManagement\AD\SidList.cs(50,26): error CS0246: The type or namespace name 'SID_AND_ATTRIBUTES' could not be found (are you missing a using directive or an assembly reference?) src\libraries\System.DirectoryServices.AccountManagement\src\System\DirectoryServices\AccountManagement\interopt.cs(439,20): error CS0246: The type or namespace name 'UNICODE_INTPTR_STRING' could not be found (are you missing a using directive or an assembly reference?) This commit fixes that by removing the System.DirectoryServices.Interop namespace and moving the types into the parent namespace. * Suppress nullable warnings in Serialization.Schema Now that Schema compiles against the source assembly of System.CodeDom, it receives nullability errors. I'm suppressing them manually for now but am filing an issue to correctly fix those. Related: https://github.com/dotnet/runtime/issues/78036 * Move SkipUseReferenceAssembly target up --- eng/Version.Details.xml | 4 +- eng/Versions.props | 2 +- eng/references.targets | 20 +++ eng/resolveContract.props | 14 -- eng/resolveContract.targets | 128 ++++++++++-------- .../System.Private.CoreLib.csproj | 3 +- .../src/System.Private.CoreLib.csproj | 3 +- src/libraries/Directory.Build.props | 2 +- src/libraries/Directory.Build.targets | 11 +- .../src/ILLink/ILLink.Suppressions.xml | 2 +- .../src/Interop/AdsOptions.cs | 2 +- .../src/Interop/AdsPropertyOperation.cs | 2 +- .../src/Interop/AdsSearchColumn.cs | 2 +- .../src/Interop/AdsSearchPreferenceInfo.cs | 2 +- .../src/Interop/AdsSearchPreferences.cs | 2 +- .../src/Interop/AdsSortKey.cs | 2 +- .../src/Interop/AdsType.cs | 2 +- .../src/Interop/AdsValue2.cs | 2 +- .../src/Interop/AdsValueHelper2.cs | 2 +- .../src/Interop/NativeMethods.cs | 2 +- .../src/Interop/SafeNativeMethods.cs | 2 +- .../src/Interop/UnsafeNativeMethods.cs | 2 +- .../ActiveDirectory/DomainController.cs | 2 +- .../DirectoryServices/AuthenticationTypes.cs | 2 - .../DirectoryServices/DirectoryEntries.cs | 1 - .../DirectoryServices/DirectoryEntry.cs | 1 - .../DirectoryEntryConfiguration.cs | 1 - .../DirectoryServices/DirectorySearcher.cs | 1 - .../DirectoryServicesCOMException.cs | 1 - .../DirectoryServices/PropertyCollection.cs | 1 - .../PropertyValueCollection.cs | 1 - .../DirectoryServices/SchemaNameCollection.cs | 1 - .../SearchResultCollection.cs | 1 - .../Serialization/Schema/CodeExporter.cs | 16 +-- src/libraries/apicompat/ApiCompat.proj | 9 +- src/libraries/shims/Directory.Build.targets | 18 ++- src/libraries/shims/src/Directory.Build.props | 7 - src/libraries/shims/src/netstandard.csproj | 2 +- .../System.Private.CoreLib.csproj | 3 +- 39 files changed, 147 insertions(+), 134 deletions(-) delete mode 100644 eng/resolveContract.props diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 8f1419c12ac43..8f89d99d6daf1 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -106,9 +106,9 @@ https://github.com/dotnet/arcade 80b6be47e1425ea90c5febffac119250043a0c92 - + https://github.com/dotnet/arcade - 80b6be47e1425ea90c5febffac119250043a0c92 + fc4ba340496ca0e45d51914f8f1606c60e3c75c6 https://github.com/dotnet/arcade diff --git a/eng/Versions.props b/eng/Versions.props index e54249982e315..a7bc4c2a1b545 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -85,7 +85,7 @@ 8.0.0-beta.22554.2 8.0.0-beta.22554.2 8.0.0-beta.22554.2 - 8.0.0-beta.22554.2 + 8.0.0-beta.22572.2 8.0.0-beta.22554.2 2.5.1-beta.22554.2 8.0.0-beta.22554.2 diff --git a/eng/references.targets b/eng/references.targets index 9ce2c0ed3e60c..0dac678971586 100644 --- a/eng/references.targets +++ b/eng/references.targets @@ -59,6 +59,26 @@ + + + + + false + + + + <_resolvedP2PFiltered Include="@(ProjectReference)" + ProjectReferenceItemSpec="$([System.IO.Path]::GetFullPath('%(ProjectReference.Identity)'))" + SkipUseReferenceAssembly="%(ProjectReference.SkipUseReferenceAssembly)" /> + <_ResolvedProjectReferencePaths Condition="'%(_resolvedP2PFiltered.ProjectReferenceItemSpec)' == '%(_resolvedP2PFiltered.MSBuildSourceProjectFile)' and + '%(_resolvedP2PFiltered.SkipUseReferenceAssembly)' == 'true'" + ReferenceAssembly="" /> + + + $(IsReferenceAssemblyProject) diff --git a/eng/resolveContract.props b/eng/resolveContract.props deleted file mode 100644 index fe4224a844a47..0000000000000 --- a/eng/resolveContract.props +++ /dev/null @@ -1,14 +0,0 @@ - - - - true - - true - true - - - - - - - diff --git a/eng/resolveContract.targets b/eng/resolveContract.targets index 57bd558774558..c3ed00145d141 100644 --- a/eng/resolveContract.targets +++ b/eng/resolveContract.targets @@ -1,20 +1,72 @@ + + + + $(LibrariesProjectRoot)$(MSBuildProjectName)\ref\$(MSBuildProjectName).csproj + true + + true + + + + + + + + + + + + + + + + + ResolvedMatchingContract true + + + true + true + <_ApiCompatCaptureGroupPattern>.+%5C$([System.IO.Path]::DirectorySeparatorChar)(.+)%5C$([System.IO.Path]::DirectorySeparatorChar)(.+) <_ApiCompatRuntimePrefixPattern>(.+)/(net%5Cd.%5Cd)-(.+)/(.+) <_ApiCompatLibReplacementString>lib/$1/$2 <_ApiCompatLibReplacementString Condition="'$(MSBuildProjectName)' == 'System.Private.CoreLib'">lib/$(NetCoreAppCurrent)/$2 + - $(RepositoryEngineeringDir)DefaultGenApiDocIds.txt - $(RepositoryEngineeringDir)LicenseHeader.txt - $([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '..', 'ref', '$(AssemblyName).cs')) - $(LangVersion) - $(CoreLibProject) + + + false + + + false + + + + + @@ -30,64 +82,30 @@ Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(NetCoreAppCurrent)'))" /> - - $(LibrariesProjectRoot)$(MSBuildProjectName)\ref\$(MSBuildProjectName).csproj - true - - - - - false - - - false - - - - - - - - - + - - - - - - - - + + $(RepositoryEngineeringDir)DefaultGenApiDocIds.txt + $(RepositoryEngineeringDir)LicenseHeader.txt + $([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '..', 'ref', '$(AssemblyName).cs')) + $(LangVersion) + $(CoreLibProject) + - - - - false - - - - <_resolvedP2PFiltered Include="@(ProjectReference)" - ProjectReferenceItemSpec="$([System.IO.Path]::GetFullPath('%(ProjectReference.Identity)'))" - SkipUseReferenceAssembly="%(ProjectReference.SkipUseReferenceAssembly)" /> - <_ResolvedProjectReferencePaths Condition="'%(_resolvedP2PFiltered.ProjectReferenceItemSpec)' == '%(_resolvedP2PFiltered.MSBuildSourceProjectFile)' and - '%(_resolvedP2PFiltered.SkipUseReferenceAssembly)' == 'true'" - ReferenceAssembly="" /> - - + + + + diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj index 153c1f6c56bc6..6394cc80b2673 100644 --- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -348,8 +348,7 @@ - true + true - diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj index b1e8c4cee8e40..0609cc6b648f5 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -608,8 +608,7 @@ - true + true - diff --git a/src/libraries/Directory.Build.props b/src/libraries/Directory.Build.props index 7cf964f8366d8..b46ee2f5249a9 100644 --- a/src/libraries/Directory.Build.props +++ b/src/libraries/Directory.Build.props @@ -70,7 +70,6 @@ - @@ -84,6 +83,7 @@ + true true false diff --git a/src/libraries/Directory.Build.targets b/src/libraries/Directory.Build.targets index 37fc0f12c2420..28ee4d2f303c6 100644 --- a/src/libraries/Directory.Build.targets +++ b/src/libraries/Directory.Build.targets @@ -125,7 +125,7 @@ - + @@ -141,11 +141,16 @@ - - + + + + + + + @@ -53,7 +54,7 @@ RoslynAssembliesPath="$(RoslynAssembliesPath)" GenerateSuppressionFile="$(ApiCompatGenerateSuppressionFile)" SuppressionFiles="$(ApiCompatNetCoreAppLatestStableBaselineFile)" - EnableRuleAttributesMustMatch="$(ApiCompatEnableRuleAttributesMustMatch)" + EnableRuleAttributesMustMatch="true" ExcludeAttributesFiles="@(ApiCompatExcludeAttributesFile)" LeftAssembliesTransformationPattern="@(ApiCompatNetCoreAppLatestStableLeftAssembliesTransformationPattern)" RightAssembliesTransformationPattern="@(ApiCompatNetCoreAppCurrentRightAssembliesTransformationPattern)" /> @@ -65,7 +66,7 @@ RoslynAssembliesPath="$(RoslynAssembliesPath)" GenerateSuppressionFile="$(ApiCompatGenerateSuppressionFile)" SuppressionFiles="$(ApiCompatNetStandard21BaselineFile)" - EnableRuleAttributesMustMatch="$(ApiCompatEnableRuleAttributesMustMatch)" + EnableRuleAttributesMustMatch="true" ExcludeAttributesFiles="@(ApiCompatExcludeAttributesFile)" LeftAssembliesTransformationPattern="@(ApiCompatNetStandard21LeftAssembliesTransformationPattern)" RightAssembliesTransformationPattern="@(ApiCompatNetCoreAppCurrentRightAssembliesTransformationPattern)" /> @@ -77,7 +78,7 @@ RoslynAssembliesPath="$(RoslynAssembliesPath)" GenerateSuppressionFile="$(ApiCompatGenerateSuppressionFile)" SuppressionFiles="$(ApiCompatNetStandard20BaselineFile)" - EnableRuleAttributesMustMatch="$(ApiCompatEnableRuleAttributesMustMatch)" + EnableRuleAttributesMustMatch="true" ExcludeAttributesFiles="@(ApiCompatExcludeAttributesFile)" LeftAssembliesTransformationPattern="@(ApiCompatNetStandard20LeftAssembliesTransformationPattern)" RightAssembliesTransformationPattern="@(ApiCompatNetCoreAppCurrentRightAssembliesTransformationPattern)" /> diff --git a/src/libraries/shims/Directory.Build.targets b/src/libraries/shims/Directory.Build.targets index 0780fa92ad2e8..c8ee44a679b42 100644 --- a/src/libraries/shims/Directory.Build.targets +++ b/src/libraries/shims/Directory.Build.targets @@ -1,17 +1,21 @@ - - - - - - + + + GenFacadesReferenceAssembly + + true $(GeneratePartialFacadeSourceDependsOn);FindReferenceAssembliesForReferences ReferencePathWithRefAssemblies + + + + + diff --git a/src/libraries/shims/src/Directory.Build.props b/src/libraries/shims/src/Directory.Build.props index 5841ecb19f20c..0b532b15f5913 100644 --- a/src/libraries/shims/src/Directory.Build.props +++ b/src/libraries/shims/src/Directory.Build.props @@ -5,11 +5,4 @@ $(MSBuildThisFileDirectory)..\ref\$(MSBuildProjectName).csproj true - - - - - diff --git a/src/libraries/shims/src/netstandard.csproj b/src/libraries/shims/src/netstandard.csproj index cce47288ba655..ee3f1d4f47b01 100644 --- a/src/libraries/shims/src/netstandard.csproj +++ b/src/libraries/shims/src/netstandard.csproj @@ -8,6 +8,6 @@ - + diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index 17a336f423c22..b23dce200a1ab 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -347,9 +347,8 @@ - true + true -