Update project configuration

This commit is contained in:
Den Delimarsky
2021-05-01 11:04:47 -07:00
parent 75ed9c7b12
commit 7f5558bd8a
6 changed files with 60 additions and 15 deletions

View File

@@ -844,8 +844,8 @@ Global
{5E7360A8-D048-4ED3-8F09-0BFD64C5529A}.Release|x64.Build.0 = Release|x64 {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.ActiveCfg = Debug|Any CPU
{3B77A64A-8005-4D43-B31A-F692E213BAE4}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Debug|x64
{3B77A64A-8005-4D43-B31A-F692E213BAE4}.Debug|x64.Build.0 = Debug|Any CPU {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.ActiveCfg = Release|Any CPU
{3B77A64A-8005-4D43-B31A-F692E213BAE4}.Release|Any CPU.Build.0 = 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 {3B77A64A-8005-4D43-B31A-F692E213BAE4}.Release|x64.ActiveCfg = Release|Any CPU

View File

@@ -162,11 +162,21 @@ namespace Espresso.Shell.Core
{ {
try try
{ {
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BUILD_REGISTRY_LOCATION); RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BUILD_REGISTRY_LOCATION);
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
if (registryKey != null)
{
var versionString = $"{registryKey.GetValue("ProductName")} {registryKey.GetValue("DisplayVersion")} {registryKey.GetValue("BuildLabEx")}"; var versionString = $"{registryKey.GetValue("ProductName")} {registryKey.GetValue("DisplayVersion")} {registryKey.GetValue("BuildLabEx")}";
return versionString; return versionString;
} }
else
{
log.Debug("Registry key acquisition for OS failed.");
return string.Empty;
}
}
catch (Exception ex) catch (Exception ex)
{ {
log.Debug($"Could not get registry key for the build number. Error: {ex.Message}"); log.Debug($"Could not get registry key for the build number. Error: {ex.Message}");

View File

@@ -14,7 +14,7 @@ namespace Espresso.Shell.Core
const int ERROR_SHARING_VIOLATION = 32; const int ERROR_SHARING_VIOLATION = 32;
const int ERROR_LOCK_VIOLATION = 33; 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++) for (int i = 0; i < retries; i++)
{ {

View File

@@ -3,6 +3,35 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\modules\Espresso</OutputPath>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x64</Platforms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)\modules\Espresso\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)\modules\Espresso\</OutputPath>
<DefineConstants>TRACE;RELEASE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -9,23 +9,23 @@ namespace Espresso.Shell.Models
public class EspressoSettingsModel public class EspressoSettingsModel
{ {
[JsonProperty("properties")] [JsonProperty("properties")]
public Properties Properties { get; set; } public Properties? Properties { get; set; }
[JsonProperty("name")] [JsonProperty("name")]
public string Name { get; set; } public string? Name { get; set; }
[JsonProperty("version")] [JsonProperty("version")]
public string Version { get; set; } public string? Version { get; set; }
} }
public class Properties public class Properties
{ {
[JsonProperty("espresso_keep_display_on")] [JsonProperty("espresso_keep_display_on")]
public KeepDisplayOn KeepDisplayOn { get; set; } public KeepDisplayOn? KeepDisplayOn { get; set; }
[JsonProperty("espresso_mode")] [JsonProperty("espresso_mode")]
public int Mode { get; set; } public int? Mode { get; set; }
[JsonProperty("espresso_hours")] [JsonProperty("espresso_hours")]
public Hours Hours { get; set; } public Hours? Hours { get; set; }
[JsonProperty("espresso_minutes")] [JsonProperty("espresso_minutes")]
public Minutes Minutes { get; set; } public Minutes? Minutes { get; set; }
} }
public class KeepDisplayOn public class KeepDisplayOn

View File

@@ -17,16 +17,21 @@ using System.Reactive.Linq;
using System.Reflection; using System.Reflection;
using System.Threading; 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 namespace Espresso.Shell
{ {
class Program class Program
{ {
private static Mutex mutex = null; private static Mutex? mutex = null;
private const string appName = "Espresso"; private const string appName = "Espresso";
private static FileSystemWatcher watcher = null; private static FileSystemWatcher? watcher = null;
public static Mutex Mutex { get => mutex; set => mutex = value; } public static Mutex Mutex { get => mutex; set => mutex = value; }
private static Logger log; private static Logger? log;
static int Main(string[] args) static int Main(string[] args)
{ {
@@ -193,6 +198,7 @@ namespace Espresso.Shell
using (fileStream) using (fileStream)
{ {
using StreamReader reader = new StreamReader(fileStream); using StreamReader reader = new StreamReader(fileStream);
settings = JsonConvert.DeserializeObject<EspressoSettingsModel>(reader.ReadToEnd()); settings = JsonConvert.DeserializeObject<EspressoSettingsModel>(reader.ReadToEnd());
} }