Remove Polyfill - #7726

Merged
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal
Apr 16, 2026
Merged

Remove Polyfill#7726
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal

Conversation

@Youssef1313

@Youssef1313Youssef Fahmy (Youssef1313) commented Apr 15, 2026

Copy link
Copy Markdown
Member

Fixes#7596

CopilotAI review requested due to automatic review settings April 15, 2026 13:43

CopilotAI 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.

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

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:01

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:40

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 20:02

CopilotAI 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

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
Youssef Fahmy (Youssef1313) merged commit 35076ae into mainApr 16, 2026
14 checks passed
@Youssef1313
Youssef Fahmy (Youssef1313) deleted the dev/ygerges/polyfill-removal branch April 16, 2026 06:53
Sign up for freeto 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

@Youssef1313@nohwnd
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Remove Polyfill - #7726

Merged
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal
Apr 16, 2026
Merged

Remove Polyfill#7726
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal

Conversation

@Youssef1313

@Youssef1313Youssef Fahmy (Youssef1313) commented Apr 15, 2026

Copy link
Copy Markdown
Member

Fixes#7596

CopilotAI review requested due to automatic review settings April 15, 2026 13:43

CopilotAI 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.

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

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:01

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:40

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 20:02

CopilotAI 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

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
Youssef Fahmy (Youssef1313) merged commit 35076ae into mainApr 16, 2026
14 checks passed
@Youssef1313
Youssef Fahmy (Youssef1313) deleted the dev/ygerges/polyfill-removal branch April 16, 2026 06:53
Sign up for freeto 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

@Youssef1313@nohwnd
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Remove Polyfill - #7726

Merged
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal
Apr 16, 2026
Merged

Remove Polyfill#7726
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal

Conversation

@Youssef1313

@Youssef1313Youssef Fahmy (Youssef1313) commented Apr 15, 2026

Copy link
Copy Markdown
Member

Fixes#7596

CopilotAI review requested due to automatic review settings April 15, 2026 13:43

CopilotAI 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.

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

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:01

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:40

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 20:02

CopilotAI 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

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
Youssef Fahmy (Youssef1313) merged commit 35076ae into mainApr 16, 2026
14 checks passed
@Youssef1313
Youssef Fahmy (Youssef1313) deleted the dev/ygerges/polyfill-removal branch April 16, 2026 06:53
Sign up for freeto 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

@Youssef1313@nohwnd
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Remove Polyfill - #7726

Merged
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal
Apr 16, 2026
Merged

Remove Polyfill#7726
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal

Conversation

@Youssef1313

@Youssef1313Youssef Fahmy (Youssef1313) commented Apr 15, 2026

Copy link
Copy Markdown
Member

Fixes#7596

CopilotAI review requested due to automatic review settings April 15, 2026 13:43

CopilotAI 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.

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

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:01

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:40

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 20:02

CopilotAI 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

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
Youssef Fahmy (Youssef1313) merged commit 35076ae into mainApr 16, 2026
14 checks passed
@Youssef1313
Youssef Fahmy (Youssef1313) deleted the dev/ygerges/polyfill-removal branch April 16, 2026 06:53
Sign up for freeto 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

@Youssef1313@nohwnd
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Remove Polyfill - #7726

Merged
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal
Apr 16, 2026
Merged

Remove Polyfill#7726
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal

Conversation

@Youssef1313

@Youssef1313Youssef Fahmy (Youssef1313) commented Apr 15, 2026

Copy link
Copy Markdown
Member

Fixes#7596

CopilotAI review requested due to automatic review settings April 15, 2026 13:43

CopilotAI 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.

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

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:01

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:40

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 20:02

CopilotAI 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

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
Youssef Fahmy (Youssef1313) merged commit 35076ae into mainApr 16, 2026
14 checks passed
@Youssef1313
Youssef Fahmy (Youssef1313) deleted the dev/ygerges/polyfill-removal branch April 16, 2026 06:53
Sign up for freeto 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

@Youssef1313@nohwnd
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Remove Polyfill - #7726

Merged
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal
Apr 16, 2026
Merged

Remove Polyfill#7726
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal

Conversation

@Youssef1313

@Youssef1313Youssef Fahmy (Youssef1313) commented Apr 15, 2026

Copy link
Copy Markdown
Member

Fixes#7596

CopilotAI review requested due to automatic review settings April 15, 2026 13:43

CopilotAI 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.

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

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:01

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:40

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 20:02

CopilotAI 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

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
Youssef Fahmy (Youssef1313) merged commit 35076ae into mainApr 16, 2026
14 checks passed
@Youssef1313
Youssef Fahmy (Youssef1313) deleted the dev/ygerges/polyfill-removal branch April 16, 2026 06:53
Sign up for freeto 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

@Youssef1313@nohwnd
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Remove Polyfill - #7726

Merged
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal
Apr 16, 2026
Merged

Remove Polyfill#7726
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal

Conversation

@Youssef1313

@Youssef1313Youssef Fahmy (Youssef1313) commented Apr 15, 2026

Copy link
Copy Markdown
Member

Fixes#7596

CopilotAI review requested due to automatic review settings April 15, 2026 13:43

CopilotAI 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.

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

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:01

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:40

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 20:02

CopilotAI 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

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
Youssef Fahmy (Youssef1313) merged commit 35076ae into mainApr 16, 2026
14 checks passed
@Youssef1313
Youssef Fahmy (Youssef1313) deleted the dev/ygerges/polyfill-removal branch April 16, 2026 06:53
Sign up for freeto 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

@Youssef1313@nohwnd
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Remove Polyfill - #7726

Merged
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal
Apr 16, 2026
Merged

Remove Polyfill#7726
Youssef Fahmy (Youssef1313) merged 24 commits into
mainfrom
dev/ygerges/polyfill-removal

Conversation

@Youssef1313

@Youssef1313Youssef Fahmy (Youssef1313) commented Apr 15, 2026

Copy link
Copy Markdown
Member

Fixes#7596

CopilotAI review requested due to automatic review settings April 15, 2026 13:43

CopilotAI 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.

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

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:01

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 15:40

CopilotAI 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

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.

CopilotAI review requested due to automatic review settings April 15, 2026 20:02

CopilotAI 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

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
Youssef Fahmy (Youssef1313) merged commit 35076ae into mainApr 16, 2026
14 checks passed
@Youssef1313
Youssef Fahmy (Youssef1313) deleted the dev/ygerges/polyfill-removal branch April 16, 2026 06:53
Sign up for freeto 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

@Youssef1313@nohwnd