Skip to content

Add support for nullable types - static headers#7852

Draft
soujay wants to merge 2 commits into
masterfrom
nullable-static-headers
Draft

Add support for nullable types - static headers#7852
soujay wants to merge 2 commits into
masterfrom
nullable-static-headers

Conversation

@soujay

@soujay soujay commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

This PR enables #nullable enable on the files in the folder, and removes
NServiceBus.StaticHeadersConfigExtensions from NullableAnnotations.ApproveNullableTypes.approved.txt

@soujay
soujay marked this pull request as ready for review July 14, 2026 15:11
@soujay
soujay requested a review from bording July 14, 2026 16:57
/// <param name="config">The <see cref="EndpointConfiguration" /> instance to apply the settings to.</param>
/// <param name="key">The static header key.</param>
/// <param name="value">The static header value.</param>
public static void AddHeaderToAllOutgoingMessages(this EndpointConfiguration config, string key, string value)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This being a public API means some more consideration is needed here.

Before this PR, because the only argument validation that is happen is related to key, that means that null is valid for for value.

Adding #nullable enable here is changing what the code is describing as valid.

Should null be allowed, or should be preventing it? What about breaking change concerns?

These are the sort of things that need to be considered when enabling nullable annotations, especially on public APIs.

@soujay soujay changed the title Add support for nullable types - static headers folder Add support for nullable types - static headers Jul 16, 2026
public static void AddHeaderToAllOutgoingMessages(this EndpointConfiguration config, string key, string value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(key);
ArgumentException.ThrowIfNullOrWhiteSpace(value);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches with CurrentStaticHeaders, which is defined as Dictionary<string, string>
Also, since we're already validating the key with the same method, it makes sense to apply the same rigor to the value.

@soujay
soujay marked this pull request as draft July 17, 2026 17:57
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.

4 participants