From 3cab27772c940ef4384a1cb2012030f462b54127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SAL=C4=B0H=20=C3=96ZKARA?= Date: Wed, 10 Dec 2025 15:24:24 +0300 Subject: [PATCH] Add SetSolutionPath method and refactor solution path handling Introduced SetSolutionPath to ActivityContext for consistent solution path updates. Refactored TelemetrySolutionInfoEnricher to use the new method and improved logic for resolving .abpsln files based on possible extensions. --- .../Telemetry/Activity/ActivityContext.cs | 24 +++++++++++ .../TelemetrySolutionInfoEnricher.cs | 40 +++++++------------ 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/ActivityContext.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/ActivityContext.cs index 7c232671e7..f6bb8e7e50 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/ActivityContext.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/ActivityContext.cs @@ -65,6 +65,30 @@ public class ActivityContext return false; } + public void SetSolutionPath(string solutionPath) + { + if (solutionPath == SolutionPath) + { + return; + } + + ExtraProperties[ActivityPropertyNames.SolutionPath] = solutionPath; + + if(Current.ContainsKey(ActivityPropertyNames.SolutionPath)) + { + Current[ActivityPropertyNames.SolutionPath] = solutionPath; + } + + if (Current.TryGetValue(ActivityPropertyNames.AdditionalProperties, out var additionalPropertiesObj) && + additionalPropertiesObj is Dictionary additionalPropertiesDict) + { + if (additionalPropertiesDict.ContainsKey(ActivityPropertyNames.SolutionPath)) + { + additionalPropertiesDict[ActivityPropertyNames.SolutionPath] = solutionPath; + } + } + } + public void Terminate() { IsTerminated = true; diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/Providers/TelemetrySolutionInfoEnricher.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/Providers/TelemetrySolutionInfoEnricher.cs index 97e487585a..97a2eba926 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/Providers/TelemetrySolutionInfoEnricher.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Activity/Providers/TelemetrySolutionInfoEnricher.cs @@ -49,7 +49,7 @@ internal sealed class TelemetrySolutionInfoEnricher : TelemetryActivityEventEnri return Task.CompletedTask; } - context.ExtraProperties[ActivityPropertyNames.SolutionPath] = correctSolutionPath; + context.SetSolutionPath(correctSolutionPath); var jsonContent = File.ReadAllText(context.SolutionPath!); using var doc = JsonDocument.Parse(jsonContent, new JsonDocumentOptions @@ -178,37 +178,27 @@ internal sealed class TelemetrySolutionInfoEnricher : TelemetryActivityEventEnri { return solutionPath; } + + var possibleExtensions = new[] + { + ".sln", + ".slnx" + }; - if (solutionPath.EndsWith(".sln")) + foreach (var extension in possibleExtensions) { - solutionPath = solutionPath.RemovePostFix(".sln") + ".abpsln"; - if (File.Exists(solutionPath)) + if (!solutionPath.EndsWith(extension)) { - return solutionPath; + continue; } - } - - if (solutionPath.EndsWith(".slnx")) - { - solutionPath = solutionPath.RemovePostFix(".slnx") + ".abpsln"; - if (File.Exists(solutionPath)) + + var abpSlnPath = solutionPath.Substring(0, solutionPath.Length - extension.Length) + ".abpsln"; + if (File.Exists(abpSlnPath)) { - return solutionPath; + return abpSlnPath; } } - - var dir = Path.GetDirectoryName(solutionPath); - if (dir.IsNullOrEmpty()) - { - return null; - } - - var abpSolutionFiles = Directory.GetFiles(dir, "*.abpsln", SearchOption.TopDirectoryOnly); - return abpSolutionFiles.Length switch - { - 1 => abpSolutionFiles[0], - _ => null - }; + return null; } } \ No newline at end of file