Open
Conversation
Replace the Polyfill NuGet package with a self-contained eng/Polyfills.cs file and project-specific polyfill extensions. - Remove Polyfill PackageReference from all 35 csproj files - Remove Polyfill configuration (PolyEnsure, PolyGuard, etc.) from Directory.Build.props - Remove PackageVersion from Directory.Packages.props - Remove global using Polyfills directives from csproj files - Add eng/Polyfills.cs with type stubs and attributes for older TFMs - Add project-specific polyfill extension methods where needed - Fix call sites for APIs not available on netstandard2.0/net462 Fixes #7596
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the third-party Polyfill NuGet dependency across the repo and replaces it with a shared, source-included polyfill implementation (eng/Polyfills.cs) plus a few project-scoped polyfill extension files to keep older TFMs building cleanly.
Changes:
- Removed
PolyfillPackageReferenceentries (and related MSBuild config/global usings) across projects. - Added
eng/Polyfills.csand wired it into builds viaDirectory.Build.props. - Updated call sites to avoid APIs/overloads not available on older TFMs (e.g.,
Enum.Parse<T>,Environment.ProcessId, async XML load/save, etc.).
Reviewed changes
Copilot reviewed 67 out of 67 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Utilities/TestFramework.ForTestingMSTest/TestFramework.ForTestingMSTest.csproj | Removes Polyfill package reference. |
| test/Utilities/Microsoft.Testing.TestInfrastructure/Microsoft.Testing.TestInfrastructure.csproj | Removes Polyfill package reference and Polyfills using. |
| test/Utilities/Automation.CLI/Automation.CLI.csproj | Removes Polyfill package reference. |
| test/UnitTests/TestFramework.UnitTests/TestFramework.UnitTests.csproj | Removes Polyfill package reference. |
| test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.AreEqualTests.cs | Switches to Split(char) overload for compatibility. |
| test/UnitTests/Microsoft.Testing.Platform.UnitTests/Microsoft.Testing.Platform.UnitTests.csproj | Removes Polyfill package reference and Polyfills using. |
| test/UnitTests/Microsoft.Testing.Extensions.VSTestBridge.UnitTests/Microsoft.Testing.Extensions.VSTestBridge.UnitTests.csproj | Removes Polyfill package reference. |
| test/UnitTests/Microsoft.Testing.Extensions.UnitTests/Microsoft.Testing.Extensions.UnitTests.csproj | Removes Polyfill package reference. |
| test/UnitTests/MSTestAdapter.UnitTests/MSTestAdapter.UnitTests.csproj | Removes Polyfill package reference. |
| test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/ObjectModel/UnitTestElementTests.cs | Replaces Enum.GetValues<T>() with non-generic overload for older TFMs. |
| test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/MSTestAdapter.PlatformServices.UnitTests.csproj | Removes Polyfill package reference. |
| test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Discovery/TypeEnumeratorTests.MockedMethodInfoWithExtraAttributes.cs | Removes conditional using Polyfills;. |
| test/UnitTests/MSTest.Analyzers.UnitTests/MSTest.Analyzers.UnitTests.csproj | Removes Polyfill package reference. |
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj | Removes Polyfill package reference. |
| test/IntegrationTests/MSTest.IntegrationTests/Utilities/TestCaseFilterFactory.cs | Removes using Polyfills;. |
| test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csproj | Removes Polyfill package reference. |
| test/IntegrationTests/MSTest.Acceptance.IntegrationTests/MSTest.Acceptance.IntegrationTests.csproj | Removes Polyfill package reference. |
| src/TestFramework/TestFramework/TestFramework.csproj | Removes Polyfill package reference and Polyfills using. |
| src/TestFramework/TestFramework/Internal/TestDataSourceUtilities.cs | Replaces string.Join(char, …) with string separator overload for older TFMs. |
| src/TestFramework/TestFramework/Internal/PolyfillExtensions.cs | Adds TestFramework-scoped polyfill extensions. |
| src/TestFramework/TestFramework.Extensions/TestFramework.Extensions.csproj | Removes Polyfill package reference and Polyfills using. |
| src/Platform/Microsoft.Testing.Platform/Services/ExecutableInfo.cs | Replaces string.Join(char, …) usage with string separator overload. |
| src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/TcpMessageHandler.cs | Adjusts flush logic to avoid FlushAsync(CancellationToken) dependency. |
| src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/ServerModePerCallOutputDevice.cs | Replaces ConcurrentBag.Clear() with fallback loop for non-NETCOREAPP. |
| src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/SerializerUtilities.cs | Replaces string.Join(char, …) usage with string separator overload. |
| src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj | Removes Polyfill package reference. |
| src/Platform/Microsoft.Testing.Platform/Helpers/System/SystemFileSystem.cs | Adds polyfilled File.Move(overwrite) and async file-read fallback. |
| src/Platform/Microsoft.Testing.Platform/Helpers/System/SystemEnvironment.cs | Adds Environment.ProcessId fallback for older TFMs. |
| src/Platform/Microsoft.Testing.Platform/Helpers/Sha256Hasher.cs | Adds hashing/hex formatting fallbacks for older TFMs. |
| src/Platform/Microsoft.Testing.Platform/Helpers/KeyValuePairDeconstruct.cs | Adds Platform-scoped KeyValuePair Deconstruct polyfill. |
| src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs | Replaces Enum.Parse<T> with non-generic overload for older TFMs. |
| src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs | Replaces Enum.Parse<T> with non-generic overloads for older TFMs. |
| src/Platform/Microsoft.Testing.Platform.MSBuild/Microsoft.Testing.Platform.MSBuild.csproj | Removes Polyfill package reference and Polyfills using. |
| src/Platform/Microsoft.Testing.Platform.AI/Microsoft.Testing.Platform.AI.csproj | Removes Polyfill package reference. |
| src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Microsoft.Testing.Extensions.VSTestBridge.csproj | Removes Polyfill package reference and Polyfills using. |
| src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.cs | Adds async XML save fallback for non-NETCOREAPP. |
| src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxCompareTool.cs | Adds async XML load fallback for non-NETCOREAPP. |
| src/Platform/Microsoft.Testing.Extensions.TrxReport/Microsoft.Testing.Extensions.TrxReport.csproj | Removes Polyfill package reference and Polyfills using. |
| src/Platform/Microsoft.Testing.Extensions.TrxReport/Hashing/EmbeddedAttribute.cs | Removes local EmbeddedAttribute in favor of shared polyfills file. |
| src/Platform/Microsoft.Testing.Extensions.TrxReport.Abstractions/PolyfillExtensions.cs | Adds Abstractions-scoped polyfill extensions (StringBuilder.AppendJoin). |
| src/Platform/Microsoft.Testing.Extensions.TrxReport.Abstractions/Microsoft.Testing.Extensions.TrxReport.Abstractions.csproj | Removes Polyfill package reference and Polyfills using. |
| src/Platform/Microsoft.Testing.Extensions.TrxReport.Abstractions/GlobalSuppressions.cs | Removes Polyfill-specific suppression entry. |
| src/Platform/Microsoft.Testing.Extensions.Telemetry/Microsoft.Testing.Extensions.Telemetry.csproj | Removes Polyfill package reference and Polyfills using. |
| src/Platform/Microsoft.Testing.Extensions.Retry/Microsoft.Testing.Extensions.Retry.csproj | Removes Polyfill package reference. |
| src/Platform/Microsoft.Testing.Extensions.OpenTelemetry/Microsoft.Testing.Extensions.OpenTelemetry.csproj | Removes Polyfill package reference and Polyfills using. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/Microsoft.Testing.Extensions.MSBuild.csproj | Removes Polyfill package reference. |
| src/Platform/Microsoft.Testing.Extensions.HotReload/Microsoft.Testing.Extensions.HotReload.csproj | Removes Polyfill package reference. |
| src/Platform/Microsoft.Testing.Extensions.HangDump/Microsoft.Testing.Extensions.HangDump.csproj | Removes Polyfill package reference. |
| src/Platform/Microsoft.Testing.Extensions.CrashDump/Microsoft.Testing.Extensions.CrashDump.csproj | Removes Polyfill package reference. |
| src/Platform/Microsoft.Testing.Extensions.AzureFoundry/Microsoft.Testing.Extensions.AzureFoundry.csproj | Removes Polyfill package reference. |
| src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/Microsoft.Testing.Extensions.AzureDevOpsReport.csproj | Removes Polyfill package reference. |
| src/Analyzers/MSTest.SourceGeneration/Helpers/SystemPolyfills.cs | Removes local type polyfills in favor of shared eng/Polyfills.cs. |
| src/Analyzers/MSTest.Analyzers/RoslynAnalyzerHelpers/AnalyzerPolyfillExtensions.cs | Adds analyzer-scoped polyfill extensions. |
| src/Analyzers/MSTest.Analyzers/MSTest.Analyzers.csproj | Removes Polyfill package reference. |
| src/Analyzers/MSTest.Analyzers.CodeFixes/MSTest.Analyzers.CodeFixes.csproj | Removes Polyfill package reference. |
| src/Adapter/MSTestAdapter.PlatformServices/Utilities/DeploymentUtility.cs | Replaces Environment.ProcessId usage with fallback. |
| src/Adapter/MSTestAdapter.PlatformServices/Services/TestSourceHost.cs | Replaces string.Join(char, …) with string separator overload in updated call site. |
| src/Adapter/MSTestAdapter.PlatformServices/Services/TestDataSource.cs | Replaces Enum.Parse<T> with non-generic overload. |
| src/Adapter/MSTestAdapter.PlatformServices/PolyfillExtensions.cs | Adds adapter-scoped polyfill extensions (including CTS.CancelAsync for < net8). |
| src/Adapter/MSTestAdapter.PlatformServices/MSTestSettings.cs | Replaces generic Enum APIs with non-generic overloads for older TFMs. |
| src/Adapter/MSTestAdapter.PlatformServices/MSTestAdapter.PlatformServices.csproj | Removes Polyfill package reference and Polyfills using. |
| src/Adapter/MSTestAdapter.PlatformServices/Extensions/MethodInfoExtensions.cs | Replaces Type.IsGenericMethodParameter usage with portable logic. |
| src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj | Removes Polyfill package reference and Polyfills using. |
| src/Adapter/MSTest.Engine/MSTest.Engine.csproj | Removes Polyfill package reference. |
| eng/Polyfills.cs | Adds shared repo-wide polyfill implementations and (conditionally) extension polyfills. |
| Directory.Packages.props | Removes Polyfill package version entry. |
| Directory.Build.props | Removes Polyfill MSBuild config and adds compilation of eng/Polyfills.cs. |
src/Adapter/MSTestAdapter.PlatformServices/PolyfillExtensions.cs
Outdated
Show resolved
Hide resolved
src/Platform/Microsoft.Testing.Platform/Helpers/System/SystemEnvironment.cs
Show resolved
Hide resolved
src/Adapter/MSTestAdapter.PlatformServices/Utilities/DeploymentUtility.cs
Outdated
Show resolved
Hide resolved
src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/TcpMessageHandler.cs
Show resolved
Hide resolved
…d param - Add Polyfills.Guard, Polyfills.Ensure, and Polyfills.Polyfill backward- compatible types in eng/Polyfills.cs (guarded by IS_CORE_MTP) to prevent TypeLoadException/MissingMethodException when old extension packages reference these types from the platform assembly via InternalsVisibleTo. - Fix unused cancellationToken parameter in TrxReportEngine constructor for netstandard2.0 builds (addresses PR review comment).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the Polyfill NuGet package with a self-contained
eng/Polyfills.csfile and project-specific polyfill extension methods.Changes
PolyfillPackageReference from all 35 csproj filesPolyEnsure,PolyGuard,PolyStringInterpolation,PolyUseEmbeddedAttribute) fromDirectory.Build.propsPackageVersionentry fromDirectory.Packages.props<Using Include="Polyfills" />directives from 12 csproj filesusing Polyfills;from source filesGlobalSuppressionsentryReplacements
eng/Polyfills.cs— Shared polyfill types and attributes for older TFMs (netstandard2.0,net462): nullable attributes, compiler attributes,ExperimentalAttribute,Index/Range,Lock,OperatingSystem,UnreachableException,Ensurehelper, etc.src/Platform/Microsoft.Testing.Platform/Helpers/KeyValuePairDeconstruct.cssrc/Platform/Microsoft.Testing.Extensions.TrxReport.Abstractions/PolyfillExtensions.cssrc/TestFramework/TestFramework/Internal/PolyfillExtensions.cssrc/Adapter/MSTestAdapter.PlatformServices/PolyfillExtensions.cssrc/Analyzers/MSTest.Analyzers/RoslynAnalyzerHelpers/AnalyzerPolyfillExtensions.csCall-site fixes
Fixed code that relied on Polyfill-provided APIs not available on older TFMs:
SHA256.HashData,Convert.ToHexStringLower,Environment.ProcessId,File.Move(3-arg),File.ReadAllTextAsync,Enum.Parse<T>,Enum.GetNames<T>,Enum.IsDefined<T>,Enum.GetValues<T>,XElement.LoadAsync,XDocument.SaveAsync,Type.IsGenericMethodParameter,string.Join(char, ...),ConcurrentBag.Clear,ConcurrentDictionary.GetOrAdd(3-arg), andTextWriter.FlushAsync(CancellationToken).Fixes #7596