Skip to content

Remove Polyfill#7726

Merged
Youssef1313 merged 24 commits intomainfrom
dev/ygerges/polyfill-removal
Apr 16, 2026
Merged

Remove Polyfill#7726
Youssef1313 merged 24 commits intomainfrom
dev/ygerges/polyfill-removal

Conversation

@Youssef1313
Copy link
Copy Markdown
Member

@Youssef1313 Youssef1313 commented Apr 15, 2026

Fixes #7596

Copilot AI review requested due to automatic review settings April 15, 2026 13:43
@Youssef1313 Youssef1313 enabled auto-merge (squash) April 15, 2026 13:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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.

This PR removes the dependency on the external Polyfill NuGet package and instead inlines polyfill source code via src/Polyfills/**/*.cs, updating call sites to be compatible across TFMs.

Changes:

  • Replaced PackageReference Include="Polyfill" with Compile Include="$(RepoRoot)src/Polyfills/**/*.cs" across many projects.
  • Added a local src/Polyfills source set (attributes, helpers, and compatibility shims) plus some per-TFM #if fallbacks.
  • Updated various code paths to avoid APIs unavailable on non-NETCOREAPP TFMs (e.g., CancelAsync, FlushAsync(CancellationToken), SaveAsync, Enum.Parse<T>, String.Contains(string, comparison)).

Reviewed changes

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

Show a summary per file
File Description
test/Utilities/TestFramework.ForTestingMSTest/TestFramework.ForTestingMSTest.csproj Replace Polyfill package with compiled local polyfills.
test/Utilities/Microsoft.Testing.TestInfrastructure/ProjectSystem.cs Adjust TFM argument validation (remove Polyfill Ensure).
test/Utilities/Microsoft.Testing.TestInfrastructure/Microsoft.Testing.TestInfrastructure.csproj Replace Polyfill package with compiled local polyfills.
test/Utilities/Automation.CLI/Automation.CLI.csproj Replace Polyfill package with compiled local polyfills.
test/UnitTests/TestFramework.UnitTests/TestFramework.UnitTests.csproj Replace Polyfill package with compiled local polyfills.
test/UnitTests/Microsoft.Testing.Platform.UnitTests/Microsoft.Testing.Platform.UnitTests.csproj Replace Polyfill package with compiled local polyfills.
test/UnitTests/Microsoft.Testing.Platform.UnitTests/Helpers/CountDownEventTests.cs Add non-NETCOREAPP cancellation fallback.
test/UnitTests/Microsoft.Testing.Extensions.VSTestBridge.UnitTests/Microsoft.Testing.Extensions.VSTestBridge.UnitTests.csproj Replace Polyfill package with compiled local polyfills.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TrxTests.cs Make TrxReportEngine ctor usage conditional on TFM.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/Microsoft.Testing.Extensions.UnitTests.csproj Replace Polyfill package with compiled local polyfills.
test/UnitTests/MSTestAdapter.UnitTests/MSTestAdapter.UnitTests.csproj Replace Polyfill package with compiled local polyfills.
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/MSTestAdapter.PlatformServices.UnitTests.csproj Replace Polyfill package with compiled local polyfills.
test/UnitTests/MSTest.Analyzers.UnitTests/MSTest.Analyzers.UnitTests.csproj Replace Polyfill package with compiled local polyfills.
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj Replace Polyfill package with compiled local polyfills.
test/IntegrationTests/MSTest.IntegrationTests/MSTest.IntegrationTests.csproj Replace Polyfill package with compiled local polyfills.
test/IntegrationTests/MSTest.Acceptance.IntegrationTests/MSTest.Acceptance.IntegrationTests.csproj Replace Polyfill package with compiled local polyfills.
src/TestFramework/TestFramework/TestFramework.csproj Inline polyfills and exclude specific polyfill subsets via constants.
src/TestFramework/TestFramework/Logger.cs Replace Polyfill Ensure checks with explicit ArgumentNullException.
src/TestFramework/TestFramework/Internal/TestDataSourceUtilities.cs Use string overload of string.Join for compatibility.
src/TestFramework/TestFramework/Attributes/TestMethod/SingleThreadedSTASynchronizationContext.cs Replace OperatingSystem.IsWindows() with RuntimeInformation check.
src/TestFramework/TestFramework/Attributes/DataSource/DynamicDataOperations.cs Guard ParamCollectionAttribute usage for pre-NET9 TFMs.
src/TestFramework/TestFramework/Assertions/CollectionAssert.cs Use HashSet for uniqueness check.
src/TestFramework/TestFramework/Assertions/Assert.ThrowsException.cs Replace Polyfill Ensure checks with explicit ArgumentNullException.
src/TestFramework/TestFramework/Assertions/Assert.That.cs Remove tuple deconstruction; make string checks explicit.
src/TestFramework/TestFramework/Assertions/Assert.Contains.cs Add non-NETCOREAPP fallback for string contains by comparison.
src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs Replace Polyfill Ensure checks with explicit ArgumentNullException.
src/TestFramework/TestFramework.Extensions/TestFramework.Extensions.csproj Replace Polyfill package with compiled local polyfills.
src/TestFramework/TestFramework.Extensions/RuntimeTypeHelper.cs Remove Polyfill Ensure guard.
src/TestFramework/TestFramework.Extensions/PrivateType.cs Replace Polyfill Ensure checks with explicit ArgumentNullException.
src/TestFramework/TestFramework.Extensions/PrivateObject.cs Replace Polyfill Ensure checks with explicit ArgumentNullException.
src/TestFramework/TestFramework.Extensions/Attributes/WinUITestTargetAttribute.cs Replace Polyfill Ensure checks with explicit ArgumentNullException.
src/Polyfills/UnreachableException.cs Add local polyfill for UnreachableException (or type forward).
src/Polyfills/UnconditionalSuppressMessageAttribute.cs Add local polyfill attribute (or type forward).
src/Polyfills/StackTraceHiddenAttribute.cs Add local polyfill attribute (or type forward).
src/Polyfills/RequiredMemberAttribute.cs Add local polyfill attribute (or type forward).
src/Polyfills/Range.cs Add local polyfill for System.Range (or type forward).
src/Polyfills/ProcessExtensions.cs Add local polyfill for Process.WaitForExitAsync.
src/Polyfills/PlatformAttributes.cs Add local polyfills for platform attributes (or type forwards).
src/Polyfills/OperatingSystem.cs Attempt to polyfill OperatingSystem.Is* checks.
src/Polyfills/NullableAttribtues.cs Add local nullable attribute polyfills (or type forwards).
src/Polyfills/ModuleInitializerAttribute.cs Add local polyfill attribute (or type forward).
src/Polyfills/IsExternalInit.cs Add local polyfill for IsExternalInit (or type forward).
src/Polyfills/InterpolatedStringHandlerAttribute.cs Add local polyfill attribute (or type forward).
src/Polyfills/InterpolatedStringHandlerArgumentAttribute.cs Add local polyfill attribute (or type forward).
src/Polyfills/Index.cs Add local polyfill for System.Index (or type forward).
src/Polyfills/HashHelpers.cs Add local HashHelpers.Combine used by polyfilled Range/Index.
src/Polyfills/ExperimentalAttribute.cs Add local polyfill attribute (or type forward).
src/Polyfills/Ensure.cs Add local Ensure helpers used by call sites.
src/Polyfills/EmbeddedAttribute.cs Add local EmbeddedAttribute used by embedded polyfills.
src/Polyfills/DynamicallyAccessedMembersAttribute.cs Add local trimming annotation polyfill (or type forward).
src/Polyfills/DynamicallyAccessedMemberTypes.cs Add local enum polyfill (or type forward).
src/Polyfills/CompilerLoweringPreserveAttribute.cs Add local polyfill attribute (or type forward).
src/Polyfills/CompilerFeatureRequiredAttribute.cs Add local polyfill attribute (or type forward).
src/Polyfills/CallerArgumentExpressionAttribute.cs Add local polyfill attribute (or type forward).
src/Platform/Microsoft.Testing.Platform/Tools/ToolsManager.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/TestHostOrchestrator/TestHostOrchestratorManager.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/TestHostControllers/TestHostControllersManager.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/TestHost/TestHostManager.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/Telemetry/TelemetryManager.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/Services/ServiceProviderExtensions.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/Services/ExecutableInfo.cs Use string overload of string.Join for compatibility.
src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/TcpMessageHandler.cs Add non-NETCOREAPP flush fallback.
src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/ServerModePerCallOutputDevice.cs Drain buffered messages via TryTake instead of Clear.
src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/SerializerUtilities.cs Remove newer APIs (TryAdd/deconstruction) for compatibility.
src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/PerRequestServerDataConsumerService.cs Remove Ensure call.
src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/IPC/Serializers/HandshakeMessageSerializer.cs Remove tuple deconstruction for compatibility.
src/Platform/Microsoft.Testing.Platform/ServerMode/DotnetTest/IPC/Serializers/DiscoveredTestMessagesSerializer.cs Replace Ensure with ApplicationStateGuard.Unreachable().
src/Platform/Microsoft.Testing.Platform/Requests/TreeNodeFilter/TreeNodeFilter.cs Replace Ensure with explicit null-guard + length checks.
src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs Avoid Split allocation in architecture parsing.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TestProgressStateAwareTerminal.cs Use Lock on NET9+ otherwise object.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporter.cs Use Lock on NET9+ otherwise object.
src/Platform/Microsoft.Testing.Platform/OutputDevice/OutputDeviceManager.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj Replace Polyfill package with compiled local polyfills and add Using Include="Polyfills".
src/Platform/Microsoft.Testing.Platform/Messages/TestNodeProperties.cs Replace AppendJoin usage with manual loop.
src/Platform/Microsoft.Testing.Platform/Messages/PropertyBag.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/Messages/PropertyBag.Property.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/Messages/MessageBusProxy.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/Messages/AsynchronousMessageBus.cs Avoid deconstruction; add NETCOREAPP/non-NETCOREAPP dictionary add patterns.
src/Platform/Microsoft.Testing.Platform/Logging/LoggingManager.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/Logging/LoggerFactoryProxy.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/Logging/LoggerFactoryExtensions.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeServer.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeClient.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Platform/Hosts/ServerTestHost.cs Replace CancelAsync usage with sync cancel + suppression.
src/Platform/Microsoft.Testing.Platform/Helpers/TimeSpanParser.cs Use string overload for StartsWith.
src/Platform/Microsoft.Testing.Platform/Helpers/TaskExtensions.cs Add local non-NETCOREAPP Task.WaitAsync polyfill.
src/Platform/Microsoft.Testing.Platform/Helpers/System/SystemProcess.cs Add non-NETCOREAPP Kill fallback.
src/Platform/Microsoft.Testing.Platform/Helpers/System/SystemFileSystem.cs Add non-NETCOREAPP file move/read async fallbacks.
src/Platform/Microsoft.Testing.Platform/Helpers/System/SystemEnvironment.cs Add non-NETCOREAPP ProcessId fallback.
src/Platform/Microsoft.Testing.Platform/Helpers/Sha256Hasher.cs Add non-NETCOREAPP hashing + hex lower fallbacks.
src/Platform/Microsoft.Testing.Platform/Helpers/ExtensionValidationHelper.cs Replace Ensure with explicit null-guards.
src/Platform/Microsoft.Testing.Platform/Extensions/CompositeExtensionsFactory.cs Replace Ensure with explicit null-guards; use Lock on NET9+.
src/Platform/Microsoft.Testing.Platform/Configurations/EnvironmentVariablesConfigurationProvider.cs Replace NotNullOrEmpty with null + empty split checks.
src/Platform/Microsoft.Testing.Platform/Configurations/ConfigurationExtensions.cs Replace Ensure with ApplicationStateGuard.Unreachable().
src/Platform/Microsoft.Testing.Platform/CommandLine/Parser.cs Use string overloads for StartsWith/EndsWith.
src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs Simplify debugger attach branch + add non-NETCOREAPP enum parsing.
src/Platform/Microsoft.Testing.Platform/BannedSymbols.txt Remove bans related to ArgumentNullException usage.
src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs Add non-NETCOREAPP enum parsing + use Lock on NET9+.
src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/ConfigurationFileTask.cs Make injected dependency non-nullable with explicit null-guard.
src/Platform/Microsoft.Testing.Platform.MSBuild/Microsoft.Testing.Platform.MSBuild.csproj Replace Polyfill package with compiled local polyfills.
src/Platform/Microsoft.Testing.Platform.AI/Microsoft.Testing.Platform.AI.csproj Replace Polyfill package with compiled local polyfills.
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/VSTestBridgedTestFrameworkBase.cs Replace Ensure with explicit null-guard.
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Microsoft.Testing.Extensions.VSTestBridge.csproj Inline polyfills; remove global Polyfills using item group.
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportExtensions.cs Add conditional using Polyfills for non-NETCOREAPP.
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.cs Make ctor + async save conditional on TFM.
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxProcessLifetimeHandler.cs Update TrxReportEngine usage for conditional ctor.
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxModeHelpers.cs Add conditional using Polyfills; adjust OperatingSystem browser check.
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxDataConsumer.cs Update TrxReportEngine usage for conditional ctor.
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxCompareTool.cs Add non-NETCOREAPP XML load fallback.
src/Platform/Microsoft.Testing.Extensions.TrxReport/Microsoft.Testing.Extensions.TrxReport.csproj Replace Polyfill package with compiled local polyfills; remove global using.
src/Platform/Microsoft.Testing.Extensions.TrxReport/BannedSymbols.txt Remove bans related to ArgumentNullException usage.
src/Platform/Microsoft.Testing.Extensions.TrxReport.Abstractions/TrxReportProperties.cs Replace AppendJoin usage with manual loop.
src/Platform/Microsoft.Testing.Extensions.TrxReport.Abstractions/Microsoft.Testing.Extensions.TrxReport.Abstractions.csproj Replace Polyfill package with compiled local polyfills; remove global using.
src/Platform/Microsoft.Testing.Extensions.TrxReport.Abstractions/BannedSymbols.txt Remove bans related to ArgumentNullException usage.
src/Platform/Microsoft.Testing.Extensions.Telemetry/Microsoft.Testing.Extensions.Telemetry.csproj Inline polyfills via compile include.
src/Platform/Microsoft.Testing.Extensions.Telemetry/AppInsightsProvider.cs Remove tuple deconstruction for compatibility.
src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs Add conditional using Polyfills for non-NETCOREAPP.
src/Platform/Microsoft.Testing.Extensions.Retry/Microsoft.Testing.Extensions.Retry.csproj Replace Polyfill package with compiled local polyfills.
src/Platform/Microsoft.Testing.Extensions.Retry/BannedSymbols.txt Remove bans related to ArgumentNullException usage.
src/Platform/Microsoft.Testing.Extensions.OpenTelemetry/Microsoft.Testing.Extensions.OpenTelemetry.csproj Inline polyfills via compile include.
src/Platform/Microsoft.Testing.Extensions.MSBuild/Microsoft.Testing.Extensions.MSBuild.csproj Replace Polyfill package with compiled local polyfills.
src/Platform/Microsoft.Testing.Extensions.MSBuild/MSBuildExtensions.cs Add conditional using Polyfills for non-NETCOREAPP.
src/Platform/Microsoft.Testing.Extensions.HotReload/Microsoft.Testing.Extensions.HotReload.csproj Replace Polyfill package with compiled local polyfills.
src/Platform/Microsoft.Testing.Extensions.HotReload/HotReloadHandler.cs Add conditional using Polyfills for non-NETCOREAPP.
src/Platform/Microsoft.Testing.Extensions.HotReload/BannedSymbols.txt Remove bans related to ArgumentNullException usage.
src/Platform/Microsoft.Testing.Extensions.HangDump/WindowsMiniDumpWriteDump.cs Exclude Windows-only code for non-NETCOREAPP builds.
src/Platform/Microsoft.Testing.Extensions.HangDump/Microsoft.Testing.Extensions.HangDump.csproj Replace Polyfill package with compiled local polyfills.
src/Platform/Microsoft.Testing.Extensions.HangDump/Helpers/IProcessExtensions.cs Add conditional using Polyfills for non-NETCOREAPP.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpExtensions.cs Add conditional using Polyfills for non-NETCOREAPP.
src/Platform/Microsoft.Testing.Extensions.HangDump/BannedSymbols.txt Remove bans related to ArgumentNullException usage.
src/Platform/Microsoft.Testing.Extensions.CrashDump/Microsoft.Testing.Extensions.CrashDump.csproj Replace Polyfill package with compiled local polyfills.
src/Platform/Microsoft.Testing.Extensions.CrashDump/BannedSymbols.txt Remove bans related to ArgumentNullException usage.
src/Platform/Microsoft.Testing.Extensions.AzureFoundry/Microsoft.Testing.Extensions.AzureFoundry.csproj Replace Polyfill package with compiled local polyfills.
src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/Microsoft.Testing.Extensions.AzureDevOpsReport.csproj Inline polyfills alongside RootFinder source include.
src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/BannedSymbols.txt Remove bans related to ArgumentNullException usage.
src/Analyzers/MSTest.Analyzers/TestContextShouldBeValidAnalyzer.cs Make StartsWith usage explicit and ordinal.
src/Analyzers/MSTest.Analyzers/RoslynAnalyzerHelpers/ArrayBuilder.cs Remove tuple deconstruction for compatibility.
src/Analyzers/MSTest.Analyzers/MSTest.Analyzers.csproj Replace Polyfill package with compiled local polyfills.
src/Analyzers/MSTest.Analyzers/FlowTestContextCancellationTokenAnalyzer.cs Make StartsWith usage explicit and ordinal.
src/Analyzers/MSTest.Analyzers/DoNotUseShadowingAnalyzer.cs Avoid GetValueOrDefault usage for compatibility.
src/Analyzers/MSTest.Analyzers/DataRowShouldBeValidAnalyzer.cs Replace IsAssignableTo usage with IsAssignableFrom patterns.
src/Analyzers/MSTest.Analyzers.CodeFixes/MSTest.Analyzers.CodeFixes.csproj Replace Polyfill package with compiled local polyfills.
src/Analyzers/MSTest.Analyzers.CodeFixes/FlowTestContextCancellationTokenFixer.cs Replace Ensure check with explicit null check.
src/Adapter/MSTestAdapter.PlatformServices/Utilities/XmlUtilities.cs Replace Ensure with explicit null-guard.
src/Adapter/MSTestAdapter.PlatformServices/Utilities/DeploymentUtilityBase.cs Remove Ensure checks in deployment loops.
src/Adapter/MSTestAdapter.PlatformServices/Utilities/DeploymentUtility.cs Add non-NETCOREAPP ProcessId fallback and use it.
src/Adapter/MSTestAdapter.PlatformServices/Utilities/DeploymentItemUtility.cs Remove tuple deconstruction for compatibility.
src/Adapter/MSTestAdapter.PlatformServices/Services/TestSourceHost.cs Use string overload of string.Join for compatibility.
src/Adapter/MSTestAdapter.PlatformServices/Services/TestDataSource.cs Add non-NETCOREAPP enum parsing fallback.
src/Adapter/MSTestAdapter.PlatformServices/Services/SettingsProvider.cs Replace Ensure with explicit null-guard.
src/Adapter/MSTestAdapter.PlatformServices/Services/MSTestAdapterSettings.cs Replace Ensure with explicit null-guard.
src/Adapter/MSTestAdapter.PlatformServices/RunConfigurationSettings.cs Remove StringSyntax annotation usage and add explicit null guard.
src/Adapter/MSTestAdapter.PlatformServices/ObjectModel/UnitTestElement.cs Replace Ensure with explicit null-guard.
src/Adapter/MSTestAdapter.PlatformServices/MSTestSettings.cs Remove StringSyntax annotations; add non-NETCOREAPP enum helpers.
src/Adapter/MSTestAdapter.PlatformServices/MSTestAdapter.PlatformServices.csproj Inline polyfills; exclude OS polyfill via constants.
src/Adapter/MSTestAdapter.PlatformServices/Helpers/TestDataSourceHelpers.cs Replace IsAssignableTo usage with IsAssignableFrom patterns.
src/Adapter/MSTestAdapter.PlatformServices/Helpers/RunSettingsUtilities.cs Remove StringSyntax annotations to reduce dependency.
src/Adapter/MSTestAdapter.PlatformServices/Helpers/ReflectHelper.cs Replace Ensure with explicit null-guard; simplify return-type match.
src/Adapter/MSTestAdapter.PlatformServices/Extensions/MethodInfoExtensions.cs Replace helper usage with reflection-based generic parameter check.
src/Adapter/MSTestAdapter.PlatformServices/Execution/UnitTestRunner.cs Replace Ensure with explicit null-guards.
src/Adapter/MSTestAdapter.PlatformServices/Execution/TypeCache.cs Adjust caching patterns for non-NETCOREAPP builds.
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodInfo.cs Replace CancelAsync usage with sync cancel + suppression.
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestExecutionManager.cs Remove tuple deconstruction for compatibility.
src/Adapter/MSTestAdapter.PlatformServices/AssemblyResolver.cs Switch lock type based on TFM; replace Ensure checks.
src/Adapter/MSTest.TestAdapter/VSTestAdapter/MSTestExecutor.cs Replace Ensure checks with explicit null + empty validation.
src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj Replace Polyfill package with compiled local polyfills.
src/Adapter/MSTest.Engine/MSTest.Engine.csproj Replace Polyfill package with compiled local polyfills.
src/Adapter/MSTest.Engine/Engine/TestArgumentsManager.cs Change dictionary registration logic.
Directory.Packages.props Remove centralized Polyfill package version.
Directory.Build.props Remove Polyfill package configuration properties.
Comments suppressed due to low confidence (3)

src/Polyfills/OperatingSystem.cs:1

  • The extension(OperatingSystem) block is not valid C# in currently supported language versions and will fail to compile. Additionally, even if implemented as extension methods, callers cannot use OperatingSystem.IsBrowser() on TFMs where System.OperatingSystem lacks these static members. Replace this with a normal helper API (e.g., Polyfill.IsBrowser() / PlatformGuards.IsBrowser()) and update call sites to use that helper under #if !NETCOREAPP, or directly use RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")) in the call sites.
    src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxModeHelpers.cs:1
  • On non-NETCOREAPP TFMs, System.OperatingSystem does not expose IsBrowser(), so this will not compile unless the polyfill injects an actual OperatingSystem.IsBrowser static member (which C# cannot do). Use an explicit #if NETCOREAPP split here (NETCOREAPP: !OperatingSystem.IsBrowser(), else: !RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER"))) or call a dedicated helper method from the polyfills that is callable on all TFMs.
    src/Polyfills/NullableAttribtues.cs:1
  • The filename has a typo: rename NullableAttribtues.cs to NullableAttributes.cs to avoid confusion and improve discoverability/maintenance.

Comment thread src/Analyzers/MSTest.Analyzers.CodeFixes/FlowTestContextCancellationTokenFixer.cs Outdated
Comment thread src/Adapter/MSTest.Engine/Engine/TestArgumentsManager.cs
Copilot AI review requested due to automatic review settings April 15, 2026 14:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 172 out of 172 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (9)

src/Polyfills/OperatingSystem.cs:1

  • extension(OperatingSystem) is not valid C# syntax in current stable language versions and will fail to compile (unless the repo is explicitly using preview extension-members support). Replace this with a C#-supported approach (e.g., a normal static helper class in the Polyfills namespace, or explicit helper methods that callers invoke), and update call sites accordingly.
    src/Polyfills/Ensure.cs:1
  • Ensure.NotEmpty<T> returns when value is null, which defeats the purpose of an argument guard and can mask null input bugs. This should throw ArgumentNullException (or otherwise be renamed to reflect that null is allowed).
    test/Utilities/Microsoft.Testing.TestInfrastructure/ProjectSystem.cs:1
  • This is validating a constructor argument, so InvalidOperationException is the wrong exception type. Prefer ArgumentNullException when tfms is null and ArgumentException (or ArgumentOutOfRangeException) when it’s empty; that keeps errors consistent and actionable for callers.
    test/Utilities/Microsoft.Testing.TestInfrastructure/ProjectSystem.cs:1
  • This is validating a constructor argument, so InvalidOperationException is the wrong exception type. Prefer ArgumentNullException when tfms is null and ArgumentException (or ArgumentOutOfRangeException) when it’s empty; that keeps errors consistent and actionable for callers.
    src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxReportEngine.cs:1
  • The constructor has different parameter lists across TFMs. That forces #if at every call site (as seen in tests/consumers) and increases maintenance cost. Consider keeping a single signature across TFMs (e.g., always accept CancellationToken but ignore it on non-NETCOREAPP), and only conditionalize the implementation (SaveAsync vs Save).
    test/UnitTests/Microsoft.Testing.Platform.UnitTests/Helpers/CountDownEventTests.cs:1
  • CancellationTokenSource.CancelAsync() is not available on all NETCOREAPP TFMs (it was introduced much later than .NET Core itself). Using NETCOREAPP here is too broad and can break compilation when targeting earlier .NET versions. Use a more specific preprocessor symbol (e.g., NET8_0_OR_GREATER) or avoid CancelAsync entirely if consistent behavior is required.
    test/UnitTests/Microsoft.Testing.Platform.UnitTests/Configuration/ConfigurationExtensionsTests.cs:1
  • The test name indicates an ArgumentNullException, but the assertion now expects InvalidOperationException. Please rename the test to reflect the new expected exception to keep test intent accurate.
    src/Polyfills/NullableAttribtues.cs:1
  • The filename NullableAttribtues.cs contains a typo and should be renamed to NullableAttributes.cs for clarity and discoverability.
    src/Polyfills/UnconditionalSuppressMessageAttribute.cs:1
  • The XML doc cref contains an extra trailing space (MessageId ), which can break doc tooling and links. Update it to MessageId.

Copilot AI review requested due to automatic review settings April 15, 2026 15:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comments suppressed due to low confidence (5)

src/Polyfills/OperatingSystem.cs:1

  • The extension(OperatingSystem) block is not valid C# syntax in released language versions and will fail compilation. If the goal is to provide OperatingSystem.IsBrowser()-style APIs on TFMs where those static methods don't exist, consider instead introducing a polyfill type and consuming it via an alias (e.g., using OperatingSystem = Polyfills.OperatingSystemPolyfill;) or refactoring call sites to use a dedicated helper (e.g., PlatformOperatingSystem.IsBrowser()), gated by #if !NETCOREAPP.
    src/Polyfills/IsExternalInit.cs:1
  • This assembly attribute is inconsistent with the other type-forwarding files and is likely to fail to compile because TypeForwardedTo is not fully qualified and IsExternalInit is not namespace-qualified. Align with the rest of the polyfills by using System.Runtime.CompilerServices.TypeForwardedTo and typeof(System.Runtime.CompilerServices.IsExternalInit) so it doesn't depend on global usings.
    src/TestFramework/TestFramework.Extensions/TestFramework.Extensions.csproj:1
  • MSBuild will treat the second DefineConstants element as an override, which likely drops TRACE from the final constants. Combine these into a single DefineConstants entry (or append in one place) so both TRACE and the new exclusion constants are preserved.
    src/Polyfills/EmbeddedAttribute.cs:1
  • Several projects in this PR (e.g., analyzer/code-fix projects) reference Microsoft.CodeAnalysis.* packages. Defining Microsoft.CodeAnalysis.EmbeddedAttribute in source can cause CS0433 type conflicts if the referenced Roslyn assemblies also define this type. A robust fix is to exclude this file from compilation in Roslyn-based projects (e.g., via <Compile Remove=\".../EmbeddedAttribute.cs\" />) so those projects use the Roslyn-provided attribute, while still compiling it into projects that don't reference Roslyn.
    src/Polyfills/Ensure.cs:1
  • Ensure.NotEmpty<T> currently returns when value is null, which makes the method name misleading and can silently accept null inputs in call sites that previously relied on Ensure.NotNullOrEmpty(...) throwing. Consider changing the null branch to throw ArgumentNullException(name) to match typical guard semantics and avoid behavior regressions.

Comment thread src/Adapter/MSTestAdapter.PlatformServices/AssemblyResolver.cs
Copilot AI review requested due to automatic review settings April 15, 2026 15:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comments suppressed due to low confidence (5)

src/Polyfills/OperatingSystem.cs:1

  • The extension(OperatingSystem) block is not valid C# syntax in mainstream language versions and will fail compilation. Replace this with regular APIs (e.g., a static helper class, or extension methods like public static bool IsBrowser(this OperatingSystem _)), and update call sites accordingly (or avoid needing these methods by using RuntimeInformation.IsOSPlatform(...) directly).
    src/Platform/Microsoft.Testing.Platform/Helpers/System/SystemEnvironment.cs:1
  • The field keyword used as a backing store is a newer/preview C# feature and can break builds if the repo isn't compiling with that language version. Use an explicit private backing field (e.g., _processId) instead of field to keep this compatible with stable C# compilers.
    src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/SerializerUtilities.cs:1
  • This changes behavior from the previous TryAdd (non-throwing) to Add (throws if the key already exists) on NETCOREAPP. Since the old code explicitly used TryAdd, it implies "node-type" may already be present in some cases; in that scenario this will now throw at runtime. Prefer keeping the non-throwing behavior by using TryAdd (or a ContainsKey guard) on NETCOREAPP as well.
    test/Utilities/Microsoft.Testing.TestInfrastructure/ProjectSystem.cs:1
  • This is validating a constructor argument, so InvalidOperationException is not the most appropriate exception type. Use ArgumentNullException for tfms is null and ArgumentException (or ArgumentOutOfRangeException) for an empty array so callers get standard parameter-validation semantics.
    src/Polyfills/Ensure.cs:1
  • NotEmpty returning successfully when value is null makes the guard ineffective and is inconsistent with typical “not empty” contracts (and with the previous usage pattern of Ensure.NotNullOrEmpty). This can permit null arguments to flow further and cause harder-to-debug failures later. Consider throwing ArgumentNullException here (and similarly updating NotEmpty(string value, ...) to throw on null) to preserve expected guard behavior.

Copilot AI review requested due to automatic review settings April 15, 2026 20:02
@Youssef1313 Youssef1313 force-pushed the dev/ygerges/polyfill-removal branch from 09d3ffe to 528eaf4 Compare April 15, 2026 20:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 178 out of 178 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (5)

src/Polyfills/OperatingSystem.cs:1

  • The extension(OperatingSystem) block is not valid C# syntax in current, broadly supported language versions and is likely to fail compilation for non-NETCOREAPP targets now that Polyfill is no longer provided via a package/tooling layer. Consider replacing this with regular helper methods (e.g., Polyfills.Polyfill.IsBrowser() etc.) and updating the non-NETCOREAPP call sites to use that helper, or otherwise remove/replace this file with portable RuntimeInformation.IsOSPlatform(...) checks directly at call sites.
    src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/SerializerUtilities.cs:1
  • This changes behavior from the previous TryAdd logic: on NETCOREAPP, properties.Add(...) will now throw if node-type is already present. To preserve the prior behavior (do nothing if already set), use TryAdd on NETCOREAPP as well, and keep the guarded ContainsKey fallback only for TFMs where TryAdd isn't available.
    src/Polyfills/Ensure.cs:1
  • Ensure.NotEmpty<T> silently returns when value is null, which is surprising for an Ensure-style guard and can hide null-argument bugs. If the intent is to enforce both non-null and non-empty, this should throw ArgumentNullException when value is null. If the intent is only to enforce non-empty when non-null, consider renaming to something like NotEmptyIfNotNull to make the contract explicit.
    test/Utilities/Microsoft.Testing.TestInfrastructure/ProjectSystem.cs:1
  • Invalid/absent tfms is an argument validation issue, but this throws InvalidOperationException with a message that doesn't include the parameter name. Prefer ArgumentNullException(nameof(tfms)) when null is passed, and ArgumentException (with paramName: nameof(tfms)) when the params array is empty, to align with .NET argument-validation conventions and improve diagnosability.
    src/Polyfills/NullableAttribtues.cs:1
  • The filename NullableAttribtues.cs appears to be misspelled; consider renaming to NullableAttributes.cs to avoid confusion and improve discoverability.

@Youssef1313 Youssef1313 merged commit 35076ae into main Apr 16, 2026
14 checks passed
@Youssef1313 Youssef1313 deleted the dev/ygerges/polyfill-removal branch April 16, 2026 06:53
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.

Consider removing Polyfill NuGet package dependency

3 participants