From 25d199cfb92ad90f43aac34b27a082d1459ea3a3 Mon Sep 17 00:00:00 2001 From: rameel Date: Tue, 3 Nov 2026 01:35:54 +0500 Subject: [PATCH] config: make the version configuration constructors internal HtmxV1Config, HtmxV2Config, and HtmxV4Config had public constructors, but nothing accepts an instance created by hand: HtmxToolkitOptions creates the configuration and passes it to the UseHtmx* delegates. Making a constructor public later is not a breaking change, while the reverse is, so keep them internal, as HtmxResponse already does. --- src/Ramstack.HtmxToolkit/Configuration/HtmxV1Config.cs | 9 ++++++++- src/Ramstack.HtmxToolkit/Configuration/HtmxV2Config.cs | 9 ++++++++- src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Ramstack.HtmxToolkit/Configuration/HtmxV1Config.cs b/src/Ramstack.HtmxToolkit/Configuration/HtmxV1Config.cs index 02cc657..78bb298 100644 --- a/src/Ramstack.HtmxToolkit/Configuration/HtmxV1Config.cs +++ b/src/Ramstack.HtmxToolkit/Configuration/HtmxV1Config.cs @@ -8,7 +8,7 @@ namespace Ramstack.HtmxToolkit.Configuration; /// /// Represents the configuration for HTMX 1.9.x. /// -public sealed class HtmxV1Config() : HtmxConfig(HtmxTargetVersion.V1) +public sealed class HtmxV1Config : HtmxConfig { /// /// Gets or sets a value indicating whether HTMX history support is enabled. @@ -327,6 +327,13 @@ public bool? TriggerSpecsCacheEnabled set => SetField(ref field, value); } + /// + /// Initializes a new instance of the class. + /// + internal HtmxV1Config() : base(HtmxTargetVersion.V1) + { + } + /// private protected override string Serialize() => JsonSerializer.Serialize(this, HtmxConfigJsonSerializerContext.Default.HtmxV1Config); diff --git a/src/Ramstack.HtmxToolkit/Configuration/HtmxV2Config.cs b/src/Ramstack.HtmxToolkit/Configuration/HtmxV2Config.cs index c8c02a8..650d7dd 100644 --- a/src/Ramstack.HtmxToolkit/Configuration/HtmxV2Config.cs +++ b/src/Ramstack.HtmxToolkit/Configuration/HtmxV2Config.cs @@ -8,7 +8,7 @@ namespace Ramstack.HtmxToolkit.Configuration; /// /// Represents the configuration for HTMX 2.x. /// -public sealed class HtmxV2Config() : HtmxConfig(HtmxTargetVersion.V2) +public sealed class HtmxV2Config : HtmxConfig { /// /// Gets or sets a value indicating whether HTMX history support is enabled. @@ -385,6 +385,13 @@ public bool? ReportValidityOfForms set => SetField(ref field, value); } + /// + /// Initializes a new instance of the class. + /// + internal HtmxV2Config() : base(HtmxTargetVersion.V2) + { + } + /// private protected override string Serialize() => JsonSerializer.Serialize(this, HtmxConfigJsonSerializerContext.Default.HtmxV2Config); diff --git a/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs b/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs index a2f8720..1889704 100644 --- a/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs +++ b/src/Ramstack.HtmxToolkit/Configuration/HtmxV4Config.cs @@ -8,7 +8,7 @@ namespace Ramstack.HtmxToolkit.Configuration; /// /// Represents the configuration for HTMX 4.x. /// -public sealed class HtmxV4Config() : HtmxConfig(HtmxTargetVersion.V4) +public sealed class HtmxV4Config : HtmxConfig { /// /// Gets or sets a value indicating whether all HTMX events are logged to the console. @@ -252,6 +252,13 @@ public IReadOnlyList? NoSwap set => SetField(ref field, value); } + /// + /// Initializes a new instance of the class. + /// + internal HtmxV4Config() : base(HtmxTargetVersion.V4) + { + } + /// private protected override string Serialize() => JsonSerializer.Serialize(this, HtmxConfigJsonSerializerContext.Default.HtmxV4Config);