Repository navigation
Enable nullable on NuGet.Protocol legacy feed types (phase 20) - #7498
Conversation
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 <[email protected]>
jebriede
left a comment
There was a problem hiding this comment.
Approving with one suggestion
| public ODataServiceDocumentResourceV2(string baseAddress, DateTime requestTime) | ||
| { | ||
| _baseAddress = baseAddress.Trim('/'); | ||
| _baseAddress = (baseAddress ?? throw new ArgumentNullException(nameof(baseAddress))).Trim('/'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
The PR description already calls it out.
Is that enough?
There was a problem hiding this comment.
You're out today, so I'll merge this now, but happy to address it in a future PR.
Bug
Progress: NuGet/Home#14851
Description
Phase 20 of the NuGet.Protocol nullable migration: enable nullable reference types on legacy V2 feed types.
Changes
string?(XML source), Authors/Owners stay non-null (Array.Emptyfallback),MinClientVersion→NuGetVersion?GetPackagereturnsV2FeedPackageInfo?, nullable params foridandSourceCacheContextstring?,searchTermnullableNextUri→string?ArgumentNullExceptionguard forbaseAddressTryCreatereturnsINuGetResource?PublicAPI.Shipped.txtfor both net472 and net8.0 (~70 entries each)null→null!inV2FeedQueryBuilderTestsforArgumentNullExceptiontestNote 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