Skip to content

Commit cb08c94

Browse files
authored
Refactor project structure and fix small code issues (#45)
* chore(deps): update NuGet package versions in `Directory.Packages.props` - Bumped `CreativeCoders.*` packages to version `6.7.2`. - Updated `Spectre.Console` to version `0.55.2`. - Reformatted the file for consistency. * refactor(core): reorganize `CreativeCoders.HomeMatic` namespaces and extract XML-RPC-specific functionality - Moved XML-RPC types and related imports from `CreativeCoders.HomeMatic.Core` to a dedicated `CreativeCoders.HomeMatic.XmlRpc` namespace. - Adjusted project references and imports for consistency across files. - Introduced new utility `CcuDeviceKindExtensions` to map device kinds to corresponding RPC ports. - Updated unit tests to reflect namespace changes and ensure compatibility. * chore(project): fix inconsistent formatting in package references in `JsonRpc.csproj` * refactor(core): remove unused XML-RPC entities and enhance documentation - Removed obsolete classes: `CcuDeviceKindExtensions`, `HomeMaticDeviceSystems`, and `XmlRpcEndpoint`. - Added XML documentation to interfaces, enums, and exception classes across `CreativeCoders.HomeMatic.Core` and `CreativeCoders.HomeMatic.XmlRpc`. - Updated unit tests to reflect the removal of deprecated types and adjusted existing tests for consistency. * refactor(homeMatic): simplify `CcuDeviceBuilder` and make `ParamSetKey` static - Removed commented-out legacy code from `CcuDeviceBuilder`. - Updated `ParamSetKey` class to be static for improved clarity and usage. * refactor(core, xmlrpc): rename enums and properties for consistency - Renamed `RxMode` to `RxModes` across codebase to align with naming conventions. - Refactored `ParameterFlags` to `ParameterUiAttributes`. - Updated related tests and XML-RPC mappings to reflect the changes. - Included suppressions for improved static analysis compatibility in `CcuDeviceBuilder`. * feat(homeMatic): add `CcuRoutingTable` for efficient device-to-client mapping - Introduced `CcuRoutingTable` as a thread-safe implementation of `ICcuRoutingTable` using `ConcurrentDictionary`. - Updated `MultiCcuClient` to leverage routing table for optimized client resolution and per-device operations. - Added tests for `CcuRoutingTable` and `MultiCcuClient` to validate new routing logic and caching behavior. * feat(tests): add comprehensive unit tests for HomeMatic components - Added new test classes: `CcuDeviceBaseTests`, `CcuDeviceTests`, `CompleteCcuDeviceBuilderTests`, `MultiCcuClientFactoryTests`, and `XmlRpcApiConnectionTests`. - Increased code coverage for device parameter mapping, factory chaining, and error handling. - Refactored existing tests to ensure consistency with updated namespaces and conventions. * feat(exporting): add support for `ParamValueNameWhitelist` in device exports - Introduced `ParamValueNameWhitelist` in `DeviceExportOptions` to filter exported parameter values by name. - Updated `DeviceExporter` to apply name-based filtering in addition to param set filtering. - Enhanced CLI command with whitelist integration and added tests for comprehensive coverage. * feat(tests): add builders for creating fake HomeMatic devices and channels - Introduced `CompleteCcuDeviceFakeBuilder` and `CompleteCcuDeviceChannelFakeBuilder` for streamlined test data creation. - Added `ParamSetValuesBuilder` to simplify parameter set construction. - Updated test suite to replace manual fake creation with new builders. - Refactored tests for `DeviceExporter` and `DeviceExportOptions` for improved readability and maintainability. * feat(core): enhance XML documentation for HomeMatic components - Added detailed XML comments to classes, interfaces, and methods across the `CreativeCoders.HomeMatic` and `CreativeCoders.HomeMatic.Exporting` namespaces. - Improved codebase maintainability and tooling support with structured summaries, parameter descriptions, and examples. * refactor: clean up namespaces and enhance XML documentation - Removed unused namespaces across multiple files. - Suppressed warnings for Inheritdoc usage in exception and class summaries. - Applied `inheritdoc` annotations for consistent XML documentation. - Refactored redundant lambda usage and adjusted collection initialization syntax. * refactor: improve type and collection definitions, add annotations - Updated return type in `BuildParamSetExportData` from `IEnumerable` to an array for consistency. - Applied `[PublicAPI]` annotations to interfaces, classes, and extensions for improved tooling support. - Simplified `CcuDevice` and `ParamSetValuesWithDescriptions` initialization expressions. - Adjusted `.gitignore` and `.editorconfig` with new entries for project customization. * refactor(core, cli): apply `[PublicAPI]` and suppressions, enhance type safety - Added `[PublicAPI]` annotations to interfaces and classes for improved tooling and API usability. - Applied `[SuppressMessage]` attributes for static analysis in methods and converters. - Improved type safety with `in` keyword and adapted property initializations in multiple constructors. - Streamlined collection initialization syntax and adjusted method signatures for consistency. * chore(tools): add `.editorconfig` with `configure_await_analysis_mode` disabled for C# and VB files
1 parent 6499633 commit cb08c94

129 files changed

Lines changed: 3800 additions & 978 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ trim_trailing_whitespace = true
1212
# IDE0060: Remove unused parameter
1313
dotnet_diagnostic.IDE0060.severity = warning
1414
configure_await_analysis_mode = library
15+
resharper_inheritdoc_consider_usage_highlighting = none

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,4 @@ ASALocalRun/
324324
.artifacts
325325

326326
.tests
327+
.tokensave

Directory.Packages.props

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
<Project>
2-
3-
<PropertyGroup>
4-
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
5-
</PropertyGroup>
6-
7-
<ItemGroup>
8-
<PackageVersion Include="CreativeCoders.CakeBuild" Version="6.7.1"/>
9-
<PackageVersion Include="CreativeCoders.Cli.Core" Version="6.7.0"/>
10-
<PackageVersion Include="CreativeCoders.Cli.Hosting" Version="6.7.0"/>
11-
<PackageVersion Include="CreativeCoders.Configuration" Version="6.7.0"/>
12-
<PackageVersion Include="CreativeCoders.Core" Version="6.7.0"/>
13-
<PackageVersion Include="CreativeCoders.Net.JsonRpc" Version="6.7.0"/>
14-
<PackageVersion Include="CreativeCoders.Net.XmlRpc" Version="6.7.0"/>
15-
<PackageVersion Include="CreativeCoders.SysConsole.Cli.Actions" Version="6.7.0"/>
16-
<PackageVersion Include="coverlet.collector" Version="8.0.1"/>
17-
<PackageVersion Include="Devlooped.CredentialManager" Version="2.7.0"/>
18-
<PackageVersion Include="FakeItEasy" Version="9.0.1"/>
19-
<PackageVersion Include="AwesomeAssertions" Version="9.4.0"/>
20-
<PackageVersion Include="JetBrains.Annotations" Version="2025.2.4"/>
21-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.6"/>
22-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.6"/>
23-
<PackageVersion Include="Microsoft.Extensions.Http" Version="10.0.6"/>
24-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.4.0"/>
25-
<PackageVersion Include="Spectre.Console" Version="0.54.0"/>
26-
<PackageVersion Include="xunit" Version="2.9.3"/>
27-
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5"/>
28-
<PackageVersion Include="XunitXml.TestLogger" Version="8.0.0"/>
29-
</ItemGroup>
30-
31-
</Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<PackageVersion Include="CreativeCoders.CakeBuild" Version="6.7.2" />
7+
<PackageVersion Include="CreativeCoders.Cli.Core" Version="6.7.2" />
8+
<PackageVersion Include="CreativeCoders.Cli.Hosting" Version="6.7.2" />
9+
<PackageVersion Include="CreativeCoders.Configuration" Version="6.7.2" />
10+
<PackageVersion Include="CreativeCoders.Core" Version="6.7.2" />
11+
<PackageVersion Include="CreativeCoders.Net.JsonRpc" Version="6.7.2" />
12+
<PackageVersion Include="CreativeCoders.Net.XmlRpc" Version="6.7.2" />
13+
<PackageVersion Include="CreativeCoders.SysConsole.Cli.Actions" Version="6.7.2" />
14+
<PackageVersion Include="coverlet.collector" Version="8.0.1" />
15+
<PackageVersion Include="Devlooped.CredentialManager" Version="2.7.0" />
16+
<PackageVersion Include="FakeItEasy" Version="9.0.1" />
17+
<PackageVersion Include="AwesomeAssertions" Version="9.4.0" />
18+
<PackageVersion Include="JetBrains.Annotations" Version="2025.2.4" />
19+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.6" />
20+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.6" />
21+
<PackageVersion Include="Microsoft.Extensions.Http" Version="10.0.6" />
22+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
23+
<PackageVersion Include="Spectre.Console" Version="0.55.2" />
24+
<PackageVersion Include="xunit" Version="2.9.3" />
25+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
26+
<PackageVersion Include="XunitXml.TestLogger" Version="8.0.0" />
27+
</ItemGroup>
28+
</Project>

HomeMatic.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "__global", "__global", "{73
1919
GitVersion.yml = GitVersion.yml
2020
Directory.Packages.props = Directory.Packages.props
2121
.github\dependabot.yml = .github\dependabot.yml
22+
.editorconfig = .editorconfig
2223
EndProjectSection
2324
EndProject
2425
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cli", "Cli", "{B79F3B3E-C9CE-4629-ADE3-B1659AF9C673}"
@@ -74,6 +75,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreativeCoders.HomeMatic.To
7475
EndProject
7576
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreativeCoders.HomeMatic.Tools.Cli.Commands", "source\Tools\Cli\CreativeCoders.HomeMatic.Tools.Cli.Commands\CreativeCoders.HomeMatic.Tools.Cli.Commands.csproj", "{822ECD72-5DB0-4637-B794-CE27B02827AC}"
7677
EndProject
78+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "__docs", "__docs", "{24644358-1979-4A95-A64C-C686A71E2AF1}"
79+
ProjectSection(SolutionItems) = preProject
80+
docs\HomeMatic-XmlRpc.md = docs\HomeMatic-XmlRpc.md
81+
EndProjectSection
82+
EndProject
7783
Global
7884
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7985
Debug|Any CPU = Debug|Any CPU

build/BuildContext.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using CreativeCoders.CakeBuild.Tasks.Templates.Settings;
77
using CreativeCoders.Core;
88
using CreativeCoders.Core.Collections;
9-
using CreativeCoders.Core.IO;
109
using JetBrains.Annotations;
1110

1211
namespace Build;

source/CreativeCoders.HomeMatic.Core/CcuDeviceKind.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

source/CreativeCoders.HomeMatic.Core/CcuDeviceUri.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,50 @@
11
using System.Diagnostics.CodeAnalysis;
2+
using CreativeCoders.HomeMatic.XmlRpc;
23

34
namespace CreativeCoders.HomeMatic.Core;
45

6+
/// <summary>
7+
/// Represents a URI that uniquely identifies a device on a specific CCU.
8+
/// </summary>
59
[ExcludeFromCodeCoverage]
610
public class CcuDeviceUri
711
{
12+
/// <summary>
13+
/// Gets the host name or IP address of the CCU.
14+
/// </summary>
15+
/// <value>The network host name or IP address of the CCU.</value>
816
public required string CcuHost { get; init; }
917

18+
/// <summary>
19+
/// Gets the logical name of the CCU.
20+
/// </summary>
21+
/// <value>The human-readable name of the CCU. The default is an empty string.</value>
1022
public string CcuName { get; init; } = string.Empty;
1123

24+
/// <summary>
25+
/// Gets the kind of device addressed by this URI.
26+
/// </summary>
27+
/// <value>One of the enumeration values that specifies the device kind.</value>
1228
public required CcuDeviceKind Kind { get; init; }
1329

30+
/// <summary>
31+
/// Gets the device address within the CCU.
32+
/// </summary>
33+
/// <value>The device or channel address.</value>
1434
public required string Address { get; init; }
1535

36+
/// <summary>
37+
/// Gets the preferred display name for the CCU host.
38+
/// </summary>
39+
/// <value>
40+
/// The value of <see cref="CcuName"/> if it is not empty; otherwise, the value of <see cref="CcuHost"/>.
41+
/// </value>
1642
public string HostDisplayName => string.IsNullOrWhiteSpace(CcuName) ? CcuHost : CcuName;
1743

44+
/// <summary>
45+
/// Returns a string representation of this URI in the form <c>{Kind}://{CcuHost}/{Address}</c>.
46+
/// </summary>
47+
/// <returns>A string representation of the device URI.</returns>
1848
public override string ToString()
1949
{
2050
return $"{Kind}://{CcuHost}/{Address}";
Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,45 @@
1-
using JetBrains.Annotations;
1+
using JetBrains.Annotations;
22

33
namespace CreativeCoders.HomeMatic.Core;
44

5+
/// <summary>
6+
/// Specifies the severity of log entries produced by the CCU.
7+
/// </summary>
58
[PublicAPI]
69
public enum CcuLogLevel
710
{
11+
/// <summary>
12+
/// All log entries are included.
13+
/// </summary>
814
All = 0,
15+
16+
/// <summary>
17+
/// Detailed diagnostic messages used for debugging.
18+
/// </summary>
919
Debug = 1,
20+
21+
/// <summary>
22+
/// Informational messages that describe normal operation.
23+
/// </summary>
1024
Info = 2,
25+
26+
/// <summary>
27+
/// Notable events that do not indicate a problem.
28+
/// </summary>
1129
Notice = 3,
30+
31+
/// <summary>
32+
/// Conditions that may indicate a potential problem.
33+
/// </summary>
1234
Warning = 4,
35+
36+
/// <summary>
37+
/// Errors that affect the current operation.
38+
/// </summary>
1339
Error = 5,
40+
41+
/// <summary>
42+
/// Fatal errors that prevent further operation.
43+
/// </summary>
1444
FatalError = 6
15-
}
45+
}

source/CreativeCoders.HomeMatic.Core/CcuRpcPorts.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

source/CreativeCoders.HomeMatic.Core/CreativeCoders.HomeMatic.Core.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
1313
</ItemGroup>
1414

15+
<ItemGroup>
16+
<ProjectReference Include="..\CreativeCoders.HomeMatic.XmlRpc\CreativeCoders.HomeMatic.XmlRpc.csproj" />
17+
</ItemGroup>
18+
1519
</Project>

0 commit comments

Comments
 (0)