55//
66using System ;
77using System . Collections . Generic ;
8- using System . Diagnostics ;
98using System . IO ;
109using System . Linq ;
1110using System . Runtime . CompilerServices ;
@@ -25,6 +24,10 @@ public class Filter : IFilter
2524 internal IList < RegexFilter > ExcludedAttributes { get ; private set ; }
2625 internal IList < RegexFilter > ExcludedFiles { get ; private set ; }
2726 internal IList < RegexFilter > TestFiles { get ; private set ; }
27+
28+ /// <summary>
29+ /// Are the filters supplied as reguar expressions
30+ /// </summary>
2831 public bool RegExFilters { get ; private set ; }
2932
3033
@@ -42,6 +45,13 @@ public Filter(bool useRegexFilters = false)
4245 RegExFilters = useRegexFilters ;
4346 }
4447
48+ /// <summary>
49+ /// Decides whether an assembly should be included in the instrumentation
50+ /// </summary>
51+ /// <param name="processName">The name of the process being profiled</param>
52+ /// <param name="assemblyName">the name of the assembly under profile</param>
53+ /// <remarks>All assemblies matching either the inclusion or exclusion filter should be included
54+ /// as it is the class that is being filtered within these unless the class filter is *</remarks>
4555 public bool UseAssembly ( string processName , string assemblyName )
4656 {
4757 processName = Path . GetFileNameWithoutExtension ( processName ) ;
@@ -65,6 +75,13 @@ public bool UseAssembly(string processName, string assemblyName)
6575 return false ;
6676 }
6777
78+ /// <summary>
79+ /// Determine if an [assemblyname]classname pair matches the current Exclusion or Inclusion filters
80+ /// </summary>
81+ /// <param name="processName">The name of the process</param>
82+ /// <param name="assemblyName">the name of the assembly under profile</param>
83+ /// <param name="className">the name of the class under profile</param>
84+ /// <returns>false - if pair matches the exclusion filter or matches no filters, true - if pair matches in the inclusion filter</returns>
6885 public bool InstrumentClass ( string processName , string assemblyName , string className )
6986 {
7087 if ( string . IsNullOrEmpty ( processName ) || string . IsNullOrEmpty ( assemblyName ) || string . IsNullOrEmpty ( className ) )
@@ -96,11 +113,23 @@ public bool InstrumentClass(string processName, string assemblyName, string clas
96113 }
97114
98115
116+ /// <summary>
117+ /// Determine if an [assemblyname]classname pair matches the current Exclusion or Inclusion filters
118+ /// </summary>
119+ /// <param name="assemblyName">the name of the assembly under profile</param>
120+ /// <param name="className">the name of the class under profile</param>
121+ /// <returns>false - if pair matches the exclusion filter or matches no filters, true - if pair matches in the inclusion filter</returns>
99122 public bool InstrumentClass ( string assemblyName , string className )
100123 {
101124 return InstrumentClass ( Guid . NewGuid ( ) . ToString ( ) , assemblyName , className ) ;
102125 }
103126
127+ /// <summary>
128+ /// Add a filter
129+ /// </summary>
130+ /// <param name="assemblyClassName">A filter is of the format (+ or -)[assemblyName]className, wildcards are allowed. <br/>
131+ /// i.e. -[mscorlib], -[System.*]*, +[App.*]*, +[*]*
132+ /// </param>
104133 public void AddFilter ( string assemblyClassName )
105134 {
106135 string assemblyName ;
@@ -154,11 +183,20 @@ private static InvalidOperationException InvalidFilterFormatException(string ass
154183 return new InvalidOperationException ( string . Format ( "The supplied filter '{0}' does not meet the required format for a filter +-[assemblyname]classname" , assemblyClassName ) ) ;
155184 }
156185
186+ /// <summary>
187+ /// Add attribute exclusion filters
188+ /// </summary>
189+ /// <param name="exclusionFilters">An array of filters that are used to wildcard match an attribute</param>
157190 public void AddAttributeExclusionFilters ( string [ ] exclusionFilters )
158191 {
159192 ExcludedAttributes . AddFilters ( exclusionFilters , RegExFilters ) ;
160193 }
161194
195+ /// <summary>
196+ /// Is this entity (method/type) excluded due to an attributeFilter
197+ /// </summary>
198+ /// <param name="entity">The entity to test</param>
199+ /// <returns></returns>
162200 public bool ExcludeByAttribute ( IMemberDefinition entity )
163201 {
164202 if ( ExcludedAttributes . Count == 0 )
@@ -207,6 +245,11 @@ where excludeAttribute.IsMatchingExpression(customAttribute.AttributeType.FullNa
207245 select excludeAttribute ) . Any ( ) ;
208246 }
209247
248+ /// <summary>
249+ /// Is this entity excluded due to an attributeFilter
250+ /// </summary>
251+ /// <param name="entity">The entity to test</param>
252+ /// <returns></returns>
210253 public bool ExcludeByAttribute ( AssemblyDefinition entity )
211254 {
212255 if ( ExcludedAttributes . Count == 0 )
@@ -215,6 +258,11 @@ public bool ExcludeByAttribute(AssemblyDefinition entity)
215258 return ExcludeByAttribute ( ( ICustomAttributeProvider ) entity ) ;
216259 }
217260
261+ /// <summary>
262+ /// Is this file excluded
263+ /// </summary>
264+ /// <param name="fileName">The name of the file to test</param>
265+ /// <returns></returns>
218266 public bool ExcludeByFile ( string fileName )
219267 {
220268 if ( ExcludedFiles . Count == 0 || string . IsNullOrWhiteSpace ( fileName ) )
@@ -223,11 +271,20 @@ public bool ExcludeByFile(string fileName)
223271 return ExcludedFiles . Any ( excludeFile => excludeFile . IsMatchingExpression ( fileName ) ) ;
224272 }
225273
274+ /// <summary>
275+ /// Add file exclusion filters
276+ /// </summary>
277+ /// <param name="exclusionFilters"></param>
226278 public void AddFileExclusionFilters ( string [ ] exclusionFilters )
227279 {
228280 ExcludedFiles . AddFilters ( exclusionFilters , RegExFilters ) ;
229281 }
230282
283+ /// <summary>
284+ /// Decides whether an assembly should be analysed for test methods
285+ /// </summary>
286+ /// <param name="assemblyName">the name of the assembly under profile</param>
287+ /// <returns>true - if the assembly matches the test assembly filter</returns>
231288 public bool UseTestAssembly ( string assemblyName )
232289 {
233290 if ( TestFiles . Count == 0 || string . IsNullOrWhiteSpace ( assemblyName ) )
@@ -236,11 +293,20 @@ public bool UseTestAssembly(string assemblyName)
236293 return TestFiles . Any ( file => file . IsMatchingExpression ( assemblyName ) ) ;
237294 }
238295
296+ /// <summary>
297+ /// Add test file filters
298+ /// </summary>
299+ /// <param name="testFilters"></param>
239300 public void AddTestFileFilters ( string [ ] testFilters )
240301 {
241302 TestFiles . AddFilters ( testFilters , RegExFilters ) ;
242303 }
243304
305+ /// <summary>
306+ /// Is the method an auto-implemented property get/set
307+ /// </summary>
308+ /// <param name="method"></param>
309+ /// <returns></returns>
244310 public bool IsAutoImplementedProperty ( MethodDefinition method )
245311 {
246312 if ( ( method . IsSetter || method . IsGetter ) && method . HasCustomAttributes )
@@ -250,6 +316,11 @@ public bool IsAutoImplementedProperty(MethodDefinition method)
250316 return false ;
251317 }
252318
319+ /// <summary>
320+ /// Should we instrument this asssembly
321+ /// </summary>
322+ /// <param name="processName"></param>
323+ /// <returns></returns>
253324 public bool InstrumentProcess ( string processName )
254325 {
255326 if ( string . IsNullOrEmpty ( processName ) )
0 commit comments