Skip to content

[net11.0][iOS] Fix CS8604 build break in BlazorWebViewHandler header marshaling - #37260

Merged
kubaflo merged 2 commits into
dotnet:net11.0from
praveenkumarkarunanithi:fix-35706-net11
Aug 10, 2026
Merged

[net11.0][iOS] Fix CS8604 build break in BlazorWebViewHandler header marshaling#37260
kubaflo merged 2 commits into
dotnet:net11.0from
praveenkumarkarunanithi:fix-35706-net11

Conversation

@praveenkumarkarunanithi

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue.

Root Cause

PR #35706 added an iOS helper, GetRequestHeaders, which reads request headers from an NSDictionary and passes them to the shared cache-policy code as KeyValuePair<string, string> entries. The implementation calls .ToString() on the dictionary key and value.

Although the key and value objects were already null-checked, NSObject.ToString() is itself nullable. The compiler therefore could not guarantee that the resulting strings were non-null when constructing KeyValuePair<string, string>, resulting in CS8604 on net11.0.

This was only a warning on net10.0, but the stricter nullable analysis in net11.0 promoted it to an error and caused the CI build failure.

Description of Change

Null-checked the  .ToString()  results via an inline  is string  pattern-match before yielding them. Semantically identical to the original loop with no behavior or performance impact — it only makes the nullable flow explicit to the compiler.

Issues Fixed

Fixes the net11.0 CI build failure caused by CS8604 in  BlazorWebViewHandler.iOS.cs

Regression Details

Regression from #35706

Platforms Tested

  • iOS
  • MacCatalyst
  • Android
  • Windows

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37260

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37260"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@praveenkumarkarunanithi praveenkumarkarunanithi changed the title [net11][iOS] Fix CS8604 build break in BlazorWebViewHandler by null-checking NSObject header keys/values [net11.0][iOS] Fix CS8604 build break in BlazorWebViewHandler by null-checking NSObject header keys/values Aug 10, 2026
@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Aug 10, 2026
@praveenkumarkarunanithi praveenkumarkarunanithi added area-blazor Blazor Hybrid / Desktop, BlazorWebView platform/ios labels Aug 10, 2026
@praveenkumarkarunanithi praveenkumarkarunanithi changed the title [net11.0][iOS] Fix CS8604 build break in BlazorWebViewHandler by null-checking NSObject header keys/values [net11.0][iOS] Fix CS8604 build break in BlazorWebViewHandler header marshaling Aug 10, 2026
@kubaflo
kubaflo marked this pull request as ready for review August 10, 2026 12:24
Copilot AI lite review requested due to automatic review settings August 10, 2026 12:24
@kubaflo
kubaflo merged commit 938271f into dotnet:net11.0 Aug 10, 2026
31 of 38 checks passed
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a net11.0-only nullable analysis build break (CS8604) in the iOS BlazorWebViewHandler request-header marshaling path by making the ToString() nullability explicit before constructing KeyValuePair<string,string> entries.

Changes:

  • Updates GetRequestHeaders to pattern-match key?.ToString() and headers[key]?.ToString() into non-null string locals before yielding.
  • Avoids passing potentially-null ToString() results into KeyValuePair<string,string> (resolving the compiler error under stricter net11.0 analysis).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Blazor Hybrid / Desktop, BlazorWebView partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants