Skip to content

Commit

Permalink
Add missing methodimpl flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
Washi1337 committed Jun 7, 2024
1 parent 9ecc97a commit bf80344
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/AsmResolver.DotNet/MethodDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,44 @@ public bool NoInlining
{
get => (ImplAttributes & MethodImplAttributes.NoInlining) != 0;
set => ImplAttributes = (ImplAttributes & ~MethodImplAttributes.NoInlining)
| (value ? MethodImplAttributes.NoInlining : 0);
| (value ? MethodImplAttributes.NoInlining : 0);
}

/// <summary>
/// Gets or sets a value indicating whether the method should be inlined if possible.
/// </summary>
public bool IsAggressiveInlining
{
get => (ImplAttributes & MethodImplAttributes.AggressiveInlining) != 0;
set => ImplAttributes = (ImplAttributes & ~MethodImplAttributes.AggressiveInlining)
| (value ? MethodImplAttributes.AggressiveInlining : 0);
}

/// <summary>
/// Gets or sets a value indicating whether the method contains hot code and should be aggressively optimized.
/// </summary>
public bool IsAggressiveOptimization
{
get => (ImplAttributes & MethodImplAttributes.AggressiveOptimization) != 0;
set => ImplAttributes = (ImplAttributes & ~MethodImplAttributes.AggressiveOptimization)
| (value ? MethodImplAttributes.AggressiveOptimization : 0);
}

/// <summary>
/// Gets or sets a value indicating that the JIT compiler should look for security mitigation attributes,
/// such as the user-defined <c>System.Runtime.CompilerServices.SecurityMitigationsAttribute</c>. If found,
/// the JIT compiler applies any related security mitigations. Available starting with .NET Framework 4.8.
/// </summary>
/// <remarks>
/// This is an undocumented flag and is currently not used:
/// Original addition: https://github.com/dotnet/dotnet-api-docs/pull/2253
/// Documentation removal: https://github.com/dotnet/dotnet-api-docs/pull/4652
/// </remarks>
public bool HasSecurityMitigations
{
get => (ImplAttributes & MethodImplAttributes.SecurityMitigations) != 0;
set => ImplAttributes = (ImplAttributes & ~MethodImplAttributes.SecurityMitigations)
| (value ? MethodImplAttributes.SecurityMitigations : 0);
}

/// <inheritdoc />
Expand Down
22 changes: 22 additions & 0 deletions src/AsmResolver.PE/DotNet/Metadata/Tables/MethodImplAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,27 @@ public enum MethodImplAttributes : ushort
/// Method may not be inlined.
/// </summary>
NoInlining = 0x0008,

/// <summary>
/// Method should be inlined if possible.
/// </summary>
AggressiveInlining = 0x0100,

/// <summary>
/// Method may contain hot code and should be aggressively optimized.
/// </summary>
AggressiveOptimization = 0x0200,

/// <summary>
/// Specifies that the JIT compiler should look for security mitigation attributes, such as the user-defined
/// <c>System.Runtime.CompilerServices.SecurityMitigationsAttribute</c>. If found, the JIT compiler applies
/// any related security mitigations. Available starting with .NET Framework 4.8.
/// </summary>
/// <remarks>
/// This is an undocumented flag and is currently not used:
/// Original addition: https://github.com/dotnet/dotnet-api-docs/pull/2253
/// Documentation removal: https://github.com/dotnet/dotnet-api-docs/pull/4652
/// </remarks>
SecurityMitigations,
}
}

0 comments on commit bf80344

Please sign in to comment.