Skip to content

tag-helpers: make enum and boolean request options non-nullable - #126

Merged
rameel merged 1 commit into
mainfrom
tag-helpers/non-nullable-request-options
Nov 2, 2026
Merged

rameel merged 1 commit into
mainfrom
tag-helpers/non-nullable-request-options

Conversation

@rameel

@rameel rameel commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Razor resolves a bare member name only for a non-nullable enum and allows an attribute without a value only for a non-nullable bool,
so hx-request-cache="NoCache" failed with CS0103 and hx-request-validate without a value failed with RZ2008.

Change Credentials, NoHeaders, Cache, Redirect, and Validate to non-nullable properties over the existing nullable storage.
Razor calls a setter only for an attribute present in the markup, so an omitted attribute still leaves the option out of the JSON,
while an explicit SameOrigin, Default, Follow, or false is still rendered.

These attributes no longer accept a nullable value, such as @(condition ? HtmxRequestCache.NoCache : null),
or a qualified name without @, such as HtmxRequestCache.NoCache.

@HtmxRequestCache.NoCache keeps working.

Razor resolves a bare member name only for a non-nullable enum and
allows an attribute without a value only for a non-nullable bool, so
hx-request-cache="NoCache" failed with CS0103 and hx-request-validate
without a value failed with RZ2008.

Change Credentials, NoHeaders, Cache, Redirect, and Validate to
non-nullable properties over the existing nullable storage. Razor calls
a setter only for an attribute present in the markup, so an omitted
attribute still leaves the option out of the JSON, while an explicit
SameOrigin, Default, Follow, or false is still rendered.

These attributes no longer accept a nullable value, such as
@(condition ? HtmxRequestCache.NoCache : null), or a qualified name
without @, such as HtmxRequestCache.NoCache. @HtmxRequestCache.NoCache
keeps working.
@rameel
rameel merged commit 91ba0cc into main Nov 2, 2026
1 check passed
@rameel
rameel deleted the tag-helpers/non-nullable-request-options branch November 2, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant