@@ -15,17 +15,19 @@ public class Detector
15
15
// Aspects must be listed in the order of detection, from the biggest (the most generic) to the
16
16
// smallest (the least generic) aspects.
17
17
public readonly static List < Type > KnownTopLevelAspects = new ( ) {
18
- typeof ( ApplicationPackage ) ,
18
+ typeof ( PackageAPK ) ,
19
+ typeof ( PackageAAB ) ,
20
+ typeof ( PackageBase ) ,
19
21
typeof ( AssemblyStore ) ,
20
22
typeof ( ApplicationAssembly ) ,
21
23
typeof ( NativeAotSharedLibrary ) ,
22
- typeof ( LibXamarinApp ) ,
24
+ typeof ( XamarinAppSharedLibrary ) ,
23
25
typeof ( SharedLibrary ) ,
24
26
} ;
25
27
26
28
readonly static List < Type > KnownSharedLibraryAspects = new ( ) {
27
29
typeof ( NativeAotSharedLibrary ) ,
28
- typeof ( LibXamarinApp ) ,
30
+ typeof ( XamarinAppSharedLibrary ) ,
29
31
typeof ( SharedLibrary ) ,
30
32
} ;
31
33
@@ -49,44 +51,53 @@ public class Detector
49
51
public static SharedLibrary ? FindSharedLibraryAspect ( Stream stream , string ? description = null )
50
52
{
51
53
Log . Debug ( $ "Looking for shared library aspect ('{ description } ')") ;
52
- // TODO: implement
54
+ return ( SharedLibrary ? ) TryFindAspect ( KnownSharedLibraryAspects , stream , description ) ;
55
+ }
56
+
57
+ static IAspect ? TryFindTopLevelAspect ( Stream stream , string ? description ) => TryFindAspect ( KnownTopLevelAspects , stream , description ) ;
58
+
59
+ static IAspect ? TryFindAspect ( List < Type > aspectTypes , Stream stream , string ? description )
60
+ {
61
+ foreach ( Type aspectType in aspectTypes ) {
62
+ IAspect ? aspect = TryProbeAndLoadAspect ( aspectType , stream , description ) ;
63
+ if ( aspect != null ) {
64
+ return aspect ;
65
+ }
66
+ }
67
+
53
68
return null ;
54
69
}
55
70
56
- static IAspect ? TryFindTopLevelAspect ( Stream stream , string ? description )
71
+ static IAspect ? TryProbeAndLoadAspect ( Type aspect , Stream stream , string ? description )
57
72
{
58
- var flags = BindingFlags . InvokeMethod | BindingFlags . Public | BindingFlags . Static ;
73
+ const BindingFlags flags = BindingFlags . InvokeMethod | BindingFlags . Public | BindingFlags . Static | BindingFlags . FlattenHierarchy ;
59
74
60
- foreach ( Type aspect in KnownTopLevelAspects ) {
61
- LogBanner ( $ "Probing aspect: { aspect } ") ;
75
+ LogBanner ( $ "Probing aspect: { aspect } ") ;
76
+ object ? result = aspect . InvokeMember (
77
+ "ProbeAspect" , flags , null , null , new object ? [ ] { stream , description }
78
+ ) ;
62
79
63
- object ? result = aspect . InvokeMember (
64
- "ProbeAspect" , flags , null , null , new object ? [ ] { stream , description }
65
- ) ;
80
+ var state = result as IAspectState ;
81
+ if ( state == null || ! state . Success ) {
82
+ return null ;
83
+ }
66
84
67
- var state = result as IAspectState ;
68
- if ( state == null || ! state . Success ) {
69
- continue ;
70
- }
85
+ LogBanner ( $ "Loading aspect: { aspect } " ) ;
86
+ result = aspect . InvokeMember (
87
+ "LoadAspect" , flags , null , null , new object ? [ ] { stream , state , description }
88
+ ) ;
71
89
72
- LogBanner ( $ "Loading aspect: { aspect } ") ;
73
- result = aspect . InvokeMember (
74
- "LoadAspect" , flags , null , null , new object ? [ ] { stream , state , description }
75
- ) ;
76
- if ( result != null ) {
77
- return ( IAspect ) result ;
78
- }
90
+ if ( result != null ) {
91
+ return ( IAspect ) result ;
79
92
}
80
93
81
94
return null ;
82
95
83
96
void LogBanner ( string what )
84
97
{
85
98
Log . Debug ( ) ;
86
- Log . Debug ( "##########" ) ;
87
- Log . Debug ( what ) ;
99
+ Log . Debug ( $ "# { what } ") ;
88
100
Log . Debug ( ) ;
89
101
}
90
102
}
91
-
92
103
}
0 commit comments