Skip to content

Inject SQL Server Application Name in a more robust way#37428

Merged
roji merged 2 commits intodotnet:mainfrom
roji:ApplicationNameAgain
Dec 30, 2025
Merged

Inject SQL Server Application Name in a more robust way#37428
roji merged 2 commits intodotnet:mainfrom
roji:ApplicationNameAgain

Conversation

@roji
Copy link
Member

@roji roji commented Dec 30, 2025

Fixes #37115

Thanks to @0xced for proposing this in #36548 (comment).

Verified via test ApplicationName_is_injected_when_not_defined_with_connection_string that the injected Application Name is the same before and after this change.

Copilot AI review requested due to automatic review settings December 30, 2025 14:01
@roji roji requested a review from a team as a code owner December 30, 2025 14:01
@roji roji enabled auto-merge (squash) December 30, 2025 14:01
Copy link

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 improves the robustness of SQL Server application name injection by replacing FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion with Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion. This change enhances NativeAOT compatibility by avoiding reliance on Assembly.Location, which can be empty or unavailable in single-file deployments and NativeAOT scenarios.

Key changes:

  • Replaced file system-based version retrieval with reflection attribute-based approach
  • Aligns with patterns used elsewhere in the codebase (ProductInfo.cs, DatabaseProvider.cs)
  • Maintains backward compatibility while improving deployment scenario support

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 30, 2025 15:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

@roji roji merged commit f822cc5 into dotnet:main Dec 30, 2025
12 of 13 checks passed
@roji roji deleted the ApplicationNameAgain branch December 30, 2025 20:03
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.

[SQL Server] Fix application name telemetry for single-file deployment

3 participants