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

[release/7.0] Don't bind against non-shipping contract assemblies #78730

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 12 additions & 1 deletion eng/resolveContract.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
<HasMatchingContract Condition="'$(HasMatchingContract)' == '' and Exists('$(ContractProject)')">true</HasMatchingContract>
<!-- Disable API compat if the project doesn't have reference assembly -->
<RunApiCompat Condition="'$(HasMatchingContract)' != 'true'">false</RunApiCompat>
<!-- Don't build against reference assemblies when projects are packable and the tfm is not the latest .NETCoreApp as
such reference assemblies don't ship to customers and only exist for tooling scenarios. -->
<AnnotateTargetPathWithContract Condition="'$(AnnotateTargetPathWithContract)' == '' and
'$(HasMatchingContract)' == 'true' and
(
'$(IsPackable)' != 'true' or
(
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
'$(TargetFrameworkVersion)' == 'v$(NetCoreAppCurrentVersion)'
)
)">true</AnnotateTargetPathWithContract>
</PropertyGroup>

<ItemGroup Condition="'$(IsSourceProject)' == 'true' or '$(IsReferenceAssemblyProject)' == 'true' or '$(IsPartialFacadeAssembly)' == 'true'">
Expand All @@ -36,7 +47,7 @@

<!-- Allow P2Ps that target a source project to build against the corresponding ref project. -->
<Target Name="AnnotateTargetPathWithTargetPlatformMonikerWithReferenceAssembly"
Condition="'$(HasMatchingContract)' == 'true'"
Condition="'$(AnnotateTargetPathWithContract)' == 'true'"
DependsOnTargets="ResolveProjectReferences"
AfterTargets="GetTargetPathWithTargetPlatformMoniker">
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<argument>ILLink</argument>
<argument>IL2050</argument>
<property name="Scope">member</property>
<property name="Target">M:System.DirectoryServices.Interop.UnsafeNativeMethods.ADsOpenObject(System.String,System.String,System.String,System.Int32,System.Guid@,System.Object@)</property>
<property name="Target">M:System.DirectoryServices.UnsafeNativeMethods.ADsOpenObject(System.String,System.String,System.String,System.Int32,System.Guid@,System.Object@)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.DirectoryServices.Interop
namespace System.DirectoryServices
{
internal enum AdsOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.DirectoryServices.Interop
namespace System.DirectoryServices
{
internal enum AdsPropertyOperation
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.Runtime.InteropServices;

namespace System.DirectoryServices.Interop
namespace System.DirectoryServices
{
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct AdsSearchColumn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.Runtime.InteropServices;

namespace System.DirectoryServices.Interop
namespace System.DirectoryServices
{
[StructLayout(LayoutKind.Sequential)]
internal struct AdsSearchPreferenceInfo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.DirectoryServices.Interop
namespace System.DirectoryServices
{
internal enum AdsSearchPreferences
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.Runtime.InteropServices;

namespace System.DirectoryServices.Interop
namespace System.DirectoryServices
{
[StructLayout(LayoutKind.Sequential)]
internal struct AdsSortKey
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.DirectoryServices.Interop
namespace System.DirectoryServices
{
internal enum AdsType
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.Runtime.InteropServices;

namespace System.DirectoryServices.Interop
namespace System.DirectoryServices
{
[StructLayout(LayoutKind.Sequential)]
internal struct Ads_Pointer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Runtime.InteropServices;
using System.Globalization;

namespace System.DirectoryServices.Interop
namespace System.DirectoryServices
{
[StructLayout(LayoutKind.Sequential)]
internal struct SystemTime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.DirectoryServices.Interop
namespace System.DirectoryServices
{
internal static class NativeMethods
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Security;
using System.Runtime.InteropServices;

namespace System.DirectoryServices.Interop
namespace System.DirectoryServices
{
internal static partial class SafeNativeMethods
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Runtime.InteropServices;
using System.Security;

namespace System.DirectoryServices.Interop
namespace System.DirectoryServices
{

[StructLayout(LayoutKind.Explicit)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public void SeizeRoleOwnership(ActiveDirectoryRole role)
// Increment the RIDAvailablePool by 30k.
if (role == ActiveDirectoryRole.RidRole)
{
System.DirectoryServices.Interop.UnsafeNativeMethods.IADsLargeInteger ridPool = (System.DirectoryServices.Interop.UnsafeNativeMethods.IADsLargeInteger)roleObjectEntry.Properties[PropertyManager.RIDAvailablePool].Value!;
System.DirectoryServices.UnsafeNativeMethods.IADsLargeInteger ridPool = (System.DirectoryServices.UnsafeNativeMethods.IADsLargeInteger)roleObjectEntry.Properties[PropertyManager.RIDAvailablePool].Value!;

// check the overflow of the low part
if (ridPool.LowPart + UpdateRidPoolSeizureValue < ridPool.LowPart)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.DirectoryServices.Interop;

namespace System.DirectoryServices
{
/// <devdoc>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Runtime.InteropServices;
using System.Collections;
using System.DirectoryServices.Interop;

namespace System.DirectoryServices
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Runtime.InteropServices;
using System.Diagnostics;
using System.DirectoryServices.Interop;
using System.ComponentModel;
using System.Threading;
using System.Reflection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.DirectoryServices.Interop;
using System.ComponentModel;

namespace System.DirectoryServices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Runtime.InteropServices;
using System.Collections;
using System.Collections.Specialized;
using System.DirectoryServices.Interop;
using System.ComponentModel;

using INTPTR_INTPTRCAST = System.IntPtr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.DirectoryServices.Interop;

namespace System.DirectoryServices
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Runtime.InteropServices;
using System.Collections;
using System.DirectoryServices.Interop;
using System.Globalization;

namespace System.DirectoryServices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;
using System.DirectoryServices.Interop;

namespace System.DirectoryServices
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;
using System.DirectoryServices.Interop;

namespace System.DirectoryServices
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Net;
using System.Runtime.InteropServices;
using System.Collections;
using System.DirectoryServices.Interop;
using System.Text;

using INTPTR_INTPTRCAST = System.IntPtr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ private static CodeTypeDeclaration CreateTypeDeclaration(string typeName, DataCo
CodeAttributeDeclaration generatedCodeAttribute = new CodeAttributeDeclaration(typeof(GeneratedCodeAttribute).FullName!);

AssemblyName assemblyName = Assembly.GetExecutingAssembly().GetName();
generatedCodeAttribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(assemblyName.Name)));
generatedCodeAttribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(assemblyName.Version?.ToString())));
generatedCodeAttribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(assemblyName.Name!)));
generatedCodeAttribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(assemblyName.Version?.ToString()!)));

// System.Diagnostics.DebuggerStepThroughAttribute not allowed on enums
// ensure that the attribute is only generated on types that are not enums
Expand Down Expand Up @@ -820,7 +820,7 @@ private void ExportClassDataContract(DataContract classDataContract, ContractCod
{
ContractCodeDomInfo baseContractCodeDomInfo = GetContractCodeDomInfo(classDataContract.BaseContract);
Debug.Assert(baseContractCodeDomInfo.IsProcessed, "Cannot generate code for type if code for base type has not been generated");
type.BaseTypes.Add(baseContractCodeDomInfo.TypeReference);
type.BaseTypes.Add(baseContractCodeDomInfo.TypeReference!);
AddBaseMemberNames(baseContractCodeDomInfo, contractCodeDomInfo);
if (baseContractCodeDomInfo.ReferencedTypeExists)
{
Expand Down Expand Up @@ -1153,7 +1153,7 @@ private void ExportISerializableDataContract(DataContract classDataContract, Con
{
ContractCodeDomInfo baseContractCodeDomInfo = GetContractCodeDomInfo(classDataContract.BaseContract);
GenerateType(classDataContract.BaseContract, baseContractCodeDomInfo);
type.BaseTypes.Add(baseContractCodeDomInfo.TypeReference);
type.BaseTypes.Add(baseContractCodeDomInfo.TypeReference!);
if (baseContractCodeDomInfo.ReferencedTypeExists)
{
Type? actualType = (Type?)baseContractCodeDomInfo.TypeReference?.UserData[s_codeUserDataActualTypeKey];
Expand Down Expand Up @@ -1238,7 +1238,7 @@ private void ExportCollectionDataContract(DataContract collectionContract, Contr
Debug.Assert(contractCodeDomInfo.TypeDeclaration != null);

CodeTypeDeclaration generatedType = contractCodeDomInfo.TypeDeclaration;
generatedType.BaseTypes.Add(baseTypeReference);
generatedType.BaseTypes.Add(baseTypeReference!);
CodeAttributeDeclaration collectionContractAttribute = new CodeAttributeDeclaration(GetClrTypeFullName(typeof(CollectionDataContractAttribute)));
collectionContractAttribute.Arguments.Add(new CodeAttributeArgument(ImportGlobals.NameProperty, new CodePrimitiveExpression(dataContractName)));
collectionContractAttribute.Arguments.Add(new CodeAttributeArgument(ImportGlobals.NamespaceProperty, new CodePrimitiveExpression(collectionContract.XmlName.Namespace)));
Expand Down Expand Up @@ -1673,7 +1673,7 @@ private static CodeThisReferenceExpression ThisReference

private static CodePrimitiveExpression NullReference
{
get { return new CodePrimitiveExpression(null); }
get { return new CodePrimitiveExpression(null!); }
}

private CodeParameterDeclarationExpression SerializationInfoParameter
Expand Down Expand Up @@ -1784,12 +1784,12 @@ private CodeMemberMethod GetSchemaStaticMethod
new CodeTypeReferenceExpression(GetCodeTypeReference(typeof(XmlSerializableServices))),
nameof(XmlSerializableServices.AddDefaultSchema),
new CodeArgumentReferenceExpression(paramDeclaration.Name),
new CodeFieldReferenceExpression(null, TypeNameFieldName)
new CodeFieldReferenceExpression(null!, TypeNameFieldName)
)
);
getSchemaStaticMethod.Statements.Add(
new CodeMethodReturnStatement(
new CodeFieldReferenceExpression(null, TypeNameFieldName)
new CodeFieldReferenceExpression(null!, TypeNameFieldName)
)
);
return getSchemaStaticMethod;
Expand Down