Skip to content

Commit 2716658

Browse files
authored
Update license file (#2978)
1 parent d0f332f commit 2716658

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed
-48 Bytes
Binary file not shown.

targets/netcore/nanoFramework.nanoCLR.CLI/VirtualSerialBrige/VirtualSerialDeviceManager.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
using System.Reflection;
1313
using 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
1519
namespace 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
}

0 commit comments

Comments
 (0)