Skip to content

Commit a4749f1

Browse files
committed
Make RouteCacheAttribute require explicit bool parameter
Changed RouteCacheAttribute to require a non-nullable bool parameter instead of a nullable bool. Updated documentation to reflect that omitting the attribute uses global settings, and clarified parameter descriptions.
1 parent b893b49 commit a4749f1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ATTRIBUTE_ROUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public partial class StaticPage : ComponentBase
216216

217217
**Parameters:**
218218

219-
- `enableCache` (bool?) - Whether to cache this route. `true` = always cache, `false` = never cache, `null` = use global settings (default)
219+
- `enableCache` (bool) - Whether to cache this route. `true` = always cache, `false` = never cache. To use global settings, omit the attribute.
220220

221221
**Note:** This affects route match caching. For more information about caching, see [CACHING.md](CACHING.md).
222222

src/Blazouter/Attributes/RouteCacheAttribute.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,18 @@ namespace Blazouter.Attributes
6363
/// </remarks>
6464
/// <param name="enableCache">
6565
/// Whether to enable caching for this route.
66-
/// true = always cache, false = never cache, null = use global settings.
66+
/// true = always cache, false = never cache.
67+
/// To use global settings, simply do not apply this attribute.
6768
/// </param>
6869
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
69-
public sealed class RouteCacheAttribute(bool? enableCache = true) : Attribute
70+
public sealed class RouteCacheAttribute(bool enableCache) : Attribute
7071
{
7172
/// <summary>
7273
/// Gets a value indicating whether caching is enabled for this route.
7374
/// </summary>
7475
/// <value>
75-
/// true to always cache this route; false to never cache; null to use global cache settings.
76+
/// true to always cache this route; false to never cache.
7677
/// </value>
77-
public bool? EnableCache { get; } = enableCache;
78+
public bool EnableCache { get; } = enableCache;
7879
}
7980
}

0 commit comments

Comments
 (0)