Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR primarily addresses analyzer warnings via updated null-check patterns / API usage, and performs a large cleanup by removing multiple legacy NETCORE test projects and their associated content.
Changes:
- Updated several components to use newer null-check APIs (
ArgumentNullException.ThrowIfNull) and newer overloads (e.g.,string.Replace(..., StringComparison)), gated by target framework. - Improved a few implementations for correctness/perf (e.g.,
MetricIdentifierinvalid-char detection; safer config-file reading). - Removed multiple NETCORE test projects (AspNetCore.Tests, WorkerService.Tests, FunctionalTests.*) and associated test assets.
Reviewed changes
Copilot reviewed 129 out of 129 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| WEB/Src/Web/Web/WebTestActivityProcessor.cs | Simplifies tag null/empty checks. |
| WEB/Src/Web/Web/UserActivityProcessor.cs | Simplifies tag null/empty checks. |
| WEB/Src/Web/Web/SyntheticUserAgentActivityProcessor.cs | Avoids repeated separator allocations; simplifies tag check. |
| WEB/Src/Web/Web/SessionActivityProcessor.cs | Simplifies tag null/empty checks. |
| WEB/Src/Web/Web/ClientIpHeaderActivityProcessor.cs | Simplifies tag null/empty checks. |
| WEB/Src/Web/Web/AuthenticatedUserIdActivityProcessor.cs | Simplifies tag null/empty checks. |
| WEB/Src/Web/Web/AccountIdActivityProcessor.cs | Simplifies tag null/empty checks. |
| NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/JavaScriptSnippet.cs | Adds TFMs guards for null checks and string operations. |
| BASE/src/Microsoft.ApplicationInsights/TelemetryClientExtensions.cs | Uses ThrowIfNull under NET6+. |
| BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs | Adjusts exception defaults; adds TFMs guards; adds analyzer suppressions for exception reconstruction. |
| BASE/src/Microsoft.ApplicationInsights/Metrics/MetricIdentifier.cs | Uses SearchValues under NET8+; adjusts Equals(object) signature/name. |
| BASE/src/Microsoft.ApplicationInsights/Internal/FeatureMetricEmissionHelper.cs | Updates IMDS fetch call signature; changes OS normalization behavior. |
| BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs | Uses ThrowIfNull under NET6+. |
| BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Tracing/SelfDiagnosticsConfigParser.cs | Reads config using actual bytes read; uses generic Enum.Parse under NETCOREAPP. |
| BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationHolder.cs | Condenses null-checks into ?? throw. |
| BASE/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs | Adds analyzer suppression for required generic exception reconstruction. |
| .publicApi/Microsoft.ApplicationInsights.dll/Stable/PublicAPI.Unshipped.txt | Updates public API signature metadata for Equals(object obj). |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/sample-appsettings.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/config-instrumentation-key.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/config-instrumentation-key-new.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/config-endpoint-address.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/config-developer-mode.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/config-connection-string.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/config-connection-string-and-instrumentation-key.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/config-all-settings-true.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/config-all-settings-false.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/content/config-all-default.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/appsettings.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/WorkerServiceAadIntegrationTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/Worker.cs | Deleted legacy test harness code. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/Microsoft.ApplicationInsights.WorkerService.Tests.csproj | Deleted legacy test project. |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/FunctionalTests.cs | Deleted legacy functional tests. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-instrumentation-key.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-instrumentation-key-new.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-endpoint-address.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-developer-mode.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-connection-string.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-connection-string-and-instrumentation-key.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-all-settings-true.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-all-settings-false.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/content/config-all-default.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/appsettings.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TestTelemetryModule.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TelemetryInitializers/WebUserTelemetryInitializerTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TelemetryInitializers/WebSessionTelemetryInitializerTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TelemetryInitializers/SyntheticTelemetryInitializerTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TelemetryInitializers/RoleNameContainerTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TelemetryInitializers/OperationNameTelemetryInitializerTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TelemetryInitializers/DomainNameRoleInstanceTelemetryInitializerTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TelemetryInitializers/ComponentVersionTelemetryInitializerTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TelemetryInitializers/ClientIpHeaderTelemetryInitializerTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TelemetryInitializers/AzureAppServiceRoleNameFromHostNameHeaderInitializerTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/TelemetryInitializers/AspNetCoreEnvironmentTelemetryInitializerTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/SdkVersionTestUtils.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/RequestTrackingTelemetryModuleTest.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Properties/launchSettings.json | Deleted legacy test asset. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Microsoft.ApplicationInsights.AspNetCore.Tests.csproj | Deleted legacy test project. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Logging/ApplicationInsightsLoggerTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/JavaScript/ApplicationInsightsJavaScriptTest.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/HttpHeadersUtilitiesTest.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Helpers/MockApplicationIdProvider.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Helpers/HttpContextAccessorHelper.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Helpers/CommonMocks.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/HeadersUtilitiesTest.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/FakeTelemetryProcessorWithImportingConstructor.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/FakeTelemetryProcessor.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/FakeTelemetryInitializer.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/FakeTelemetryChannel.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensions/HttpRequestExtensionsTest.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensions/ApplicationInsightsServiceOptionsTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensions/ApplicationInsightsExtensionsTests/MockLoggingFactory.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensions/ApplicationInsightsExtensionsTests/IServiceProviderExtensions.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensions/ApplicationInsightsExtensionsTests/BaseTestClass.cs | Deleted legacy test harness base. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensions/ApplicationInsightsExtensionsTests/AddApplicationInsightsSettingsTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensions/ApplicationInsightsAadIntegrationTests.cs | Deleted legacy integration tests. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensibility/Implementation/Tracing/TestEventListener.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensibility/Implementation/Tracing/EventSourceTests.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensibility/Implementation/Tracing/AspNetEventSourceTests.cs | Deleted legacy test coverage. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/EnvironmentHelper.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/AspNetCoreMajorVersion.cs | Deleted legacy test helper. |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/App.config | Deleted legacy test asset. |
| NETCORE/test/FunctionalTests.WebApi.Tests/xunit.runner.json | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.WebApi.Tests/appsettings.json | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.WebApi.Tests/appsettings.Development.json | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.WebApi.Tests/Startup.cs | Deleted legacy functional test host startup. |
| NETCORE/test/FunctionalTests.WebApi.Tests/Properties/launchSettings.json | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.WebApi.Tests/FunctionalTests.WebApi.Tests.csproj | Deleted legacy functional test project. |
| NETCORE/test/FunctionalTests.WebApi.Tests/FunctionalTest/RequestDependencyCorrelationTests.cs | Deleted legacy functional test coverage. |
| NETCORE/test/FunctionalTests.WebApi.Tests/FunctionalTest/RequestCorrelationTests.cs | Deleted legacy functional test coverage. |
| NETCORE/test/FunctionalTests.WebApi.Tests/FunctionalTest/RequestCollectionTests.cs | Deleted legacy functional test coverage. |
| NETCORE/test/FunctionalTests.WebApi.Tests/FunctionalTest/MultipleWebHostsTests.cs | Deleted legacy functional test coverage. |
| NETCORE/test/FunctionalTests.WebApi.Tests/Controllers/ValuesController.cs | Deleted legacy functional test host controller. |
| NETCORE/test/FunctionalTests.WebApi.Tests/Controllers/ExceptionController.cs | Deleted legacy functional test host controller. |
| NETCORE/test/FunctionalTests.WebApi.Tests/Controllers/DependencyController.cs | Deleted legacy functional test host controller. |
| NETCORE/test/FunctionalTests.Utils/TelemetryTestsBase.cs | Deleted legacy functional test utilities. |
| NETCORE/test/FunctionalTests.Utils/TelemetryItemFactory.cs | Deleted legacy functional test utilities. |
| NETCORE/test/FunctionalTests.Utils/TelemetryHttpListenerObservable.cs | Deleted legacy functional test utilities. |
| NETCORE/test/FunctionalTests.Utils/TelemetryExtensions.cs | Deleted legacy functional test utilities. |
| NETCORE/test/FunctionalTests.Utils/Properties/launchSettings.json | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.Utils/InProcessServer.cs | Deleted legacy functional test utilities. |
| NETCORE/test/FunctionalTests.Utils/HttpListenerObservableBase.cs | Deleted legacy functional test utilities. |
| NETCORE/test/FunctionalTests.Utils/FunctionalTests.Utils.csproj | Deleted legacy functional test utilities project. |
| NETCORE/test/FunctionalTests.MVC.Tests/xunit.runner.json | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/bundleconfig.json | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/bower.json | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/appsettings.json | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/appsettings.Development.json | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/Views/_ViewStart.cshtml | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/Views/_ViewImports.cshtml | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/Views/Shared/_ValidationScriptsPartial.cshtml | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/Views/Shared/_Layout.cshtml | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/Views/Shared/Error.cshtml | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/Views/Home/Index.cshtml | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/Views/Home/Contact.cshtml | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/Views/Home/About.cshtml | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/Startup.cs | Deleted legacy functional test host startup. |
| NETCORE/test/FunctionalTests.MVC.Tests/Properties/launchSettings.json | Deleted legacy functional test asset. |
| NETCORE/test/FunctionalTests.MVC.Tests/Models/ErrorViewModel.cs | Deleted legacy functional test host model. |
| NETCORE/test/FunctionalTests.MVC.Tests/FunctionalTests.MVC.Tests.csproj | Deleted legacy functional test project. |
| NETCORE/test/FunctionalTests.MVC.Tests/FunctionalTest/TelemetryModuleWorkingMvcTests.cs | Deleted legacy functional test coverage. |
| NETCORE/test/FunctionalTests.MVC.Tests/FunctionalTest/RequestTelemetryMvcTests.cs | Deleted legacy functional test coverage. |
| NETCORE/test/FunctionalTests.MVC.Tests/FunctionalTest/ExceptionTelemetryMvcTests.cs | Deleted legacy functional test coverage. |
| NETCORE/test/FunctionalTests.MVC.Tests/FunctionalTest/DependencyTelemetryMvcTests.cs | Deleted legacy functional test coverage. |
| NETCORE/test/FunctionalTests.MVC.Tests/FunctionalTest/CorrelationMvcTests.cs | Deleted legacy functional test coverage. |
| NETCORE/test/FunctionalTests.MVC.Tests/Controllers/HomeController.cs | Deleted legacy functional test host controller. |
| NETCORE/test/FunctionalTests.MVC.Tests/.bowerrc | Deleted legacy functional test asset. |
Comments suppressed due to low confidence (5)
NETCORE/test/FunctionalTests.WebApi.Tests/FunctionalTests.WebApi.Tests.csproj:1
- This test project is being removed, but
NETCORE/ApplicationInsights.AspNetCore.slnstill referencestest\\FunctionalTests.WebApi.Tests\\FunctionalTests.WebApi.Tests.csproj(solution line ~52). Update the solution/build inputs accordingly or keep the project to avoid missing-project failures.
NETCORE/test/FunctionalTests.MVC.Tests/FunctionalTests.MVC.Tests.csproj:1 - This test project is being removed, but
NETCORE/ApplicationInsights.AspNetCore.slnstill referencestest\\FunctionalTests.MVC.Tests\\FunctionalTests.MVC.Tests.csproj(solution line ~50). Update the solution/build inputs accordingly or keep the project to avoid missing-project failures.
NETCORE/test/FunctionalTests.Utils/FunctionalTests.Utils.csproj:1 - This project is being removed, but
NETCORE/ApplicationInsights.AspNetCore.slnstill referencestest\\FunctionalTests.Utils\\FunctionalTests.Utils.csproj(solution line ~48). Update the solution/build inputs accordingly or keep the project to avoid missing-project failures.
NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Microsoft.ApplicationInsights.AspNetCore.Tests.csproj:1 - This test project is being removed, but
NETCORE/ApplicationInsights.AspNetCore.slnstill referencestest\\Microsoft.ApplicationInsights.AspNetCore.Tests\\Microsoft.ApplicationInsights.AspNetCore.Tests.csproj(solution line ~22). Update the solution/build inputs to remove the reference (or keep the project) to avoid solution-based builds failing due to a missing project file.
NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/Microsoft.ApplicationInsights.WorkerService.Tests.csproj:1 - This test project is being removed, but
NETCORE/ApplicationInsights.AspNetCore.slnstill referencestest\\Microsoft.ApplicationInsights.WorkerService.Tests\\Microsoft.ApplicationInsights.WorkerService.Tests.csproj(solution line ~30). Update the solution/build inputs to remove the reference (or keep the project) to prevent solution-based builds from breaking.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
BASE/src/Microsoft.ApplicationInsights/Internal/FeatureMetricEmissionHelper.cs
Outdated
Show resolved
Hide resolved
xiang17
approved these changes
Jan 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Issue # .
Changes
(Please provide a brief description of the changes here.)
Checklist
For significant contributions please make sure you have completed the following items:
The PR will trigger build, unit tests, and functional tests automatically. Please follow these instructions to build and test locally.
Notes for authors: