@@ -115,9 +115,9 @@ private static (DeserializedInput, DeserializedInput, DeserializedInput) LoadRep
115
115
DeserializedInput ? macosRepositories = null ;
116
116
DeserializedInput ? windowsRepositories = null ;
117
117
118
- void SetLinuxRepositories ( ) => linuxRepositories = DeserializeInput ( searchPathLinux , input ) ;
119
- void SetMacosRepositories ( ) => macosRepositories = DeserializeInput ( searchPathMacos , input ) ;
120
- void SetWindowsRepositories ( ) => windowsRepositories = DeserializeInput ( searchPathWindows , input ) ;
118
+ void SetLinuxRepositories ( ) => linuxRepositories = DeserializeInput ( "linux" , searchPathLinux , input ) ;
119
+ void SetMacosRepositories ( ) => macosRepositories = DeserializeInput ( "macos" , searchPathMacos , input ) ;
120
+ void SetWindowsRepositories ( ) => windowsRepositories = DeserializeInput ( "windows" , searchPathWindows , input ) ;
121
121
122
122
if ( disableAsync )
123
123
{
@@ -137,15 +137,14 @@ private static (DeserializedInput, DeserializedInput, DeserializedInput) LoadRep
137
137
return ( linuxRepositories ! , macosRepositories ! , windowsRepositories ! ) ;
138
138
}
139
139
140
- private static DeserializedInput DeserializeInput ( string ? searchPath , string [ ] input )
140
+ private static DeserializedInput DeserializeInput ( string platformName , string ? searchPath , string [ ] input )
141
141
{
142
- if ( searchPath is null )
143
- return DeserializedInput . Empty ( ) ;
142
+ var repositoryResolver = GetRepositoryResolver ( platformName , searchPath ) ;
144
143
145
144
var inputRepositories = input
146
- . Select ( x => Path . Join ( searchPath , x ) )
147
- . Where ( File . Exists )
148
- . Select ( x => new FileInfo ( x ) . OpenRead ( ) . DeserializeGirInputModel ( ) )
145
+ . Select ( fileName => repositoryResolver . ResolveRepository ( fileName ) )
146
+ . Where ( inputRepository => inputRepository != null )
147
+ . Select ( inputRepository => inputRepository ! )
149
148
. ToList ( ) ;
150
149
151
150
// Get the namespaces corresponding to the input gir files.
@@ -154,13 +153,30 @@ private static DeserializedInput DeserializeInput(string? searchPath, string[] i
154
153
. Select ( repository => repository . Namespace == null ? "" : GetNamespaceName ( repository . Namespace ) )
155
154
. ToList ( ) ;
156
155
157
- var includeResolver = new IncludeResolver ( searchPath ) ;
156
+ var includeResolver = new IncludeResolver ( repositoryResolver ) ;
158
157
var loader = new GirLoader . Loader ( includeResolver . ResolveInclude ) ;
159
158
var outputRepositories = loader . Load ( inputRepositories ) . ToList ( ) ;
160
159
161
160
return new DeserializedInput ( outputRepositories , inputNamespaces ) ;
162
161
}
163
162
163
+ private static IRepositoryResolver GetRepositoryResolver ( string platformName , string ? searchPath )
164
+ {
165
+ var assembly = typeof ( GenerateCommand ) . Assembly ;
166
+ var embeddedResolver = new EmbeddedRepositoryResolver ( assembly , platformName ) ;
167
+
168
+ if ( searchPath == null )
169
+ {
170
+ return embeddedResolver ;
171
+ }
172
+ else
173
+ {
174
+ var directoryResolver = new DirectoryRepositoryResolver ( searchPath ) ;
175
+ return new ChainedRepositoryResolver (
176
+ new IRepositoryResolver [ ] { directoryResolver , embeddedResolver } ) ;
177
+ }
178
+ }
179
+
164
180
private static string GetNamespaceName ( GirModel . Namespace ns )
165
181
{
166
182
return $ "{ ns . Name } -{ ns . Version } ";
0 commit comments