@@ -60,11 +60,19 @@ private void InstrumentModule()
6060 {
6161 resolver . AddSearchDirectory ( Path . GetDirectoryName ( _module ) ) ;
6262 var parameters = new ReaderParameters { ReadSymbols = true , AssemblyResolver = resolver } ;
63+
6364 using ( var module = ModuleDefinition . ReadModule ( stream , parameters ) )
6465 {
65- foreach ( var type in module . GetTypes ( ) )
66+ var types = module . GetTypes ( ) ;
67+ foreach ( var type in types )
6668 {
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 ) ;
6876 }
6977
7078 module . Write ( stream ) ;
@@ -74,13 +82,14 @@ private void InstrumentModule()
7482
7583 private void InstrumentType ( TypeDefinition type )
7684 {
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 )
8287 {
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 ) )
8493 InstrumentMethod ( method ) ;
8594 }
8695 }
@@ -116,7 +125,7 @@ private void InstrumentIL(MethodDefinition method)
116125 var instruction = processor . Body . Instructions [ index ] ;
117126 var sequencePoint = method . DebugInformation . GetSequencePoint ( instruction ) ;
118127 var targetedBranchPoints = branchPoints . Where ( p => p . EndOffset == instruction . Offset ) ;
119-
128+
120129 if ( sequencePoint != null && ! sequencePoint . IsHidden )
121130 {
122131 var target = AddInstrumentationCode ( method , processor , instruction , sequencePoint ) ;
@@ -139,7 +148,7 @@ private void InstrumentIL(MethodDefinition method)
139148 */
140149 if ( _branchTarget . StartLine == - 1 || _branchTarget . Document == null )
141150 continue ;
142-
151+
143152 var target = AddInstrumentationCode ( method , processor , instruction , _branchTarget ) ;
144153 foreach ( var _instruction in processor . Body . Instructions )
145154 ReplaceInstructionTarget ( _instruction , instruction , target ) ;
0 commit comments