Skip to content

Commit

Permalink
Service code quality improvements and more
Browse files Browse the repository at this point in the history
- Add more logging of EC read/write errors

- Move service string resources to their own .resx file

- Fix service code style

- Miscellaneous other service code changes

- Fix incorrect assembly titles after move to SDK-based .csproj files

- Small .editorconfig change
  • Loading branch information
Sparronator9999 committed Jul 25, 2024
1 parent c35f12d commit 9a89152
Show file tree
Hide file tree
Showing 14 changed files with 770 additions and 537 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
end_of_line = crlf

[*.cs]
csharp_using_directive_placement = outside_namespace:suggestion
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_simple_using_statement = false:suggestion
csharp_prefer_braces = true:suggestion
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
Expand Down
31 changes: 16 additions & 15 deletions YAMDCC.Config/YAMDCC.Config.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<OutputType>Library</OutputType>
<Title>YAMDCC config library</Title>
<Authors>Sparronator9999</Authors>
<Copyright>Copyright © 2023-2024 Sparronator9999</Copyright>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Library</OutputType>
<Title>YAMDCC config library</Title>
<AssemblyTitle>YAMDCC config library</AssemblyTitle>
<Authors>Sparronator9999</Authors>
<Copyright>Copyright © 2023-2024 Sparronator9999</Copyright>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<AssemblyVersion>0.6.9.420</AssemblyVersion>
<FileVersion>0.6.9.420</FileVersion>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
</Project>
56 changes: 24 additions & 32 deletions YAMDCC.ECAccess/YAMDCC.ECAccess.csproj
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<OutputType>Library</OutputType>
<Title>YAMDCC EC access library</Title>
<Authors>Sparronator9999</Authors>
<Copyright>Copyright © 2023-2024 Sparronator9999</Copyright>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<AssemblyVersion>0.6.9.420</AssemblyVersion>
<FileVersion>0.6.9.420</FileVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG;X64</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<DefineConstants>TRACE;X64</DefineConstants>
</PropertyGroup>
<ItemGroup>
<None Update="WinRing0.sys">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="WinRing0x64.sys">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<PropertyGroup />
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Library</OutputType>
<Title>YAMDCC EC access library</Title>
<AssemblyTitle>YAMDCC EC access library</AssemblyTitle>
<Authors>Sparronator9999</Authors>
<Copyright>Copyright © 2023-2024 Sparronator9999</Copyright>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<AssemblyVersion>0.6.9.420</AssemblyVersion>
<FileVersion>0.6.9.420</FileVersion>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<ItemGroup>
<None Update="WinRing0.sys">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="WinRing0x64.sys">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
</Project>
111 changes: 55 additions & 56 deletions YAMDCC.GUI/YAMDCC.GUI.csproj
Original file line number Diff line number Diff line change
@@ -1,58 +1,57 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<OutputType>WinExe</OutputType>
<AssemblyName>YAMDCC</AssemblyName>
<Title>YAMDCC configuration utility</Title>
<Authors>Sparronator9999</Authors>
<Copyright>Copyright © 2023-2024 Sparronator9999</Copyright>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<PublishUrl>publish\</PublishUrl>
<BootstrapperEnabled>true</BootstrapperEnabled>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>fan.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject></StartupObject>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.IO.Compression" />
<Reference Include="System.ServiceProcess" />
</ItemGroup>
<ItemGroup>
<Content Include="fan.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\YAMDCC.Config\YAMDCC.Config.csproj" />
<ProjectReference Include="..\YAMDCC.Service\YAMDCC.Service.csproj" />
<ProjectReference Include="..\YAMDCC.IPC\YAMDCC.IPC.csproj" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>WinExe</OutputType>
<AssemblyName>YAMDCC</AssemblyName>
<AssemblyTitle>YAMDCC configuration utility</AssemblyTitle>
<Title>YAMDCC configuration utility</Title>
<Authors>Sparronator9999</Authors>
<Copyright>Copyright © 2023-2024 Sparronator9999</Copyright>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<PublishUrl>publish\</PublishUrl>
<BootstrapperEnabled>true</BootstrapperEnabled>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>fan.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AssemblyVersion>0.6.9.420</AssemblyVersion>
<FileVersion>0.6.9.420</FileVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.IO.Compression" />
<Reference Include="System.ServiceProcess" />
</ItemGroup>
<ItemGroup>
<Content Include="fan.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\YAMDCC.Config\YAMDCC.Config.csproj" />
<ProjectReference Include="..\YAMDCC.Service\YAMDCC.Service.csproj" />
<ProjectReference Include="..\YAMDCC.IPC\YAMDCC.IPC.csproj" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
</Project>
3 changes: 1 addition & 2 deletions YAMDCC.GUI/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@
"YAMDCC.Logs": "[1.0.0, )"
}
}
},
".NETFramework,Version=v4.8/win7-x86": {}
}
}
}
35 changes: 17 additions & 18 deletions YAMDCC.IPC/YAMDCC.IPC.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<OutputType>Library</OutputType>
<Title>Named Pipe Wrapper library</Title>
<Description>A simple, easy to use, strongly-typed wrapper around .NET named pipes, modified for MSI Fan Control.</Description>
<Copyright>Copyright © 2013 Andrew C. Dvorak, 2023-2024 Sparronator9999</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<AssemblyVersion>0.6.9.420</AssemblyVersion>
<FileVersion>0.6.9.420</FileVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MessagePack" Version="2.5.171" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Library</OutputType>
<Title>Named Pipe Wrapper library</Title>
<AssemblyTitle>Named Pipe Wrapper library</AssemblyTitle>
<Description>A simple, easy to use, strongly-typed wrapper around .NET named pipes, modified for MSI Fan Control.</Description>
<Copyright>Copyright © 2013 Andrew C. Dvorak, 2023-2024 Sparronator9999</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<AssemblyVersion>0.6.9.420</AssemblyVersion>
<FileVersion>0.6.9.420</FileVersion>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MessagePack" Version="2.5.171" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
</Project>
33 changes: 16 additions & 17 deletions YAMDCC.Logs/YAMDCC.Logs.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<OutputType>Library</OutputType>
<Title>YAMDCC log library</Title>
<Authors>Sparronator9999</Authors>
<Copyright>Copyright © 2023-2024 Sparronator9999</Copyright>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<AssemblyVersion>0.6.9.420</AssemblyVersion>
<FileVersion>0.6.9.420</FileVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Library</OutputType>
<Title>YAMDCC logging library</Title>
<AssemblyTitle>YAMDCC logging library</AssemblyTitle>
<Authors>Sparronator9999</Authors>
<Copyright>Copyright © 2023-2024 Sparronator9999</Copyright>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<AssemblyVersion>0.6.9.420</AssemblyVersion>
<FileVersion>0.6.9.420</FileVersion>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
</Project>
20 changes: 1 addition & 19 deletions YAMDCC.Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,18 @@
// You should have received a copy of the GNU General Public License along with
// YAMDCC. If not, see <https://www.gnu.org/licenses/>.

using YAMDCC.Logs;
using System;
using System.Resources;
using System.ServiceProcess;

namespace YAMDCC.Service
{
internal static class Program
{
private static readonly Logger Log = new Logger
{
ConsoleLogLevel = LogLevel.None,
FileLogLevel = LogLevel.Debug,
};

private static readonly ResourceManager Res = new ResourceManager(typeof(Program));

/// <summary>
/// The main entry point for the application.
/// </summary>
private static void Main()
{
AppDomain.CurrentDomain.UnhandledException += LogUnhandledException;

ServiceBase.Run(new ServiceBase[] { new svcFanControl(Log, Res) });
}

private static void LogUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Log.Fatal(Res.GetString("svcException"), e.ExceptionObject);
ServiceBase.Run(new svcFanControl());
}
}
}
Loading

0 comments on commit 9a89152

Please sign in to comment.