Skip to content

Enable nullable for NuGet.Protocol HttpSource types - #7370

Merged
nkolev92 merged 5 commits into
devfrom
dev-nkolev92-protocolNullablePhase7-v2
May 13, 2026
Merged

nkolev92 merged 5 commits into
devfrom
dev-nkolev92-protocolNullablePhase7-v2

Conversation

@nkolev92

@nkolev92 nkolev92 commented May 5, 2026 •

Copy link
Copy Markdown
Member

Bug

Progress: NuGet/Home#14851

Description

Enable nullable annotations for NuGet.Protocol HttpSource types (Phases 7-9 of the NuGet.Protocol nullable enablement effort).

Phase 7 - HttpSource leaf types (11 files)

  • Refactored ProxyAuthenticationHandler.AcquireCredentialsAsync and PromptForProxyCredentialsAsync to accept IWebProxy and ICredentialService as parameters from guarded call sites, removing redundant null checks.
  • PromptForProxyCredentialsAsync is now static (no longer accesses instance state).

Phase 8 - HttpSource mid-level types (10 files)

  • HttpSourceResult second constructor accepts nullable cacheFileName (callers already pass null for direct network downloads).

Phase 9 - HttpSource core (3 files)

  • No behavioral changes, only nullable annotation enablement.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@nkolev92 nkolev92 changed the title Enable nullable for NuGet.Protocol HttpSource leaf types (Phase 7) Enable nullable for NuGet.Protocol HttpSource types (Phases 7-8) May 6, 2026
@nkolev92
nkolev92 force-pushed the dev-nkolev92-protocolNullablePhase7-v2 branch from 4093185 to 8669189 Compare May 7, 2026 01:07
@nkolev92 nkolev92 changed the title Enable nullable for NuGet.Protocol HttpSource types (Phases 7-8) Enable nullable for NuGet.Protocol HttpSource types (Phases 7-9) May 7, 2026
@nkolev92
nkolev92 marked this pull request as ready for review May 7, 2026 21:49
@nkolev92
nkolev92 requested a review from a team as a code owner May 7, 2026 21:49
@nkolev92 nkolev92 changed the title Enable nullable for NuGet.Protocol HttpSource types (Phases 7-9) Enable nullable for NuGet.Protocol HttpSource types May 7, 2026
Nigusu-Allehu
Nigusu-Allehu previously approved these changes May 8, 2026
donnie-msft
donnie-msft previously approved these changes May 9, 2026
zivkan
zivkan previously approved these changes May 9, 2026

@zivkan zivkan left a comment

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.

When I did the annotations for NuGet.Versioning, NuGet.Frameworks, and NuGet.Common, I very intentionally tried to avoid making product changes, and just annotating APIs as they were used.

But I'm wondering if now that we're using copilot to automate a lot of the work, and doing it in smaller pull requests, if it's worthwhile trying to set up some good patterns?

I'm concerned about the amount of ! we're going to end up with suppressing issues. If AI keeps being used to write code in this repo, we don't want the AI to learn that it's ok to use ! in new code.

But I'd like to keep annotating our existing code quickly, to avoid taking too much time fixing code to avoid !.

nkolev92 and others added 4 commits May 12, 2026 17:03
Remove #nullable disable from 11 HttpSource leaf-level files:
DownloadTimeoutStreamContent, HttpCacheResult, HttpHandlerResourceV3,
HttpRequestMessageConfiguration, HttpSourceCredentials, HttpSourceException,
HttpStreamValidation, IThrottle, ProxyAuthenticationHandler,
ServerWarningLogHandler, TokenStore.

Key changes:
- HttpHandlerResourceV3.CredentialService: Lazy<ICredentialService>?
- HttpHandlerResourceV3.CredentialsSuccessfullyUsed: Action<Uri, ICredentials>?
- HttpSourceCredentials.Credentials: ICredentials?
- ProxyAuthenticationHandler: pass IWebProxy and ICredentialService as
  non-null params to AcquireCredentialsAsync/PromptForProxyCredentialsAsync
  (removing redundant null checks, method now static)
- TokenStore: ConcurrentDictionary values are nullable
- HttpStreamValidation: null checks for stream parameters
- Update PublicAPI.Shipped.txt for net472 and net8.0
- Remove stale GlobalSuppressions entry, update CA1031 target

Co-authored-by: Copilot <[email protected]>
Remove #nullable disable from 10 HttpSource mid-level files:
HttpRetryHandlerRequest, IHttpRetryHandler, HttpCacheUtility,
HttpRequestMessageExtensions, HttpRequestMessageFactory, HttpSourceResult,
NullThrottle, SemaphoreSlimThrottle, StsAuthenticationHandler,
HttpSourceResource.

Co-authored-by: Copilot <[email protected]>
@nkolev92
nkolev92 dismissed stale reviews from zivkan, donnie-msft, and Nigusu-Allehu via 4a66339 May 13, 2026 00:06
@nkolev92
nkolev92 force-pushed the dev-nkolev92-protocolNullablePhase7-v2 branch from 8669189 to 4a66339 Compare May 13, 2026 00:06
@nkolev92
nkolev92 enabled auto-merge (squash) May 13, 2026 17:02
@nkolev92
nkolev92 merged commit 7b398f9 into dev May 13, 2026
17 of 18 checks passed
@nkolev92
nkolev92 deleted the dev-nkolev92-protocolNullablePhase7-v2 branch May 13, 2026 17:17
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