Skip to content

Enable nullable for NuGet.Protocol V2Feed leaves, and trivial V3 metadata leaves - #7587

Merged
nkolev92 merged 10 commits into
devfrom
dev-nkolev92-nullableProtocolFinalPhase
Jul 23, 2026
Merged

nkolev92 merged 10 commits into
devfrom
dev-nkolev92-nullableProtocolFinalPhase

Conversation

@nkolev92

@nkolev92 nkolev92 commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Bug

Progress: NuGet/Home#14851 (Phases 24 + 27)

Description

Continues the incremental NuGet.Protocol nullable-reference-types enablement by removing #nullable disable from a set of isolated leaf resources, providers, and downloaders (Phase 27 wiring, the trivial V3 metadata leaves, and the Phase 24 legacy V2Feed leaves that derive from already-annotated bases).

Notable decisions:

  • Provider TryCreate overrides are widened to Task<Tuple<bool, INuGetResource?>> with ?? throw guards on GetResourceAsync<T>(), whose result is genuinely nullable — mirrors the established provider pattern.
  • Genuinely-nullable factories are honest, not suppressed. DependencyInfoResourceV2Feed.ResolvePackage now returns Task<SourcePackageDependencyInfo?>, and the CreateOrNull factories (ReportAbuseResourceV3, PackageDetailsUriResourceV3) return nullable.
  • V2FeedParser.LoadXmlAsync cacheKey becomes string? — it was already null-checked internally and every caller passes null.
  • Minor behavior hardening in AutoCompleteResourceV2Feed: an empty response (204/404 → null stream) now yields an empty result set instead of throwing an NullReferenceException.
  • PublicAPI.Shipped.txt updated for both net472 and net8.0, replacing the oblivious (~) entries in place.

No public API is added or removed; only nullability annotations change.

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 and others added 10 commits July 22, 2026 09:10
Annotate IsFileSource() with [MemberNotNullWhen(false, nameof(_httpSource))]
and pass the non-null HttpSource into PushPackageToServer,
DeletePackageFromServer, and GetSecureApiKey, removing internal null guards.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: d6ed873c-2b1e-4d4e-9cde-c217bfdc3a73
Route file-vs-server on the source argument's URI (sourceUri.IsFile)
instead of IsFileSource(), which reflects the resource's primary source.
This preserves correct routing when the symbol source's file-ness differs
from the primary push source.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 851207a5-650b-47dd-8883-e1b5db685c44
DeletePackage was always called with _source, and IsFileSource() reasons
about _httpSource (derived from _source). Referencing _source directly
prevents a future caller from passing a different source and reintroducing
the file-vs-server routing mismatch just fixed on the push path.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 851207a5-650b-47dd-8883-e1b5db685c44
… downloaders)

Removes #nullable disable from the 5 remaining composition-layer files:
FactoryExtensionsV3, FactoryExtensionsVS, FeedTypeResourceProvider,
LocalPackageArchiveDownloader, RemotePackageArchiveDownloader.

OfflineFeedUtility now passes the real offline-feed folder as the downloader
source instead of null, matching the non-null IPackageDownloader.Source contract.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: adcfe3e1-067b-4ef1-89e7-cd0e377c18b2
…roviders

Annotates ReportAbuseResourceV3 (ctor accepts string? uriTemplate, GetReportAbuseUrl
non-null in/out) and the 3 providers whose TryCreate only needed widening to
Task<Tuple<bool, INuGetResource?>>: MetadataResourceV3Provider,
PackageDetailsUriResourceV3Provider, ReportAbuseResourceV3Provider.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: adcfe3e1-067b-4ef1-89e7-cd0e377c18b2
CreateOrNull now returns a nullable resource, so the valid-template call sites
suppress with resource! (the templates are known valid in these tests).

Co-authored-by: Copilot <[email protected]>
Copilot-Session: adcfe3e1-067b-4ef1-89e7-cd0e377c18b2
Annotates the 11 isolated Phase 24 V2Feed leaves (6 resources + 5 providers)
that derive from already-annotated bases. Providers widen TryCreate to
Task<Tuple<bool, INuGetResource?>>. DependencyInfoResourceV2Feed.ResolvePackage
now returns Task<SourcePackageDependencyInfo?>. V2FeedParser.LoadXmlAsync cacheKey
becomes nullable (already null-checked internally). PublicAPI.Shipped.txt updated
for both TFMs.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: adcfe3e1-067b-4ef1-89e7-cd0e377c18b2
@nkolev92 nkolev92 changed the title Enable nullable for NuGet.Protocol Phase 27 and trivial V3 metadata leaves Enable nullable for NuGet.Protocol Phase 27, Phase 24 V2Feed leaves, and trivial V3 metadata leaves Jul 22, 2026
@nkolev92 nkolev92 changed the title Enable nullable for NuGet.Protocol Phase 27, Phase 24 V2Feed leaves, and trivial V3 metadata leaves Enable nullable for NuGet.Protocol V2Feed leaves, and trivial V3 metadata leaves Jul 22, 2026
@nkolev92
nkolev92 marked this pull request as ready for review July 23, 2026 00:52
@nkolev92
nkolev92 requested a review from a team as a code owner July 23, 2026 00:52
@nkolev92
nkolev92 merged commit 3a60b3b into dev Jul 23, 2026
17 of 18 checks passed
@nkolev92
nkolev92 deleted the dev-nkolev92-nullableProtocolFinalPhase branch July 23, 2026 19:42
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.

2 participants