11namespace BitMono . Core . Analyzing ;
22
3- [ SuppressMessage ( "ReSharper" , "ConvertIfStatementToSwitchStatement" ) ]
43public class SpecificNamespaceCriticalAnalyzer : ICriticalAnalyzer < IMetadataMember >
54{
65 private readonly ObfuscationSettings _obfuscationSettings ;
@@ -10,35 +9,32 @@ public SpecificNamespaceCriticalAnalyzer(IOptions<ObfuscationSettings> obfuscati
109 _obfuscationSettings = obfuscation . Value ;
1110 }
1211
13- public bool NotCriticalToMakeChanges ( IMetadataMember member )
12+ private static string ? GetNamespace ( IMetadataMember member )
1413 {
15- if ( _obfuscationSettings . SpecificNamespacesObfuscationOnly == false )
14+ if ( member is TypeDefinition type )
1615 {
17- return true ;
16+ return type . Namespace ? . Value ;
1817 }
19-
20- var specificNamespaces = _obfuscationSettings . SpecificNamespaces ! ;
21- if ( member is TypeDefinition type && type . HasNamespace ( ) )
18+ if ( member is MethodDefinition method )
2219 {
23- if ( specificNamespaces . Any ( s => s . Equals ( type . Namespace ? . Value ) ) == false )
24- {
25- return false ;
26- }
20+ return method . DeclaringType ? . Namespace ? . Value ;
2721 }
28- if ( member is MethodDefinition method && method . DeclaringType ? . HasNamespace ( ) == true )
22+ if ( member is FieldDefinition field )
2923 {
30- if ( specificNamespaces . Any ( s => s . Equals ( method . DeclaringType . Namespace ? . Value ) ) == false )
31- {
32- return false ;
33- }
24+ return field . DeclaringType ? . Namespace ? . Value ;
3425 }
35- if ( member is FieldDefinition field && field . DeclaringType ? . HasNamespace ( ) == true )
26+ return null ;
27+ }
28+
29+ public bool NotCriticalToMakeChanges ( IMetadataMember member )
30+ {
31+ if ( ! _obfuscationSettings . SpecificNamespacesObfuscationOnly )
3632 {
37- if ( specificNamespaces . Any ( s => s . Equals ( field . DeclaringType . Namespace ? . Value ) ) == false )
38- {
39- return false ;
40- }
33+ return true ;
4134 }
42- return true ;
35+
36+ string [ ] specificNamespaces = _obfuscationSettings . SpecificNamespaces ! ;
37+ string ns = GetNamespace ( member ) ?? string . Empty ;
38+ return Array . IndexOf ( specificNamespaces , ns ) != - 1 ;
4339 }
4440}
0 commit comments