DebuggableAttribute.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. namespace System.Diagnostics
  5. {
  6. // Attribute class used by the compiler to mark modules.
  7. // If present, then debugging information for everything in the
  8. // assembly was generated by the compiler, and will be preserved
  9. // by the Runtime so that the debugger can provide full functionality
  10. // in the case of JIT attach. If not present, then the compiler may
  11. // or may not have included debugging information, and the Runtime
  12. // won't preserve the debugging info, which will make debugging after
  13. // a JIT attach difficult.
  14. [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module, AllowMultiple = false)]
  15. public sealed class DebuggableAttribute : Attribute
  16. {
  17. [Flags]
  18. public enum DebuggingModes
  19. {
  20. None = 0x0,
  21. Default = 0x1,
  22. DisableOptimizations = 0x100,
  23. IgnoreSymbolStoreSequencePoints = 0x2,
  24. EnableEditAndContinue = 0x4
  25. }
  26. public DebuggableAttribute(bool isJITTrackingEnabled, bool isJITOptimizerDisabled)
  27. {
  28. DebuggingFlags = 0;
  29. if (isJITTrackingEnabled)
  30. {
  31. DebuggingFlags |= DebuggingModes.Default;
  32. }
  33. if (isJITOptimizerDisabled)
  34. {
  35. DebuggingFlags |= DebuggingModes.DisableOptimizations;
  36. }
  37. }
  38. public DebuggableAttribute(DebuggingModes modes)
  39. {
  40. DebuggingFlags = modes;
  41. }
  42. public bool IsJITTrackingEnabled => (DebuggingFlags & DebuggingModes.Default) != 0;
  43. public bool IsJITOptimizerDisabled => (DebuggingFlags & DebuggingModes.DisableOptimizations) != 0;
  44. public DebuggingModes DebuggingFlags { get; }
  45. }
  46. }