Skip to content

Commit

Permalink
Enable Supported attributes from sdk for non browser build, fix relat…
Browse files Browse the repository at this point in the history
…ed warnings (#45504)
  • Loading branch information
buyaa-n committed Dec 14, 2020
1 parent 448bc55 commit 6e7fc2f
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 26 deletions.
9 changes: 4 additions & 5 deletions eng/versioning.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
</AssemblyMetadata>
</ItemGroup>

<!-- Adds SupportedOSPlatform attribute for Windows Specific libraries and Windows targets -->
<ItemGroup Condition="('$(IsWindowsSpecific)' == 'true' or '$(TargetsWindows)' == 'true') and '$(IsTestProject)' != 'true'">
<!-- Adds SupportedOSPlatform attribute for Windows Specific libraries -->
<ItemGroup Condition="'$(IsWindowsSpecific)' == 'true' and '$(IsTestProject)' != 'true'">
<AssemblyAttribute Include="System.Runtime.Versioning.SupportedOSPlatform">
<_Parameter1>windows</_Parameter1>
</AssemblyAttribute>
Expand Down Expand Up @@ -165,9 +165,8 @@

</Target>

<!-- Removes specified assembly level attributes. https://github.com/dotnet/runtime/issues/44257-->
<Target Name="RemoveSupportedPlatformAssemblyLevelAttribute"
AfterTargets="GetAssemblyAttributes">
<!-- Removes assembly level attributes for Browser. -->
<Target Name="RemoveSupportedPlatformAssemblyAttributeForBrowser" AfterTargets="GetAssemblyAttributes" Condition="'$(TargetFrameworkSuffix)' == 'Browser' or '$(IsTestProject)' == 'true'">
<ItemGroup>
<AssemblyAttribute Remove="System.Runtime.Versioning.SupportedOSPlatformAttribute" />
<AssemblyAttribute Remove="System.Runtime.Versioning.TargetPlatformAttribute" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -488,4 +489,7 @@
<data name="DirectoryServicesProtocols_PlatformNotSupported" xml:space="preserve">
<value>System.DirectoryServices.Protocols is not supported on this platform.</value>
</data>
</root>
<data name="QuotaControlNotSupported" xml:space="preserve">
<value>System.DirectoryServices.Protocols.QuotaControl is not supported on this platform.</value>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeDllSafeSearchPathAttribute>true</IncludeDllSafeSearchPathAttribute>
Expand Down Expand Up @@ -41,6 +41,7 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
<Compile Include="System\DirectoryServices\Protocols\common\BerConverter.Windows.cs" />
<Compile Include="System\DirectoryServices\Protocols\common\QuotaControl.Windows.cs" />
<Compile Include="System\DirectoryServices\Protocols\Interop\LdapPal.Windows.cs" />
<Compile Include="System\DirectoryServices\Protocols\Interop\BerPal.Windows.cs" />
<Compile Include="System\DirectoryServices\Protocols\ldap\LdapConnection.Windows.cs" />
Expand All @@ -58,6 +59,7 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
<Compile Include="System\DirectoryServices\Protocols\common\BerConverter.Linux.cs" />
<Compile Include="System\DirectoryServices\Protocols\common\QuotaControl.Linux.cs" />
<Compile Include="System\DirectoryServices\Protocols\Interop\LdapPal.Linux.cs" />
<Compile Include="System\DirectoryServices\Protocols\Interop\BerPal.Linux.cs" />
<Compile Include="System\DirectoryServices\Protocols\ldap\LdapConnection.Linux.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ public byte[] ContextId
}

[SupportedOSPlatform("windows")]
public class QuotaControl : DirectoryControl
public partial class QuotaControl : DirectoryControl
{
private byte[] _sid;

Expand All @@ -1033,23 +1033,6 @@ public QuotaControl(SecurityIdentifier querySid) : this()
QuerySid = querySid;
}

public SecurityIdentifier QuerySid
{
get => _sid == null ? null : new SecurityIdentifier(_sid, 0);
set
{
if (value == null)
{
_sid = null;
}
else
{
_sid = new byte[value.BinaryLength];
value.GetBinaryForm(_sid, 0);
}
}
}

public override byte[] GetValue()
{
_directoryControlValue = BerConverter.Encode("{o}", new object[] { _sid });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Security.Principal;

namespace System.DirectoryServices.Protocols
{
public partial class QuotaControl : DirectoryControl
{
public SecurityIdentifier QuerySid
{
get => _sid == null ? null : throw new System.PlatformNotSupportedException(SR.QuotaControlNotSupported);
set
{
if (value == null)
{
_sid = null;
}
else
{
throw new System.PlatformNotSupportedException(SR.QuotaControlNotSupported);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Security.Principal;

namespace System.DirectoryServices.Protocols
{
public partial class QuotaControl : DirectoryControl
{
public SecurityIdentifier QuerySid
{
get => _sid == null ? null : new SecurityIdentifier(_sid, 0);
set
{
if (value == null)
{
_sid = null;
}
else
{
_sid = new byte[value.BinaryLength];
value.GetBinaryForm(_sid, 0);
}
}
}
}
}

0 comments on commit 6e7fc2f

Please sign in to comment.