Skip to content

Warnings cleanup #431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/v2/Meadow.CLI/Meadow.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Authors>Wilderness Labs, Inc</Authors>
<Company>Wilderness Labs, Inc</Company>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>2.0.0.5</PackageVersion>
<PackageVersion>2.0.0.6</PackageVersion>
<Platforms>AnyCPU</Platforms>
<PackageProjectUrl>http://developer.wildernesslabs.co/Meadow/Meadow.Foundation/</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
Expand Down
6 changes: 3 additions & 3 deletions Source/v2/Meadow.Cli/AppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public static async Task DeployApplication(
.Except(localFiles.Keys
.Select(f => Path.GetFileName(f)));

if (removeFiles.Count() == 0)
if (!removeFiles.Any())
{
logger.LogInformation($"No files to delete");
logger?.LogInformation($"No files to delete");
}

// delete those files
Expand All @@ -105,7 +105,7 @@ public static async Task DeployApplication(

send_file:

if (!await connection?.WriteFile(localFile.Key, null, cancellationToken))
if (!await connection.WriteFile(localFile.Key, null, cancellationToken))
{
logger?.LogWarning($"Error sending'{Path.GetFileName(localFile.Key)}'. Retrying.");
await Task.Delay(100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected override async ValueTask ExecuteCommand()
if (wasRuntimeEnabled)
{
// restore runtime state
Logger.LogInformation("Enabling runtime...");
Logger?.LogInformation("Enabling runtime...");

await connection.RuntimeEnable(CancellationToken);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/v2/Meadow.Cli/Commands/Current/App/AppRunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private async Task<bool> DeployApplication(IMeadowConnection connection, string

Logger?.LogInformation($"Deploying app from {file.DirectoryName}...");

await AppManager.DeployApplication(_packageManager, connection, file.DirectoryName, true, false, Logger, CancellationToken);
await AppManager.DeployApplication(_packageManager, connection, file.DirectoryName!, true, false, Logger, CancellationToken);

connection.FileWriteProgress -= OnFileWriteProgress;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected override async ValueTask ExecuteCommand()
{
Logger?.LogInformation($"Uploading package {Path.GetFileName(MpakPath)}...");

var package = await _packageService.UploadPackage(MpakPath, org.Id, Description, Host, CancellationToken);
var package = await _packageService.UploadPackage(MpakPath, org.Id, Description ?? string.Empty, Host, CancellationToken);
Logger?.LogInformation($"Upload complete. Package Id: {package.Id}");
}
catch (MeadowCloudException mex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ public DeviceProvisionCommand(DeviceService deviceService, MeadowConnectionManag

protected override async ValueTask ExecuteCommand()
{
UserOrg org;
UserOrg? org;

try
{
if (Host == null) Host = DefaultHost;
Host ??= DefaultHost;

var identityManager = new IdentityManager(Logger);
var _userService = new UserService(identityManager);

Logger?.LogInformation("Retrieving your user and organization information...");

var userOrgs = await _userService.GetUserOrgs(Host, CancellationToken).ConfigureAwait(false);

if (userOrgs == null || !userOrgs.Any())
{
Logger?.LogInformation($"Please visit {Host} to register your account.");
Expand All @@ -60,6 +61,7 @@ protected override async ValueTask ExecuteCommand()
}

org = userOrgs.FirstOrDefault(o => o.Id == OrgId || o.Name == OrgId);

if (org == null)
{
Logger?.LogInformation($"Unable to find an organization with a Name or ID matching '{OrgId}'");
Expand Down
8 changes: 5 additions & 3 deletions Source/v2/Meadow.Cli/MeadowConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,12 @@ public static IList<string> GetMeadowSerialPortsForWindows()
foreach (ManagementObject moResult in searcher.Get())
{
// Try Caption and if not Name, they both seems to contain the COM port
string portLongName = moResult["Caption"].ToString();
string portLongName = $"{moResult["Caption"]}";
if (string.IsNullOrEmpty(portLongName))
portLongName = moResult["Name"].ToString();
string pnpDeviceId = moResult["PNPDeviceID"].ToString();
{
portLongName = $"{moResult["Name"]}";
}
string pnpDeviceId = $"{moResult["PNPDeviceID"]}";

// we could collect and return a fair bit of other info from the query:

Expand Down
2 changes: 1 addition & 1 deletion Source/v2/Meadow.Cli/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace Meadow.CLI
{
public static class Constants
{
public const string CLI_VERSION = "2.0.0.5";
public const string CLI_VERSION = "2.0.0.6";
}
}
4 changes: 2 additions & 2 deletions Source/v2/Meadow.Cloud.Client/Identity/LibSecret.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public LibSecret(String service, String account)
(int)AttributeType.STRING, IntPtr.Zero);
}

public void SetSecret(String password)
public void SetSecret(string password)
{
_ = secret_password_store_sync(intPt, COLLECTION_SESSION, $"{Service}/{Account}", password, IntPtr.Zero, out IntPtr errorPtr, serviceLabel, Service, accountLabel, Account, IntPtr.Zero);
HandleError(errorPtr, "An error was encountered while writing secret to keyring");
}

public string GetSecret()
public string? GetSecret()
{
IntPtr passwordPtr = secret_password_lookup_sync(intPt, IntPtr.Zero, out IntPtr errorPtr, serviceLabel, Service, accountLabel, Account, IntPtr.Zero);
HandleError(errorPtr, "An error was encountered while reading secret from keyring");
Expand Down
4 changes: 2 additions & 2 deletions Source/v2/Meadow.Cloud.Client/Services/PackageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Meadow.Cloud;

public class PackageService : CloudServiceBase
{
private string _info_json = "info.json";
private readonly string _info_json = "info.json";

public PackageService(IdentityManager identityManager) : base(identityManager)
{
Expand Down Expand Up @@ -86,7 +86,7 @@ private string GetPackageOsVersion(string packagePath)
{
var content = File.ReadAllText(tempInfoJson);
var packageInfo = JsonSerializer.Deserialize<PackageInfo>(content);
result = packageInfo.OsVersion;
result = packageInfo?.OsVersion ?? string.Empty;
File.Delete(tempInfoJson);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/v2/Meadow.Hcom/Connections/ConnectionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public abstract class ConnectionBase : IMeadowConnection, IDisposable
{
private bool _isDisposed;

public ConnectionState State { get; protected set; }
public virtual ConnectionState State { get; protected set; }
public IMeadowDevice? Device { get; protected set; }

public event EventHandler<(string message, string? source)> DeviceMessageReceived = default!;
Expand Down
36 changes: 17 additions & 19 deletions Source/v2/Meadow.Hcom/Connections/SerialConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ public void RemoveListener(IConnectionListener listener)
// TODO: stop maintaining connection?
}

public ConnectionState State
public override ConnectionState State
{
get => _state;
private set
protected set
{
if (value == State) return;
if (value == State) { return; }

var old = _state;
_state = value;
Expand Down Expand Up @@ -237,7 +237,7 @@ public override void Detach()
}
}

private async void CommandManager()
private void CommandManager()
{
while (!_isDisposed)
{
Expand Down Expand Up @@ -1203,25 +1203,23 @@ void OnFileDataReceived(object? sender, string data)

public override async Task<DebuggingServer> StartDebuggingSession(int port, ILogger? logger, CancellationToken cancellationToken)
{
if (Device != null)
if (Device == null)
{
logger?.LogDebug($"Start Debugging on port: {port}");
await Device.StartDebugging(port, logger, cancellationToken);
throw new DeviceNotFoundException();
}

/* TODO logger?.LogDebug("Reinitialize the device");
await ReInitializeMeadow(cancellationToken); */
logger?.LogDebug($"Start Debugging on port: {port}");
await Device.StartDebugging(port, logger, cancellationToken);

var endpoint = new IPEndPoint(IPAddress.Loopback, port);
var debuggingServer = new DebuggingServer(Device, endpoint, logger);
/* TODO logger?.LogDebug("Reinitialize the device");
await ReInitializeMeadow(cancellationToken); */

logger?.LogDebug("Tell the Debugging Server to Start Listening");
await debuggingServer.StartListening(cancellationToken);
return debuggingServer;
}
else
{
throw new DeviceNotFoundException();
}
var endpoint = new IPEndPoint(IPAddress.Loopback, port);
var debuggingServer = new DebuggingServer(Device, endpoint, logger);

logger?.LogDebug("Tell the Debugging Server to Start Listening");
await debuggingServer.StartListening(cancellationToken);
return debuggingServer;
}

public override async Task StartDebugging(int port, ILogger? logger, CancellationToken? cancellationToken)
Expand Down
6 changes: 4 additions & 2 deletions Source/v2/Meadow.Hcom/Connections/TcpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public TcpConnection(string uri)
_client = new HttpClient();
}

public override async Task<IMeadowDevice?> Attach(CancellationToken? cancellationToken = null, int timeoutSeconds = 10)
public override Task<IMeadowDevice?> Attach(CancellationToken? cancellationToken = null, int timeoutSeconds = 10)
{
/*
var request = RequestBuilder.Build<GetDeviceInfoRequest>();
Expand All @@ -43,7 +43,9 @@ public TcpConnection(string uri)
*/

// TODO: is there a way to "attach"? ping result? device info?
return Device = new MeadowDevice(this);
Device = new MeadowDevice(this);

return Task.FromResult<IMeadowDevice?>(Device);

// TODO: web socket for listen?
}
Expand Down
Loading