Skip to content

Commit

Permalink
Mark all APIs that call Assembly.GetCallingAssembly with `[Requires…
Browse files Browse the repository at this point in the history
…DynamicCode]`.
  • Loading branch information
teo-tsirpanis committed Jul 11, 2022
1 parent efa25b2 commit 31b5aac
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ 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()
{
Expand Down Expand Up @@ -56,5 +56,5 @@ public static Assembly LoadWithPartialName(string partialName)
return null;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ internal ErrObject() { }
public string Source { get { throw null; } set { } }
public void Clear() { }
public System.Exception? GetException() { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("ErrObject.Raise is not supported in AOT environments. Throw exceptions with the Throw keyword instead.")]
public void Raise(int Number, object? Source = null, object? Description = null, object? HelpFile = null, object? HelpContext = null) { }
}
[System.FlagsAttribute]
Expand All @@ -329,6 +330,7 @@ public enum FileAttribute
Directory = 16,
Archive = 32,
}
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("The FileSystem module is not supported in AOT environments. Use members of the System.IO namespace instead.")]
[Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute]
public sealed partial class FileSystem
{
Expand Down Expand Up @@ -1146,6 +1148,7 @@ public sealed partial class ProjectData
internal ProjectData() { }
public static void ClearProjectError() { }
public static System.Exception CreateProjectError(int hr) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("ProjectData.EndApp is not supported in AOT environments. Use System.Environment.Exit(0) instead.")]
public static void EndApp() { }
public static void SetProjectError(System.Exception? ex) { }
public static void SetProjectError(System.Exception? ex, int lErl) { }
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.

Imports System
Imports System.Diagnostics.CodeAnalysis

Namespace Global.Microsoft.VisualBasic.CompilerServices

Expand Down Expand Up @@ -177,6 +178,7 @@ Namespace Global.Microsoft.VisualBasic.CompilerServices
Err.Clear()
End Sub

<RequiresDynamicCode("ProjectData.EndApp is not supported in AOT environments. Use System.Environment.Exit(0) instead.")>
Public Shared Sub EndApp()
FileSystem.CloseAllFiles(System.Reflection.Assembly.GetCallingAssembly())
System.Environment.Exit(0) 'System.Environment.Exit will cause finalizers to be run at shutdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Imports Microsoft.VisualBasic.CompilerServices
Imports Microsoft.VisualBasic.CompilerServices.Utils

Imports System
Imports System.Diagnostics.CodeAnalysis
Imports System.Runtime.InteropServices

Namespace Microsoft.VisualBasic
Expand Down Expand Up @@ -269,6 +270,7 @@ Namespace Microsoft.VisualBasic
''' <param name="Description">If not supplied, we try to look one up based on the error code being raised</param>
''' <param name="HelpFile"></param>
''' <param name="HelpContext"></param>
<RequiresDynamicCode("ErrObject.Raise is not supported in AOT environments. Throw exceptions with the Throw keyword instead.")>
Public Sub Raise(ByVal Number As Integer,
Optional ByVal Source As Object = Nothing,
Optional ByVal Description As Object = Nothing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Imports Microsoft.VisualBasic.CompilerServices.Utils

Namespace Microsoft.VisualBasic

<RequiresDynamicCode("The FileSystem module is not supported in AOT environments. Use members of the System.IO namespace instead.")>
Public Module FileSystem

Private Const ERROR_FILE_NOT_FOUND As Integer = 2
Expand Down

0 comments on commit 31b5aac

Please sign in to comment.