@@ -23,6 +23,7 @@ internal class Instrumenter
2323 private readonly string [ ] _includeFilters ;
2424 private readonly string [ ] _excludedFiles ;
2525 private readonly string [ ] _excludedAttributes ;
26+ private readonly bool _isCoreLibrary ;
2627 private InstrumenterResult _result ;
2728 private FieldDefinition _customTrackerHitsFilePath ;
2829 private FieldDefinition _customTrackerHitsArray ;
@@ -42,11 +43,9 @@ public Instrumenter(string module, string identifier, string[] excludeFilters, s
4243 _excludedFiles = excludedFiles ?? Array . Empty < string > ( ) ;
4344 _excludedAttributes = excludedAttributes ;
4445
45- IsCoreLibrary = Path . GetFileNameWithoutExtension ( _module ) == "System.Private.CoreLib" ;
46+ _isCoreLibrary = Path . GetFileNameWithoutExtension ( _module ) == "System.Private.CoreLib" ;
4647 }
4748
48- private bool IsCoreLibrary { get ; }
49-
5049 public bool CanInstrument ( ) => InstrumentationHelper . HasPdb ( _module ) ;
5150
5251 public InstrumenterResult Instrument ( )
@@ -78,7 +77,7 @@ private void InstrumentModule()
7877 {
7978 resolver . AddSearchDirectory ( Path . GetDirectoryName ( _module ) ) ;
8079 var parameters = new ReaderParameters { ReadSymbols = true , AssemblyResolver = resolver } ;
81- if ( IsCoreLibrary )
80+ if ( _isCoreLibrary )
8281 {
8382 parameters . MetadataImporterProvider = new CoreLibMetadataImporterProvider ( ) ;
8483 }
@@ -100,7 +99,7 @@ private void InstrumentModule()
10099 var actualType = type . DeclaringType ?? type ;
101100 if ( ! actualType . CustomAttributes . Any ( IsExcludeAttribute )
102101 // Instrumenting Interlocked which is used for recording hits would cause an infinite loop.
103- && ( ! IsCoreLibrary || actualType . FullName != "System.Threading.Interlocked" )
102+ && ( ! _isCoreLibrary || actualType . FullName != "System.Threading.Interlocked" )
104103 && ! InstrumentationHelper . IsTypeExcluded ( _module , actualType . FullName , _excludeFilters )
105104 && InstrumentationHelper . IsTypeIncluded ( _module , actualType . FullName , _includeFilters ) )
106105 InstrumentType ( type ) ;
@@ -433,7 +432,7 @@ private Instruction AddInstrumentationInstructions(MethodDefinition method, ILPr
433432 {
434433 if ( _customTrackerRecordHitMethod == null )
435434 {
436- var recordHitMethodName = IsCoreLibrary
435+ var recordHitMethodName = _isCoreLibrary
437436 ? nameof ( ModuleTrackerTemplate . RecordHitInCoreLibrary )
438437 : nameof ( ModuleTrackerTemplate . RecordHit ) ;
439438 _customTrackerRecordHitMethod = new MethodReference (
0 commit comments