@@ -60,11 +60,19 @@ private void InstrumentModule()
60
60
{
61
61
resolver . AddSearchDirectory ( Path . GetDirectoryName ( _module ) ) ;
62
62
var parameters = new ReaderParameters { ReadSymbols = true , AssemblyResolver = resolver } ;
63
+
63
64
using ( var module = ModuleDefinition . ReadModule ( stream , parameters ) )
64
65
{
65
- foreach ( var type in module . GetTypes ( ) )
66
+ var types = module . GetTypes ( ) ;
67
+ foreach ( var type in types )
66
68
{
67
- InstrumentType ( type ) ;
69
+ TypeDefinition actualType = type ;
70
+ if ( type . FullName . Contains ( "/" ) )
71
+ actualType = types . FirstOrDefault ( t => t . FullName == type . FullName . Split ( '/' ) [ 0 ] ) ;
72
+
73
+ if ( ! actualType . CustomAttributes . Any ( IsExcludeAttribute )
74
+ && ! InstrumentationHelper . IsTypeExcluded ( _module , actualType . FullName , _filters ) )
75
+ InstrumentType ( type ) ;
68
76
}
69
77
70
78
module . Write ( stream ) ;
@@ -74,13 +82,14 @@ private void InstrumentModule()
74
82
75
83
private void InstrumentType ( TypeDefinition type )
76
84
{
77
- if ( type . CustomAttributes . Any ( IsExcludeAttribute )
78
- || InstrumentationHelper . IsTypeExcluded ( _module , type . FullName , _filters ) )
79
- return ;
80
-
81
- foreach ( var method in type . Methods )
85
+ var methods = type . GetMethods ( ) ;
86
+ foreach ( var method in methods )
82
87
{
83
- if ( ! method . CustomAttributes . Any ( IsExcludeAttribute ) )
88
+ MethodDefinition actualMethod = method ;
89
+ if ( InstrumentationHelper . IsLocalMethod ( method . Name ) )
90
+ actualMethod = methods . FirstOrDefault ( m => m . Name == method . Name . Split ( '>' ) [ 0 ] . Substring ( 1 ) ) ?? method ;
91
+
92
+ if ( ! actualMethod . CustomAttributes . Any ( IsExcludeAttribute ) )
84
93
InstrumentMethod ( method ) ;
85
94
}
86
95
}
@@ -116,7 +125,7 @@ private void InstrumentIL(MethodDefinition method)
116
125
var instruction = processor . Body . Instructions [ index ] ;
117
126
var sequencePoint = method . DebugInformation . GetSequencePoint ( instruction ) ;
118
127
var targetedBranchPoints = branchPoints . Where ( p => p . EndOffset == instruction . Offset ) ;
119
-
128
+
120
129
if ( sequencePoint != null && ! sequencePoint . IsHidden )
121
130
{
122
131
var target = AddInstrumentationCode ( method , processor , instruction , sequencePoint ) ;
@@ -139,7 +148,7 @@ private void InstrumentIL(MethodDefinition method)
139
148
*/
140
149
if ( _branchTarget . StartLine == - 1 || _branchTarget . Document == null )
141
150
continue ;
142
-
151
+
143
152
var target = AddInstrumentationCode ( method , processor , instruction , _branchTarget ) ;
144
153
foreach ( var _instruction in processor . Body . Instructions )
145
154
ReplaceInstructionTarget ( _instruction , instruction , target ) ;
0 commit comments