Skip to content

Commit 711e9a9

Browse files
Bring back settings holder EnableFeature because we need it for the transactional session (#7452)
Co-authored-by: Daniel Marbach <danielmarbach@users.noreply.github.com>
1 parent 840f3c7 commit 711e9a9

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/NServiceBus.Core.Tests/ApprovalFiles/APIApprovals.ApproveNServiceBus.approved.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,8 @@ namespace NServiceBus.Features
13291329
}
13301330
public static class SettingsExtensions
13311331
{
1332+
public static void EnableFeature<T>(this NServiceBus.Settings.SettingsHolder settings)
1333+
where T : NServiceBus.Features.Feature { }
13321334
[System.Obsolete("It is no longer possible to enable features by default on the settings. Features " +
13331335
"can enable other features by calling EnableByDefault<T> in the constructor. Will" +
13341336
" be removed in version 11.0.0.", true)]

src/NServiceBus.Core/Features/EndpointConfigurationExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static partial class EndpointConfigurationExtensions
1717
public static void EnableFeature<T>(this EndpointConfiguration config) where T : Feature
1818
{
1919
ArgumentNullException.ThrowIfNull(config);
20-
config.Settings.Get<FeatureComponent.Settings>().EnableFeature<T>();
20+
config.Settings.EnableFeature<T>();
2121
}
2222

2323
/// <summary>

src/NServiceBus.Core/Features/SettingsExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ namespace NServiceBus.Features;
1010
/// </summary>
1111
public static partial class SettingsExtensions
1212
{
13+
/// <summary>
14+
/// Enables the given feature.
15+
/// </summary>
16+
/// <remarks>Enabling features is intended to be used for downstream components that only have access to settings. Features that need to enable other features should use <see cref="Feature.EnableByDefault{T}"/>.</remarks>
17+
/// <typeparam name="T">The feature to enable.</typeparam>
18+
public static void EnableFeature<T>(this SettingsHolder settings) where T : Feature
19+
=> settings.Get<FeatureComponent.Settings>().EnableFeature<T>();
20+
1321
/// <summary>
1422
/// Returns if a given feature has been activated in this endpoint.
1523
/// </summary>

0 commit comments

Comments
 (0)