Declare AllowReversePInvokeCallsAttribute as Obsolete. (#39636)
authorAaron Robinson <arobins@microsoft.com>
Mon, 20 Jul 2020 21:24:50 +0000 (14:24 -0700)
committerGitHub <noreply@github.com>
Mon, 20 Jul 2020 21:24:50 +0000 (14:24 -0700)
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/AllowReversePInvokeCallsAttribute.cs
src/libraries/System.Reflection.Metadata/tests/Resources/Interop/Interop.Mock01.cs
src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs
src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.Tests.csproj
src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/AllowReversePInvokeCallsAttributeTests.cs [deleted file]

index 5b14e88..99b3a57 100644 (file)
@@ -3,8 +3,8 @@
 
 namespace System.Runtime.InteropServices
 {
-    // To be used on methods that sink reverse P/Invoke calls.
-    // This attribute was a Silverlight security measure, currently ignored.
+    // This attribute was a Silverlight security measure and is no longer respected.
+    [Obsolete(Obsoletions.CodeAccessSecurityMessage, DiagnosticId = Obsoletions.CodeAccessSecurityDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
     [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
     public sealed class AllowReversePInvokeCallsAttribute : Attribute
     {
index 612ed41..0ad8ac9 100644 (file)
@@ -98,7 +98,6 @@ namespace MockInterop01
     [TypeLibImportClass(typeof(object))]
     public interface IBar
     {
-        [AllowReversePInvokeCalls()]
         object DoSomething(params string[] ary);
         [ComRegisterFunction()]
         object Register([MarshalAs(UnmanagedType.IDispatch), Optional, DefaultParameterValue(null)] ref object o);
index 62a7124..e4860f7 100644 (file)
@@ -91,6 +91,7 @@ namespace System.Runtime.CompilerServices
 }
 namespace System.Runtime.InteropServices
 {
+    [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.Method, AllowMultiple=false, Inherited=false)]
     public sealed partial class AllowReversePInvokeCallsAttribute : System.Attribute
     {
index 1e6ec37..a4dab3d 100644 (file)
@@ -8,7 +8,6 @@
     <Compile Include="AssemblyInfo.cs" />
     <Compile Include="System\DllNotFoundExceptionTests.cs" />
     <Compile Include="System\Runtime\CompilerServices\IUnknownConstantAttributeTests.cs" />
-    <Compile Include="System\Runtime\InteropServices\AllowReversePInvokeCallsAttributeTests.cs" />
     <Compile Include="System\Runtime\InteropServices\ArrayWithOffsetTests.cs" />
     <Compile Include="System\Runtime\InteropServices\BestFitMappingAttributeTests.cs" />
     <Compile Include="System\Runtime\InteropServices\BStrWrapperTests.cs" />
diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/AllowReversePInvokeCallsAttributeTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/AllowReversePInvokeCallsAttributeTests.cs
deleted file mode 100644 (file)
index e2a9f2e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Linq;
-using System.Reflection;
-using Xunit;
-
-namespace System.Runtime.InteropServices.Tests
-{
-    public class AllowReversePInvokeCallsAttributeTests
-    {
-        [AllowReversePInvokeCalls]
-        private int Func(int a, int b) => a + b;
-
-        [Fact]
-        public void Exists()
-        {
-            Type type = typeof(AllowReversePInvokeCallsAttributeTests);
-            MethodInfo method = type.GetTypeInfo().DeclaredMethods.Single(m => m.Name == "Func");
-            AllowReversePInvokeCallsAttribute attribute = Assert.Single(method.GetCustomAttributes< AllowReversePInvokeCallsAttribute>(inherit: false));
-            Assert.NotNull(attribute);
-        }
-    }
-}