88using System . Diagnostics . CodeAnalysis ;
99using System . IO ;
1010using System . Linq ;
11- using System . Net . Http ;
1211using System . Runtime . InteropServices ;
1312using System . Runtime . InteropServices . Marshalling ;
1413using System . Security . Cryptography ;
@@ -50,7 +49,7 @@ public static int Main(params string[] args)
5049 return 2 ;
5150 }
5251
53- FileInfo ? fileInfo = FindPluginLibraryAndGetAssets ( path , out List < SelfUpdateAssetInfo > assetInfo , out SelfUpdateReferenceInfo ? reference ) ;
52+ FileInfo ? fileInfo = FindPluginLibraryAndGetAssets ( path , out List < SelfUpdateAssetInfo > assetInfo , out PluginManifest ? reference ) ;
5453 if ( fileInfo == null || reference == null || string . IsNullOrEmpty ( reference . MainLibraryName ) )
5554 {
5655 Console . Error . WriteLine ( "No valid plugin library was found." ) ;
@@ -67,7 +66,7 @@ public static int Main(params string[] args)
6766 }
6867 }
6968
70- private static int WriteToJson ( SelfUpdateReferenceInfo reference , string referenceFilePath , List < SelfUpdateAssetInfo > assetInfo )
69+ private static int WriteToJson ( PluginManifest reference , string referenceFilePath , List < SelfUpdateAssetInfo > assetInfo )
7170 {
7271 DateTimeOffset creationDate = reference . PluginCreationDate . ToOffset ( reference . PluginCreationDate . Offset ) ;
7372
@@ -90,17 +89,17 @@ private static int WriteToJson(SelfUpdateReferenceInfo reference, string referen
9089
9190 writer . WriteStartObject ( ) ;
9291
93- writer . WriteString ( nameof ( SelfUpdateReferenceInfo . MainLibraryName ) , reference . MainLibraryName ) ;
94- writer . WriteString ( nameof ( SelfUpdateReferenceInfo . MainPluginName ) , reference . MainPluginName ) ;
95- writer . WriteString ( nameof ( SelfUpdateReferenceInfo . MainPluginAuthor ) , reference . MainPluginAuthor ) ;
96- writer . WriteString ( nameof ( SelfUpdateReferenceInfo . MainPluginDescription ) , reference . MainPluginDescription ) ;
97- writer . WriteString ( nameof ( SelfUpdateReferenceInfo . PluginStandardVersion ) , reference . PluginStandardVersion . ToString ( ) ) ;
98- writer . WriteString ( nameof ( SelfUpdateReferenceInfo . PluginVersion ) , reference . PluginVersion . ToString ( ) ) ;
99- writer . WriteString ( nameof ( SelfUpdateReferenceInfo . PluginCreationDate ) , creationDate ) ;
100- writer . WriteString ( nameof ( SelfUpdateReferenceInfo . ManifestDate ) , DateTimeOffset . Now ) ;
92+ writer . WriteString ( nameof ( PluginManifest . MainLibraryName ) , reference . MainLibraryName ) ;
93+ writer . WriteString ( nameof ( PluginManifest . MainPluginName ) , reference . MainPluginName ) ;
94+ writer . WriteString ( nameof ( PluginManifest . MainPluginAuthor ) , reference . MainPluginAuthor ) ;
95+ writer . WriteString ( nameof ( PluginManifest . MainPluginDescription ) , reference . MainPluginDescription ) ;
96+ writer . WriteString ( nameof ( PluginManifest . PluginStandardVersion ) , reference . PluginStandardVersion . ToString ( ) ) ;
97+ writer . WriteString ( nameof ( PluginManifest . PluginVersion ) , reference . PluginVersion . ToString ( ) ) ;
98+ writer . WriteString ( nameof ( PluginManifest . PluginCreationDate ) , creationDate ) ;
99+ writer . WriteString ( nameof ( PluginManifest . ManifestDate ) , DateTimeOffset . Now ) ;
101100 if ( reference . PluginAlternativeIcon ? . Length != 0 )
102101 {
103- writer . WriteBase64String ( nameof ( SelfUpdateReferenceInfo . PluginAlternativeIcon ) , reference . PluginAlternativeIcon ) ;
102+ writer . WriteString ( nameof ( PluginManifest . PluginAlternativeIcon ) , reference . PluginAlternativeIcon ) ;
104103 }
105104
106105 writer . WriteStartArray ( "Assets" ) ;
@@ -123,15 +122,15 @@ private static int WriteToJson(SelfUpdateReferenceInfo reference, string referen
123122 return 0 ;
124123 }
125124
126- private static FileInfo ? FindPluginLibraryAndGetAssets ( string dirPath , out List < SelfUpdateAssetInfo > fileList , out SelfUpdateReferenceInfo ? referenceInfo )
125+ private static FileInfo ? FindPluginLibraryAndGetAssets ( string dirPath , out List < SelfUpdateAssetInfo > fileList , out PluginManifest ? referenceInfo )
127126 {
128127 DirectoryInfo directoryInfo = new DirectoryInfo ( dirPath ) ;
129128 List < SelfUpdateAssetInfo > fileListRef = [ ] ;
130129 fileList = fileListRef ;
131130 referenceInfo = null ;
132131
133132 FileInfo ? mainLibraryFileInfo = null ;
134- SelfUpdateReferenceInfo ? referenceInfoResult = null ;
133+ PluginManifest ? referenceInfoResult = null ;
135134
136135 Parallel . ForEach ( directoryInfo . EnumerateFiles ( "*" , SearchOption . AllDirectories ) . Where ( x => ! x . Name . Equals ( "manifest.json" , StringComparison . OrdinalIgnoreCase ) ) , Impl ) ;
137136 referenceInfo = referenceInfoResult ;
@@ -143,7 +142,7 @@ void Impl(FileInfo fileInfo)
143142 string fileName = fileInfo . FullName . AsSpan ( directoryInfo . FullName . Length ) . TrimStart ( "\\ /" ) . ToString ( ) ;
144143
145144 if ( mainLibraryFileInfo == null &&
146- IsPluginLibrary ( fileInfo , fileName , out SelfUpdateReferenceInfo ? referenceInfoInner ) )
145+ IsPluginLibrary ( fileInfo , fileName , out PluginManifest ? referenceInfoInner ) )
147146 {
148147 Interlocked . Exchange ( ref mainLibraryFileInfo , fileInfo ) ;
149148 Interlocked . Exchange ( ref referenceInfoResult , referenceInfoInner ) ;
@@ -186,7 +185,7 @@ void Impl(FileInfo fileInfo)
186185 private unsafe delegate void * GetPlugin ( ) ;
187186 private unsafe delegate GameVersion * GetVersion ( ) ;
188187
189- private static unsafe bool IsPluginLibrary ( FileInfo fileInfo , string fileName , [ NotNullWhen ( true ) ] out SelfUpdateReferenceInfo ? referenceInfo )
188+ private static unsafe bool IsPluginLibrary ( FileInfo fileInfo , string fileName , [ NotNullWhen ( true ) ] out PluginManifest ? referenceInfo )
190189 {
191190 nint handle = nint . Zero ;
192191 referenceInfo = null ;
@@ -256,7 +255,7 @@ private static unsafe bool IsPluginLibrary(FileInfo fileInfo, string fileName, [
256255 plugin . GetPluginDescription ( out string ? pluginDescription ) ;
257256 plugin . GetPluginCreationDate ( out DateTime * pluginCreationDate ) ;
258257
259- referenceInfo = new SelfUpdateReferenceInfo
258+ referenceInfo = new PluginManifest
260259 {
261260 Assets = [ ] ,
262261 MainPluginName = pluginName ,
@@ -285,7 +284,7 @@ private static void PrintHelp()
285284 Console . WriteLine ( $ "Usage: { execPath } [plugin_dll_directory_path]") ;
286285 }
287286
288- private static byte [ ] ? TryGetAlternateIconData ( IPlugin plugin )
287+ private static string ? TryGetAlternateIconData ( IPlugin plugin )
289288 {
290289 try
291290 {
@@ -297,19 +296,15 @@ private static void PrintHelp()
297296
298297 if ( Base64 . IsValid ( iconUrlOrData ) )
299298 {
300- return Convert . FromBase64String ( iconUrlOrData ) ;
299+ return iconUrlOrData ;
301300 }
302301
303- // Download if the string is a URL.
304302 if ( ! Uri . TryCreate ( iconUrlOrData , UriKind . Absolute , out Uri ? iconUrl ) )
305303 {
306304 return null ;
307305 }
308306
309- using HttpClient httpClient = new HttpClient ( ) ;
310- using HttpResponseMessage response = httpClient . GetAsync ( iconUrl , HttpCompletionOption . ResponseHeadersRead ) . GetAwaiter ( ) . GetResult ( ) ;
311-
312- return ! response . IsSuccessStatusCode ? null : response . Content . ReadAsByteArrayAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
307+ return iconUrl . ToString ( ) ;
313308 }
314309 catch ( Exception ex )
315310 {
0 commit comments