Skip to content

Commit

Permalink
Mark Assembly.GetCallingAssembly with [RequiresDynamicCode].
Browse files Browse the repository at this point in the history
  • Loading branch information
teo-tsirpanis committed Jul 11, 2022
1 parent af63ef1 commit efa25b2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -71,6 +72,7 @@ public static Assembly GetExecutingAssembly()
}

[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
[RequiresDynamicCode("Assembly.GetCallingAssembly is not supported in AOT environments.")]
public static Assembly GetCallingAssembly()
{
// LookForMyCallersCaller is not guaranteed to return the correct stack frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Configuration.Assemblies;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.IO;

Expand All @@ -16,7 +17,8 @@ public abstract partial class Assembly : ICustomAttributeProvider, ISerializable

[System.Runtime.CompilerServices.Intrinsic]
public static Assembly GetExecutingAssembly() { throw NotImplemented.ByDesign; } //Implemented by toolchain.


[RequiresDynamicCode("Assembly.GetCallingAssembly is not supported in AOT environments.")]
public static Assembly GetCallingAssembly()
{
if (AppContext.TryGetSwitch("Switch.System.Reflection.Assembly.SimulatedCallingAssembly", out bool isSimulated) && isSimulated)
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10731,6 +10731,7 @@ public virtual event System.Reflection.ModuleResolveEventHandler? ModuleResolve
public static string CreateQualifiedName(string? assemblyName, string? typeName) { throw null; }
public override bool Equals(object? o) { throw null; }
public static System.Reflection.Assembly? GetAssembly(System.Type type) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Assembly.GetCallingAssembly is not supported in AOT environments.")]
public static System.Reflection.Assembly GetCallingAssembly() { throw null; }
public virtual object[] GetCustomAttributes(bool inherit) { throw null; }
public virtual object[] GetCustomAttributes(System.Type attributeType, bool inherit) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -42,6 +43,7 @@ public static Assembly GetExecutingAssembly()
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern RuntimeAssembly GetExecutingAssembly(ref StackCrawlMark stackMark);

[RequiresDynamicCode("Assembly.GetCallingAssembly is not supported in AOT environments.")]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern Assembly GetCallingAssembly();

Expand Down

0 comments on commit efa25b2

Please sign in to comment.