File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
targets/netcore/nanoFramework.nanoCLR.CLI Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 1212using System . Reflection ;
1313using System . Text . RegularExpressions ;
1414
15+ // TODO: Add IsInstalled method that does the following:
16+ // A) Get the guid from SerialPortLibraryClass
17+ // B) Checks registry for the existence of the library ex: HKEY_CLASSES_ROOT\CLSID\{e13da62c-3a88-45a4-a5d0-224dea7bf4ff}
18+ // TODO: Check license AFTER confirming installation so a more specific error can be displayed
1519namespace nanoFramework . nanoCLR . CLI
1620{
1721 public class VirtualSerialDeviceManager
@@ -190,16 +194,26 @@ private void InstallLicense()
190194 {
191195 var assembly = typeof ( VirtualSerialDeviceManager ) . GetTypeInfo ( ) . Assembly ;
192196
193- Stream resource = assembly . GetManifestResourceStream ( _licenseResourceName ) ;
194- MemoryStream memoryStream = new MemoryStream ( ) ;
197+ using var resource = assembly . GetManifestResourceStream ( _licenseResourceName ) ;
198+ if ( resource is null )
199+ {
200+ // TODO: Should probably return an error
201+ return ;
202+ }
203+
204+ using var memoryStream = new MemoryStream ( ) ;
195205
196206 resource . CopyTo ( memoryStream ) ;
197207 var bytes = memoryStream . ToArray ( ) ;
198208
199- if ( bytes . Length > 0 )
209+ if ( bytes . Length <= 0 )
200210 {
201- _serialPortLibrary . installLicenseInMemory ( bytes ) ;
211+ // TODO: Should probably return an error
212+ return ;
202213 }
214+
215+ // This appears to be a misleading name as the license appears to be persisted
216+ _serialPortLibrary . installLicenseInMemory ( bytes ) ;
203217 }
204218 }
205219}
You can’t perform that action at this time.
0 commit comments