File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change 1+ using System . Text . RegularExpressions ;
2+
13namespace Sundstrom . CheckedExceptions ;
24
35public static class HeuristicRules
46{
5- public static bool IsForGetter ( string name ) => name is not null &&
6- ( name . Contains ( " get " ) ||
7- name . Contains ( " gets " ) ||
8- name . Contains ( " getting " ) ||
9- name . Contains ( " retrieved " ) ) ;
10-
11- public static bool IsForSetter ( string name ) => name is not null && (
12- name . Contains ( " set " ) ||
13- name . Contains ( " sets " ) ||
14- name . Contains ( " setting " ) ) ;
7+ private static readonly Regex GetterRegex = new ( @"\b(gets?|retriev(es|ing|ed)|returns?|provides?)\b" ,
8+ RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
9+
10+ private static readonly Regex SetterRegex = new ( @"\b(sets?|assigns?|specif(y|ies)|updat(es|ing)|allow(s|ed) setting)\b" ,
11+ RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
12+
13+ public static bool IsForGetter ( string text ) =>
14+ ! string . IsNullOrWhiteSpace ( text ) && GetterRegex . IsMatch ( text ) ;
15+
16+ public static bool IsForSetter ( string text ) =>
17+ ! string . IsNullOrWhiteSpace ( text ) && SetterRegex . IsMatch ( text ) ;
18+ public static bool IsForBoth ( string text ) =>
19+ IsForGetter ( text ) && IsForSetter ( text ) ;
1520}
You can’t perform that action at this time.
0 commit comments