From 3e129b297749b9d8554a619e1ecc9827b6de3d37 Mon Sep 17 00:00:00 2001 From: PhilippNaused Date: Thu, 12 Feb 2026 20:53:07 +0100 Subject: [PATCH 1/2] Add MethodImplAttributes.Async flag --- src/DotNet/MethodDef.cs | 8 ++++++++ src/DotNet/MethodImplAttributes.cs | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/DotNet/MethodDef.cs b/src/DotNet/MethodDef.cs index 1411eb1ae..6fe8a88b9 100644 --- a/src/DotNet/MethodDef.cs +++ b/src/DotNet/MethodDef.cs @@ -853,6 +853,14 @@ public bool IsAggressiveOptimization { public bool HasSecurityMitigations { get => ((MethodImplAttributes)implAttributes & MethodImplAttributes.SecurityMitigations) != 0; set => ModifyImplAttributes(value, MethodImplAttributes.SecurityMitigations); + } + + /// + /// Gets/sets the bit + /// + public bool IsAsync { + get => ((MethodImplAttributes)implAttributes & MethodImplAttributes.Async) != 0; + set => ModifyImplAttributes(value, MethodImplAttributes.Async); } /// diff --git a/src/DotNet/MethodImplAttributes.cs b/src/DotNet/MethodImplAttributes.cs index b1d3b3a48..eaedf3ccd 100644 --- a/src/DotNet/MethodImplAttributes.cs +++ b/src/DotNet/MethodImplAttributes.cs @@ -46,5 +46,7 @@ public enum MethodImplAttributes : ushort { AggressiveOptimization = 0x0200, /// The JIT compiler should look for security mitigation attributes, such as the user-defined System.Runtime.CompilerServices.SecurityMitigationsAttribute. If found, the JIT compiler applies any related security mitigations. Available starting with .NET Framework 4.8. SecurityMitigations = 0x0400, + /// Method requires async state machine rewrite. Available starting with .NET 11.0. + Async = 0x2000, } } From 98d43d7404bf512b2d233440ac60b92481978e83 Mon Sep 17 00:00:00 2001 From: PhilippNaused Date: Mon, 1 Jun 2026 08:34:10 +0200 Subject: [PATCH 2/2] Add remarks to MethodDef.HasReturnType --- src/DotNet/MethodDef.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/DotNet/MethodDef.cs b/src/DotNet/MethodDef.cs index 6fe8a88b9..1821508e7 100644 --- a/src/DotNet/MethodDef.cs +++ b/src/DotNet/MethodDef.cs @@ -498,6 +498,12 @@ public TypeSig ReturnType { /// /// true if the method returns a value (i.e., return type is not ) /// + /// + /// methods also do not have matching return type conventions as sync methods. + /// For sync methods, the stack should contain a value convertible to the stated return type before the instruction. + /// For async methods, the stack should be empty in the case of Task or ValueTask, or the type argument in the case of Task<T> or ValueTask<T>. + /// + /// public bool HasReturnType => ReturnType.RemovePinnedAndModifiers().GetElementType() != ElementType.Void; /// @@ -853,8 +859,8 @@ public bool IsAggressiveOptimization { public bool HasSecurityMitigations { get => ((MethodImplAttributes)implAttributes & MethodImplAttributes.SecurityMitigations) != 0; set => ModifyImplAttributes(value, MethodImplAttributes.SecurityMitigations); - } - + } + /// /// Gets/sets the bit ///