Skip to content

Fix Grpc.Net.ClientFactory version range check - Fixes #7565#7566

Open
Ghost93 wants to merge 6 commits into
dotnet:mainfrom
Ghost93:fix/grpc-net-clientfactory-version-range
Open

Fix Grpc.Net.ClientFactory version range check - Fixes #7565#7566
Ghost93 wants to merge 6 commits into
dotnet:mainfrom
Ghost93:fix/grpc-net-clientfactory-version-range

Conversation

@Ghost93

@Ghost93 Ghost93 commented Jun 15, 2026

Copy link
Copy Markdown

Fixes #7565

Summary

  • Normalize Grpc.Net.ClientFactory NuGet version metadata before calling VersionLessThan in the Microsoft.Extensions.Http.Resilience buildTransitive target.
  • Handle bracket-pinned versions such as [2.80.0] without failing the build with MSB4184.
  • Add regression coverage for all version sources checked by the target:
    • PackageReference.Version
    • PackageReference.VersionOverride
    • PackageVersion.Version
    • ReferencePath.NuGetPackageVersion

Validation

  • ./restore.sh
  • ./.dotnet/dotnet test test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Microsoft.Extensions.Http.Resilience.Tests.csproj --filter GrpcNetClientFactoryVersionTargetTests --no-restore -v:minimal
  • ./build.sh --vs Polly,Resilience
  • ./build.sh --build --test
Microsoft Reviewers: Open in CodeFlow

@Ghost93

Ghost93 commented Jun 15, 2026

Copy link
Copy Markdown
Author

@dotnet-policy-service agree company="Microsoft"

@Ghost93 Ghost93 force-pushed the fix/grpc-net-clientfactory-version-range branch from a2c32db to 7895395 Compare June 15, 2026 10:13
@Ghost93 Ghost93 marked this pull request as ready for review June 15, 2026 11:35
Copilot AI review requested due to automatic review settings June 15, 2026 11:35
@Ghost93 Ghost93 requested a review from a team as a code owner June 15, 2026 11:35

Copilot AI 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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds resilience build-transitive validation for Grpc.Net.ClientFactory versions and tests to ensure version parsing no longer fails on non-System.Version NuGet version formats.

Changes:

  • Parse comparable versions from PackageReference / PackageVersion / transitive ReferencePath using a regex to avoid MSB4184 when versions are ranges or include prerelease labels.
  • Emit warnings based on the parsed comparable version instead of the raw NuGet version string.
  • Add integration-style tests that run dotnet msbuild against a temporary project to verify warning/no-warning behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/BuildTransitive/GrpcNetClientFactoryVersionTargetTests.cs New tests that execute the MSBuild target and assert warnings are/aren’t emitted for various version sources and formats.
src/Libraries/Microsoft.Extensions.Http.Resilience/buildTransitive/Microsoft.Extensions.Http.Resilience.targets Updates the target to extract a comparable numeric version via regex before calling MSBuild::VersionLessThan.

using FluentAssertions;
using Xunit;

namespace Microsoft.Extensions.Http.Resilience.Test.BuildTransitive;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I kept this as Microsoft.Extensions.Http.Resilience.Test.BuildTransitive because this test project explicitly sets:

<RootNamespace>Microsoft.Extensions.Http.Resilience.Test</RootNamespace>

and the existing tests consistently use Microsoft.Extensions.Http.Resilience.Test.* namespaces. So this new namespace follows the prevailing project convention rather than the folder name.

@Ghost93

Ghost93 commented Jun 15, 2026

Copy link
Copy Markdown
Author

Update on the remaining extensions-ci failures: the MessagePack / NU1903 failures in Microsoft.Extensions.AI.Templates.Tests appear unrelated to this Http.Resilience change.

The same issue is being tracked/fixed separately in #7561: Aspire.Hosting.AppHost -> Aspire.Hosting -> StreamJsonRpc 2.22.23 -> MessagePack >= 2.5.192, where NuGet resolves the vulnerable MessagePack 2.5.192 and the template sandbox treats NU1903 as an error.

This PR’s WarningsCheck issue from the test helper has been addressed in e8fa206209.

@Ghost93 Ghost93 force-pushed the fix/grpc-net-clientfactory-version-range branch from e8fa206 to 892d086 Compare June 15, 2026 16:25
@dotnet-comment-bot

Copy link
Copy Markdown
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.Diagnostics.Testing Line 99 98.65 🔻
Microsoft.Extensions.Telemetry Line 93 91.95 🔻
Microsoft.Extensions.AI Line 89 88.55 🔻
Microsoft.Extensions.AI Branch 89 88.57 🔻
Microsoft.Extensions.AI.OpenAI Line 75 62.65 🔻
Microsoft.Extensions.AI.OpenAI Branch 75 49.63 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Line 75 4.46 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Branch 75 0 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Line 99 96.03 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Branch 99 94.39 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes Line 99 97.73 🔻
Microsoft.Extensions.ServiceDiscovery.Dns Line 75 69.93 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Line 75 42.11 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Branch 75 42.86 🔻
Microsoft.Extensions.ServiceDiscovery Line 75 67.96 🔻
Microsoft.Extensions.ServiceDiscovery Branch 75 71.43 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Line 75 73.85 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Branch 75 70 🔻
Microsoft.Extensions.VectorData.Abstractions Line 75 37.39 🔻
Microsoft.Extensions.VectorData.Abstractions Branch 75 22.73 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Gen.BuildMetadata 97 100
Microsoft.Gen.MetadataExtractor 57 73
Microsoft.Gen.MetricsReports 67 69
Microsoft.Extensions.AI.Abstractions 82 85
Microsoft.Extensions.AI.Evaluation.NLP 0 78
Microsoft.Extensions.Caching.Hybrid 82 85
Microsoft.Extensions.DataIngestion 75 89
Microsoft.Extensions.DataIngestion.Markdig 75 90
Microsoft.Extensions.Http.Resilience 97 100

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1464903&view=codecoverage-tab

@Ghost93 Ghost93 force-pushed the fix/grpc-net-clientfactory-version-range branch from 892d086 to 911bf59 Compare June 15, 2026 18:16
@dotnet-comment-bot

Copy link
Copy Markdown
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.Diagnostics.Testing Line 99 98.65 🔻
Microsoft.Extensions.Telemetry Line 93 91.95 🔻
Microsoft.Extensions.AI Line 89 88.58 🔻
Microsoft.Extensions.AI Branch 89 88.57 🔻
Microsoft.Extensions.AI.OpenAI Line 75 62.65 🔻
Microsoft.Extensions.AI.OpenAI Branch 75 49.63 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Line 75 4.46 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Branch 75 0 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Line 99 96.03 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Branch 99 94.39 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes Line 99 97.73 🔻
Microsoft.Extensions.ServiceDiscovery.Dns Line 75 68.32 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Line 75 42.11 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Branch 75 42.86 🔻
Microsoft.Extensions.ServiceDiscovery Line 75 67.21 🔻
Microsoft.Extensions.ServiceDiscovery Branch 75 71.43 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Line 75 73.85 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Branch 75 70 🔻
Microsoft.Extensions.VectorData.Abstractions Line 75 37.39 🔻
Microsoft.Extensions.VectorData.Abstractions Branch 75 22.73 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Gen.BuildMetadata 97 100
Microsoft.Gen.MetadataExtractor 57 73
Microsoft.Gen.MetricsReports 67 69
Microsoft.Extensions.AI.Abstractions 82 85
Microsoft.Extensions.AI.Evaluation.NLP 0 78
Microsoft.Extensions.Caching.Hybrid 82 89
Microsoft.Extensions.DataIngestion 75 89
Microsoft.Extensions.DataIngestion.Markdig 75 90
Microsoft.Extensions.Http.Resilience 97 100

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1465046&view=codecoverage-tab

@Ghost93 Ghost93 force-pushed the fix/grpc-net-clientfactory-version-range branch from 911bf59 to 0c487a8 Compare June 15, 2026 19:54
@dotnet-comment-bot

Copy link
Copy Markdown
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.Diagnostics.Testing Line 99 98.65 🔻
Microsoft.Extensions.Telemetry Line 93 91.95 🔻
Microsoft.Extensions.AI Line 89 88.65 🔻
Microsoft.Extensions.AI Branch 89 88.57 🔻
Microsoft.Extensions.AI.OpenAI Line 75 62.65 🔻
Microsoft.Extensions.AI.OpenAI Branch 75 49.63 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Line 75 4.46 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Branch 75 0 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Line 99 96.03 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Branch 99 94.39 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes Line 99 97.73 🔻
Microsoft.Extensions.ServiceDiscovery.Dns Line 75 69.93 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Line 75 42.11 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Branch 75 42.86 🔻
Microsoft.Extensions.ServiceDiscovery Line 75 68.42 🔻
Microsoft.Extensions.ServiceDiscovery Branch 75 71.43 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Line 75 73.85 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Branch 75 70 🔻
Microsoft.Extensions.VectorData.Abstractions Line 75 37.39 🔻
Microsoft.Extensions.VectorData.Abstractions Branch 75 22.73 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Gen.BuildMetadata 97 100
Microsoft.Gen.MetadataExtractor 57 73
Microsoft.Gen.MetricsReports 67 69
Microsoft.Extensions.AI.Abstractions 82 85
Microsoft.Extensions.AI.Evaluation.NLP 0 78
Microsoft.Extensions.Caching.Hybrid 82 84
Microsoft.Extensions.DataIngestion 75 89
Microsoft.Extensions.DataIngestion.Markdig 75 90
Microsoft.Extensions.Http.Resilience 97 100

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1465182&view=codecoverage-tab

Ghost93 and others added 6 commits June 16, 2026 10:21
Normalize NuGet version range metadata before calling VersionLessThan in the Http.Resilience buildTransitive target.

Add regression coverage for bracket-pinned versions across all target inputs.

Fixes dotnet#7565

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Avoid letting temporary directory cleanup failures mask the original test assertion or process failure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Kill the process tree where supported, wait for termination, and observe output reader tasks before reporting a timeout.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Prefer ProcessStartInfo.ArgumentList on modern target frameworks while keeping the quoted Arguments fallback for net462.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Explain the comparable version regex inputs so future changes preserve the MSBuild VersionLessThan guard behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Avoid empty catch blocks while preserving best-effort cleanup and output task observation behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Ghost93 Ghost93 force-pushed the fix/grpc-net-clientfactory-version-range branch from 0c487a8 to 4c7e573 Compare June 16, 2026 07:21
@dotnet-comment-bot

Copy link
Copy Markdown
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.Diagnostics.Testing Line 99 98.65 🔻
Microsoft.Extensions.Telemetry Line 93 91.95 🔻
Microsoft.Extensions.AI Line 89 88.52 🔻
Microsoft.Extensions.AI Branch 89 88.57 🔻
Microsoft.Extensions.AI.OpenAI Line 75 62.65 🔻
Microsoft.Extensions.AI.OpenAI Branch 75 49.63 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Line 75 4.46 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Branch 75 0 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Line 99 96.03 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Branch 99 94.39 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes Line 99 97.73 🔻
Microsoft.Extensions.ServiceDiscovery.Dns Line 75 69.93 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Line 75 42.11 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Branch 75 42.86 🔻
Microsoft.Extensions.ServiceDiscovery Line 75 67.21 🔻
Microsoft.Extensions.ServiceDiscovery Branch 75 71.43 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Line 75 73.85 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Branch 75 70 🔻
Microsoft.Extensions.VectorData.Abstractions Line 75 37.39 🔻
Microsoft.Extensions.VectorData.Abstractions Branch 75 22.73 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Gen.BuildMetadata 97 100
Microsoft.Gen.MetadataExtractor 57 73
Microsoft.Gen.MetricsReports 67 69
Microsoft.Extensions.AI.Abstractions 82 85
Microsoft.Extensions.AI.Evaluation.NLP 0 78
Microsoft.Extensions.Caching.Hybrid 82 84
Microsoft.Extensions.DataIngestion 75 89
Microsoft.Extensions.DataIngestion.Markdig 75 90
Microsoft.Extensions.Http.Resilience 97 100

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1465941&view=codecoverage-tab

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.

[Resilience] _CheckGrpcNetClientFactoryVersion target crashes on bracket-pinned Grpc.Net.ClientFactory

3 participants