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

Enable Supported attributes from sdk for non browser build, fix related warnings #45504

Merged
merged 3 commits into from
Dec 14, 2020
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
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'">
Copy link
Member Author

@buyaa-n buyaa-n Dec 2, 2020

Choose a reason for hiding this comment

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

As SupportedOSPlatform("windows") for windows targets will be added by MSBuild we don't need it anymore

<!-- 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 @@ -156,9 +156,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'">
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
<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);
Copy link
Member Author

Choose a reason for hiding this comment

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

Separated the section accessing windows only API

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);
}
}
}
}
}