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
{
[TypeLibImportClass(typeof(object))]
public interface IBar
{
- [AllowReversePInvokeCalls()]
object DoSomething(params string[] ary);
[ComRegisterFunction()]
object Register([MarshalAs(UnmanagedType.IDispatch), Optional, DefaultParameterValue(null)] ref object o);
}
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
{
<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" />
+++ /dev/null
-// 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);
- }
- }
-}