Skip to content

Commit

Permalink
Merge pull request #329 from WildernessLabs/v1.1.0.0
Browse files Browse the repository at this point in the history
V1.1.0.0
  • Loading branch information
adrianstevens authored Jul 11, 2023
2 parents da926cb + 76e728b commit 01547da
Show file tree
Hide file tree
Showing 78 changed files with 2,442 additions and 1,621 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ jobs:
with:
dotnet-version:
7.0.x


- name: apply required VS workloads
run: dotnet workload restore Meadow.Core/source/Meadow.Core.sln

- name: Build Meadow.Core
run: dotnet build -c Release Meadow.Core/source/Meadow.Core.sln
20 changes: 20 additions & 0 deletions source/Meadow.Core.sln
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "windows", "windows", "{BF8A
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Windows", "implementations\windows\Meadow.Windows\Meadow.Windows.csproj", "{893B86CC-CB07-4C75-8D6A-6EC7B95277D7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ui", "ui", "{E7E568E2-4B82-4FF8-839F-AC2648925485}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Avalonia", "ui\Meadow.Avalonia\Meadow.Avalonia.csproj", "{FF2A0504-AFBE-46DD-A400-EC33256ACC3D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Meadow.Maui", "ui\Meadow.Maui\Meadow.Maui.csproj", "{F4AAB2CD-E4E8-4F6C-8DCE-3AB16A719570}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Core|Any CPU = Core|Any CPU
Expand Down Expand Up @@ -83,6 +89,18 @@ Global
{893B86CC-CB07-4C75-8D6A-6EC7B95277D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{893B86CC-CB07-4C75-8D6A-6EC7B95277D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{893B86CC-CB07-4C75-8D6A-6EC7B95277D7}.Release|Any CPU.Build.0 = Release|Any CPU
{FF2A0504-AFBE-46DD-A400-EC33256ACC3D}.Core|Any CPU.ActiveCfg = Debug|Any CPU
{FF2A0504-AFBE-46DD-A400-EC33256ACC3D}.Core|Any CPU.Build.0 = Debug|Any CPU
{FF2A0504-AFBE-46DD-A400-EC33256ACC3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF2A0504-AFBE-46DD-A400-EC33256ACC3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF2A0504-AFBE-46DD-A400-EC33256ACC3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF2A0504-AFBE-46DD-A400-EC33256ACC3D}.Release|Any CPU.Build.0 = Release|Any CPU
{F4AAB2CD-E4E8-4F6C-8DCE-3AB16A719570}.Core|Any CPU.ActiveCfg = Debug|Any CPU
{F4AAB2CD-E4E8-4F6C-8DCE-3AB16A719570}.Core|Any CPU.Build.0 = Debug|Any CPU
{F4AAB2CD-E4E8-4F6C-8DCE-3AB16A719570}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4AAB2CD-E4E8-4F6C-8DCE-3AB16A719570}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4AAB2CD-E4E8-4F6C-8DCE-3AB16A719570}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4AAB2CD-E4E8-4F6C-8DCE-3AB16A719570}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -98,6 +116,8 @@ Global
{89E8BFD9-BC4E-4409-8AB5-9B1FD0A72CAB} = {CC469899-D08C-417C-A908-C052CA155BEC}
{BF8A3E34-3958-4D8D-975A-353EAC05B87A} = {CC469899-D08C-417C-A908-C052CA155BEC}
{893B86CC-CB07-4C75-8D6A-6EC7B95277D7} = {BF8A3E34-3958-4D8D-975A-353EAC05B87A}
{FF2A0504-AFBE-46DD-A400-EC33256ACC3D} = {E7E568E2-4B82-4FF8-839F-AC2648925485}
{F4AAB2CD-E4E8-4F6C-8DCE-3AB16A719570} = {E7E568E2-4B82-4FF8-839F-AC2648925485}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {346406ED-19A9-40FB-A3F7-14139F44C0C8}
Expand Down
14 changes: 13 additions & 1 deletion source/Meadow.Core/Bases/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public abstract class App<D> : IApp, IAsyncDisposable
{
private ExecutionContext executionContext;

/// <inheritdoc/>
public CancellationToken CancellationToken { get; internal set; }

/// <summary>
Expand All @@ -36,7 +37,18 @@ protected App()
/// <param name="state">An optional state object to pass to the Action</param>
public void InvokeOnMainThread(Action<object?> action, object? state = null)
{
ExecutionContext.Run(executionContext, new ContextCallback(action), state);
switch (Device.Information.Platform)
{
// ExecutionContext in Mono on the F7 isn't fully working - but we also don't worry about a MainThread there either
case Hardware.MeadowPlatform.F7FeatherV1:
case Hardware.MeadowPlatform.F7FeatherV2:
case Hardware.MeadowPlatform.F7CoreComputeV2:
action.Invoke(state);
break;
default:
ExecutionContext.Run(executionContext, new ContextCallback(action), state);
break;
}
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions source/Meadow.Core/Configuration/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Meadow
{
public static class AppSettings
public interface IAppSettings

Check warning on line 5 in source/Meadow.Core/Configuration/AppSettings.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'IAppSettings'
{
public static ILoggingSettings DefaultLoggingSettings => new DefaultLoggingSettings();
public static ILifecycleSettings DefaultLifecycleSettings => new DefaultLifecycleSettings();
public static IUpdateSettings DefaultUpdateSettings => new DefaultUpdateSettings();
public ILoggingSettings LoggingSettings { get; }

Check warning on line 7 in source/Meadow.Core/Configuration/AppSettings.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'IAppSettings.LoggingSettings'
public ILifecycleSettings LifecycleSettings { get; }

Check warning on line 8 in source/Meadow.Core/Configuration/AppSettings.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'IAppSettings.LifecycleSettings'
public IUpdateSettings UpdateSettings { get; }

Check warning on line 9 in source/Meadow.Core/Configuration/AppSettings.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'IAppSettings.UpdateSettings'
}
}
145 changes: 145 additions & 0 deletions source/Meadow.Core/Configuration/AppSettingsParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
using Meadow.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Core.Unit.Tests")]

namespace Meadow;

internal class AppSettingsParser
{
public MeadowAppSettings Parse(string settingsFile)
{
var settings = new MeadowAppSettings();

var index = 0;
var spacing = 2;
var parent = string.Empty;
var parents = new List<string>();
var lastLevel = 0;

int endLine;
string lastKey;
do
{
var level = 0;

endLine = settingsFile.IndexOf('\n', index);

while (settingsFile[index] == ' ')
{
index += spacing;
level++;
}

string line;

if (endLine != -1)
{
line = settingsFile.Substring(index, endLine - index - 1).TrimEnd();
}
else
{
// last line with no newline
line = settingsFile.Substring(index).TrimEnd();
}

if (line != string.Empty && line[0] != '#')
{

if (level > lastLevel)
{
//parent = parent.Length == 0 ? lastKey : $"{parent}.{lastKey}";
parent = string.Join('.', parents);
}
else if (level < lastLevel)
{
parents.RemoveRange(level, parents.Count - level);
parent = string.Join('.', parents.Take(level));
}
lastLevel = level;

var kvp = line
.Split(':', System.StringSplitOptions.RemoveEmptyEntries);

switch (kvp.Length)
{
case 0:
break;
case 1:
lastKey = kvp[0].Trim();
parents.Add(lastKey);
break;
default:
var name = $"{parent}.{kvp[0]}";
var value = kvp[1].Trim();
ApplySetting(settings, name, value);
break;
}
}

index = endLine + 1;
} while (endLine > 0 && index < settingsFile.Length);

return settings;
}

private void ApplySetting(MeadowAppSettings settings, string settingName, string settingValue)
{
switch (settingName)
{
case "Logging.LogLevel.Default":
if (Enum.TryParse<LogLevel>(settingValue, true, out LogLevel level))
{
settings.LoggingSettings.LogLevel.Default = level;
}
break;
case "Logging.ShowTicks":
if (bool.TryParse(settingValue, out bool st))
{
settings.LoggingSettings.ShowTicks = st;
}
break;

case "Lifecycle.ResetOnAppFailure":
if (bool.TryParse(settingValue, out bool r))
{
settings.LifecycleSettings.RestartOnAppFailure = r;
}
break;
case "Lifecycle.AppFailureRestartDelaySeconds":
if (int.TryParse(settingValue, out int rd))
{
settings.LifecycleSettings.AppFailureRestartDelaySeconds = rd;
}
break;

case "Update.Enabled":
if (bool.TryParse(settingValue, out bool ue))
{
settings.UpdateSettings.Enabled = ue;
}
break;
case "Update.UpdateServer":
settings.UpdateSettings.UpdateServer = settingValue;
break;
case "Update.UpdatePort":
if (int.TryParse(settingValue, out int up))
{
settings.UpdateSettings.UpdatePort = up;
}
break;
case "Update.AuthServer":
settings.UpdateSettings.AuthServer = settingValue;
break;
case "Update.AuthPort":
if (int.TryParse(settingValue, out int cp))
{
settings.UpdateSettings.AuthPort = cp;
}
break;
}
}
}
Loading

0 comments on commit 01547da

Please sign in to comment.