@@ -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,17 +82,14 @@ private void InstrumentModule()
7482
7583 private void InstrumentType ( TypeDefinition type )
7684 {
77- TypeDefinition actualType = type ;
78- if ( type . FullName . Contains ( "/" ) )
79- actualType = type . Module . GetTypes ( ) . FirstOrDefault ( t => t . FullName == type . FullName . Split ( '/' ) [ 0 ] ) ;
80-
81- if ( actualType . CustomAttributes . Any ( IsExcludeAttribute )
82- || InstrumentationHelper . IsTypeExcluded ( _module , actualType . FullName , _filters ) )
83- return ;
84-
85- foreach ( var method in type . Methods )
85+ var methods = type . GetMethods ( ) ;
86+ foreach ( var method in methods )
8687 {
87- 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 ) )
8893 InstrumentMethod ( method ) ;
8994 }
9095 }
0 commit comments