File tree Expand file tree Collapse file tree 3 files changed +34
-9
lines changed
nanoFirmwareFlasher.Library Expand file tree Collapse file tree 3 files changed +34
-9
lines changed Original file line number Diff line number Diff line change 1- using System ;
1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the MIT license.
3+
4+ using System ;
25using System . Collections . Generic ;
36using System . Linq ;
47using System . Text ;
@@ -20,5 +23,10 @@ public class CloudSmithPackageDetail
2023 /// Package version.
2124 /// </summary>
2225 public string Version { get ; set ; }
26+
27+ /// <summary>
28+ /// Platform code
29+ /// </summary>
30+ public string Platform { get ; set ; }
2331 }
2432}
Original file line number Diff line number Diff line change @@ -187,7 +187,7 @@ public async Task<ExitCodes> DownloadFirmwareFromRepository(
187187 {
188188 IsPreview = preview ,
189189 Name = remoteTarget . Name ,
190- Platform = platform . ToString ( ) ,
190+ Platform = remoteTarget . Platform ?? platform ? . ToString ( ) ,
191191 Version = remoteTarget . Version ,
192192 } ;
193193 File . WriteAllText (
@@ -209,11 +209,6 @@ public async Task<ExitCodes> DownloadFirmwareFromRepository(
209209 /// </summary>
210210 private sealed class PersistedPackageInformation : CloudSmithPackageDetail
211211 {
212- /// <summary>
213- /// Platform code
214- /// </summary>
215- public string Platform { get ; set ; }
216-
217212 /// <summary>
218213 /// Indicates whether this is a preview
219214 /// </summary>
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ public abstract class FirmwarePackage : IDisposable
3838 ".nanoFramework" ,
3939 "fw_cache" ) ;
4040 private static readonly AsyncLocal < string > s_locationPathBase = new ( ) ;
41+ private static readonly HashSet < string > s_supportedPlatforms = new HashSet < string > ( Enum . GetNames ( typeof ( SupportedPlatform ) ) , StringComparer . OrdinalIgnoreCase ) ;
4142
4243 /// <summary>
4344 /// Path with the base location for firmware packages.
@@ -197,11 +198,32 @@ public static List<CloudSmithPackageDetail> GetTargetList(
197198 return targetPackages ;
198199 }
199200
200- targetPackages = JsonConvert . DeserializeObject < List < CloudSmithPackageDetail > > ( responseBody ) ;
201-
201+ List < CloudSmithPackageDetailJson > deserializedPackages = JsonConvert . DeserializeObject < List < CloudSmithPackageDetailJson > > ( responseBody ) ;
202+ targetPackages . AddRange ( from p in deserializedPackages
203+ select new CloudSmithPackageDetail ( )
204+ {
205+ Name = p . Name ,
206+ Version = p . Version ,
207+ Platform = p . Tags ? . Info is null
208+ ? null
209+ : ( from t in p . Tags . Info
210+ where s_supportedPlatforms . Contains ( t )
211+ select t ) . FirstOrDefault ( ) ,
212+ } ) ;
202213 return targetPackages ;
203214 }
204215
216+ private sealed class CloudSmithPackageDetailJson : CloudSmithPackageDetail
217+ {
218+ public CloudSmithPackageDetailTagsJson Tags { get ; set ; }
219+
220+ public sealed class CloudSmithPackageDetailTagsJson
221+ {
222+ public List < string > Info { get ; set ; }
223+ }
224+ }
225+
226+
205227 /// <summary>
206228 /// Download the firmware zip, extract this zip file, and get the firmware parts
207229 /// </summary>
You can’t perform that action at this time.
0 commit comments