Skip to content

Enable nullable on NuGet.Protocol legacy feed types (phase 20)#7498

Open
nkolev92 wants to merge 1 commit into
devfrom
dev-nkolev92-nullableProtocolPhase20
Open

Enable nullable on NuGet.Protocol legacy feed types (phase 20)#7498
nkolev92 wants to merge 1 commit into
devfrom
dev-nkolev92-nullableProtocolPhase20

Conversation

@nkolev92

@nkolev92 nkolev92 commented Jun 22, 2026

Copy link
Copy Markdown
Member

Bug

Fixes: NuGet/Home#13836

Description

Phase 20 of the NuGet.Protocol nullable migration: enable nullable reference types on legacy V2 feed types.

Changes

  • V2FeedPackageInfo: most string properties → string? (XML source), Authors/Owners stay non-null (Array.Empty fallback), MinClientVersionNuGetVersion?
  • V2FeedParser: GetPackage returns V2FeedPackageInfo?, nullable params for id and SourceCacheContext
  • V2FeedQueryBuilder: private helpers return string?, searchTerm nullable
  • V2FeedPage: NextUristring?
  • PackageSearchMetadataV2Feed: nullable URIs, Description, Summary, Tags; Title stays non-null (PackageId fallback)
  • ODataServiceDocumentResourceV2: add ArgumentNullException guard for baseAddress
  • ODataServiceDocumentResourceV2Provider: TryCreate returns INuGetResource?
  • Update PublicAPI.Shipped.txt for both net472 and net8.0 (~70 entries each)
  • Fix test: nullnull! in V2FeedQueryBuilderTests for ArgumentNullException test

Note that IPackageSearchMetadata is not yet annotated. The idea is we annotate the implementation first and then we basically OR all of those values to annotate IPackageSearchMetadata correctly.

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.

Remove #nullable disable from all phase 20 files and add honest nullable
annotations:

- V2FeedPackageInfo: most string properties → string? (XML source),
  Authors/Owners stay non-null (Array.Empty fallback)
- V2FeedParser: GetPackage returns V2FeedPackageInfo?, nullable params
  for id and SourceCacheContext
- V2FeedQueryBuilder: private helpers return string?, searchTerm nullable
- V2FeedPage: NextUri → string?
- PackageSearchMetadataV2Feed: nullable URIs, Description, Summary, Tags;
  Title stays non-null (PackageId fallback)
- ODataServiceDocumentResourceV2: add ArgumentNullException guard for
  baseAddress
- ODataServiceDocumentResourceV2Provider: TryCreate returns INuGetResource?
- Update PublicAPI.Shipped.txt for both net472 and net8.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nkolev92 nkolev92 marked this pull request as ready for review June 23, 2026 18:53
@nkolev92 nkolev92 requested a review from a team as a code owner June 23, 2026 18:53

@jebriede jebriede 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.

Approving with one suggestion

public ODataServiceDocumentResourceV2(string baseAddress, DateTime requestTime)
{
_baseAddress = baseAddress.Trim('/');
_baseAddress = (baseAddress ?? throw new ArgumentNullException(nameof(baseAddress))).Trim('/');

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.

This guard actually changes behavior: before, a null baseAddress would throw an NullReferenceException when .Trim('/') ran, and now it throws ArgumentNullException instead. That's a good change, but it's the only behavioral change in what's otherwise an annotation-only PR, and the checklist shows no tests were added. Should we add a small test, or at least mention it in the PR remarks? That way the difference from the old behavior is clearly intentional and covered.

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.

Could not write to output file 'C:\.xml' -- 'Access to the path 'C:\.xml' is denied

3 participants