Last active
April 14, 2018 15:02
-
-
Save bruno-garcia/4443962b586eef8916a8644db21fc724 to your computer and use it in GitHub Desktop.
Is .NET assembly optimized
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel; | |
using System.Diagnostics; | |
using System.Reflection; | |
[EditorBrowsable(EditorBrowsableState.Never)] | |
internal static class AssemblyExtensions | |
{ | |
/// <summary> | |
/// Whether the assembly was compiled with the optimize+ flag | |
/// </summary> | |
/// <param name="asm">The assemlby to verify the optimization flag</param> | |
/// <returns> | |
/// true if no <see cref="DebuggableAttribute"/> exists or | |
/// <see cref="DebuggableAttribute.IsJITOptimizerDisabled"/> is false, | |
/// otherwise, false. | |
/// </returns> | |
public static bool IsOptimized(this Assembly asm) | |
{ | |
var att = asm.GetCustomAttribute<DebuggableAttribute>(); | |
return att == null || att.IsJITOptimizerDisabled == false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment