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

Mark DirectoryServices CAS APIs as Obsolete #40756

Merged
merged 5 commits into from
Aug 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
13 changes: 13 additions & 0 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,19 @@
</When>
</Choose>

<!-- Adds ObsoleteAttribute to projects that need to apply downlevel Obsoletions with DiagnosticId and UrlFormat -->
<Choose>
<When Condition="'$(IncludeInternalObsoleteAttribute)' == 'true' and ($(TargetFramework.StartsWith('netstandard')) or $(TargetFramework.StartsWith('netcoreapp')) or '$(TargetFrameworkIdentifier)' == '.NETFramework')">
<ItemGroup>
<Compile Include="$(CoreLibSharedDir)System\ObsoleteAttribute.cs" Link="System\ObsoleteAttribute.cs" />
</ItemGroup>
<PropertyGroup>
<!-- Suppress CS0436 to allow ObsoleteAttribute to be internally defined and used in netstandard -->
<NoWarn>$(NoWarn);CS0436</NoWarn>
</PropertyGroup>
</When>
</Choose>

<!-- The Default behavior in VS is to show files for the first target framework in TargetFrameworks property.
This is required to show all the files corresponding to all target frameworks in VS. -->
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ public DirectoryServicesCOMException(string message, System.Exception inner) { }
public string ExtendedErrorMessage { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
}
[System.ObsoleteAttribute("Code Access Security is not supported or honored by the runtime.", DiagnosticId = "SYSLIB0003", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public sealed partial class DirectoryServicesPermission : System.Security.Permissions.ResourcePermissionBase
{
public DirectoryServicesPermission() { }
Expand All @@ -274,6 +275,7 @@ public enum DirectoryServicesPermissionAccess
Browse = 2,
Write = 6,
}
[System.ObsoleteAttribute("Code Access Security is not supported or honored by the runtime.", DiagnosticId = "SYSLIB0003", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)]
public partial class DirectoryServicesPermissionAttribute : System.Security.Permissions.CodeAccessSecurityAttribute
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<IncludeInternalObsoleteAttribute>true</IncludeInternalObsoleteAttribute>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.DirectoryServices.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;netstandard2.0;netcoreapp2.0-Windows_NT</TargetFrameworks>
<ExcludeCurrentNetCoreAppFromPackage>true</ExcludeCurrentNetCoreAppFromPackage>
<IncludeInternalObsoleteAttribute>true</IncludeInternalObsoleteAttribute>
</PropertyGroup>
<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup>
Expand Down Expand Up @@ -135,6 +136,7 @@
<Compile Include="Interop\NativeMethods.cs" />
<Compile Include="Interop\SafeNativeMethods.cs" />
<Compile Include="Interop\UnsafeNativeMethods.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs" Link="System\Obsoletions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Security.Permissions\src\System.Security.Permissions.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

namespace System.DirectoryServices
{
#pragma warning disable SYSLIB0003
// Conditionally marking this type as obsolete in .NET 5+ will require diverging its net5.0 build from netstandard2.0
// https://github.com/dotnet/runtime/issues/39413
[Obsolete(Obsoletions.CodeAccessSecurityMessage, DiagnosticId = Obsoletions.CodeAccessSecurityDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public sealed class DirectoryServicesPermission : ResourcePermissionBase
{
public DirectoryServicesPermission() { }
Expand All @@ -16,5 +14,4 @@ public DirectoryServicesPermission(PermissionState state) { }
public DirectoryServicesPermission(DirectoryServicesPermissionAccess permissionAccess, string path) { }
public DirectoryServicesPermissionEntryCollection PermissionEntries { get; }
}
#pragma warning restore SYSLIB0003
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

namespace System.DirectoryServices
{
#pragma warning disable SYSLIB0003
// Conditionally marking this type as obsolete in .NET 5+ will require diverging its net5.0 build from netstandard2.0
// https://github.com/dotnet/runtime/issues/39413
[Obsolete(Obsoletions.CodeAccessSecurityMessage, DiagnosticId = Obsoletions.CodeAccessSecurityDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct |
AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Event,
AllowMultiple = true, Inherited = false)]
Expand All @@ -19,5 +17,4 @@ public DirectoryServicesPermissionAttribute(SecurityAction action) : base(defaul
public string Path { get; set; }
public override IPermission CreatePermission() { return default(IPermission); }
}
#pragma warning restore SYSLIB0003
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ namespace System
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum |
AttributeTargets.Interface | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Delegate,
Inherited = false)]
public sealed class ObsoleteAttribute : Attribute
#if SYSTEM_PRIVATE_CORELIB
public
#else
#nullable enable
internal
#endif
sealed class ObsoleteAttribute : Attribute
{
public ObsoleteAttribute()
{
Expand Down