From 7f5558bd8aebb26d68d0bb5f49dcfc4f1f20ad96 Mon Sep 17 00:00:00 2001
From: Den Delimarsky <1389609+dend@users.noreply.github.com>
Date: Sat, 1 May 2021 11:04:47 -0700
Subject: [PATCH] Update project configuration
---
PowerToys.sln | 4 +--
.../espresso/Espresso.Shell/Core/APIHelper.cs | 14 +++++++--
.../Espresso.Shell/Core/SettingsHelper.cs | 2 +-
.../Espresso.Shell/Espresso.Shell.csproj | 29 +++++++++++++++++++
.../Models/EspressoSettingsModel.cs | 14 ++++-----
.../espresso/Espresso.Shell/Program.cs | 12 ++++++--
6 files changed, 60 insertions(+), 15 deletions(-)
diff --git a/PowerToys.sln b/PowerToys.sln
index d7a7bfc47f..c379a605d4 100644
--- a/PowerToys.sln
+++ b/PowerToys.sln
@@ -844,8 +844,8 @@ Global
{5E7360A8-D048-4ED3-8F09-0BFD64C5529A}.Release|x64.Build.0 = Release|x64
{3B77A64A-8005-4D43-B31A-F692E213BAE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B77A64A-8005-4D43-B31A-F692E213BAE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3B77A64A-8005-4D43-B31A-F692E213BAE4}.Debug|x64.ActiveCfg = Debug|Any CPU
- {3B77A64A-8005-4D43-B31A-F692E213BAE4}.Debug|x64.Build.0 = Debug|Any CPU
+ {3B77A64A-8005-4D43-B31A-F692E213BAE4}.Debug|x64.ActiveCfg = Debug|x64
+ {3B77A64A-8005-4D43-B31A-F692E213BAE4}.Debug|x64.Build.0 = Debug|x64
{3B77A64A-8005-4D43-B31A-F692E213BAE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B77A64A-8005-4D43-B31A-F692E213BAE4}.Release|Any CPU.Build.0 = Release|Any CPU
{3B77A64A-8005-4D43-B31A-F692E213BAE4}.Release|x64.ActiveCfg = Release|Any CPU
diff --git a/src/modules/espresso/Espresso.Shell/Core/APIHelper.cs b/src/modules/espresso/Espresso.Shell/Core/APIHelper.cs
index 5d947f359c..e0c96ad75c 100644
--- a/src/modules/espresso/Espresso.Shell/Core/APIHelper.cs
+++ b/src/modules/espresso/Espresso.Shell/Core/APIHelper.cs
@@ -162,10 +162,20 @@ namespace Espresso.Shell.Core
{
try
{
+#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BUILD_REGISTRY_LOCATION);
+#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
- var versionString = $"{registryKey.GetValue("ProductName")} {registryKey.GetValue("DisplayVersion")} {registryKey.GetValue("BuildLabEx")}";
- return versionString;
+ if (registryKey != null)
+ {
+ var versionString = $"{registryKey.GetValue("ProductName")} {registryKey.GetValue("DisplayVersion")} {registryKey.GetValue("BuildLabEx")}";
+ return versionString;
+ }
+ else
+ {
+ log.Debug("Registry key acquisition for OS failed.");
+ return string.Empty;
+ }
}
catch (Exception ex)
{
diff --git a/src/modules/espresso/Espresso.Shell/Core/SettingsHelper.cs b/src/modules/espresso/Espresso.Shell/Core/SettingsHelper.cs
index 1275c459ff..3a3aabd2f9 100644
--- a/src/modules/espresso/Espresso.Shell/Core/SettingsHelper.cs
+++ b/src/modules/espresso/Espresso.Shell/Core/SettingsHelper.cs
@@ -14,7 +14,7 @@ namespace Espresso.Shell.Core
const int ERROR_SHARING_VIOLATION = 32;
const int ERROR_LOCK_VIOLATION = 33;
- public static FileStream GetSettingsFile(string path, int retries)
+ public static FileStream? GetSettingsFile(string path, int retries)
{
for (int i = 0; i < retries; i++)
{
diff --git a/src/modules/espresso/Espresso.Shell/Espresso.Shell.csproj b/src/modules/espresso/Espresso.Shell/Espresso.Shell.csproj
index 04aba56431..4e2bd2fb4c 100644
--- a/src/modules/espresso/Espresso.Shell/Espresso.Shell.csproj
+++ b/src/modules/espresso/Espresso.Shell/Espresso.Shell.csproj
@@ -3,6 +3,35 @@
Exe
netcoreapp3.1
+ $(SolutionDir)$(Platform)\$(Configuration)\modules\Espresso
+ enable
+ AnyCPU;x64
+ false
+ false
+
+
+
+ ..\..\..\..\$(Platform)\$(Configuration)\modules\Espresso\
+ DEBUG;TRACE
+ full
+ x64
+ prompt
+ MinimumRecommendedRules.ruleset
+ 4
+ false
+ true
+
+
+
+ ..\..\..\..\$(Platform)\$(Configuration)\modules\Espresso\
+ TRACE;RELEASE
+ true
+ pdbonly
+ x64
+ prompt
+ MinimumRecommendedRules.ruleset
+ 4
+ true
diff --git a/src/modules/espresso/Espresso.Shell/Models/EspressoSettingsModel.cs b/src/modules/espresso/Espresso.Shell/Models/EspressoSettingsModel.cs
index cb005bbc0c..8925fac979 100644
--- a/src/modules/espresso/Espresso.Shell/Models/EspressoSettingsModel.cs
+++ b/src/modules/espresso/Espresso.Shell/Models/EspressoSettingsModel.cs
@@ -9,23 +9,23 @@ namespace Espresso.Shell.Models
public class EspressoSettingsModel
{
[JsonProperty("properties")]
- public Properties Properties { get; set; }
+ public Properties? Properties { get; set; }
[JsonProperty("name")]
- public string Name { get; set; }
+ public string? Name { get; set; }
[JsonProperty("version")]
- public string Version { get; set; }
+ public string? Version { get; set; }
}
public class Properties
{
[JsonProperty("espresso_keep_display_on")]
- public KeepDisplayOn KeepDisplayOn { get; set; }
+ public KeepDisplayOn? KeepDisplayOn { get; set; }
[JsonProperty("espresso_mode")]
- public int Mode { get; set; }
+ public int? Mode { get; set; }
[JsonProperty("espresso_hours")]
- public Hours Hours { get; set; }
+ public Hours? Hours { get; set; }
[JsonProperty("espresso_minutes")]
- public Minutes Minutes { get; set; }
+ public Minutes? Minutes { get; set; }
}
public class KeepDisplayOn
diff --git a/src/modules/espresso/Espresso.Shell/Program.cs b/src/modules/espresso/Espresso.Shell/Program.cs
index 2211dc1a55..91393ea80e 100644
--- a/src/modules/espresso/Espresso.Shell/Program.cs
+++ b/src/modules/espresso/Espresso.Shell/Program.cs
@@ -17,16 +17,21 @@ using System.Reactive.Linq;
using System.Reflection;
using System.Threading;
+#pragma warning disable CS8602 // Dereference of a possibly null reference.
+#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
+#pragma warning disable CS8603 // Possible null reference return.
+
namespace Espresso.Shell
{
class Program
{
- private static Mutex mutex = null;
+ private static Mutex? mutex = null;
private const string appName = "Espresso";
- private static FileSystemWatcher watcher = null;
+ private static FileSystemWatcher? watcher = null;
+
public static Mutex Mutex { get => mutex; set => mutex = value; }
- private static Logger log;
+ private static Logger? log;
static int Main(string[] args)
{
@@ -193,6 +198,7 @@ namespace Espresso.Shell
using (fileStream)
{
using StreamReader reader = new StreamReader(fileStream);
+
settings = JsonConvert.DeserializeObject(reader.ReadToEnd());
}