Code Review Bench PR #62755 - [Blazor] Remove obsolete APIs from Components#6
Code Review Bench PR #62755 - [Blazor] Remove obsolete APIs from Components#6ketkarameya wants to merge 3 commits intobase_pr_62755_20260125_8069from
Conversation
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
| public void Redirect() | ||
| { | ||
| if (_tokenResult.InteractionOptions != null && _tokenResult.InteractiveRequestUrl != null) | ||
| if (_tokenResult.InteractionOptions != null) |
There was a problem hiding this comment.
⚠️ Bug: Redirect() else branch will NullRef on InteractiveRequestUrl
In AccessTokenNotAvailableException.Redirect(), the null-check condition was simplified from checking both InteractionOptions != null && InteractiveRequestUrl != null to just InteractionOptions != null. The else branch now calls _navigation.NavigateTo(_tokenResult.InteractiveRequestUrl!) — but if InteractionOptions is null, InteractiveRequestUrl is also likely null (the built-in RemoteAuthenticationService always sets them as a pair, both non-null or both null).
Previously, the else branch used the now-removed RedirectUrl property as a dedicated fallback. The new code in the else branch uses InteractiveRequestUrl with a null-forgiving operator, which will throw a NullReferenceException if it's null.
While the built-in RemoteAuthenticationService creates AccessTokenResult with both properties set together (both non-null for RequiresRedirect, both null for Success), custom IAccessTokenProvider implementations could pass different combinations. Additionally, the AccessTokenResult constructor accepts interactiveRequestUrl as string? (nullable), so a null value is a valid input.
The most defensive fix would be to guard against InteractiveRequestUrl being null:
public void Redirect()
{
if (_tokenResult.InteractiveRequestUrl is not null && _tokenResult.InteractionOptions != null)
{
_navigation.NavigateToLogin(_tokenResult.InteractiveRequestUrl, _tokenResult.InteractionOptions);
}
else if (_tokenResult.InteractiveRequestUrl is not null)
{
_navigation.NavigateTo(_tokenResult.InteractiveRequestUrl);
}
}Or at minimum, throw a descriptive exception rather than a NullReferenceException.
Was this helpful? React with 👍 / 👎
| if (_tokenResult.InteractionOptions != null) | |
| if (_tokenResult.InteractionOptions != null && _tokenResult.InteractiveRequestUrl != null) | |
| { | |
| _navigation.NavigateToLogin(_tokenResult.InteractiveRequestUrl, _tokenResult.InteractionOptions); | |
| } | |
| else if (_tokenResult.InteractiveRequestUrl != null) | |
| { | |
| _navigation.NavigateTo(_tokenResult.InteractiveRequestUrl); | |
| } |
- Apply suggested fix
There was a problem hiding this comment.
Configure merge blocking · Maintainers can dismiss this review. Gitar never approves changes.
Code Review
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
Code Review Bench PR dotnet#62755 - [Blazor] Remove obsolete APIs from Components
Benchmark PR for Gitar evaluation
Original PR: agentic-review-benchmarks#6
Removes obsolete APIs from Blazor Components library.
Summary by Gitar
[Obsolete]marked APIs across Components, Forms, Web, and WebAssembly packages (Router.PreferExactMatches, EditContextDataAnnotationsExtensions methods, AccessTokenResult constructor/property, RemoteAuthenticationService constructor)RemoteBrowserFileStreamOptions.cs,WebEventCallbackFactoryEventArgsExtensions.cs,SignOutSessionStateManager.cs(456 lines removed)RemoteAuthenticatorViewCore.csafter removing deprecated dual code pathsPublicAPI.Unshipped.txtfiles with*REMOVED*markers across 6 packagesThis will update automatically on new commits.