Guest User

Untitled

a guest
Jan 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. Index: ILScanner.cs
  2. ===================================================================
  3. --- ILScanner.cs (revision 84518)
  4. +++ ILScanner.cs (working copy)
  5. @@ -43,6 +43,13 @@
  6. }
  7. }*/
  8.  
  9. + public class ScannerQueueItem
  10. + {
  11. + public object Item;
  12. + public object SourceItem;
  13. + public string QueueReason;
  14. + }
  15. +
  16. public class ILScanner : IDisposable
  17. {
  18. protected ILReader mReader;
  19. @@ -51,7 +58,7 @@
  20. protected OurHashSet<object> mItems = new OurHashSet<object>();
  21. protected List<object> mItemsList = new List<object>();
  22. // Contains items to be scanned, both types and methods
  23. - protected Queue<object> mQueue = new Queue<object>();
  24. + protected Queue<ScannerQueueItem> mQueue = new Queue<ScannerQueueItem>();
  25. // Virtual methods are nasty and constantly need to be rescanned for
  26. // overriding methods in new types, so we keep track of them separately.
  27. // They are also in the main mItems and mQueue.
  28. @@ -116,7 +123,7 @@
  29. mLogEnabled = true;
  30. }
  31.  
  32. - protected void Queue(object aItem, object aSrc, string aSrcType)
  33. + protected void Queue(object aItem, object aSrc, string aSrcType, object sourceItem = null)
  34. {
  35. var xMemInfo = aItem as MemberInfo;
  36. //TODO: fix this, as each label/symbol should also contain an assembly specifier.
  37. @@ -135,7 +142,8 @@
  38. }
  39. mItems.Add(aItem);
  40. mItemsList.Add(aItem);
  41. - mQueue.Enqueue(aItem);
  42. +
  43. + mQueue.Enqueue(new ScannerQueueItem() { Item = aItem, QueueReason = aSrcType, SourceItem = aSrc + Environment.NewLine + sourceItem });
  44. }
  45. }
  46.  
  47. @@ -156,7 +164,7 @@
  48. }
  49. if (xAttrib == null)
  50. {
  51. - ScanMethod(xMethod, true);
  52. + ScanMethod(xMethod, true, "Plug Sub Method");
  53. }
  54. else
  55. {
  56. @@ -166,7 +174,7 @@
  57. }
  58. if (xAttrib.Enabled && !xAttrib.IsMonoOnly)
  59. {
  60. - ScanMethod(xMethod, true);
  61. + ScanMethod(xMethod, true, ".Net plug Method");
  62. }
  63. }
  64. }
  65. @@ -662,7 +670,7 @@
  66. }
  67. }
  68.  
  69. - protected void ScanMethod(MethodBase aMethod, bool aIsPlug)
  70. + protected void ScanMethod(MethodBase aMethod, bool aIsPlug, object sourceItem)
  71. {
  72. var xParams = aMethod.GetParameters();
  73. var xParamTypes = new Type[xParams.Length];
  74. @@ -804,7 +812,7 @@
  75. }
  76. if (xNeedsPlug)
  77. {
  78. - throw new Exception("Plug needed. " + MethodInfoLabelGenerator.GenerateFullName(aMethod));
  79. + throw new Exception("Plug needed. " + MethodInfoLabelGenerator.GenerateFullName(aMethod) + "." + Environment.NewLine + " Called from :" + Environment.NewLine + sourceItem);
  80. }
  81.  
  82. //TODO: As we scan each method, we could update or put in a new list
  83. @@ -823,7 +831,7 @@
  84. {
  85. if (xOpCode is ILOpCodes.OpMethod)
  86. {
  87. - Queue(((ILOpCodes.OpMethod)xOpCode).Value, aMethod, "Call");
  88. + Queue(((ILOpCodes.OpMethod)xOpCode).Value, aMethod, "Call",sourceItem);
  89. }
  90. else if (xOpCode is ILOpCodes.OpType)
  91. {
  92. @@ -942,15 +950,15 @@
  93. var xItem = mQueue.Dequeue();
  94. // Check for MethodBase first, they are more numerous
  95. // and will reduce compares
  96. - if (xItem is MethodBase)
  97. + if (xItem.Item is MethodBase)
  98. {
  99. - ScanMethod((MethodBase)xItem, false);
  100. + ScanMethod((MethodBase)xItem.Item, false, xItem.SourceItem);
  101. }
  102. - else if (xItem is Type)
  103. + else if (xItem.Item is Type)
  104. {
  105. - ScanType((Type)xItem);
  106. + ScanType((Type)xItem.Item);
  107. }
  108. - else if (xItem is FieldInfo)
  109. + else if (xItem.Item is FieldInfo)
  110. {
  111. // todo: static fields need more processing?
  112. }
Add Comment
Please, Sign In to add comment