Skip to content

[main] Source code updates from nuget/nuget.client - #6930

Merged
dotnet-maestro[bot] merged 4 commits into
mainfrom
darc-main-18347aee-9945-4fdd-83b7-8b25b8ba5b02
Jun 1, 2026
Merged

dotnet-maestro[bot] merged 4 commits into
mainfrom
darc-main-18347aee-9945-4fdd-83b7-8b25b8ba5b02

Conversation

@dotnet-maestro

Copy link
Copy Markdown
Contributor

Note

This is a codeflow update. It may contain both source code changes from
the source repo
as well as dependency updates. Learn more here.

This pull request brings the following source code changes

From https://github.com/nuget/nuget.client

Diff the source with this PR branch
darc vmr diff --name-only https://github.com/nuget/nuget.client:515c04139c0ac8c31aef7943d667f015a052f7d2..https://github.com/dotnet/dotnet:darc-main-18347aee-9945-4fdd-83b7-8b25b8ba5b02

@dotnet-maestro

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team May 31, 2026 02:07
…7406

NuGet/NuGet.Client PR #7406 ("Enable nullable for NuGet.Protocol
repository abstractions") changed SourceRepository.GetResourceAsync<T>
to return Task<T?>, matching the long-standing XML doc contract
("Null if the resource does not exist"). Consumers in sdk's
TemplateEngine NuGet helpers were storing the result in non-nullable
locals and dereferencing immediately, producing CS8600/CS8602 under
nullable-enabled compilation with TreatWarningsAsErrors=true.

Mirror the same pattern nuget.client now uses internally
(SourceRepository.GetFeedType): throw InvalidOperationException if a
provider cannot produce the requested resource, then proceed with a
non-null value.

Fixed 4 call sites across 2 files:
  src/Cli/Microsoft.TemplateEngine.Cli/NuGet/NugetApiManager.cs
    - GetResourceAsync<PackageMetadataResource>
    - GetResourceAsync<PackageSearchResource>
  test/TemplateEngine/Microsoft.TemplateEngine.TestHelper/PackageManager.cs
    - GetResourceAsync<FindPackageByIdResource>
    - GetResourceAsync<PackageMetadataResource>

Co-authored-by: Copilot <[email protected]>
@lewing

lewing commented May 31, 2026

Copy link
Copy Markdown
Member

Pushed a fix for the nullability errors caused by nuget/nuget.client#7406, which flipped SourceRepository.GetResourceAsync<T> to Task<T?>. The 4 affected sites in src/Cli/Microsoft.TemplateEngine.Cli/NuGet/NugetApiManager.cs and test/TemplateEngine/Microsoft.TemplateEngine.TestHelper/PackageManager.cs now throw InvalidOperationException when a provider can't produce the requested resource (mirroring the pattern nuget.client adopted internally in SourceRepository.GetFeedType). The same commit was applied to the sibling [main] / [10.0.4xx] / [preview5] codeflow PRs. Will backflow into dotnet/sdk after merge. cc @dotnet/dotnet-cli

@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team May 31, 2026 16:23
Repository.GetResource<T>() is now annotated to return T? (matching the
documented null-on-missing behavior). The TemplateSearch.TemplateDiscovery
tool dereferences the result and stores it in a non-nullable field, so the
build fails with CS8600/CS8602/CS8618. Throw InvalidOperationException
when the source does not provide the requested resource, matching the
pattern used in NugetApiManager.cs and PackageManager.cs (and mirroring
nuget.client's own internal SourceRepository.GetFeedType adoption).

Co-authored-by: Copilot <[email protected]>
@lewing

lewing commented May 31, 2026

Copy link
Copy Markdown
Member

Additional fix: src/sdk/src/TemplateEngine/Tools/Microsoft.TemplateSearch.TemplateDiscovery/NuGet/NugetPackProvider.cs hits the same nuget.client #7406 nullability change (Repository.GetResource<T>() is now T?). Applied the same ?? throw new InvalidOperationException(...) pattern. /cc @dotnet/dotnet-cli

…#7406

GetResourceAsync<PackageMetadataResource> now returns Task<T?> — add null
check with InvalidOperationException, matching the pattern used elsewhere.

Co-authored-by: Copilot <[email protected]>
@lewing

lewing commented May 31, 2026

Copy link
Copy Markdown
Member

Pushed an additional fix for \NugetPackProvider.GetPackageInfoAsync\ — the \GetResourceAsync\ call also returns \T?\ after nuget.client#7406. Same null-check pattern applied. The previous commit covered the constructor calls but missed the async path at line 213. Same fix applied to the sibling preview5 PR #6928.

@dotnet-maestro
dotnet-maestro Bot merged commit c929e5f into main Jun 1, 2026
16 checks passed
@dotnet-maestro
dotnet-maestro Bot deleted the darc-main-18347aee-9945-4fdd-83b7-8b25b8ba5b02 branch June 1, 2026 15:27
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team June 1, 2026 15:28
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.

3 participants