Skip to content

Fix warnings and cleanup.#3089

Merged
rajkumar-rangaraj merged 3 commits intomainfrom
rajrang/cleanFixWarn
Jan 27, 2026
Merged

Fix warnings and cleanup.#3089
rajkumar-rangaraj merged 3 commits intomainfrom
rajrang/cleanFixWarn

Conversation

@rajkumar-rangaraj
Copy link
Member

Fix Issue # .

Changes

(Please provide a brief description of the changes here.)

Checklist

  • I ran Unit Tests locally.
  • CHANGELOG.md updated with one line description of the fix, and a link to the original issue if available.

For significant contributions please make sure you have completed the following items:

  • Design discussion issue #
  • Changes in public surface reviewed

The PR will trigger build, unit tests, and functional tests automatically. Please follow these instructions to build and test locally.

Notes for authors:

  • FxCop and other analyzers will fail the build. To see these errors yourself, compile localy using the Release configuration.

Copilot AI review requested due to automatic review settings January 27, 2026 02:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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., MetricIdentifier invalid-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.sln still references test\\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.sln still references test\\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.sln still references test\\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.sln still references test\\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.sln still references test\\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.

@rajkumar-rangaraj rajkumar-rangaraj enabled auto-merge (squash) January 27, 2026 19:20
@rajkumar-rangaraj rajkumar-rangaraj merged commit f6d08d1 into main Jan 27, 2026
22 checks passed
@rajkumar-rangaraj rajkumar-rangaraj deleted the rajrang/cleanFixWarn branch January 27, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants