From f5da22db689402e51bddd1418e55b5906c63c2f1 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Tue, 5 Aug 2025 19:54:42 -0700 Subject: [PATCH 01/30] Use framework-specific dependency collection for .Net Framework versions --- OpenTelemetry.AutoInstrumentation.sln | 19 + build/AssemblyRedirectionSourceGenerator.cs | 94 +++- build/Build.Steps.Windows.cs | 48 +- build/Build.Steps.cs | 92 +++- .../Extensions/TargetFrameworksExtensions.cs | 22 + build/Projects.cs | 1 + build/TargetFramework.cs | 5 +- .../OpenTelemetry.DotNet.Auto.psm1.template | 34 +- src/Directory.Packages.props | 85 +++- .../Loader.NetFramework.cs | 69 ++- .../cor_profiler.cpp | 108 ++++- .../cor_profiler.h | 6 +- .../netfx_assembly_redirection.h | 448 ++++++++++++------ ...utoInstrumentation.NetFx.Assemblies.csproj | 19 + .../OpenTelemetry.AutoInstrumentation.csproj | 31 +- tools/DependencyListGenerator/Generator.cs | 4 +- 16 files changed, 848 insertions(+), 237 deletions(-) create mode 100644 src/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies.csproj diff --git a/OpenTelemetry.AutoInstrumentation.sln b/OpenTelemetry.AutoInstrumentation.sln index 4fd31cdae1..853eed381c 100644 --- a/OpenTelemetry.AutoInstrumentation.sln +++ b/OpenTelemetry.AutoInstrumentation.sln @@ -249,6 +249,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication.Log4NetBrid EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication.SelectiveSampler", "test\test-applications\integrations\TestApplication.SelectiveSampler\TestApplication.SelectiveSampler.csproj", "{FD1A1ABD-6A48-4E94-B5F7-2081AFCD1BBB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.AutoInstrumentation.NetFx.Assemblies", "src\OpenTelemetry.AutoInstrumentation.NetFx.Assemblies\OpenTelemetry.AutoInstrumentation.NetFx.Assemblies.csproj", "{B69564D4-7D5B-7147-6CBA-233BB8A33C50}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1549,6 +1551,22 @@ Global {FD1A1ABD-6A48-4E94-B5F7-2081AFCD1BBB}.Release|x64.Build.0 = Release|Any CPU {FD1A1ABD-6A48-4E94-B5F7-2081AFCD1BBB}.Release|x86.ActiveCfg = Release|Any CPU {FD1A1ABD-6A48-4E94-B5F7-2081AFCD1BBB}.Release|x86.Build.0 = Release|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Debug|ARM64.Build.0 = Debug|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Debug|x64.ActiveCfg = Debug|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Debug|x64.Build.0 = Debug|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Debug|x86.ActiveCfg = Debug|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Debug|x86.Build.0 = Debug|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Release|Any CPU.Build.0 = Release|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Release|ARM64.ActiveCfg = Release|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Release|ARM64.Build.0 = Release|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Release|x64.ActiveCfg = Release|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Release|x64.Build.0 = Release|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Release|x86.ActiveCfg = Release|Any CPU + {B69564D4-7D5B-7147-6CBA-233BB8A33C50}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1640,6 +1658,7 @@ Global {C75FA076-D460-414B-97F7-6F8D0E85AE74} = {00F4C92D-6652-4BD8-A334-B35D3E711BE6} {926B7C03-42C2-4192-94A7-CD0B1C693279} = {E409ADD3-9574-465C-AB09-4324D205CC7C} {FD1A1ABD-6A48-4E94-B5F7-2081AFCD1BBB} = {E409ADD3-9574-465C-AB09-4324D205CC7C} + {B69564D4-7D5B-7147-6CBA-233BB8A33C50} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F} diff --git a/build/AssemblyRedirectionSourceGenerator.cs b/build/AssemblyRedirectionSourceGenerator.cs index cb2c42fcda..97811a77b4 100644 --- a/build/AssemblyRedirectionSourceGenerator.cs +++ b/build/AssemblyRedirectionSourceGenerator.cs @@ -1,4 +1,6 @@ +using System.Collections; using System.Text; +using System.Text.RegularExpressions; using Mono.Cecil; using Serilog; @@ -7,8 +9,36 @@ public static class AssemblyRedirectionSourceGenerator public static void Generate(string assembliesFolderPath, string generatedFilePath) { Log.Debug("Generating assembly redirection file {0}", generatedFilePath); - var assemblies = new SortedDictionary(); - foreach (var fileName in Directory.EnumerateFiles(assembliesFolderPath)) + var assemblies = new SortedDictionary>(); + + var folders = new Dictionary(); + + var frameworkVersionRegEx = new Regex(@"^net(?\d{2,3})$"); + foreach (var directory in Directory.EnumerateDirectories(assembliesFolderPath)) + { + var folderName = Path.GetFileName(directory); + var framework = frameworkVersionRegEx.Match(folderName).Groups["version"].Value; + if (framework == string.Empty) + { + Log.Error("Unexpected folder name: {0}, will not be processed", framework); + continue; + } + var frameworkVersion = int.Parse(framework); + if (frameworkVersion < 100) + { + frameworkVersion *= 10; + } + + if (folders.TryGetValue(frameworkVersion, out var folder)) + { + Log.Error("For {0}: already registered folder {1}, {2} will be skipped", frameworkVersion, folder, directory); + continue; + } + folders[frameworkVersion] = directory; + assemblies[frameworkVersion] = new SortedDictionary(); + } + + void Process(string fileName, int? framework) { try { @@ -17,11 +47,16 @@ public static void Generate(string assembliesFolderPath, string generatedFilePat if (assemblyDef.Name == "netstandard") { // Skip netstandard, since it doesn't need redirection. - continue; + return; } - assemblies[assemblyDef.Name] = assemblyDef; - Log.Debug("Adding {0} assembly to the redirection map. Targeted version {1}", assemblyDef.Name, assemblyDef.Version); + + foreach (var keys in framework != null ? (IEnumerable)[framework.Value] : assemblies.Keys) + { + assemblies[keys][assemblyDef.Name] = assemblyDef; + Log.Debug("Adding {0} assembly to the redirection map {1}. Targeted version {2}", assemblyDef.Name, + keys, assemblyDef.Version); + } } catch (BadImageFormatException) { @@ -29,13 +64,34 @@ public static void Generate(string assembliesFolderPath, string generatedFilePat } } + foreach (var fileName in Directory.EnumerateFiles(assembliesFolderPath)) + { + Process(fileName, null); + + } + + foreach (var fx in folders) + { + foreach (var fileName in Directory.EnumerateFiles(fx.Value)) + { + var filenameToProcess = fileName; + if (Path.GetExtension(fileName) == "link") + { + filenameToProcess = Path.Combine(generatedFilePath, File.ReadAllText(fileName), + Path.GetFileNameWithoutExtension(fileName)); + } + + Process(filenameToProcess, fx.Key); + } + } + var sourceContents = GenerateSourceContents(assemblies); File.WriteAllText(generatedFilePath, sourceContents); Log.Information("Assembly redirection source generated {0}", generatedFilePath); } - private static string GenerateSourceContents(SortedDictionary assemblies) + private static string GenerateSourceContents(SortedDictionary> assemblies) { #pragma warning disable format return @@ -70,22 +126,26 @@ namespace trace #pragma warning restore format } - private static string GenerateEntries(SortedDictionary assemblies) + private static string GenerateEntries(SortedDictionary> frameworks) { - var longLineLength = 80; - var sb = new StringBuilder(assemblies.Count * longLineLength); + var sb = new StringBuilder(); - foreach (var kvp in assemblies) + foreach (var fx in frameworks) { - var v = kvp.Value.Version!; - if (kvp.Key != "OpenTelemetry.AutoInstrumentation") - { - sb.AppendLine($" {{ L\"{kvp.Key}\", {{{v.Major}, {v.Minor}, {v.Build}, {v.Revision}}} }},"); - } - else + sb.AppendLine($" {{ {fx.Key}, {{"); + foreach (var kvp in fx.Value) { - sb.AppendLine($" {{ L\"{kvp.Key}\", {{auto_major, 0, 0, 0}} }},"); + var v = kvp.Value.Version!; + if (kvp.Key != "OpenTelemetry.AutoInstrumentation") + { + sb.AppendLine($" {{ L\"{kvp.Key}\", {{{v.Major}, {v.Minor}, {v.Build}, {v.Revision}}} }},"); + } + else + { + sb.AppendLine($" {{ L\"{kvp.Key}\", {{auto_major, 0, 0, 0}} }},"); + } } + sb.AppendLine(" }},"); } return sb.ToString() diff --git a/build/Build.Steps.Windows.cs b/build/Build.Steps.Windows.cs index 6743580a7c..b02ea36a73 100644 --- a/build/Build.Steps.Windows.cs +++ b/build/Build.Steps.Windows.cs @@ -1,4 +1,5 @@ using DependencyListGenerator; +using Extensions; using Nuke.Common; using Nuke.Common.IO; using Nuke.Common.ProjectModel; @@ -208,47 +209,38 @@ void BuildDockerImage(Project project, params string[] targets) .Executes(() => { // The target project needs to have its NuGet packages restored prior to running the tool. - var targetProject = Solution.GetProjectByName(Projects.AutoInstrumentation); + var targetProject = Solution.GetProjectByName(Projects.AutoInstrumentationNetFxAssemblies); DotNetRestore(s => s.SetProjectFile(targetProject)); var project = targetProject.GetMSBuildProject(); var packages = Solution.Directory / "src" / "Directory.Packages.props"; - const string label = $"Transient dependencies auto-generated by {nameof(GenerateNetFxTransientDependencies)}"; - - var packagesGroup = project.Xml.ItemGroups.FirstOrDefault(x => x.Label == label); - if (packagesGroup == null) - { - packagesGroup = project.Xml.AddItemGroup(); - packagesGroup.Label = label; - packagesGroup.Condition = " '$(TargetFramework)' == 'net462' AND $(_IsPacking) != true "; - } - - var packagesProject = ProjectModelTasks.ParseProject(packages); - var versionGroup = packagesProject.Xml.ItemGroups.FirstOrDefault(x => x.Label == label); - if (versionGroup == null) + foreach (var framework in TargetFramework.NetFramework) { - versionGroup = packagesProject.Xml.AddItemGroup(); - versionGroup.Label = label; - } + var label = + $"Transient dependencies auto-generated by {nameof(GenerateNetFxTransientDependencies)} for {framework}"; - var deps = Generator.EnumerateDependencies(project.FullPath); - foreach (var item in deps) - { - if (!packagesGroup.Items.Any(x => x.Include == item.Name)) + var packagesProject = ProjectModelTasks.ParseProject(packages); + var versionGroup = packagesProject.Xml.ItemGroups.FirstOrDefault(x => x.Label == label); + if (versionGroup == null) { - packagesGroup.AddItem("PackageReference", item.Name); + versionGroup = packagesProject.Xml.AddItemGroup(); + versionGroup.Label = label; + versionGroup.Condition = $" '$(TargetFramework)' == '{framework}' "; } - if (!versionGroup.Items.Any(x => x.Include == item.Name)) + var deps = Generator.EnumerateDependencies(project.FullPath, framework.GetVersion()); + foreach (var item in deps) { - var reference = versionGroup.AddItem("PackageVersion", item.Name); - reference.AddMetadata("Version", item.Version, expressAsAttribute: true); + if (!versionGroup.Items.Any(x => x.Include == item.Name)) + { + var reference = versionGroup.AddItem("PackageVersion", item.Name); + reference.AddMetadata("Version", item.Version, expressAsAttribute: true); + } } - } - project.Save(); - packagesProject.Save(); + packagesProject.Save(); + } }); Target GenerateNetFxAssemblyRedirectionSource => _ => _ diff --git a/build/Build.Steps.cs b/build/Build.Steps.cs index 96ff2b5526..24774eae3c 100644 --- a/build/Build.Steps.cs +++ b/build/Build.Steps.cs @@ -1,5 +1,7 @@ using System.Diagnostics; using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; using System.Text.Json; using System.Text.Json.Nodes; using Extensions; @@ -42,9 +44,17 @@ partial class Build : new[] { MSBuildTargetPlatform.x86 }; private static readonly IEnumerable TargetFrameworks = new[] + { + TargetFramework.NET8_0, + TargetFramework.NET462, + }; + + private static readonly IEnumerable TargetFrameworksNetFx = new[] { TargetFramework.NET462, - TargetFramework.NET8_0 + TargetFramework.NET47, + TargetFramework.NET471, + TargetFramework.NET472, }; private static readonly IEnumerable TestFrameworks = TargetFrameworks @@ -267,18 +277,30 @@ DotNetBuildSettings BuildTestApplication(DotNetBuildSettings x, string targetFra { var targetFrameworks = IsWin ? TargetFrameworks - : TargetFrameworks.Where(framework => !framework.ToString().StartsWith("net4")); + : TargetFrameworks.ExceptNetFramework(); + // Publish Projects.AutoInstrumentation for .NET targets DotNetPublish(s => s .SetProject(Solution.GetProjectByName(Projects.AutoInstrumentation)) .SetConfiguration(BuildConfiguration) .SetTargetPlatformAnyCPU() .EnableNoBuild() .SetNoRestore(NoRestore) - .CombineWith(targetFrameworks, (p, framework) => p + .CombineWith(targetFrameworks.ExceptNetFramework(), (p, framework) => p .SetFramework(framework) .SetOutput(TracerHomeDirectory / MapToFolderOutput(framework)))); + // Publish OpenTelemetry.AutoInstrumentation.NetFx.Assemblies for .NET Framework targets + DotNetPublish(s => s + .SetProject(Solution.GetProjectByName(Projects.AutoInstrumentationNetFxAssemblies)) + .SetConfiguration(BuildConfiguration) + .SetTargetPlatformAnyCPU() + .EnableNoBuild() + .SetNoRestore(NoRestore) + .CombineWith(TargetFrameworksNetFx, (p, framework) => p + .SetFramework(framework) + .SetOutput(TracerHomeDirectory / MapToFolderOutputNetFx(framework)))); + // StartupHook is supported starting .Net Core 3.1. // We need to emit AutoInstrumentationStartupHook for .Net Core 3.1 target framework // to avoid application crash with .Net Core 3.1 and .NET 5.0 apps. @@ -313,6 +335,8 @@ DotNetBuildSettings BuildTestApplication(DotNetBuildSettings x, string targetFra RemoveFilesInNetFolderAvailableInAdditionalStore(); RemoveNonLibraryFilesFromOutput(); + + RemoveDuplicateNetFxLibraries(); }); void RemoveNonLibraryFilesFromOutput() @@ -356,6 +380,61 @@ void RemoveFilesInNetFolderAvailableInAdditionalStore() } } + void RemoveDuplicateNetFxLibraries() + { + bool FilesAreEqual(string filePath1, string filePath2) + { + using var hashAlg = SHA256.Create(); + using var stream1 = File.OpenRead(filePath1); + using var stream2 = File.OpenRead(filePath2); + + var hash1 = hashAlg.ComputeHash(stream1); + var hash2 = hashAlg.ComputeHash(stream2); + + return hash1.SequenceEqual(hash2); + } + + if (IsWin) + { + (TracerHomeDirectory / "netfx" ).GlobFiles("**/*.link").DeleteFiles(); + var latestFramework = TargetFramework.NetFramework.Last(); + (TracerHomeDirectory / "netfx" / latestFramework).GlobFiles("*.*") + .Where(file => TargetFramework.NetFramework.TakeUntil(older => older == latestFramework) + .All(olderFramework => + { + var duplicateCandidate = TracerHomeDirectory / "netfx" / olderFramework / file.Name; + return File.Exists(duplicateCandidate) && FilesAreEqual(file, duplicateCandidate); + })).ForEach(file => + { + file.MoveToDirectory(TracerHomeDirectory / "netfx", ExistsPolicy.FileOverwrite); + TargetFramework.NetFramework.TakeUntil(older => older == latestFramework) + .ForEach(olderFramework => + (TracerHomeDirectory / "netfx" / olderFramework / file.Name).DeleteFile()); + } + ); + + foreach (var currentFramework in TargetFramework.NetFramework.Skip(1).Reverse()) + { + (TracerHomeDirectory / "netfx" / currentFramework).GlobFiles("*.dll").ForEach(file => + { + foreach (var olderFramework in TargetFramework.NetFramework.TakeUntil(older => + older == currentFramework)) + { + var duplicateCandidate = TracerHomeDirectory / "netfx" / olderFramework / file.Name; + if (File.Exists(duplicateCandidate) && FilesAreEqual(file, duplicateCandidate)) + { + file.DeleteFile(); + (TracerHomeDirectory / "netfx" / currentFramework / (file.Name + ".link")).WriteAllText( + olderFramework, Encoding.ASCII, false); + break; + } + } + } + ); + } + } + } + Target PublishNativeProfiler => _ => _ .Unlisted() .DependsOn(PublishNativeProfilerWindows) @@ -726,7 +805,12 @@ private void RunBootstrappingTests() private string MapToFolderOutput(TargetFramework targetFramework) { - return targetFramework.ToString().StartsWith("net4") ? "netfx" : "net"; + return targetFramework.ToString().StartsWith("net4") ? $"netfx" : "net"; + } + + private string MapToFolderOutputNetFx(TargetFramework targetFramework) + { + return $"netfx/{targetFramework}"; } private void RestoreLegacyNuGetPackagesConfig(IEnumerable legacyRestoreProjects) diff --git a/build/Extensions/TargetFrameworksExtensions.cs b/build/Extensions/TargetFrameworksExtensions.cs index d40acb3619..40dbe3388c 100644 --- a/build/Extensions/TargetFrameworksExtensions.cs +++ b/build/Extensions/TargetFrameworksExtensions.cs @@ -6,4 +6,26 @@ public static IEnumerable ExceptNetFramework(this IEnumerable + + + true + + @@ -45,7 +50,85 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/OpenTelemetry.AutoInstrumentation.Loader/Loader.NetFramework.cs b/src/OpenTelemetry.AutoInstrumentation.Loader/Loader.NetFramework.cs index 85b57fc019..b8c812c8ff 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Loader/Loader.NetFramework.cs +++ b/src/OpenTelemetry.AutoInstrumentation.Loader/Loader.NetFramework.cs @@ -4,6 +4,7 @@ #if NETFRAMEWORK using System.Reflection; +using Microsoft.Win32; namespace OpenTelemetry.AutoInstrumentation.Loader; @@ -16,7 +17,45 @@ private static string ResolveManagedProfilerDirectory() { var tracerHomeDirectory = ReadEnvironmentVariable("OTEL_DOTNET_AUTO_HOME") ?? string.Empty; var tracerFrameworkDirectory = "netfx"; - return Path.Combine(tracerHomeDirectory, tracerFrameworkDirectory); + var frameworkVersion = GetNetFrameworkVersionFolder(); + + return Path.Combine(tracerHomeDirectory, tracerFrameworkDirectory, frameworkVersion); + } + + private static string GetNetFrameworkVersionFolder() + { + try + { + // Try to get version from Windows Registry first (most reliable method) + using var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default); + using var subKey = baseKey.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"); + var releaseValue = subKey?.GetValue("Release"); + if (releaseValue is int release) + { + // Map release number to framework version number + // Based on https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed + if (release >= 461808) + { + return "net472"; // .NET Framework 4.7.2 + } + + if (release >= 461308) + { + return "net471"; // .NET Framework 4.7.1 + } + + if (release >= 460798) + { + return "net47"; // .NET Framework 4.7 + } + } + } + catch (Exception ex) + { + Logger.Debug(ex, "Error getting .NET Framework version from Windows Registry"); + } + + return "net462"; } private static Assembly? AssemblyResolve_ManagedProfilerDependencies(object sender, ResolveEventArgs args) @@ -57,7 +96,33 @@ private static string ResolveManagedProfilerDirectory() return null; } - var path = Path.Combine(ManagedProfilerDirectory, $"{assemblyName}.dll"); + var path = Path.Combine(Path.GetDirectoryName(ManagedProfilerDirectory) ?? ManagedProfilerDirectory, $"{assemblyName}.dll"); + if (!File.Exists(path)) + { + path = Path.Combine(ManagedProfilerDirectory, $"{assemblyName}.dll"); + if (!File.Exists(path)) + { + var link = Path.Combine(ManagedProfilerDirectory, $"{assemblyName}.dll.link"); + if (File.Exists(link)) + { + try + { + var linkPath = File.ReadAllText(link).Trim(); + path = Path.Combine(Path.GetDirectoryName(ManagedProfilerDirectory) ?? ManagedProfilerDirectory, linkPath, $"{assemblyName}.dll"); + } + catch (Exception ex) + { + Logger.Debug(ex, "Error reading .link file {0}", link); + } + } + else + { + // Not found + return null; + } + } + } + if (File.Exists(path)) { try diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp index 2e1fe019d8..a9e8c358e0 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp +++ b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp @@ -1,4 +1,4 @@ -// Copyright The OpenTelemetry Authors +// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #include "cor_profiler.h" @@ -125,6 +125,13 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Initialize(IUnknown* cor_profiler_info_un // code is ready to get runtime information runtime_information_ = GetRuntimeInformation(this->info_); +#ifdef _WIN32 + if (runtime_information_.is_desktop()) + { + DetectFrameworkVersion(); + } +#endif + if (Logger::IsDebugEnabled()) { if (runtime_information_.is_desktop()) @@ -369,6 +376,11 @@ HRESULT STDMETHODCALLTYPE CorProfiler::AssemblyLoadFinished(AssemblyID assembly_ void CorProfiler::RedirectAssemblyReferences(const ComPtr& assembly_import, const ComPtr& assembly_emit) { + if (!assembly_version_redirect_map_current_framework_) + { + return; + } + HRESULT hr = S_FALSE; HCORENUM core_enum_handle = NULL; const ULONG assembly_refs_sz = 16; @@ -416,8 +428,8 @@ void CorProfiler::RedirectAssemblyReferences(const ComPtr(&releaseValue), &dataSize); + + RegCloseKey(hKey); + + if (result != ERROR_SUCCESS || valueType != REG_DWORD) + { + Logger::Warn("DetectFrameworkVersion: Failed to read Release value, using default version 462"); + } + else + { + + // Map release numbers to framework versions + // Based on Microsoft documentation: + // https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed + if (releaseValue >= 533320) + { + frameworkVersion = 481; // 4.8.1 + } + else if (releaseValue >= 528040) + { + frameworkVersion = 480; // 4.8 + } + else if (releaseValue >= 461808) + { + frameworkVersion = 472; // 4.7.2 + } + else if (releaseValue >= 461308) + { + frameworkVersion = 471; // 4.7.1 + } + else if (releaseValue >= 460798) + { + frameworkVersion = 470; // 4.7 + } + else if (releaseValue >= 394802) + { + frameworkVersion = 462; // 4.6.2 + } + else + { + Logger::Warn("DetectFrameworkVersion: Old .Net Framework detected, use 462 as fallback"); + } + } + + Logger::Debug("DetectFrameworkVersion: Detected .NET Framework version ", frameworkVersion, + " (Release: ", releaseValue, ")"); + } + + int selectedKey = 0; + for (auto& [key, values] : assembly_version_redirect_map_) + { + if (key <= frameworkVersion && key > selectedKey) + { + selectedKey = key; + assembly_version_redirect_map_current_framework_ = &values; + } + } + + if (selectedKey != 0) + { + Logger::Warn("DetectFrameworkVersion: No assembly redirection tables found. Assembly version redirecting will be disabled."); + } + else + { + Logger::Debug("DetectFrameworkVersion: Use assembly redirection table for ", selectedKey); + } +} +#endif + } // namespace trace \ No newline at end of file diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.h b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.h index 2b54636aff..a9f0fab396 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.h +++ b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.h @@ -1,4 +1,4 @@ -/* +/* * Copyright The OpenTelemetry Authors * SPDX-License-Identifier: Apache-2.0 */ @@ -95,7 +95,8 @@ class CorProfiler : public CorProfilerBase // // Assembly redirect private members. // - std::unordered_map assembly_version_redirect_map_; + std::unordered_map> assembly_version_redirect_map_; + std::unordered_map* assembly_version_redirect_map_current_framework_; void InitNetFxAssemblyRedirectsMap(); void RedirectAssemblyReferences( const ComPtr& assembly_import, @@ -112,6 +113,7 @@ class CorProfiler : public CorProfilerBase mdMethodDef* patch_app_domain_setup_method); HRESULT ModifyAppDomainCreate(const ModuleID module_id, mdMethodDef patch_app_domain_setup_method); HRESULT AddIISPreStartInitFlags(const ModuleID module_id, const mdToken function_token); + void DetectFrameworkVersion(); #endif // diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/netfx_assembly_redirection.h b/src/OpenTelemetry.AutoInstrumentation.Native/netfx_assembly_redirection.h index 964699b068..ab4ade4188 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Native/netfx_assembly_redirection.h +++ b/src/OpenTelemetry.AutoInstrumentation.Native/netfx_assembly_redirection.h @@ -18,148 +18,312 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap() const USHORT auto_major = atoi(AUTO_MAJOR); assembly_version_redirect_map_.insert({ - { L"Microsoft.Bcl.AsyncInterfaces", {9, 0, 0, 6} }, - { L"Microsoft.Extensions.Configuration", {9, 0, 0, 6} }, - { L"Microsoft.Extensions.Configuration.Abstractions", {9, 0, 0, 6} }, - { L"Microsoft.Extensions.Configuration.Binder", {9, 0, 0, 6} }, - { L"Microsoft.Extensions.DependencyInjection", {9, 0, 0, 6} }, - { L"Microsoft.Extensions.DependencyInjection.Abstractions", {9, 0, 0, 6} }, - { L"Microsoft.Extensions.Diagnostics.Abstractions", {9, 0, 0, 6} }, - { L"Microsoft.Extensions.Logging", {9, 0, 0, 6} }, - { L"Microsoft.Extensions.Logging.Abstractions", {9, 0, 0, 6} }, - { L"Microsoft.Extensions.Logging.Configuration", {9, 0, 0, 6} }, - { L"Microsoft.Extensions.Options", {9, 0, 0, 6} }, - { L"Microsoft.Extensions.Options.ConfigurationExtensions", {9, 0, 0, 6} }, - { L"Microsoft.Extensions.Primitives", {9, 0, 0, 6} }, - { L"Microsoft.Win32.Primitives", {4, 0, 3, 0} }, - { L"OpenTelemetry", {1, 0, 0, 0} }, - { L"OpenTelemetry.Api", {1, 0, 0, 0} }, - { L"OpenTelemetry.Api.ProviderBuilderExtensions", {1, 0, 0, 0} }, - { L"OpenTelemetry.AutoInstrumentation", {auto_major, 0, 0, 0} }, - { L"OpenTelemetry.Exporter.Console", {1, 0, 0, 0} }, - { L"OpenTelemetry.Exporter.OpenTelemetryProtocol", {1, 0, 0, 0} }, - { L"OpenTelemetry.Exporter.Prometheus.HttpListener", {1, 0, 0, 0} }, - { L"OpenTelemetry.Exporter.Zipkin", {1, 0, 0, 0} }, - { L"OpenTelemetry.Extensions.Propagators", {1, 0, 0, 0} }, - { L"OpenTelemetry.Instrumentation.AspNet", {1, 12, 0, 489} }, - { L"OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule", {1, 12, 0, 489} }, - { L"OpenTelemetry.Instrumentation.GrpcNetClient", {1, 12, 0, 492} }, - { L"OpenTelemetry.Instrumentation.Http", {1, 12, 0, 493} }, - { L"OpenTelemetry.Instrumentation.Process", {1, 12, 0, 494} }, - { L"OpenTelemetry.Instrumentation.Quartz", {1, 12, 0, 495} }, - { L"OpenTelemetry.Instrumentation.Runtime", {1, 12, 0, 496} }, - { L"OpenTelemetry.Instrumentation.SqlClient", {1, 12, 0, 582} }, - { L"OpenTelemetry.Instrumentation.Wcf", {1, 12, 0, 500} }, - { L"OpenTelemetry.Resources.Azure", {1, 12, 0, 501} }, - { L"OpenTelemetry.Resources.Host", {1, 12, 0, 503} }, - { L"OpenTelemetry.Resources.OperatingSystem", {1, 12, 0, 504} }, - { L"OpenTelemetry.Resources.Process", {1, 12, 0, 505} }, - { L"OpenTelemetry.Resources.ProcessRuntime", {1, 12, 0, 506} }, - { L"OpenTelemetry.Shims.OpenTracing", {1, 0, 0, 0} }, - { L"OpenTracing", {0, 12, 1, 0} }, - { L"System.AppContext", {4, 1, 2, 0} }, - { L"System.Buffers", {4, 0, 5, 0} }, - { L"System.Collections", {4, 0, 11, 0} }, - { L"System.Collections.Concurrent", {4, 0, 11, 0} }, - { L"System.Collections.NonGeneric", {4, 0, 3, 0} }, - { L"System.Collections.Specialized", {4, 0, 3, 0} }, - { L"System.ComponentModel", {4, 0, 1, 0} }, - { L"System.ComponentModel.EventBasedAsync", {4, 0, 11, 0} }, - { L"System.ComponentModel.Primitives", {4, 1, 2, 0} }, - { L"System.ComponentModel.TypeConverter", {4, 1, 2, 0} }, - { L"System.Console", {4, 0, 2, 0} }, - { L"System.Data.Common", {4, 2, 0, 0} }, - { L"System.Diagnostics.Contracts", {4, 0, 1, 0} }, - { L"System.Diagnostics.Debug", {4, 0, 11, 0} }, - { L"System.Diagnostics.DiagnosticSource", {9, 0, 0, 6} }, - { L"System.Diagnostics.FileVersionInfo", {4, 0, 2, 0} }, - { L"System.Diagnostics.Process", {4, 1, 2, 0} }, - { L"System.Diagnostics.StackTrace", {4, 1, 0, 0} }, - { L"System.Diagnostics.TextWriterTraceListener", {4, 0, 2, 0} }, - { L"System.Diagnostics.Tools", {4, 0, 1, 0} }, - { L"System.Diagnostics.TraceSource", {4, 0, 2, 0} }, - { L"System.Diagnostics.Tracing", {4, 2, 0, 0} }, - { L"System.Drawing.Primitives", {4, 0, 2, 0} }, - { L"System.Dynamic.Runtime", {4, 0, 11, 0} }, - { L"System.Globalization", {4, 0, 11, 0} }, - { L"System.Globalization.Calendars", {4, 0, 3, 0} }, - { L"System.Globalization.Extensions", {4, 1, 0, 0} }, - { L"System.IO", {4, 1, 2, 0} }, - { L"System.IO.Compression", {4, 2, 0, 0} }, - { L"System.IO.Compression.ZipFile", {4, 0, 3, 0} }, - { L"System.IO.FileSystem", {4, 0, 3, 0} }, - { L"System.IO.FileSystem.DriveInfo", {4, 0, 2, 0} }, - { L"System.IO.FileSystem.Primitives", {4, 0, 3, 0} }, - { L"System.IO.FileSystem.Watcher", {4, 0, 2, 0} }, - { L"System.IO.IsolatedStorage", {4, 0, 2, 0} }, - { L"System.IO.MemoryMappedFiles", {4, 0, 2, 0} }, - { L"System.IO.Pipelines", {9, 0, 0, 6} }, - { L"System.IO.Pipes", {4, 0, 2, 0} }, - { L"System.IO.UnmanagedMemoryStream", {4, 0, 3, 0} }, - { L"System.Linq", {4, 1, 2, 0} }, - { L"System.Linq.Expressions", {4, 1, 2, 0} }, - { L"System.Linq.Parallel", {4, 0, 1, 0} }, - { L"System.Linq.Queryable", {4, 0, 1, 0} }, - { L"System.Memory", {4, 0, 5, 0} }, - { L"System.Net.Http", {4, 2, 0, 0} }, - { L"System.Net.NameResolution", {4, 0, 2, 0} }, - { L"System.Net.NetworkInformation", {4, 1, 2, 0} }, - { L"System.Net.Ping", {4, 0, 2, 0} }, - { L"System.Net.Primitives", {4, 0, 11, 0} }, - { L"System.Net.Requests", {4, 0, 11, 0} }, - { L"System.Net.Security", {4, 0, 2, 0} }, - { L"System.Net.Sockets", {4, 2, 0, 0} }, - { L"System.Net.WebHeaderCollection", {4, 0, 1, 0} }, - { L"System.Net.WebSockets", {4, 0, 2, 0} }, - { L"System.Net.WebSockets.Client", {4, 0, 2, 0} }, - { L"System.Numerics.Vectors", {4, 1, 6, 0} }, - { L"System.ObjectModel", {4, 0, 11, 0} }, - { L"System.Reflection", {4, 1, 2, 0} }, - { L"System.Reflection.Extensions", {4, 0, 1, 0} }, - { L"System.Reflection.Primitives", {4, 0, 1, 0} }, - { L"System.Resources.Reader", {4, 0, 2, 0} }, - { L"System.Resources.ResourceManager", {4, 0, 1, 0} }, - { L"System.Resources.Writer", {4, 0, 2, 0} }, - { L"System.Runtime", {4, 1, 2, 0} }, - { L"System.Runtime.CompilerServices.Unsafe", {6, 0, 3, 0} }, - { L"System.Runtime.CompilerServices.VisualC", {4, 0, 2, 0} }, - { L"System.Runtime.Extensions", {4, 1, 2, 0} }, - { L"System.Runtime.Handles", {4, 0, 1, 0} }, - { L"System.Runtime.InteropServices", {4, 1, 2, 0} }, - { L"System.Runtime.InteropServices.RuntimeInformation", {4, 0, 2, 0} }, - { L"System.Runtime.Numerics", {4, 0, 1, 0} }, - { L"System.Runtime.Serialization.Formatters", {4, 0, 2, 0} }, - { L"System.Runtime.Serialization.Json", {4, 0, 1, 0} }, - { L"System.Runtime.Serialization.Primitives", {4, 2, 0, 0} }, - { L"System.Runtime.Serialization.Xml", {4, 1, 3, 0} }, - { L"System.Security.Claims", {4, 0, 3, 0} }, - { L"System.Security.Cryptography.Algorithms", {4, 3, 0, 0} }, - { L"System.Security.Cryptography.Csp", {4, 0, 2, 0} }, - { L"System.Security.Cryptography.Encoding", {4, 0, 2, 0} }, - { L"System.Security.Cryptography.Primitives", {4, 0, 2, 0} }, - { L"System.Security.Cryptography.X509Certificates", {4, 1, 2, 0} }, - { L"System.Security.Principal", {4, 0, 1, 0} }, - { L"System.Security.SecureString", {4, 1, 0, 0} }, - { L"System.Text.Encoding", {4, 0, 11, 0} }, - { L"System.Text.Encoding.Extensions", {4, 0, 11, 0} }, - { L"System.Text.Encodings.Web", {9, 0, 0, 2} }, - { L"System.Text.Json", {9, 0, 0, 2} }, - { L"System.Text.RegularExpressions", {4, 1, 1, 0} }, - { L"System.Threading", {4, 0, 11, 0} }, - { L"System.Threading.Overlapped", {4, 1, 0, 0} }, - { L"System.Threading.Tasks", {4, 0, 11, 0} }, - { L"System.Threading.Tasks.Extensions", {4, 2, 4, 0} }, - { L"System.Threading.Tasks.Parallel", {4, 0, 1, 0} }, - { L"System.Threading.Thread", {4, 0, 2, 0} }, - { L"System.Threading.ThreadPool", {4, 0, 12, 0} }, - { L"System.Threading.Timer", {4, 0, 1, 0} }, - { L"System.ValueTuple", {4, 0, 5, 0} }, - { L"System.Xml.ReaderWriter", {4, 1, 1, 0} }, - { L"System.Xml.XDocument", {4, 0, 11, 0} }, - { L"System.Xml.XmlDocument", {4, 0, 3, 0} }, - { L"System.Xml.XmlSerializer", {4, 0, 11, 0} }, - { L"System.Xml.XPath", {4, 0, 3, 0} }, - { L"System.Xml.XPath.XDocument", {4, 1, 0, 0} } + { 462, { + { L"Microsoft.Bcl.AsyncInterfaces", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Configuration", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Configuration.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Configuration.Binder", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.DependencyInjection", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.DependencyInjection.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Diagnostics.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Logging", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Logging.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Logging.Configuration", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Options", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Options.ConfigurationExtensions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Primitives", {9, 0, 0, 6} }, + { L"Microsoft.Win32.Primitives", {4, 0, 3, 0} }, + { L"OpenTelemetry", {1, 0, 0, 0} }, + { L"OpenTelemetry.Api", {1, 0, 0, 0} }, + { L"OpenTelemetry.Api.ProviderBuilderExtensions", {1, 0, 0, 0} }, + { L"OpenTelemetry.AutoInstrumentation", {auto_major, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.Console", {1, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.OpenTelemetryProtocol", {1, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.Prometheus.HttpListener", {1, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.Zipkin", {1, 0, 0, 0} }, + { L"OpenTelemetry.Extensions.Propagators", {1, 0, 0, 0} }, + { L"OpenTelemetry.Instrumentation.AspNet", {1, 12, 0, 489} }, + { L"OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule", {1, 12, 0, 489} }, + { L"OpenTelemetry.Instrumentation.GrpcNetClient", {1, 12, 0, 492} }, + { L"OpenTelemetry.Instrumentation.Http", {1, 12, 0, 493} }, + { L"OpenTelemetry.Instrumentation.Process", {1, 12, 0, 494} }, + { L"OpenTelemetry.Instrumentation.Quartz", {1, 12, 0, 495} }, + { L"OpenTelemetry.Instrumentation.Runtime", {1, 12, 0, 496} }, + { L"OpenTelemetry.Instrumentation.SqlClient", {1, 12, 0, 582} }, + { L"OpenTelemetry.Instrumentation.Wcf", {1, 12, 0, 500} }, + { L"OpenTelemetry.Resources.Azure", {1, 12, 0, 501} }, + { L"OpenTelemetry.Resources.Host", {1, 12, 0, 503} }, + { L"OpenTelemetry.Resources.OperatingSystem", {1, 12, 0, 504} }, + { L"OpenTelemetry.Resources.Process", {1, 12, 0, 505} }, + { L"OpenTelemetry.Resources.ProcessRuntime", {1, 12, 0, 506} }, + { L"OpenTelemetry.Shims.OpenTracing", {1, 0, 0, 0} }, + { L"OpenTracing", {0, 12, 1, 0} }, + { L"System.AppContext", {4, 1, 2, 0} }, + { L"System.Buffers", {4, 0, 5, 0} }, + { L"System.Collections", {4, 0, 11, 0} }, + { L"System.Collections.Concurrent", {4, 0, 11, 0} }, + { L"System.Collections.NonGeneric", {4, 0, 3, 0} }, + { L"System.Collections.Specialized", {4, 0, 3, 0} }, + { L"System.ComponentModel", {4, 0, 1, 0} }, + { L"System.ComponentModel.EventBasedAsync", {4, 0, 11, 0} }, + { L"System.ComponentModel.Primitives", {4, 1, 2, 0} }, + { L"System.ComponentModel.TypeConverter", {4, 1, 2, 0} }, + { L"System.Console", {4, 0, 2, 0} }, + { L"System.Data.Common", {4, 2, 0, 0} }, + { L"System.Diagnostics.Contracts", {4, 0, 1, 0} }, + { L"System.Diagnostics.Debug", {4, 0, 11, 0} }, + { L"System.Diagnostics.DiagnosticSource", {9, 0, 0, 6} }, + { L"System.Diagnostics.FileVersionInfo", {4, 0, 2, 0} }, + { L"System.Diagnostics.Process", {4, 1, 2, 0} }, + { L"System.Diagnostics.StackTrace", {4, 1, 0, 0} }, + { L"System.Diagnostics.TextWriterTraceListener", {4, 0, 2, 0} }, + { L"System.Diagnostics.Tools", {4, 0, 1, 0} }, + { L"System.Diagnostics.TraceSource", {4, 0, 2, 0} }, + { L"System.Diagnostics.Tracing", {4, 2, 0, 0} }, + { L"System.Drawing.Primitives", {4, 0, 2, 0} }, + { L"System.Dynamic.Runtime", {4, 0, 11, 0} }, + { L"System.Globalization", {4, 0, 11, 0} }, + { L"System.Globalization.Calendars", {4, 0, 3, 0} }, + { L"System.Globalization.Extensions", {4, 1, 0, 0} }, + { L"System.IO", {4, 1, 2, 0} }, + { L"System.IO.Compression", {4, 2, 0, 0} }, + { L"System.IO.Compression.ZipFile", {4, 0, 3, 0} }, + { L"System.IO.FileSystem", {4, 0, 3, 0} }, + { L"System.IO.FileSystem.DriveInfo", {4, 0, 2, 0} }, + { L"System.IO.FileSystem.Primitives", {4, 0, 3, 0} }, + { L"System.IO.FileSystem.Watcher", {4, 0, 2, 0} }, + { L"System.IO.IsolatedStorage", {4, 0, 2, 0} }, + { L"System.IO.MemoryMappedFiles", {4, 0, 2, 0} }, + { L"System.IO.Pipelines", {9, 0, 0, 6} }, + { L"System.IO.Pipes", {4, 0, 2, 0} }, + { L"System.IO.UnmanagedMemoryStream", {4, 0, 3, 0} }, + { L"System.Linq", {4, 1, 2, 0} }, + { L"System.Linq.Expressions", {4, 1, 2, 0} }, + { L"System.Linq.Parallel", {4, 0, 1, 0} }, + { L"System.Linq.Queryable", {4, 0, 1, 0} }, + { L"System.Memory", {4, 0, 5, 0} }, + { L"System.Net.Http", {4, 2, 0, 0} }, + { L"System.Net.NameResolution", {4, 0, 2, 0} }, + { L"System.Net.NetworkInformation", {4, 1, 2, 0} }, + { L"System.Net.Ping", {4, 0, 2, 0} }, + { L"System.Net.Primitives", {4, 0, 11, 0} }, + { L"System.Net.Requests", {4, 0, 11, 0} }, + { L"System.Net.Security", {4, 0, 2, 0} }, + { L"System.Net.Sockets", {4, 2, 0, 0} }, + { L"System.Net.WebHeaderCollection", {4, 0, 1, 0} }, + { L"System.Net.WebSockets", {4, 0, 2, 0} }, + { L"System.Net.WebSockets.Client", {4, 0, 2, 0} }, + { L"System.Numerics.Vectors", {4, 1, 6, 0} }, + { L"System.ObjectModel", {4, 0, 11, 0} }, + { L"System.Reflection", {4, 1, 2, 0} }, + { L"System.Reflection.Extensions", {4, 0, 1, 0} }, + { L"System.Reflection.Primitives", {4, 0, 1, 0} }, + { L"System.Resources.Reader", {4, 0, 2, 0} }, + { L"System.Resources.ResourceManager", {4, 0, 1, 0} }, + { L"System.Resources.Writer", {4, 0, 2, 0} }, + { L"System.Runtime", {4, 1, 2, 0} }, + { L"System.Runtime.CompilerServices.Unsafe", {6, 0, 3, 0} }, + { L"System.Runtime.CompilerServices.VisualC", {4, 0, 2, 0} }, + { L"System.Runtime.Extensions", {4, 1, 2, 0} }, + { L"System.Runtime.Handles", {4, 0, 1, 0} }, + { L"System.Runtime.InteropServices", {4, 1, 2, 0} }, + { L"System.Runtime.InteropServices.RuntimeInformation", {4, 0, 2, 0} }, + { L"System.Runtime.Numerics", {4, 0, 1, 0} }, + { L"System.Runtime.Serialization.Formatters", {4, 0, 2, 0} }, + { L"System.Runtime.Serialization.Json", {4, 0, 1, 0} }, + { L"System.Runtime.Serialization.Primitives", {4, 2, 0, 0} }, + { L"System.Runtime.Serialization.Xml", {4, 1, 3, 0} }, + { L"System.Security.Claims", {4, 0, 3, 0} }, + { L"System.Security.Cryptography.Algorithms", {4, 3, 0, 0} }, + { L"System.Security.Cryptography.Csp", {4, 0, 2, 0} }, + { L"System.Security.Cryptography.Encoding", {4, 0, 2, 0} }, + { L"System.Security.Cryptography.Primitives", {4, 0, 2, 0} }, + { L"System.Security.Cryptography.X509Certificates", {4, 1, 2, 0} }, + { L"System.Security.Principal", {4, 0, 1, 0} }, + { L"System.Security.SecureString", {4, 1, 0, 0} }, + { L"System.Text.Encoding", {4, 0, 11, 0} }, + { L"System.Text.Encoding.Extensions", {4, 0, 11, 0} }, + { L"System.Text.Encodings.Web", {9, 0, 0, 2} }, + { L"System.Text.Json", {9, 0, 0, 2} }, + { L"System.Text.RegularExpressions", {4, 1, 1, 0} }, + { L"System.Threading", {4, 0, 11, 0} }, + { L"System.Threading.Overlapped", {4, 1, 0, 0} }, + { L"System.Threading.Tasks", {4, 0, 11, 0} }, + { L"System.Threading.Tasks.Extensions", {4, 2, 4, 0} }, + { L"System.Threading.Tasks.Parallel", {4, 0, 1, 0} }, + { L"System.Threading.Thread", {4, 0, 2, 0} }, + { L"System.Threading.ThreadPool", {4, 0, 12, 0} }, + { L"System.Threading.Timer", {4, 0, 1, 0} }, + { L"System.ValueTuple", {4, 0, 5, 0} }, + { L"System.Xml.ReaderWriter", {4, 1, 1, 0} }, + { L"System.Xml.XDocument", {4, 0, 11, 0} }, + { L"System.Xml.XmlDocument", {4, 0, 3, 0} }, + { L"System.Xml.XmlSerializer", {4, 0, 11, 0} }, + { L"System.Xml.XPath", {4, 0, 3, 0} }, + { L"System.Xml.XPath.XDocument", {4, 1, 0, 0} }, + }}, + { 470, { + { L"Microsoft.Bcl.AsyncInterfaces", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Configuration", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Configuration.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Configuration.Binder", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.DependencyInjection", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.DependencyInjection.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Diagnostics.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Logging", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Logging.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Logging.Configuration", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Options", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Options.ConfigurationExtensions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Primitives", {9, 0, 0, 6} }, + { L"OpenTelemetry", {1, 0, 0, 0} }, + { L"OpenTelemetry.Api", {1, 0, 0, 0} }, + { L"OpenTelemetry.Api.ProviderBuilderExtensions", {1, 0, 0, 0} }, + { L"OpenTelemetry.AutoInstrumentation", {auto_major, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.Console", {1, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.OpenTelemetryProtocol", {1, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.Prometheus.HttpListener", {1, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.Zipkin", {1, 0, 0, 0} }, + { L"OpenTelemetry.Extensions.Propagators", {1, 0, 0, 0} }, + { L"OpenTelemetry.Instrumentation.AspNet", {1, 12, 0, 489} }, + { L"OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule", {1, 12, 0, 489} }, + { L"OpenTelemetry.Instrumentation.GrpcNetClient", {1, 12, 0, 492} }, + { L"OpenTelemetry.Instrumentation.Http", {1, 12, 0, 493} }, + { L"OpenTelemetry.Instrumentation.Process", {1, 12, 0, 494} }, + { L"OpenTelemetry.Instrumentation.Quartz", {1, 12, 0, 495} }, + { L"OpenTelemetry.Instrumentation.Runtime", {1, 12, 0, 496} }, + { L"OpenTelemetry.Instrumentation.SqlClient", {1, 12, 0, 582} }, + { L"OpenTelemetry.Instrumentation.Wcf", {1, 12, 0, 500} }, + { L"OpenTelemetry.Resources.Azure", {1, 12, 0, 501} }, + { L"OpenTelemetry.Resources.Host", {1, 12, 0, 503} }, + { L"OpenTelemetry.Resources.OperatingSystem", {1, 12, 0, 504} }, + { L"OpenTelemetry.Resources.Process", {1, 12, 0, 505} }, + { L"OpenTelemetry.Resources.ProcessRuntime", {1, 12, 0, 506} }, + { L"OpenTelemetry.Shims.OpenTracing", {1, 0, 0, 0} }, + { L"OpenTracing", {0, 12, 1, 0} }, + { L"System.Buffers", {4, 0, 5, 0} }, + { L"System.Diagnostics.DiagnosticSource", {9, 0, 0, 6} }, + { L"System.IO.Pipelines", {9, 0, 0, 6} }, + { L"System.Memory", {4, 0, 5, 0} }, + { L"System.Numerics.Vectors", {4, 1, 6, 0} }, + { L"System.Runtime.CompilerServices.Unsafe", {6, 0, 3, 0} }, + { L"System.Runtime.InteropServices.RuntimeInformation", {4, 0, 2, 0} }, + { L"System.Security.Cryptography.Algorithms", {4, 3, 0, 0} }, + { L"System.Text.Encodings.Web", {9, 0, 0, 2} }, + { L"System.Text.Json", {9, 0, 0, 2} }, + { L"System.Threading.Tasks.Extensions", {4, 2, 4, 0} }, + { L"System.ValueTuple", {4, 0, 5, 0} }, + }}, + { 471, { + { L"Microsoft.Bcl.AsyncInterfaces", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Configuration", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Configuration.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Configuration.Binder", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.DependencyInjection", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.DependencyInjection.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Diagnostics.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Logging", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Logging.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Logging.Configuration", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Options", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Options.ConfigurationExtensions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Primitives", {9, 0, 0, 6} }, + { L"OpenTelemetry", {1, 0, 0, 0} }, + { L"OpenTelemetry.Api", {1, 0, 0, 0} }, + { L"OpenTelemetry.Api.ProviderBuilderExtensions", {1, 0, 0, 0} }, + { L"OpenTelemetry.AutoInstrumentation", {auto_major, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.Console", {1, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.OpenTelemetryProtocol", {1, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.Prometheus.HttpListener", {1, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.Zipkin", {1, 0, 0, 0} }, + { L"OpenTelemetry.Extensions.Propagators", {1, 0, 0, 0} }, + { L"OpenTelemetry.Instrumentation.AspNet", {1, 12, 0, 489} }, + { L"OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule", {1, 12, 0, 489} }, + { L"OpenTelemetry.Instrumentation.GrpcNetClient", {1, 12, 0, 492} }, + { L"OpenTelemetry.Instrumentation.Http", {1, 12, 0, 493} }, + { L"OpenTelemetry.Instrumentation.Process", {1, 12, 0, 494} }, + { L"OpenTelemetry.Instrumentation.Quartz", {1, 12, 0, 495} }, + { L"OpenTelemetry.Instrumentation.Runtime", {1, 12, 0, 496} }, + { L"OpenTelemetry.Instrumentation.SqlClient", {1, 12, 0, 582} }, + { L"OpenTelemetry.Instrumentation.Wcf", {1, 12, 0, 500} }, + { L"OpenTelemetry.Resources.Azure", {1, 12, 0, 501} }, + { L"OpenTelemetry.Resources.Host", {1, 12, 0, 503} }, + { L"OpenTelemetry.Resources.OperatingSystem", {1, 12, 0, 504} }, + { L"OpenTelemetry.Resources.Process", {1, 12, 0, 505} }, + { L"OpenTelemetry.Resources.ProcessRuntime", {1, 12, 0, 506} }, + { L"OpenTelemetry.Shims.OpenTracing", {1, 0, 0, 0} }, + { L"OpenTracing", {0, 12, 1, 0} }, + { L"System.Buffers", {4, 0, 5, 0} }, + { L"System.Data.Common", {4, 2, 0, 0} }, + { L"System.Diagnostics.DiagnosticSource", {9, 0, 0, 6} }, + { L"System.Diagnostics.StackTrace", {4, 1, 0, 0} }, + { L"System.Diagnostics.Tracing", {4, 2, 0, 0} }, + { L"System.Globalization.Extensions", {4, 1, 0, 0} }, + { L"System.IO.Compression", {4, 2, 0, 0} }, + { L"System.IO.Pipelines", {9, 0, 0, 6} }, + { L"System.Memory", {4, 0, 5, 0} }, + { L"System.Net.Http", {4, 2, 0, 0} }, + { L"System.Net.Sockets", {4, 2, 0, 0} }, + { L"System.Numerics.Vectors", {4, 1, 6, 0} }, + { L"System.Runtime.CompilerServices.Unsafe", {6, 0, 3, 0} }, + { L"System.Runtime.Serialization.Primitives", {4, 2, 0, 0} }, + { L"System.Security.Cryptography.Algorithms", {4, 3, 0, 0} }, + { L"System.Security.SecureString", {4, 1, 0, 0} }, + { L"System.Text.Encodings.Web", {9, 0, 0, 2} }, + { L"System.Text.Json", {9, 0, 0, 2} }, + { L"System.Threading.Overlapped", {4, 1, 0, 0} }, + { L"System.Threading.Tasks.Extensions", {4, 2, 4, 0} }, + { L"System.Xml.XPath.XDocument", {4, 1, 0, 0} }, + }}, + { 472, { + { L"Microsoft.Bcl.AsyncInterfaces", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Configuration", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Configuration.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Configuration.Binder", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.DependencyInjection", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.DependencyInjection.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Diagnostics.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Logging", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Logging.Abstractions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Logging.Configuration", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Options", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Options.ConfigurationExtensions", {9, 0, 0, 6} }, + { L"Microsoft.Extensions.Primitives", {9, 0, 0, 6} }, + { L"OpenTelemetry", {1, 0, 0, 0} }, + { L"OpenTelemetry.Api", {1, 0, 0, 0} }, + { L"OpenTelemetry.Api.ProviderBuilderExtensions", {1, 0, 0, 0} }, + { L"OpenTelemetry.AutoInstrumentation", {auto_major, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.Console", {1, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.OpenTelemetryProtocol", {1, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.Prometheus.HttpListener", {1, 0, 0, 0} }, + { L"OpenTelemetry.Exporter.Zipkin", {1, 0, 0, 0} }, + { L"OpenTelemetry.Extensions.Propagators", {1, 0, 0, 0} }, + { L"OpenTelemetry.Instrumentation.AspNet", {1, 12, 0, 489} }, + { L"OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule", {1, 12, 0, 489} }, + { L"OpenTelemetry.Instrumentation.GrpcNetClient", {1, 12, 0, 492} }, + { L"OpenTelemetry.Instrumentation.Http", {1, 12, 0, 493} }, + { L"OpenTelemetry.Instrumentation.Process", {1, 12, 0, 494} }, + { L"OpenTelemetry.Instrumentation.Quartz", {1, 12, 0, 495} }, + { L"OpenTelemetry.Instrumentation.Runtime", {1, 12, 0, 496} }, + { L"OpenTelemetry.Instrumentation.SqlClient", {1, 12, 0, 582} }, + { L"OpenTelemetry.Instrumentation.Wcf", {1, 12, 0, 500} }, + { L"OpenTelemetry.Resources.Azure", {1, 12, 0, 501} }, + { L"OpenTelemetry.Resources.Host", {1, 12, 0, 503} }, + { L"OpenTelemetry.Resources.OperatingSystem", {1, 12, 0, 504} }, + { L"OpenTelemetry.Resources.Process", {1, 12, 0, 505} }, + { L"OpenTelemetry.Resources.ProcessRuntime", {1, 12, 0, 506} }, + { L"OpenTelemetry.Shims.OpenTracing", {1, 0, 0, 0} }, + { L"OpenTracing", {0, 12, 1, 0} }, + { L"System.Buffers", {4, 0, 5, 0} }, + { L"System.Diagnostics.DiagnosticSource", {9, 0, 0, 6} }, + { L"System.IO.Pipelines", {9, 0, 0, 6} }, + { L"System.Memory", {4, 0, 5, 0} }, + { L"System.Numerics.Vectors", {4, 1, 6, 0} }, + { L"System.Runtime.CompilerServices.Unsafe", {6, 0, 3, 0} }, + { L"System.Text.Encodings.Web", {9, 0, 0, 2} }, + { L"System.Text.Json", {9, 0, 0, 2} }, + { L"System.Threading.Tasks.Extensions", {4, 2, 4, 0} }, + }} }); } } diff --git a/src/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies.csproj b/src/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies.csproj new file mode 100644 index 0000000000..d174f2c4eb --- /dev/null +++ b/src/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies.csproj @@ -0,0 +1,19 @@ + + + + + + net462;net47;net471;net472 + none + false + false + true + false + false + + + + + + + diff --git a/src/OpenTelemetry.AutoInstrumentation/OpenTelemetry.AutoInstrumentation.csproj b/src/OpenTelemetry.AutoInstrumentation/OpenTelemetry.AutoInstrumentation.csproj index 11b865a9c1..79ad3521ce 100644 --- a/src/OpenTelemetry.AutoInstrumentation/OpenTelemetry.AutoInstrumentation.csproj +++ b/src/OpenTelemetry.AutoInstrumentation/OpenTelemetry.AutoInstrumentation.csproj @@ -8,6 +8,7 @@ true Generated $(GeneratedFolder)\$(TargetFramework) + false @@ -58,34 +59,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/DependencyListGenerator/Generator.cs b/tools/DependencyListGenerator/Generator.cs index 9308f51bf7..e747b1fa9f 100644 --- a/tools/DependencyListGenerator/Generator.cs +++ b/tools/DependencyListGenerator/Generator.cs @@ -8,7 +8,7 @@ namespace DependencyListGenerator; public static class Generator { - public static IEnumerable EnumerateDependencies(string projectPath) + public static IEnumerable EnumerateDependencies(string projectPath, Version version) { var dotNetRunner = new DotNetRunner(); var fileSystem = new FileSystem(); @@ -19,7 +19,7 @@ public static IEnumerable EnumerateDependencies(string proj fileSystem: fileSystem); var result = analysisService.AnalyzeProject(projectPath, true, true, 1024)[0]; - var net462 = result.TargetFrameworks.First(x => x.Name.ToString() == ".NETFramework,Version=v4.6.2"); + var net462 = result.TargetFrameworks.First(x => x.Name.ToString() == (version.Build != 0 ? $".NETFramework,Version=v{version.Major}.{version.Minor}.{version.Build}" : $".NETFramework,Version=v{version.Major}.{version.Minor}")); foreach (var dep in net462.Dependencies.OrderBy(x => x.Name)) { From 0045c40769ff8fc7e2614f1594810193bec63f7a Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Tue, 7 Oct 2025 11:17:02 -0700 Subject: [PATCH 02/30] Format fix --- .../cor_profiler.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp index 2396756fe5..2718da19bc 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp +++ b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp @@ -3729,14 +3729,15 @@ void CorProfiler::DetectFrameworkVersion() { if (key <= frameworkVersion && key > selectedKey) { - selectedKey = key; + selectedKey = key; assembly_version_redirect_map_current_framework_ = &values; } } if (selectedKey != 0) { - Logger::Warn("DetectFrameworkVersion: No assembly redirection tables found. Assembly version redirecting will be disabled."); + Logger::Warn("DetectFrameworkVersion: No assembly redirection tables found. Assembly version redirecting will " + "be disabled."); } else { From 8b4d03bf98f4b6545595f978a68648a1053abbf2 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Tue, 7 Oct 2025 11:42:06 -0700 Subject: [PATCH 03/30] Excluded Assemblies.NetFramework from build on non-windows OS --- OpenTelemetry.AutoInstrumentation.sln | 2 +- build/Build.Steps.cs | 2 +- build/Projects.cs | 2 +- build/ProjectsHelper.cs | 3 ++- ...lemetry.AutoInstrumentation.Assemblies.NetFramework.csproj} | 0 5 files changed, 5 insertions(+), 4 deletions(-) rename src/{OpenTelemetry.AutoInstrumentation.NetFx.Assemblies/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies.csproj => OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework.csproj} (100%) diff --git a/OpenTelemetry.AutoInstrumentation.sln b/OpenTelemetry.AutoInstrumentation.sln index 94f790263c..0775f4cf04 100644 --- a/OpenTelemetry.AutoInstrumentation.sln +++ b/OpenTelemetry.AutoInstrumentation.sln @@ -253,7 +253,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication.ProfilerSpa EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication.NoCode", "test\test-applications\integrations\TestApplication.NoCode\TestApplication.NoCode.csproj", "{500BF40F-EECB-4F6A-377B-EDBDFFDE09BE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.AutoInstrumentation.NetFx.Assemblies", "src\OpenTelemetry.AutoInstrumentation.NetFx.Assemblies\OpenTelemetry.AutoInstrumentation.NetFx.Assemblies.csproj", "{B69564D4-7D5B-7147-6CBA-233BB8A33C50}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework", "src\OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework\OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework.csproj", "{B69564D4-7D5B-7147-6CBA-233BB8A33C50}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/build/Build.Steps.cs b/build/Build.Steps.cs index 24774eae3c..b739ee10ab 100644 --- a/build/Build.Steps.cs +++ b/build/Build.Steps.cs @@ -290,7 +290,7 @@ DotNetBuildSettings BuildTestApplication(DotNetBuildSettings x, string targetFra .SetFramework(framework) .SetOutput(TracerHomeDirectory / MapToFolderOutput(framework)))); - // Publish OpenTelemetry.AutoInstrumentation.NetFx.Assemblies for .NET Framework targets + // Publish OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework for .NET Framework targets DotNetPublish(s => s .SetProject(Solution.GetProjectByName(Projects.AutoInstrumentationNetFxAssemblies)) .SetConfiguration(BuildConfiguration) diff --git a/build/Projects.cs b/build/Projects.cs index fb1c8f901d..46b224d841 100644 --- a/build/Projects.cs +++ b/build/Projects.cs @@ -1,7 +1,7 @@ public static class Projects { public const string AutoInstrumentation = "OpenTelemetry.AutoInstrumentation"; - public const string AutoInstrumentationNetFxAssemblies = "OpenTelemetry.AutoInstrumentation.NetFx.Assemblies"; + public const string AutoInstrumentationNetFxAssemblies = "OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework"; public const string AutoInstrumentationLoader = "OpenTelemetry.AutoInstrumentation.Loader"; public const string AutoInstrumentationNative = "OpenTelemetry.AutoInstrumentation.Native"; public const string AutoInstrumentationStartupHook = "OpenTelemetry.AutoInstrumentation.StartupHook"; diff --git a/build/ProjectsHelper.cs b/build/ProjectsHelper.cs index d9ab9e033b..c1162bdaaf 100644 --- a/build/ProjectsHelper.cs +++ b/build/ProjectsHelper.cs @@ -26,7 +26,8 @@ public static IEnumerable GetManagedSrcProjects(this Solution solution) // Should contain in the src directory SrcDirectory.Contains(x.Directory) && // Should not be native projects - !x.Name.Contains(NativeProjectMarker)); + !x.Name.Contains(NativeProjectMarker) + && (!x.Name.EndsWith(NetFrameworkMarker) || EnvironmentInfo.IsWin)); } public static IEnumerable GetNativeSrcProjects(this Solution solution) diff --git a/src/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies.csproj b/src/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework.csproj similarity index 100% rename from src/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies/OpenTelemetry.AutoInstrumentation.NetFx.Assemblies.csproj rename to src/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework.csproj From c347876b214b43d8b7873ad48a19e7cf6c140277 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Tue, 7 Oct 2025 11:59:27 -0700 Subject: [PATCH 04/30] Publish .Net Framework project only on windows --- build/Build.Steps.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/build/Build.Steps.cs b/build/Build.Steps.cs index b739ee10ab..dfef35db1a 100644 --- a/build/Build.Steps.cs +++ b/build/Build.Steps.cs @@ -290,16 +290,19 @@ DotNetBuildSettings BuildTestApplication(DotNetBuildSettings x, string targetFra .SetFramework(framework) .SetOutput(TracerHomeDirectory / MapToFolderOutput(framework)))); - // Publish OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework for .NET Framework targets - DotNetPublish(s => s - .SetProject(Solution.GetProjectByName(Projects.AutoInstrumentationNetFxAssemblies)) - .SetConfiguration(BuildConfiguration) - .SetTargetPlatformAnyCPU() - .EnableNoBuild() - .SetNoRestore(NoRestore) - .CombineWith(TargetFrameworksNetFx, (p, framework) => p - .SetFramework(framework) - .SetOutput(TracerHomeDirectory / MapToFolderOutputNetFx(framework)))); + if (IsWin) + { + // Publish OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework for .NET Framework targets + DotNetPublish(s => s + .SetProject(Solution.GetProjectByName(Projects.AutoInstrumentationNetFxAssemblies)) + .SetConfiguration(BuildConfiguration) + .SetTargetPlatformAnyCPU() + .EnableNoBuild() + .SetNoRestore(NoRestore) + .CombineWith(TargetFrameworksNetFx, (p, framework) => p + .SetFramework(framework) + .SetOutput(TracerHomeDirectory / MapToFolderOutputNetFx(framework)))); + } // StartupHook is supported starting .Net Core 3.1. // We need to emit AutoInstrumentationStartupHook for .Net Core 3.1 target framework From 8b05f5f7dcc3820f0dae8e3e90f99ce38848bbf3 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Tue, 7 Oct 2025 12:22:42 -0700 Subject: [PATCH 05/30] Fixed format for c# files --- build/AssemblyRedirectionSourceGenerator.cs | 16 ++++++++-------- build/Build.Steps.cs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build/AssemblyRedirectionSourceGenerator.cs b/build/AssemblyRedirectionSourceGenerator.cs index 97811a77b4..7368b8868c 100644 --- a/build/AssemblyRedirectionSourceGenerator.cs +++ b/build/AssemblyRedirectionSourceGenerator.cs @@ -74,14 +74,14 @@ void Process(string fileName, int? framework) { foreach (var fileName in Directory.EnumerateFiles(fx.Value)) { - var filenameToProcess = fileName; - if (Path.GetExtension(fileName) == "link") - { - filenameToProcess = Path.Combine(generatedFilePath, File.ReadAllText(fileName), - Path.GetFileNameWithoutExtension(fileName)); - } - - Process(filenameToProcess, fx.Key); + var filenameToProcess = fileName; + if (Path.GetExtension(fileName) == "link") + { + filenameToProcess = Path.Combine(generatedFilePath, File.ReadAllText(fileName), + Path.GetFileNameWithoutExtension(fileName)); + } + + Process(filenameToProcess, fx.Key); } } diff --git a/build/Build.Steps.cs b/build/Build.Steps.cs index dfef35db1a..74356e7d03 100644 --- a/build/Build.Steps.cs +++ b/build/Build.Steps.cs @@ -399,7 +399,7 @@ bool FilesAreEqual(string filePath1, string filePath2) if (IsWin) { - (TracerHomeDirectory / "netfx" ).GlobFiles("**/*.link").DeleteFiles(); + (TracerHomeDirectory / "netfx").GlobFiles("**/*.link").DeleteFiles(); var latestFramework = TargetFramework.NetFramework.Last(); (TracerHomeDirectory / "netfx" / latestFramework).GlobFiles("*.*") .Where(file => TargetFramework.NetFramework.TakeUntil(older => older == latestFramework) From 4ef8534c19552cd4bedcc127327650c912519ca0 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Tue, 7 Oct 2025 12:54:20 -0700 Subject: [PATCH 06/30] Excluded .NetFramework assemblies-collecting project from producing NuGet package. Removed TransientDependenciesTests - it should be rewritten later. --- build/Build.NuGet.Steps.cs | 2 +- .../TransientDependenciesTests.cs | 106 ------------------ 2 files changed, 1 insertion(+), 107 deletions(-) delete mode 100644 test/OpenTelemetry.AutoInstrumentation.Tests/TransientDependenciesTests.cs diff --git a/build/Build.NuGet.Steps.cs b/build/Build.NuGet.Steps.cs index f809f46487..b56c295b64 100644 --- a/build/Build.NuGet.Steps.cs +++ b/build/Build.NuGet.Steps.cs @@ -30,7 +30,7 @@ partial class Build .Description("Build the NuGet packages that are generated directly from src/**/*.csproj files") .Executes(() => { - foreach (var project in Solution.GetManagedSrcProjects().Where(p => !p.Name.EndsWith("AdditionalDeps"))) + foreach (var project in Solution.GetManagedSrcProjects().Where(p => !p.Name.EndsWith("AdditionalDeps") && !p.Name.Contains("Assemblies"))) { DotNetPack(x => x .SetProject(project) diff --git a/test/OpenTelemetry.AutoInstrumentation.Tests/TransientDependenciesTests.cs b/test/OpenTelemetry.AutoInstrumentation.Tests/TransientDependenciesTests.cs deleted file mode 100644 index d66d9c7496..0000000000 --- a/test/OpenTelemetry.AutoInstrumentation.Tests/TransientDependenciesTests.cs +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// This test is defined in NET 9.0 because the tool is written in .NET 9.0 -// The actual test is testing .NET Framework 4.6.2 context. -#if NET9_0_OR_GREATER - -using System.Reflection; -using System.Runtime.InteropServices; -using System.Xml.Linq; -using DependencyListGenerator; -using Xunit; - -namespace OpenTelemetry.AutoInstrumentation.Tests; - -public class TransientDependenciesTests -{ - [SkippableFact] - public void DefinedTransientDeps_Are_MatchingGeneratedDeps() - { - Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Supported only on Windows."); - - var currentTestLocation = Assembly.GetExecutingAssembly().Location; - var testDir = FindParentDir(currentTestLocation, "test"); - var srcDir = Path.Combine(Directory.GetParent(testDir)!.FullName, "src"); - var codeDir = Path.Combine(srcDir, "OpenTelemetry.AutoInstrumentation"); - var projectPath = Path.Combine(codeDir, "OpenTelemetry.AutoInstrumentation.csproj"); - var projectGenPath = Path.Combine(codeDir, "OpenTelemetry.AutoInstrumentation.g.csproj"); - - File.Copy(projectPath, projectGenPath, overwrite: true); - - var deps = ReadTransientDeps(projectGenPath); - - CleanTransientDeps(projectGenPath); - - var generatedDeps = Generator - .EnumerateDependencies(projectGenPath) - .Select(x => x.Name) - .ToList(); - - // TODO automate detecting new transitive dependencies https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/issues/3817 - generatedDeps.Add("System.IO.Pipelines"); - - File.Delete(projectGenPath); - - Assert.Equal(generatedDeps.Count, deps.Count); - Assert.Equivalent(generatedDeps, deps); - } - - private static XElement? GetTransientDepsGroup(XElement projXml) - { - const string label = "Transient dependencies auto-generated by GenerateNetFxTransientDependencies"; - - return projXml - .Elements("ItemGroup") - .FirstOrDefault(x => - x.HasAttributes && - x.Attribute("Label")?.Value == label); - } - - private static void CleanTransientDeps(string projPath) - { - var projXml = XElement.Load(projPath); - var depsGroup = GetTransientDepsGroup(projXml); - if (depsGroup != null) - { - depsGroup.Remove(); - } - - projXml.Save(projPath); - } - - private static ICollection ReadTransientDeps(string projPath) - { - var projXml = XElement.Load(projPath); - var depsGroup = GetTransientDepsGroup(projXml); - if (depsGroup == null) - { - return Array.Empty(); - } - - return depsGroup - .Descendants("PackageReference") - .Where(x => x.HasAttributes && x.Attribute("Include") != null) - .Select(x => x.Attribute("Include")!.Value) - .ToList(); - } - - private static string FindParentDir(string location, string parentName) - { - var parent = Directory.GetParent(location); - if (parent == null) - { - throw new InvalidOperationException("Could not find parent test directory"); - } - - if (parent.Name == parentName) - { - return parent.FullName; - } - - return FindParentDir(parent.FullName, parentName); - } -} - -#endif From ba8784df4ba9f66826c63baf48201c55727e2c9a Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Tue, 7 Oct 2025 19:15:28 -0700 Subject: [PATCH 07/30] Fixed test --- ...DistributionStructure_windows.verified.txt | 339 +++++++++++++----- .../TestLibrary.InstrumentationTarget.csproj | 8 +- 2 files changed, 250 insertions(+), 97 deletions(-) diff --git a/test/IntegrationTests/BuildTests.DistributionStructure_windows.verified.txt b/test/IntegrationTests/BuildTests.DistributionStructure_windows.verified.txt index 4cec95c98b..942b70bbfc 100644 --- a/test/IntegrationTests/BuildTests.DistributionStructure_windows.verified.txt +++ b/test/IntegrationTests/BuildTests.DistributionStructure_windows.verified.txt @@ -83,111 +83,258 @@ \netfx\OpenTelemetry.Shims.OpenTracing.dll, \netfx\OpenTelemetry.dll, \netfx\OpenTracing.dll, - \netfx\System.AppContext.dll, + \netfx\Microsoft.Bcl.AsyncInterfaces.dll, + \netfx\Microsoft.Extensions.Configuration.Abstractions.dll, + \netfx\Microsoft.Extensions.Configuration.Binder.dll, + \netfx\Microsoft.Extensions.Configuration.dll, + \netfx\Microsoft.Extensions.DependencyInjection.Abstractions.dll, + \netfx\Microsoft.Extensions.DependencyInjection.dll, + \netfx\Microsoft.Extensions.Diagnostics.Abstractions.dll, + \netfx\Microsoft.Extensions.Logging.Abstractions.dll, + \netfx\Microsoft.Extensions.Logging.Configuration.dll, + \netfx\Microsoft.Extensions.Logging.dll, + \netfx\Microsoft.Extensions.Options.ConfigurationExtensions.dll, + \netfx\Microsoft.Extensions.Options.dll, + \netfx\Microsoft.Extensions.Primitives.dll, + \netfx\OpenTelemetry.Api.ProviderBuilderExtensions.dll, + \netfx\OpenTelemetry.Api.dll, + \netfx\OpenTelemetry.AutoInstrumentation.dll, + \netfx\OpenTelemetry.AutoInstrumentation.pdb, + \netfx\OpenTelemetry.Exporter.Console.dll, + \netfx\OpenTelemetry.Exporter.OpenTelemetryProtocol.dll, + \netfx\OpenTelemetry.Exporter.Prometheus.HttpListener.dll, + \netfx\OpenTelemetry.Exporter.Zipkin.dll, + \netfx\OpenTelemetry.Extensions.Propagators.dll, + \netfx\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.dll, + \netfx\OpenTelemetry.Instrumentation.AspNet.dll, + \netfx\OpenTelemetry.Instrumentation.GrpcNetClient.dll, + \netfx\OpenTelemetry.Instrumentation.Http.dll, + \netfx\OpenTelemetry.Instrumentation.Process.dll, + \netfx\OpenTelemetry.Instrumentation.Quartz.dll, + \netfx\OpenTelemetry.Instrumentation.Runtime.dll, + \netfx\OpenTelemetry.Instrumentation.SqlClient.dll, + \netfx\OpenTelemetry.Instrumentation.Wcf.dll, + \netfx\OpenTelemetry.Resources.Azure.dll, + \netfx\OpenTelemetry.Resources.Host.dll, + \netfx\OpenTelemetry.Resources.OperatingSystem.dll, + \netfx\OpenTelemetry.Resources.Process.dll, + \netfx\OpenTelemetry.Resources.ProcessRuntime.dll, + \netfx\OpenTelemetry.Shims.OpenTracing.dll, + \netfx\OpenTelemetry.dll, + \netfx\OpenTracing.dll, \netfx\System.Buffers.dll, - \netfx\System.Collections.Concurrent.dll, - \netfx\System.Collections.NonGeneric.dll, - \netfx\System.Collections.Specialized.dll, - \netfx\System.Collections.dll, - \netfx\System.ComponentModel.EventBasedAsync.dll, - \netfx\System.ComponentModel.Primitives.dll, - \netfx\System.ComponentModel.TypeConverter.dll, - \netfx\System.ComponentModel.dll, - \netfx\System.Console.dll, - \netfx\System.Data.Common.dll, - \netfx\System.Diagnostics.Contracts.dll, - \netfx\System.Diagnostics.Debug.dll, \netfx\System.Diagnostics.DiagnosticSource.dll, - \netfx\System.Diagnostics.FileVersionInfo.dll, - \netfx\System.Diagnostics.Process.dll, - \netfx\System.Diagnostics.StackTrace.dll, - \netfx\System.Diagnostics.TextWriterTraceListener.dll, - \netfx\System.Diagnostics.Tools.dll, - \netfx\System.Diagnostics.TraceSource.dll, - \netfx\System.Diagnostics.Tracing.dll, - \netfx\System.Drawing.Primitives.dll, - \netfx\System.Dynamic.Runtime.dll, - \netfx\System.Globalization.Calendars.dll, - \netfx\System.Globalization.Extensions.dll, - \netfx\System.Globalization.dll, - \netfx\System.IO.Compression.ZipFile.dll, - \netfx\System.IO.Compression.dll, - \netfx\System.IO.FileSystem.DriveInfo.dll, - \netfx\System.IO.FileSystem.Primitives.dll, - \netfx\System.IO.FileSystem.Watcher.dll, - \netfx\System.IO.FileSystem.dll, - \netfx\System.IO.IsolatedStorage.dll, - \netfx\System.IO.MemoryMappedFiles.dll, \netfx\System.IO.Pipelines.dll, - \netfx\System.IO.Pipes.dll, - \netfx\System.IO.UnmanagedMemoryStream.dll, - \netfx\System.IO.dll, - \netfx\System.Linq.Expressions.dll, - \netfx\System.Linq.Parallel.dll, - \netfx\System.Linq.Queryable.dll, - \netfx\System.Linq.dll, \netfx\System.Memory.dll, - \netfx\System.Net.Http.dll, - \netfx\System.Net.NameResolution.dll, - \netfx\System.Net.NetworkInformation.dll, - \netfx\System.Net.Ping.dll, - \netfx\System.Net.Primitives.dll, - \netfx\System.Net.Requests.dll, - \netfx\System.Net.Security.dll, - \netfx\System.Net.Sockets.dll, - \netfx\System.Net.WebHeaderCollection.dll, - \netfx\System.Net.WebSockets.Client.dll, - \netfx\System.Net.WebSockets.dll, \netfx\System.Numerics.Vectors.dll, - \netfx\System.ObjectModel.dll, - \netfx\System.Reflection.Extensions.dll, - \netfx\System.Reflection.Primitives.dll, - \netfx\System.Reflection.dll, - \netfx\System.Resources.Reader.dll, - \netfx\System.Resources.ResourceManager.dll, - \netfx\System.Resources.Writer.dll, \netfx\System.Runtime.CompilerServices.Unsafe.dll, - \netfx\System.Runtime.CompilerServices.VisualC.dll, - \netfx\System.Runtime.Extensions.dll, - \netfx\System.Runtime.Handles.dll, - \netfx\System.Runtime.InteropServices.RuntimeInformation.dll, - \netfx\System.Runtime.InteropServices.dll, - \netfx\System.Runtime.Numerics.dll, - \netfx\System.Runtime.Serialization.Formatters.dll, - \netfx\System.Runtime.Serialization.Json.dll, - \netfx\System.Runtime.Serialization.Primitives.dll, - \netfx\System.Runtime.Serialization.Xml.dll, - \netfx\System.Runtime.dll, - \netfx\System.Security.Claims.dll, - \netfx\System.Security.Cryptography.Algorithms.dll, - \netfx\System.Security.Cryptography.Csp.dll, - \netfx\System.Security.Cryptography.Encoding.dll, - \netfx\System.Security.Cryptography.Primitives.dll, - \netfx\System.Security.Cryptography.X509Certificates.dll, - \netfx\System.Security.Principal.dll, - \netfx\System.Security.SecureString.dll, - \netfx\System.Text.Encoding.Extensions.dll, - \netfx\System.Text.Encoding.dll, \netfx\System.Text.Encodings.Web.dll, \netfx\System.Text.Json.dll, - \netfx\System.Text.RegularExpressions.dll, - \netfx\System.Threading.Overlapped.dll, \netfx\System.Threading.Tasks.Extensions.dll, - \netfx\System.Threading.Tasks.Parallel.dll, - \netfx\System.Threading.Tasks.dll, - \netfx\System.Threading.Thread.dll, - \netfx\System.Threading.ThreadPool.dll, - \netfx\System.Threading.Timer.dll, - \netfx\System.Threading.dll, - \netfx\System.ValueTuple.dll, - \netfx\System.Xml.ReaderWriter.dll, - \netfx\System.Xml.XDocument.dll, - \netfx\System.Xml.XPath.XDocument.dll, - \netfx\System.Xml.XPath.dll, - \netfx\System.Xml.XmlDocument.dll, - \netfx\System.Xml.XmlSerializer.dll, - \netfx\netstandard.dll, - \store\x64\net8.0\microsoft.extensions.configuration.abstractions\9.0.0\lib\net9.0\Microsoft.Extensions.Configuration.Abstractions.dll, + \netfx\net462\Microsoft.Win32.Primitives.dll, + \netfx\net462\System.AppContext.dll, + \netfx\net462\System.Collections.Concurrent.dll, + \netfx\net462\System.Collections.NonGeneric.dll, + \netfx\net462\System.Collections.Specialized.dll, + \netfx\net462\System.Collections.dll, + \netfx\net462\System.ComponentModel.EventBasedAsync.dll, + \netfx\net462\System.ComponentModel.Primitives.dll, + \netfx\net462\System.ComponentModel.TypeConverter.dll, + \netfx\net462\System.ComponentModel.dll, + \netfx\net462\System.Console.dll, + \netfx\net462\System.Data.Common.dll, + \netfx\net462\System.Diagnostics.Contracts.dll, + \netfx\net462\System.Diagnostics.Debug.dll, + \netfx\net462\System.Diagnostics.FileVersionInfo.dll, + \netfx\net462\System.Diagnostics.Process.dll, + \netfx\net462\System.Diagnostics.StackTrace.dll, + \netfx\net462\System.Diagnostics.TextWriterTraceListener.dll, + \netfx\net462\System.Diagnostics.Tools.dll, + \netfx\net462\System.Diagnostics.TraceSource.dll, + \netfx\net462\System.Diagnostics.Tracing.dll, + \netfx\net462\System.Drawing.Primitives.dll, + \netfx\net462\System.Dynamic.Runtime.dll, + \netfx\net462\System.Globalization.Calendars.dll, + \netfx\net462\System.Globalization.Extensions.dll, + \netfx\net462\System.Globalization.dll, + \netfx\net462\System.IO.Compression.ZipFile.dll, + \netfx\net462\System.IO.Compression.dll, + \netfx\net462\System.IO.FileSystem.DriveInfo.dll, + \netfx\net462\System.IO.FileSystem.Primitives.dll, + \netfx\net462\System.IO.FileSystem.Watcher.dll, + \netfx\net462\System.IO.FileSystem.dll, + \netfx\net462\System.IO.IsolatedStorage.dll, + \netfx\net462\System.IO.MemoryMappedFiles.dll, + \netfx\net462\System.IO.Pipes.dll, + \netfx\net462\System.IO.UnmanagedMemoryStream.dll, + \netfx\net462\System.IO.dll, + \netfx\net462\System.Linq.Expressions.dll, + \netfx\net462\System.Linq.Parallel.dll, + \netfx\net462\System.Linq.Queryable.dll, + \netfx\net462\System.Linq.dll, + \netfx\net462\System.Net.Http.dll, + \netfx\net462\System.Net.NameResolution.dll, + \netfx\net462\System.Net.NetworkInformation.dll, + \netfx\net462\System.Net.Ping.dll, + \netfx\net462\System.Net.Primitives.dll, + \netfx\net462\System.Net.Requests.dll, + \netfx\net462\System.Net.Security.dll, + \netfx\net462\System.Net.Sockets.dll, + \netfx\net462\System.Net.WebHeaderCollection.dll, + \netfx\net462\System.Net.WebSockets.Client.dll, + \netfx\net462\System.Net.WebSockets.dll, + \netfx\net462\System.ObjectModel.dll, + \netfx\net462\System.Reflection.Extensions.dll, + \netfx\net462\System.Reflection.Primitives.dll, + \netfx\net462\System.Reflection.dll, + \netfx\net462\System.Resources.Reader.dll, + \netfx\net462\System.Resources.ResourceManager.dll, + \netfx\net462\System.Resources.Writer.dll, + \netfx\net462\System.Runtime.CompilerServices.VisualC.dll, + \netfx\net462\System.Runtime.Extensions.dll, + \netfx\net462\System.Runtime.Handles.dll, + \netfx\net462\System.Runtime.InteropServices.RuntimeInformation.dll, + \netfx\net462\System.Runtime.InteropServices.dll, + \netfx\net462\System.Runtime.Numerics.dll, + \netfx\net462\System.Runtime.Serialization.Formatters.dll, + \netfx\net462\System.Runtime.Serialization.Json.dll, + \netfx\net462\System.Runtime.Serialization.Primitives.dll, + \netfx\net462\System.Runtime.Serialization.Xml.dll, + \netfx\net462\System.Runtime.dll, + \netfx\net462\System.Security.Claims.dll, + \netfx\net462\System.Security.Cryptography.Algorithms.dll, + \netfx\net462\System.Security.Cryptography.Csp.dll, + \netfx\net462\System.Security.Cryptography.Encoding.dll, + \netfx\net462\System.Security.Cryptography.Primitives.dll, + \netfx\net462\System.Security.Cryptography.X509Certificates.dll, + \netfx\net462\System.Security.Principal.dll, + \netfx\net462\System.Security.SecureString.dll, + \netfx\net462\System.Text.Encoding.Extensions.dll, + \netfx\net462\System.Text.Encoding.dll, + \netfx\net462\System.Text.RegularExpressions.dll, + \netfx\net462\System.Threading.Overlapped.dll, + \netfx\net462\System.Threading.Tasks.Parallel.dll, + \netfx\net462\System.Threading.Tasks.dll, + \netfx\net462\System.Threading.Thread.dll, + \netfx\net462\System.Threading.ThreadPool.dll, + \netfx\net462\System.Threading.Timer.dll, + \netfx\net462\System.Threading.dll, + \netfx\net462\System.ValueTuple.dll, + \netfx\net462\System.Xml.ReaderWriter.dll, + \netfx\net462\System.Xml.XDocument.dll, + \netfx\net462\System.Xml.XPath.XDocument.dll, + \netfx\net462\System.Xml.XPath.dll, + \netfx\net462\System.Xml.XmlDocument.dll, + \netfx\net462\System.Xml.XmlSerializer.dll, + \netfx\net462\netstandard.dll, + \netfx\net471\System.Data.Common.dll, + \netfx\net471\System.Diagnostics.StackTrace.dll, + \netfx\net471\System.Diagnostics.Tracing.dll, + \netfx\net471\System.Globalization.Extensions.dll, + \netfx\net471\System.IO.Compression.dll, + \netfx\net471\System.Net.Http.dll, + \netfx\net471\System.Net.Sockets.dll, + \netfx\net471\System.Runtime.Serialization.Primitives.dll, + \netfx\net471\System.Security.Cryptography.Algorithms.dll, + \netfx\net471\System.Security.SecureString.dll, + \netfx\net471\System.Threading.Overlapped.dll, + \netfx\net471\System.Xml.XPath.XDocument.dll, + \netfx\net47\Microsoft.Win32.Primitives.dll.link, + \netfx\net47\System.AppContext.dll.link, + \netfx\net47\System.Collections.Concurrent.dll.link, + \netfx\net47\System.Collections.NonGeneric.dll.link, + \netfx\net47\System.Collections.Specialized.dll.link, + \netfx\net47\System.Collections.dll.link, + \netfx\net47\System.ComponentModel.EventBasedAsync.dll.link, + \netfx\net47\System.ComponentModel.Primitives.dll.link, + \netfx\net47\System.ComponentModel.TypeConverter.dll.link, + \netfx\net47\System.ComponentModel.dll.link, + \netfx\net47\System.Console.dll.link, + \netfx\net47\System.Data.Common.dll.link, + \netfx\net47\System.Diagnostics.Contracts.dll.link, + \netfx\net47\System.Diagnostics.Debug.dll.link, + \netfx\net47\System.Diagnostics.FileVersionInfo.dll.link, + \netfx\net47\System.Diagnostics.Process.dll.link, + \netfx\net47\System.Diagnostics.StackTrace.dll.link, + \netfx\net47\System.Diagnostics.TextWriterTraceListener.dll.link, + \netfx\net47\System.Diagnostics.Tools.dll.link, + \netfx\net47\System.Diagnostics.TraceSource.dll.link, + \netfx\net47\System.Diagnostics.Tracing.dll.link, + \netfx\net47\System.Drawing.Primitives.dll.link, + \netfx\net47\System.Dynamic.Runtime.dll.link, + \netfx\net47\System.Globalization.Calendars.dll.link, + \netfx\net47\System.Globalization.Extensions.dll.link, + \netfx\net47\System.Globalization.dll.link, + \netfx\net47\System.IO.Compression.ZipFile.dll.link, + \netfx\net47\System.IO.Compression.dll.link, + \netfx\net47\System.IO.FileSystem.DriveInfo.dll.link, + \netfx\net47\System.IO.FileSystem.Primitives.dll.link, + \netfx\net47\System.IO.FileSystem.Watcher.dll.link, + \netfx\net47\System.IO.FileSystem.dll.link, + \netfx\net47\System.IO.IsolatedStorage.dll.link, + \netfx\net47\System.IO.MemoryMappedFiles.dll.link, + \netfx\net47\System.IO.Pipes.dll.link, + \netfx\net47\System.IO.UnmanagedMemoryStream.dll.link, + \netfx\net47\System.IO.dll.link, + \netfx\net47\System.Linq.Expressions.dll.link, + \netfx\net47\System.Linq.Parallel.dll.link, + \netfx\net47\System.Linq.Queryable.dll.link, + \netfx\net47\System.Linq.dll.link, + \netfx\net47\System.Net.Http.dll.link, + \netfx\net47\System.Net.NameResolution.dll.link, + \netfx\net47\System.Net.NetworkInformation.dll.link, + \netfx\net47\System.Net.Ping.dll.link, + \netfx\net47\System.Net.Primitives.dll.link, + \netfx\net47\System.Net.Requests.dll.link, + \netfx\net47\System.Net.Security.dll.link, + \netfx\net47\System.Net.Sockets.dll.link, + \netfx\net47\System.Net.WebHeaderCollection.dll.link, + \netfx\net47\System.Net.WebSockets.Client.dll.link, + \netfx\net47\System.Net.WebSockets.dll.link, + \netfx\net47\System.ObjectModel.dll.link, + \netfx\net47\System.Reflection.Extensions.dll.link, + \netfx\net47\System.Reflection.Primitives.dll.link, + \netfx\net47\System.Reflection.dll.link, + \netfx\net47\System.Resources.Reader.dll.link, + \netfx\net47\System.Resources.ResourceManager.dll.link, + \netfx\net47\System.Resources.Writer.dll.link, + \netfx\net47\System.Runtime.CompilerServices.VisualC.dll.link, + \netfx\net47\System.Runtime.Extensions.dll.link, + \netfx\net47\System.Runtime.Handles.dll.link, + \netfx\net47\System.Runtime.InteropServices.RuntimeInformation.dll, + \netfx\net47\System.Runtime.InteropServices.dll.link, + \netfx\net47\System.Runtime.Numerics.dll.link, + \netfx\net47\System.Runtime.Serialization.Formatters.dll.link, + \netfx\net47\System.Runtime.Serialization.Json.dll.link, + \netfx\net47\System.Runtime.Serialization.Primitives.dll.link, + \netfx\net47\System.Runtime.Serialization.Xml.dll.link, + \netfx\net47\System.Runtime.dll.link, + \netfx\net47\System.Security.Claims.dll.link, + \netfx\net47\System.Security.Cryptography.Algorithms.dll, + \netfx\net47\System.Security.Cryptography.Csp.dll.link, + \netfx\net47\System.Security.Cryptography.Encoding.dll.link, + \netfx\net47\System.Security.Cryptography.Primitives.dll.link, + \netfx\net47\System.Security.Cryptography.X509Certificates.dll.link, + \netfx\net47\System.Security.Principal.dll.link, + \netfx\net47\System.Security.SecureString.dll.link, + \netfx\net47\System.Text.Encoding.Extensions.dll.link, + \netfx\net47\System.Text.Encoding.dll.link, + \netfx\net47\System.Text.RegularExpressions.dll.link, + \netfx\net47\System.Threading.Overlapped.dll.link, + \netfx\net47\System.Threading.Tasks.Parallel.dll.link, + \netfx\net47\System.Threading.Tasks.dll.link, + \netfx\net47\System.Threading.Thread.dll.link, + \netfx\net47\System.Threading.ThreadPool.dll.link, + \netfx\net47\System.Threading.Timer.dll.link, + \netfx\net47\System.Threading.dll.link, + \netfx\net47\System.ValueTuple.dll, + \netfx\net47\System.Xml.ReaderWriter.dll.link, + \netfx\net47\System.Xml.XDocument.dll.link, + \netfx\net47\System.Xml.XPath.XDocument.dll.link, + \netfx\net47\System.Xml.XPath.dll.link, + \netfx\net47\System.Xml.XmlDocument.dll.link, + \netfx\net47\System.Xml.XmlSerializer.dll.link, + \netfx\net47\netstandard.dll.link, \store\x64\net8.0\microsoft.extensions.configuration.abstractions\9.0.0\lib\net9.0\Microsoft.Extensions.Configuration.Abstractions.dll, \store\x64\net8.0\microsoft.extensions.configuration.binder\9.0.0\lib\net9.0\Microsoft.Extensions.Configuration.Binder.dll, \store\x64\net8.0\microsoft.extensions.configuration\9.0.0\lib\net9.0\Microsoft.Extensions.Configuration.dll, \store\x64\net8.0\microsoft.extensions.dependencyinjection.abstractions\9.0.0\lib\net9.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll, diff --git a/test/test-applications/integrations/dependency-libs/TestLibrary.InstrumentationTarget/TestLibrary.InstrumentationTarget.csproj b/test/test-applications/integrations/dependency-libs/TestLibrary.InstrumentationTarget/TestLibrary.InstrumentationTarget.csproj index 5c1a66f03a..1e12728fea 100644 --- a/test/test-applications/integrations/dependency-libs/TestLibrary.InstrumentationTarget/TestLibrary.InstrumentationTarget.csproj +++ b/test/test-applications/integrations/dependency-libs/TestLibrary.InstrumentationTarget/TestLibrary.InstrumentationTarget.csproj @@ -1,4 +1,4 @@ - + Library @@ -10,4 +10,10 @@ + + + + + + From db32846d855f2f841cc429ee0bbe0050195b48f0 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Tue, 7 Oct 2025 19:55:06 -0700 Subject: [PATCH 08/30] Bootstrap test fix (explicit reference) --- ...elemetry.AutoInstrumentation.Bootstrapping.Tests.csproj | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests.csproj b/test/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests.csproj index b7f31c5dca..58142d679a 100644 --- a/test/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests.csproj +++ b/test/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests.csproj @@ -8,4 +8,11 @@ + + + + + + + From ce49362d381a28c3c588fc211946355e971a29f1 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Tue, 7 Oct 2025 20:23:12 -0700 Subject: [PATCH 09/30] Test fix (explicit reference) --- .../OpenTelemetry.AutoInstrumentation.Tests.csproj | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/OpenTelemetry.AutoInstrumentation.Tests/OpenTelemetry.AutoInstrumentation.Tests.csproj b/test/OpenTelemetry.AutoInstrumentation.Tests/OpenTelemetry.AutoInstrumentation.Tests.csproj index e34a9eb301..05df53c8fb 100644 --- a/test/OpenTelemetry.AutoInstrumentation.Tests/OpenTelemetry.AutoInstrumentation.Tests.csproj +++ b/test/OpenTelemetry.AutoInstrumentation.Tests/OpenTelemetry.AutoInstrumentation.Tests.csproj @@ -11,6 +11,13 @@ + + + + + + + PreserveNewest From 3c38ccc6a77efa08242112b8c8b96e04e24b44ca Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Tue, 7 Oct 2025 21:01:38 -0700 Subject: [PATCH 10/30] Verified file structure fixed --- ...DistributionStructure_windows.verified.txt | 43 +------------------ 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/test/IntegrationTests/BuildTests.DistributionStructure_windows.verified.txt b/test/IntegrationTests/BuildTests.DistributionStructure_windows.verified.txt index 942b70bbfc..d9c204f211 100644 --- a/test/IntegrationTests/BuildTests.DistributionStructure_windows.verified.txt +++ b/test/IntegrationTests/BuildTests.DistributionStructure_windows.verified.txt @@ -56,46 +56,6 @@ \netfx\Microsoft.Extensions.Options.ConfigurationExtensions.dll, \netfx\Microsoft.Extensions.Options.dll, \netfx\Microsoft.Extensions.Primitives.dll, - \netfx\Microsoft.Win32.Primitives.dll, - \netfx\OpenTelemetry.Api.ProviderBuilderExtensions.dll, - \netfx\OpenTelemetry.Api.dll, - \netfx\OpenTelemetry.AutoInstrumentation.dll, - \netfx\OpenTelemetry.AutoInstrumentation.pdb, - \netfx\OpenTelemetry.Exporter.Console.dll, - \netfx\OpenTelemetry.Exporter.OpenTelemetryProtocol.dll, - \netfx\OpenTelemetry.Exporter.Prometheus.HttpListener.dll, - \netfx\OpenTelemetry.Exporter.Zipkin.dll, - \netfx\OpenTelemetry.Extensions.Propagators.dll, - \netfx\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.dll, - \netfx\OpenTelemetry.Instrumentation.AspNet.dll, - \netfx\OpenTelemetry.Instrumentation.GrpcNetClient.dll, - \netfx\OpenTelemetry.Instrumentation.Http.dll, - \netfx\OpenTelemetry.Instrumentation.Process.dll, - \netfx\OpenTelemetry.Instrumentation.Quartz.dll, - \netfx\OpenTelemetry.Instrumentation.Runtime.dll, - \netfx\OpenTelemetry.Instrumentation.SqlClient.dll, - \netfx\OpenTelemetry.Instrumentation.Wcf.dll, - \netfx\OpenTelemetry.Resources.Azure.dll, - \netfx\OpenTelemetry.Resources.Host.dll, - \netfx\OpenTelemetry.Resources.OperatingSystem.dll, - \netfx\OpenTelemetry.Resources.Process.dll, - \netfx\OpenTelemetry.Resources.ProcessRuntime.dll, - \netfx\OpenTelemetry.Shims.OpenTracing.dll, - \netfx\OpenTelemetry.dll, - \netfx\OpenTracing.dll, - \netfx\Microsoft.Bcl.AsyncInterfaces.dll, - \netfx\Microsoft.Extensions.Configuration.Abstractions.dll, - \netfx\Microsoft.Extensions.Configuration.Binder.dll, - \netfx\Microsoft.Extensions.Configuration.dll, - \netfx\Microsoft.Extensions.DependencyInjection.Abstractions.dll, - \netfx\Microsoft.Extensions.DependencyInjection.dll, - \netfx\Microsoft.Extensions.Diagnostics.Abstractions.dll, - \netfx\Microsoft.Extensions.Logging.Abstractions.dll, - \netfx\Microsoft.Extensions.Logging.Configuration.dll, - \netfx\Microsoft.Extensions.Logging.dll, - \netfx\Microsoft.Extensions.Options.ConfigurationExtensions.dll, - \netfx\Microsoft.Extensions.Options.dll, - \netfx\Microsoft.Extensions.Primitives.dll, \netfx\OpenTelemetry.Api.ProviderBuilderExtensions.dll, \netfx\OpenTelemetry.Api.dll, \netfx\OpenTelemetry.AutoInstrumentation.dll, @@ -334,7 +294,8 @@ \netfx\net47\System.Xml.XPath.dll.link, \netfx\net47\System.Xml.XmlDocument.dll.link, \netfx\net47\System.Xml.XmlSerializer.dll.link, - \netfx\net47\netstandard.dll.link, \store\x64\net8.0\microsoft.extensions.configuration.abstractions\9.0.0\lib\net9.0\Microsoft.Extensions.Configuration.Abstractions.dll, + \netfx\net47\netstandard.dll.link, + \store\x64\net8.0\microsoft.extensions.configuration.abstractions\9.0.0\lib\net9.0\Microsoft.Extensions.Configuration.Abstractions.dll, \store\x64\net8.0\microsoft.extensions.configuration.binder\9.0.0\lib\net9.0\Microsoft.Extensions.Configuration.Binder.dll, \store\x64\net8.0\microsoft.extensions.configuration\9.0.0\lib\net9.0\Microsoft.Extensions.Configuration.dll, \store\x64\net8.0\microsoft.extensions.dependencyinjection.abstractions\9.0.0\lib\net9.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll, From 98f034d8d1e4d07af2c4a91cd6a39675765d3ac7 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Tue, 7 Oct 2025 22:29:08 -0700 Subject: [PATCH 11/30] Integration test fix (explicit reference) --- test/IntegrationTests/IntegrationTests.csproj | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/IntegrationTests/IntegrationTests.csproj b/test/IntegrationTests/IntegrationTests.csproj index e74ab4b9a9..35df1d9270 100644 --- a/test/IntegrationTests/IntegrationTests.csproj +++ b/test/IntegrationTests/IntegrationTests.csproj @@ -22,6 +22,13 @@ + + + + + + + From fad337eff634a0f6a853f47aaa5360385be01895 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Wed, 8 Oct 2025 00:08:49 -0700 Subject: [PATCH 12/30] Preserve empty folders with "_._" file --- build/Build.Steps.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build/Build.Steps.cs b/build/Build.Steps.cs index 74356e7d03..dd40cc6144 100644 --- a/build/Build.Steps.cs +++ b/build/Build.Steps.cs @@ -400,6 +400,7 @@ bool FilesAreEqual(string filePath1, string filePath2) if (IsWin) { (TracerHomeDirectory / "netfx").GlobFiles("**/*.link").DeleteFiles(); + (TracerHomeDirectory / "netfx").GlobFiles("**/_._").DeleteFiles(); var latestFramework = TargetFramework.NetFramework.Last(); (TracerHomeDirectory / "netfx" / latestFramework).GlobFiles("*.*") .Where(file => TargetFramework.NetFramework.TakeUntil(older => older == latestFramework) @@ -435,6 +436,16 @@ bool FilesAreEqual(string filePath1, string filePath2) } ); } + + // Create placeholder file for empty directories + foreach (var currentFramework in TargetFramework.NetFramework) + { + if ((TracerHomeDirectory / "netfx" / currentFramework).GlobFiles("*.*").Count == 0) + { + (TracerHomeDirectory / "netfx" / currentFramework / "_._") + .WriteAllText(string.Empty, Encoding.ASCII, false); + } + } } } From 96cfbecf39ffaff3fff2fff543141803d91bf301 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Wed, 8 Oct 2025 08:06:02 -0700 Subject: [PATCH 13/30] Include _._ in verified structure. --- .../BuildTests.DistributionStructure_windows.verified.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/IntegrationTests/BuildTests.DistributionStructure_windows.verified.txt b/test/IntegrationTests/BuildTests.DistributionStructure_windows.verified.txt index d9c204f211..b44dd7222f 100644 --- a/test/IntegrationTests/BuildTests.DistributionStructure_windows.verified.txt +++ b/test/IntegrationTests/BuildTests.DistributionStructure_windows.verified.txt @@ -199,6 +199,7 @@ \netfx\net471\System.Security.SecureString.dll, \netfx\net471\System.Threading.Overlapped.dll, \netfx\net471\System.Xml.XPath.XDocument.dll, + \netfx\net472\_._, \netfx\net47\Microsoft.Win32.Primitives.dll.link, \netfx\net47\System.AppContext.dll.link, \netfx\net47\System.Collections.Concurrent.dll.link, From 3b2b3fe20513e3bdca34ab7a2d1e74c9ba0b01d2 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Thu, 9 Oct 2025 19:38:16 -0700 Subject: [PATCH 14/30] Fixed assembly redirection table generation / selection --- build/AssemblyRedirectionSourceGenerator.cs | 6 +- .../cor_profiler.cpp | 23 ++--- .../cor_profiler.h | 2 +- .../netfx_assembly_redirection.h | 92 +++++++++++++++++++ 4 files changed, 104 insertions(+), 19 deletions(-) diff --git a/build/AssemblyRedirectionSourceGenerator.cs b/build/AssemblyRedirectionSourceGenerator.cs index 7368b8868c..35a7860393 100644 --- a/build/AssemblyRedirectionSourceGenerator.cs +++ b/build/AssemblyRedirectionSourceGenerator.cs @@ -1,4 +1,3 @@ -using System.Collections; using System.Text; using System.Text.RegularExpressions; using Mono.Cecil; @@ -67,7 +66,6 @@ void Process(string fileName, int? framework) foreach (var fileName in Directory.EnumerateFiles(assembliesFolderPath)) { Process(fileName, null); - } foreach (var fx in folders) @@ -75,9 +73,9 @@ void Process(string fileName, int? framework) foreach (var fileName in Directory.EnumerateFiles(fx.Value)) { var filenameToProcess = fileName; - if (Path.GetExtension(fileName) == "link") + if (Path.GetExtension(fileName) == ".link") { - filenameToProcess = Path.Combine(generatedFilePath, File.ReadAllText(fileName), + filenameToProcess = Path.Combine(assembliesFolderPath, File.ReadAllText(fileName), Path.GetFileNameWithoutExtension(fileName)); } diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp index 2718da19bc..228987abe9 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp +++ b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp @@ -125,12 +125,6 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Initialize(IUnknown* cor_profiler_info_un // code is ready to get runtime information runtime_information_ = GetRuntimeInformation(this->info_); -#ifdef _WIN32 - if (runtime_information_.is_desktop()) - { - DetectFrameworkVersion(); - } -#endif if (Logger::IsDebugEnabled()) { @@ -160,6 +154,7 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Initialize(IUnknown* cor_profiler_info_un if (runtime_information_.is_desktop() && IsNetFxAssemblyRedirectionEnabled()) { InitNetFxAssemblyRedirectsMap(); + DetectFrameworkVersionTableForRedirectsMap(); } #endif @@ -3656,7 +3651,7 @@ HRESULT STDMETHODCALLTYPE CorProfiler::EventPipeEventDelivered(EVENTPIPE_PROVIDE } #ifdef _WIN32 -void CorProfiler::DetectFrameworkVersion() +void CorProfiler::DetectFrameworkVersionTableForRedirectsMap() { // Default to 4.6.2 (462) if detection fails int frameworkVersion = 462; @@ -3667,7 +3662,7 @@ void CorProfiler::DetectFrameworkVersion() if (result != ERROR_SUCCESS) { - Logger::Warn("DetectFrameworkVersion: Failed to open registry key, using default version 462"); + Logger::Warn("DetectFrameworkVersionTableForRedirectsMap: Failed to open registry key, using default version 462"); } else { @@ -3682,7 +3677,7 @@ void CorProfiler::DetectFrameworkVersion() if (result != ERROR_SUCCESS || valueType != REG_DWORD) { - Logger::Warn("DetectFrameworkVersion: Failed to read Release value, using default version 462"); + Logger::Warn("DetectFrameworkVersionTableForRedirectsMap: Failed to read Release value, using default version 462"); } else { @@ -3716,11 +3711,11 @@ void CorProfiler::DetectFrameworkVersion() } else { - Logger::Warn("DetectFrameworkVersion: Old .Net Framework detected, use 462 as fallback"); + Logger::Warn("DetectFrameworkVersionTableForRedirectsMap: Old .Net Framework detected, use 462 as fallback"); } } - Logger::Debug("DetectFrameworkVersion: Detected .NET Framework version ", frameworkVersion, + Logger::Debug("DetectFrameworkVersionTableForRedirectsMap: Detected .NET Framework version ", frameworkVersion, " (Release: ", releaseValue, ")"); } @@ -3736,12 +3731,12 @@ void CorProfiler::DetectFrameworkVersion() if (selectedKey != 0) { - Logger::Warn("DetectFrameworkVersion: No assembly redirection tables found. Assembly version redirecting will " - "be disabled."); + Logger::Debug("DetectFrameworkVersionTableForRedirectsMap: Use assembly redirection table for ", selectedKey); } else { - Logger::Debug("DetectFrameworkVersion: Use assembly redirection table for ", selectedKey); + Logger::Warn("DetectFrameworkVersionTableForRedirectsMap: No assembly redirection tables found. Assembly version redirecting will " + "be disabled."); } } #endif diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.h b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.h index a9f0fab396..60485718c4 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.h +++ b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.h @@ -113,7 +113,7 @@ class CorProfiler : public CorProfilerBase mdMethodDef* patch_app_domain_setup_method); HRESULT ModifyAppDomainCreate(const ModuleID module_id, mdMethodDef patch_app_domain_setup_method); HRESULT AddIISPreStartInitFlags(const ModuleID module_id, const mdToken function_token); - void DetectFrameworkVersion(); + void DetectFrameworkVersionTableForRedirectsMap(); #endif // diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/netfx_assembly_redirection.h b/src/OpenTelemetry.AutoInstrumentation.Native/netfx_assembly_redirection.h index 4507cf68ba..f7823a67ec 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Native/netfx_assembly_redirection.h +++ b/src/OpenTelemetry.AutoInstrumentation.Native/netfx_assembly_redirection.h @@ -176,6 +176,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap() { L"Microsoft.Extensions.Options", {9, 0, 0, 8} }, { L"Microsoft.Extensions.Options.ConfigurationExtensions", {9, 0, 0, 8} }, { L"Microsoft.Extensions.Primitives", {9, 0, 0, 8} }, + { L"Microsoft.Win32.Primitives", {4, 0, 3, 0} }, { L"OpenTelemetry", {1, 0, 0, 0} }, { L"OpenTelemetry.Api", {1, 0, 0, 0} }, { L"OpenTelemetry.Api.ProviderBuilderExtensions", {1, 0, 0, 0} }, @@ -201,18 +202,109 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap() { L"OpenTelemetry.Resources.ProcessRuntime", {1, 12, 0, 506} }, { L"OpenTelemetry.Shims.OpenTracing", {1, 0, 0, 0} }, { L"OpenTracing", {0, 12, 1, 0} }, + { L"System.AppContext", {4, 1, 2, 0} }, { L"System.Buffers", {4, 0, 5, 0} }, + { L"System.Collections", {4, 0, 11, 0} }, + { L"System.Collections.Concurrent", {4, 0, 11, 0} }, + { L"System.Collections.NonGeneric", {4, 0, 3, 0} }, + { L"System.Collections.Specialized", {4, 0, 3, 0} }, + { L"System.ComponentModel", {4, 0, 1, 0} }, + { L"System.ComponentModel.EventBasedAsync", {4, 0, 11, 0} }, + { L"System.ComponentModel.Primitives", {4, 1, 2, 0} }, + { L"System.ComponentModel.TypeConverter", {4, 1, 2, 0} }, + { L"System.Console", {4, 0, 2, 0} }, + { L"System.Data.Common", {4, 2, 0, 0} }, + { L"System.Diagnostics.Contracts", {4, 0, 1, 0} }, + { L"System.Diagnostics.Debug", {4, 0, 11, 0} }, { L"System.Diagnostics.DiagnosticSource", {9, 0, 0, 8} }, + { L"System.Diagnostics.FileVersionInfo", {4, 0, 2, 0} }, + { L"System.Diagnostics.Process", {4, 1, 2, 0} }, + { L"System.Diagnostics.StackTrace", {4, 1, 0, 0} }, + { L"System.Diagnostics.TextWriterTraceListener", {4, 0, 2, 0} }, + { L"System.Diagnostics.Tools", {4, 0, 1, 0} }, + { L"System.Diagnostics.TraceSource", {4, 0, 2, 0} }, + { L"System.Diagnostics.Tracing", {4, 2, 0, 0} }, + { L"System.Drawing.Primitives", {4, 0, 2, 0} }, + { L"System.Dynamic.Runtime", {4, 0, 11, 0} }, + { L"System.Globalization", {4, 0, 11, 0} }, + { L"System.Globalization.Calendars", {4, 0, 3, 0} }, + { L"System.Globalization.Extensions", {4, 1, 0, 0} }, + { L"System.IO", {4, 1, 2, 0} }, + { L"System.IO.Compression", {4, 2, 0, 0} }, + { L"System.IO.Compression.ZipFile", {4, 0, 3, 0} }, + { L"System.IO.FileSystem", {4, 0, 3, 0} }, + { L"System.IO.FileSystem.DriveInfo", {4, 0, 2, 0} }, + { L"System.IO.FileSystem.Primitives", {4, 0, 3, 0} }, + { L"System.IO.FileSystem.Watcher", {4, 0, 2, 0} }, + { L"System.IO.IsolatedStorage", {4, 0, 2, 0} }, + { L"System.IO.MemoryMappedFiles", {4, 0, 2, 0} }, { L"System.IO.Pipelines", {9, 0, 0, 8} }, + { L"System.IO.Pipes", {4, 0, 2, 0} }, + { L"System.IO.UnmanagedMemoryStream", {4, 0, 3, 0} }, + { L"System.Linq", {4, 1, 2, 0} }, + { L"System.Linq.Expressions", {4, 1, 2, 0} }, + { L"System.Linq.Parallel", {4, 0, 1, 0} }, + { L"System.Linq.Queryable", {4, 0, 1, 0} }, { L"System.Memory", {4, 0, 5, 0} }, + { L"System.Net.Http", {4, 2, 0, 0} }, + { L"System.Net.NameResolution", {4, 0, 2, 0} }, + { L"System.Net.NetworkInformation", {4, 1, 2, 0} }, + { L"System.Net.Ping", {4, 0, 2, 0} }, + { L"System.Net.Primitives", {4, 0, 11, 0} }, + { L"System.Net.Requests", {4, 0, 11, 0} }, + { L"System.Net.Security", {4, 0, 2, 0} }, + { L"System.Net.Sockets", {4, 2, 0, 0} }, + { L"System.Net.WebHeaderCollection", {4, 0, 1, 0} }, + { L"System.Net.WebSockets", {4, 0, 2, 0} }, + { L"System.Net.WebSockets.Client", {4, 0, 2, 0} }, { L"System.Numerics.Vectors", {4, 1, 6, 0} }, + { L"System.ObjectModel", {4, 0, 11, 0} }, + { L"System.Reflection", {4, 1, 2, 0} }, + { L"System.Reflection.Extensions", {4, 0, 1, 0} }, + { L"System.Reflection.Primitives", {4, 0, 1, 0} }, + { L"System.Resources.Reader", {4, 0, 2, 0} }, + { L"System.Resources.ResourceManager", {4, 0, 1, 0} }, + { L"System.Resources.Writer", {4, 0, 2, 0} }, + { L"System.Runtime", {4, 1, 2, 0} }, { L"System.Runtime.CompilerServices.Unsafe", {6, 0, 3, 0} }, + { L"System.Runtime.CompilerServices.VisualC", {4, 0, 2, 0} }, + { L"System.Runtime.Extensions", {4, 1, 2, 0} }, + { L"System.Runtime.Handles", {4, 0, 1, 0} }, + { L"System.Runtime.InteropServices", {4, 1, 2, 0} }, { L"System.Runtime.InteropServices.RuntimeInformation", {4, 0, 2, 0} }, + { L"System.Runtime.Numerics", {4, 0, 1, 0} }, + { L"System.Runtime.Serialization.Formatters", {4, 0, 2, 0} }, + { L"System.Runtime.Serialization.Json", {4, 0, 1, 0} }, + { L"System.Runtime.Serialization.Primitives", {4, 2, 0, 0} }, + { L"System.Runtime.Serialization.Xml", {4, 1, 3, 0} }, + { L"System.Security.Claims", {4, 0, 3, 0} }, { L"System.Security.Cryptography.Algorithms", {4, 3, 0, 0} }, + { L"System.Security.Cryptography.Csp", {4, 0, 2, 0} }, + { L"System.Security.Cryptography.Encoding", {4, 0, 2, 0} }, + { L"System.Security.Cryptography.Primitives", {4, 0, 2, 0} }, + { L"System.Security.Cryptography.X509Certificates", {4, 1, 2, 0} }, + { L"System.Security.Principal", {4, 0, 1, 0} }, + { L"System.Security.SecureString", {4, 1, 0, 0} }, + { L"System.Text.Encoding", {4, 0, 11, 0} }, + { L"System.Text.Encoding.Extensions", {4, 0, 11, 0} }, { L"System.Text.Encodings.Web", {9, 0, 0, 8} }, { L"System.Text.Json", {9, 0, 0, 8} }, + { L"System.Text.RegularExpressions", {4, 1, 1, 0} }, + { L"System.Threading", {4, 0, 11, 0} }, + { L"System.Threading.Overlapped", {4, 1, 0, 0} }, + { L"System.Threading.Tasks", {4, 0, 11, 0} }, { L"System.Threading.Tasks.Extensions", {4, 2, 4, 0} }, + { L"System.Threading.Tasks.Parallel", {4, 0, 1, 0} }, + { L"System.Threading.Thread", {4, 0, 2, 0} }, + { L"System.Threading.ThreadPool", {4, 0, 12, 0} }, + { L"System.Threading.Timer", {4, 0, 1, 0} }, { L"System.ValueTuple", {4, 0, 5, 0} }, + { L"System.Xml.ReaderWriter", {4, 1, 1, 0} }, + { L"System.Xml.XDocument", {4, 0, 11, 0} }, + { L"System.Xml.XmlDocument", {4, 0, 3, 0} }, + { L"System.Xml.XmlSerializer", {4, 0, 11, 0} }, + { L"System.Xml.XPath", {4, 0, 3, 0} }, + { L"System.Xml.XPath.XDocument", {4, 1, 0, 0} }, }}, { 471, { { L"Microsoft.Bcl.AsyncInterfaces", {9, 0, 0, 8} }, From 08293415b015ec989bb882518784d7c75e1dafc9 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Thu, 9 Oct 2025 20:34:00 -0700 Subject: [PATCH 15/30] Format fix --- .../cor_profiler.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp index 228987abe9..d7cfd57507 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp +++ b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp @@ -3662,7 +3662,8 @@ void CorProfiler::DetectFrameworkVersionTableForRedirectsMap() if (result != ERROR_SUCCESS) { - Logger::Warn("DetectFrameworkVersionTableForRedirectsMap: Failed to open registry key, using default version 462"); + Logger::Warn( + "DetectFrameworkVersionTableForRedirectsMap: Failed to open registry key, using default version 462"); } else { @@ -3677,7 +3678,8 @@ void CorProfiler::DetectFrameworkVersionTableForRedirectsMap() if (result != ERROR_SUCCESS || valueType != REG_DWORD) { - Logger::Warn("DetectFrameworkVersionTableForRedirectsMap: Failed to read Release value, using default version 462"); + Logger::Warn( + "DetectFrameworkVersionTableForRedirectsMap: Failed to read Release value, using default version 462"); } else { @@ -3711,7 +3713,8 @@ void CorProfiler::DetectFrameworkVersionTableForRedirectsMap() } else { - Logger::Warn("DetectFrameworkVersionTableForRedirectsMap: Old .Net Framework detected, use 462 as fallback"); + Logger::Warn( + "DetectFrameworkVersionTableForRedirectsMap: Old .Net Framework detected, use 462 as fallback"); } } @@ -3735,8 +3738,8 @@ void CorProfiler::DetectFrameworkVersionTableForRedirectsMap() } else { - Logger::Warn("DetectFrameworkVersionTableForRedirectsMap: No assembly redirection tables found. Assembly version redirecting will " - "be disabled."); + Logger::Warn("DetectFrameworkVersionTableForRedirectsMap: No assembly redirection tables found. Assembly " + "version redirecting will be disabled."); } } #endif From 200839eeb05a387d5ed92ad274e48f6397caece1 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Sat, 11 Oct 2025 19:27:16 -0700 Subject: [PATCH 16/30] Corrected build/test machine GAC install/uninstall --- build/Build.Steps.Windows.cs | 9 ++++++++- build/TargetFramework.cs | 1 + tools/GacInstallTool/Program.cs | 14 +++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/build/Build.Steps.Windows.cs b/build/Build.Steps.Windows.cs index b02ea36a73..8e9d87a783 100644 --- a/build/Build.Steps.Windows.cs +++ b/build/Build.Steps.Windows.cs @@ -280,9 +280,16 @@ private void RunNetFxGacOperation(string operation) throw new InvalidOperationException("This target must be run on Windows as Administrator."); } - var netFxAssembliesFolder = TracerHomeDirectory / MapToFolderOutput(TargetFramework.NET462); + // We assume that dev machine running test has .Net Framework not older than TargetFrameworksNetFx.Last() + var netFxCommonAssembliesFolder = TracerHomeDirectory / MapToFolderOutput(TargetFrameworksNetFx.Last()); + var netFxAssembliesFolder = TracerHomeDirectory / MapToFolderOutputNetFx(TargetFrameworksNetFx.Last()); var installTool = Solution.GetProjectByName(Projects.Tools.GacInstallTool); + DotNetRun(s => s + .SetProjectFile(installTool) + .SetConfiguration(BuildConfiguration) + .SetApplicationArguments(operation, netFxCommonAssembliesFolder)); + DotNetRun(s => s .SetProjectFile(installTool) .SetConfiguration(BuildConfiguration) diff --git a/build/TargetFramework.cs b/build/TargetFramework.cs index a14b9b4ee7..f40e1a5bbb 100644 --- a/build/TargetFramework.cs +++ b/build/TargetFramework.cs @@ -16,6 +16,7 @@ public class TargetFramework : Enumeration public static readonly TargetFramework NET8_0 = new() { Value = "net8.0" }; public static readonly TargetFramework NET9_0 = new() { Value = "net9.0" }; + // should be in version order public static readonly TargetFramework[] NetFramework = { NET462, NET47, NET471, NET472, NET472 }; diff --git a/tools/GacInstallTool/Program.cs b/tools/GacInstallTool/Program.cs index 99775fb73b..2af7bc2c3a 100644 --- a/tools/GacInstallTool/Program.cs +++ b/tools/GacInstallTool/Program.cs @@ -30,7 +30,13 @@ public static void Main(string[] args) var install = flag == InstallFlag; var publisher = new System.EnterpriseServices.Internal.Publish(); - var files = Directory.GetFiles(dir, "*.dll"); + var files = Directory.GetFiles(dir, "*.dll").ToList(); + var links = Directory.GetFiles(dir, "*.link"); + foreach (var link in links) + { + var linkTarget = File.ReadAllText(link); + files.Add(Path.Combine(dir, "..", linkTarget, Path.GetFileNameWithoutExtension(link))); + } foreach (var file in files) { @@ -46,9 +52,11 @@ public static void Main(string[] args) } } + + var resultText = install - ? $"Success: Installed {files.Length} libraries in the GAC." - : $"Success: Uninstalled {files.Length} libraries from the GAC."; + ? $"Success: Installed {files.Count} libraries in the GAC." + : $"Success: Uninstalled {files.Count} libraries from the GAC."; Console.WriteLine(resultText); } } From 69075e0ed0a29dbefa6b5b403805856b115c48eb Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Sat, 11 Oct 2025 20:15:47 -0700 Subject: [PATCH 17/30] Fixed empty lines --- tools/GacInstallTool/Program.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/GacInstallTool/Program.cs b/tools/GacInstallTool/Program.cs index 2af7bc2c3a..f9160e244d 100644 --- a/tools/GacInstallTool/Program.cs +++ b/tools/GacInstallTool/Program.cs @@ -52,8 +52,6 @@ public static void Main(string[] args) } } - - var resultText = install ? $"Success: Installed {files.Count} libraries in the GAC." : $"Success: Uninstalled {files.Count} libraries from the GAC."; From ba9f1ce6dade3e0c60e608dc3e2c38d604096e17 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Wed, 15 Oct 2025 10:35:50 -0700 Subject: [PATCH 18/30] Moved transitive dependencies pinning to OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework It partially resolve #4520 by making both NuGet and zip version of OpenTelemetry.AutoInstrumentation reference same versions of dependencies, but not change assembly redirections or versions included in zip. Switched DependencyListGenerator to use dotnet list package internally. Validate defined PackageVersion through MsBuild evaluation. --- build/Build.Steps.Windows.cs | 21 +-- src/Directory.Packages.props | 111 +--------------- .../Directory.Packages.props | 124 ++++++++++++++++++ test/IntegrationTests/IntegrationTests.csproj | 7 - ...Instrumentation.Bootstrapping.Tests.csproj | 7 - ...Telemetry.AutoInstrumentation.Tests.csproj | 7 - .../Exceptions/CommandValidationException.cs | 14 -- .../DotNetOutdated/Models/Dependency.cs | 29 +--- .../DotNetOutdated/Models/PackageListModel.cs | 51 +++++++ .../DotNetOutdated/Models/Project.cs | 20 +-- .../DotNetOutdated/Models/TargetFramework.cs | 11 +- .../Services/DependencyGraphService.cs | 49 ------- .../Services/DotNetPackageListService.cs | 26 ++++ .../Services/ProjectAnalysisService.cs | 123 ++++++----------- tools/DependencyListGenerator/Generator.cs | 23 ++-- 15 files changed, 274 insertions(+), 349 deletions(-) create mode 100644 src/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework/Directory.Packages.props delete mode 100644 tools/DependencyListGenerator/DotNetOutdated/Exceptions/CommandValidationException.cs create mode 100644 tools/DependencyListGenerator/DotNetOutdated/Models/PackageListModel.cs delete mode 100644 tools/DependencyListGenerator/DotNetOutdated/Services/DependencyGraphService.cs create mode 100644 tools/DependencyListGenerator/DotNetOutdated/Services/DotNetPackageListService.cs diff --git a/build/Build.Steps.Windows.cs b/build/Build.Steps.Windows.cs index 8e9d87a783..0ad47fcfa2 100644 --- a/build/Build.Steps.Windows.cs +++ b/build/Build.Steps.Windows.cs @@ -1,5 +1,6 @@ using DependencyListGenerator; using Extensions; +using NuGet.Versioning; using Nuke.Common; using Nuke.Common.IO; using Nuke.Common.ProjectModel; @@ -213,14 +214,19 @@ void BuildDockerImage(Project project, params string[] targets) DotNetRestore(s => s.SetProjectFile(targetProject)); var project = targetProject.GetMSBuildProject(); - var packages = Solution.Directory / "src" / "Directory.Packages.props"; + var deps = Generator.EnumerateDependencies(project.FullPath); + var packages = Solution.Directory / "src" / Projects.AutoInstrumentationNetFxAssemblies / "Directory.Packages.props"; + var packagesProject = ProjectModelTasks.ParseProject(packages); - foreach (var framework in TargetFramework.NetFramework) + foreach (var framework in targetProject.GetTargetFrameworks() ?? []) { var label = $"Transient dependencies auto-generated by {nameof(GenerateNetFxTransientDependencies)} for {framework}"; - var packagesProject = ProjectModelTasks.ParseProject(packages); + var projectForTfm = targetProject.GetMSBuildProject(targetFramework: framework); + var definedVersions = projectForTfm + .Items.Where(it => it.ItemType == "PackageVersion").ToDictionary(item => item.EvaluatedInclude, item => item.GetMetadata("Version")); + var versionGroup = packagesProject.Xml.ItemGroups.FirstOrDefault(x => x.Label == label); if (versionGroup == null) { @@ -229,18 +235,17 @@ void BuildDockerImage(Project project, params string[] targets) versionGroup.Condition = $" '$(TargetFramework)' == '{framework}' "; } - var deps = Generator.EnumerateDependencies(project.FullPath, framework.GetVersion()); - foreach (var item in deps) + foreach (var item in deps[framework]) { - if (!versionGroup.Items.Any(x => x.Include == item.Name)) + if (!definedVersions.ContainsKey(item.Name)) { var reference = versionGroup.AddItem("PackageVersion", item.Name); reference.AddMetadata("Version", item.Version, expressAsAttribute: true); } } - - packagesProject.Save(); } + + packagesProject.Save(); }); Target GenerateNetFxAssemblyRedirectionSource => _ => _ diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 76bb2ec32b..77fd624cd6 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -1,10 +1,5 @@ - + - - - true - - @@ -50,108 +45,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework/Directory.Packages.props b/src/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework/Directory.Packages.props new file mode 100644 index 0000000000..4847c39579 --- /dev/null +++ b/src/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework/Directory.Packages.props @@ -0,0 +1,124 @@ + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/IntegrationTests/IntegrationTests.csproj b/test/IntegrationTests/IntegrationTests.csproj index 35df1d9270..e74ab4b9a9 100644 --- a/test/IntegrationTests/IntegrationTests.csproj +++ b/test/IntegrationTests/IntegrationTests.csproj @@ -22,13 +22,6 @@ - - - - - - - diff --git a/test/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests.csproj b/test/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests.csproj index 58142d679a..b7f31c5dca 100644 --- a/test/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests.csproj +++ b/test/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests/OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests.csproj @@ -8,11 +8,4 @@ - - - - - - - diff --git a/test/OpenTelemetry.AutoInstrumentation.Tests/OpenTelemetry.AutoInstrumentation.Tests.csproj b/test/OpenTelemetry.AutoInstrumentation.Tests/OpenTelemetry.AutoInstrumentation.Tests.csproj index 05df53c8fb..e34a9eb301 100644 --- a/test/OpenTelemetry.AutoInstrumentation.Tests/OpenTelemetry.AutoInstrumentation.Tests.csproj +++ b/test/OpenTelemetry.AutoInstrumentation.Tests/OpenTelemetry.AutoInstrumentation.Tests.csproj @@ -11,13 +11,6 @@ - - - - - - - PreserveNewest diff --git a/tools/DependencyListGenerator/DotNetOutdated/Exceptions/CommandValidationException.cs b/tools/DependencyListGenerator/DotNetOutdated/Exceptions/CommandValidationException.cs deleted file mode 100644 index 1cf1db7b36..0000000000 --- a/tools/DependencyListGenerator/DotNetOutdated/Exceptions/CommandValidationException.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace DependencyListGenerator.DotNetOutdated.Exceptions; - -public class CommandValidationException : Exception -{ - public CommandValidationException(string message) - : base(message) - { - } - - public CommandValidationException(string message, Exception innerException) - : base(message, innerException) - { - } -} diff --git a/tools/DependencyListGenerator/DotNetOutdated/Models/Dependency.cs b/tools/DependencyListGenerator/DotNetOutdated/Models/Dependency.cs index 0ef1944a95..dfc85cafc6 100644 --- a/tools/DependencyListGenerator/DotNetOutdated/Models/Dependency.cs +++ b/tools/DependencyListGenerator/DotNetOutdated/Models/Dependency.cs @@ -1,31 +1,10 @@ -using NuGet.Versioning; - namespace DependencyListGenerator.DotNetOutdated.Models; -public class Dependency +public class Dependency(string name, string resolvedVersion, bool isDevelopmentDependency) { - public Dependency(string name, VersionRange versionRange, NuGetVersion resolvedVersion, bool isAutoReferenced, bool isTransitive, bool isDevelopmentDependency, bool isVersionCentrallyManaged) - { - Name = name; - VersionRange = versionRange; - ResolvedVersion = resolvedVersion; - IsAutoReferenced = isAutoReferenced; - IsTransitive = isTransitive; - IsDevelopmentDependency = isDevelopmentDependency; - IsVersionCentrallyManaged = isVersionCentrallyManaged; - } - - public bool IsAutoReferenced { get; } - - public bool IsDevelopmentDependency { get; } - - public bool IsTransitive { get; } - - public bool IsVersionCentrallyManaged { get; } - - public string Name { get; } + public bool IsDevelopmentDependency { get; } = isDevelopmentDependency; - public NuGetVersion ResolvedVersion { get; } + public string Name { get; } = name; - public VersionRange VersionRange { get; } + public string ResolvedVersion { get; } = resolvedVersion; } diff --git a/tools/DependencyListGenerator/DotNetOutdated/Models/PackageListModel.cs b/tools/DependencyListGenerator/DotNetOutdated/Models/PackageListModel.cs new file mode 100644 index 0000000000..1510762cbc --- /dev/null +++ b/tools/DependencyListGenerator/DotNetOutdated/Models/PackageListModel.cs @@ -0,0 +1,51 @@ +namespace DependencyListGenerator.DotNetOutdated.Models; + +using System.Text.Json.Serialization; + +public record PackageListModel +{ + [JsonPropertyName("version")] + public int Version { get; init; } + + [JsonPropertyName("parameters")] + public string Parameters { get; init; } = string.Empty; + + [JsonPropertyName("projects")] + public ProjectInfo[] Projects { get; init; } = []; + + public record ProjectInfo + { + [JsonPropertyName("path")] + public string Path { get; init; } = string.Empty; + + [JsonPropertyName("frameworks")] + public FrameworkInfo[] Frameworks { get; init; } = []; + } + + public record FrameworkInfo + { + [JsonPropertyName("framework")] + public string Framework { get; init; } = string.Empty; + + [JsonPropertyName("topLevelPackages")] + public PackageReference[] TopLevelPackages { get; init; } = []; + + [JsonPropertyName("transitivePackages")] + public PackageReference[] TransitivePackages { get; init; } = []; + } + + public record PackageReference + { + [JsonPropertyName("id")] + public string Id { get; init; } = string.Empty; + + [JsonPropertyName("requestedVersion")] + public string RequestedVersion { get; init; } + + [JsonPropertyName("resolvedVersion")] + public string ResolvedVersion { get; init; } = string.Empty; + + [JsonPropertyName("latestVersion")] + public string LatestVersion { get; init; } + } +} diff --git a/tools/DependencyListGenerator/DotNetOutdated/Models/Project.cs b/tools/DependencyListGenerator/DotNetOutdated/Models/Project.cs index a2153795c1..a56f539f90 100644 --- a/tools/DependencyListGenerator/DotNetOutdated/Models/Project.cs +++ b/tools/DependencyListGenerator/DotNetOutdated/Models/Project.cs @@ -2,23 +2,9 @@ namespace DependencyListGenerator.DotNetOutdated.Models; -public class Project +public class Project(string filePath, IList targets) { - public Project(string name, string filePath, IEnumerable sources, NuGetVersion version) - { - FilePath = filePath; - Name = name; - Sources = new List(sources); - Version = version; - } + public string FilePath { get; } = filePath; - public string FilePath { get; } - - public string Name { get; } - - public IList Sources { get; } - - public IList TargetFrameworks { get; } = new List(); - - public NuGetVersion Version { get; } + public IList TargetFrameworks { get; } = targets; } diff --git a/tools/DependencyListGenerator/DotNetOutdated/Models/TargetFramework.cs b/tools/DependencyListGenerator/DotNetOutdated/Models/TargetFramework.cs index 88f6a5079e..6a3c4ab629 100644 --- a/tools/DependencyListGenerator/DotNetOutdated/Models/TargetFramework.cs +++ b/tools/DependencyListGenerator/DotNetOutdated/Models/TargetFramework.cs @@ -2,14 +2,9 @@ namespace DependencyListGenerator.DotNetOutdated.Models; -public class TargetFramework +public class TargetFramework(string name, IList dependencies) { - public TargetFramework(NuGetFramework name) - { - Name = name; - } + public IList Dependencies { get; } = dependencies; - public IList Dependencies { get; } = new List(); - - public NuGetFramework Name { get; set; } + public string Name { get; set; } = name; } diff --git a/tools/DependencyListGenerator/DotNetOutdated/Services/DependencyGraphService.cs b/tools/DependencyListGenerator/DotNetOutdated/Services/DependencyGraphService.cs deleted file mode 100644 index 94d6841811..0000000000 --- a/tools/DependencyListGenerator/DotNetOutdated/Services/DependencyGraphService.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.IO.Abstractions; -using DependencyListGenerator.DotNetOutdated.Exceptions; -using NuGet.ProjectModel; - -namespace DependencyListGenerator.DotNetOutdated.Services; - -/// -/// Credit for the stuff happening in here goes to the https://github.com/jaredcnance/dotnet-status project -/// -public class DependencyGraphService -{ - private readonly DotNetRunner _dotNetRunner; - private readonly IFileSystem _fileSystem; - - public DependencyGraphService(DotNetRunner dotNetRunner, IFileSystem fileSystem) - { - _dotNetRunner = dotNetRunner; - _fileSystem = fileSystem; - } - - public DependencyGraphSpec GenerateDependencyGraph(string projectPath) - { - var dgOutput = _fileSystem.Path.Combine(_fileSystem.Path.GetTempPath(), _fileSystem.Path.GetRandomFileName()); - - string[] arguments = { "msbuild", $"\"{projectPath}\"", "/t:Restore,GenerateRestoreGraphFile", $"/p:RestoreGraphOutputPath=\"{dgOutput}\"" }; - - var runStatus = _dotNetRunner.Run(_fileSystem.Path.GetDirectoryName(projectPath), arguments); - - if (runStatus.IsSuccess) - { - /* - TempDirectory is a hacky workaround for DependencyGraphSpec(JObject) - being deprecated. Unfortunately it looks like the only alternative - is to load the file locally. Which is ok normally, but complicates - testing. - */ - using (var tempDirectory = new TempDirectory()) - { - var dependencyGraphFilename = Path.Combine(tempDirectory.DirectoryPath, "DependencyGraph.json"); - var dependencyGraphText = _fileSystem.File.ReadAllText(dgOutput); - File.WriteAllText(dependencyGraphFilename, dependencyGraphText); - return DependencyGraphSpec.Load(dependencyGraphFilename); - } - } - - throw new CommandValidationException($"Unable to process the project `{projectPath}. Are you sure this is a valid .NET Core or .NET Standard project type?" + - $"{Environment.NewLine}{Environment.NewLine}Here is the full error message returned from the Microsoft Build Engine:{Environment.NewLine}{Environment.NewLine}{runStatus.Output} - {runStatus.Errors} - exit code: {runStatus.ExitCode}"); - } -} diff --git a/tools/DependencyListGenerator/DotNetOutdated/Services/DotNetPackageListService.cs b/tools/DependencyListGenerator/DotNetOutdated/Services/DotNetPackageListService.cs new file mode 100644 index 0000000000..c9fd95a2ed --- /dev/null +++ b/tools/DependencyListGenerator/DotNetOutdated/Services/DotNetPackageListService.cs @@ -0,0 +1,26 @@ +using System.IO.Abstractions; + +namespace DependencyListGenerator.DotNetOutdated.Services; + +public class DotNetPackageListService +{ + private readonly DotNetRunner _dotNetRunner; + private readonly IFileSystem _fileSystem; + + public DotNetPackageListService(DotNetRunner dotNetRunner, IFileSystem fileSystem) + { + _dotNetRunner = dotNetRunner; + _fileSystem = fileSystem; + } + + public RunStatus ListPackages(string projectPath) + { + string[] arguments = new[] + { + "list", $"\"{projectPath}\"", "package", "--include-transitive", "--format", "json", "--output-version", + "1" + }; + + return _dotNetRunner.Run(_fileSystem.Path.GetDirectoryName(projectPath), arguments); + } +} diff --git a/tools/DependencyListGenerator/DotNetOutdated/Services/ProjectAnalysisService.cs b/tools/DependencyListGenerator/DotNetOutdated/Services/ProjectAnalysisService.cs index ed282a36a7..02180f8a40 100644 --- a/tools/DependencyListGenerator/DotNetOutdated/Services/ProjectAnalysisService.cs +++ b/tools/DependencyListGenerator/DotNetOutdated/Services/ProjectAnalysisService.cs @@ -1,121 +1,76 @@ using System.IO.Abstractions; +using System.Text.Json; using DependencyListGenerator.DotNetOutdated.Models; using NuGet.Common; +using NuGet.Configuration; using NuGet.Packaging.Core; -using NuGet.ProjectModel; using NuGet.Protocol; +using NuGet.Versioning; namespace DependencyListGenerator.DotNetOutdated.Services; public class ProjectAnalysisService { - private readonly DependencyGraphService _dependencyGraphService; private readonly DotNetRestoreService _dotNetRestoreService; + private readonly DotNetPackageListService _packageListService; private readonly IFileSystem _fileSystem; - public ProjectAnalysisService(DependencyGraphService dependencyGraphService, DotNetRestoreService dotNetRestoreService, IFileSystem fileSystem) + public ProjectAnalysisService(DotNetRestoreService dotNetRestoreService, DotNetPackageListService packageListService, IFileSystem fileSystem) { - _dependencyGraphService = dependencyGraphService; _dotNetRestoreService = dotNetRestoreService; + _packageListService = packageListService; _fileSystem = fileSystem; } - public List AnalyzeProject(string projectPath, bool runRestore, bool includeTransitiveDependencies, int transitiveDepth) + public List AnalyzeProject(string projectPath, bool runRestore) { - var dependencyGraph = _dependencyGraphService.GenerateDependencyGraph(projectPath); - if (dependencyGraph == null) + if (runRestore) { - return null; + _dotNetRestoreService.Restore(projectPath); } - var projects = new List(); - foreach (var packageSpec in dependencyGraph.Projects.Where(p => p.RestoreMetadata.ProjectStyle == ProjectStyle.PackageReference)) - { - // Restore the packages - if (runRestore) - { - _dotNetRestoreService.Restore(packageSpec.FilePath); - } + var packagesFolder = + SettingsUtility.GetGlobalPackagesFolder( + Settings.LoadDefaultSettings(root: _fileSystem.Path.GetDirectoryName(projectPath))); - // Load the lock file - string lockFilePath = _fileSystem.Path.Combine(packageSpec.RestoreMetadata.OutputPath, "project.assets.json"); - var lockFile = LockFileUtilities.GetLockFile(lockFilePath, NullLogger.Instance); + var result = _packageListService.ListPackages(projectPath); + if (!result.IsSuccess) + { + return null; + } - // Create a project - var project = new Project(packageSpec.Name, packageSpec.FilePath, packageSpec.RestoreMetadata.Sources.Select(s => s.SourceUri).ToList(), packageSpec.Version); - projects.Add(project); + var packageListModel = JsonSerializer.Deserialize(result.Output); + var projects = new List(); + foreach (var modelProject in packageListModel.Projects) + { + var targets = new List(); // Get the target frameworks with their dependencies - foreach (var targetFrameworkInformation in packageSpec.TargetFrameworks) + foreach (var targetFrameworkInformation in modelProject.Frameworks) { - var targetFramework = new TargetFramework(targetFrameworkInformation.FrameworkName); - project.TargetFrameworks.Add(targetFramework); - - var target = lockFile.Targets.FirstOrDefault(t => t.TargetFramework.Equals(targetFrameworkInformation.FrameworkName)); - - if (target != null) + var dependencies = new List(); + foreach (var projectDependency in targetFrameworkInformation.TopLevelPackages.Concat( + targetFrameworkInformation.TransitivePackages)) { - foreach (var projectDependency in targetFrameworkInformation.Dependencies) + // Determine whether this is a development dependency + var isDevelopmentDependency = false; + var packageIdentity = new PackageIdentity(projectDependency.Id, NuGetVersion.Parse(projectDependency.ResolvedVersion)); + var packageInfo = + LocalFolderUtility.GetPackageV3(packagesFolder, packageIdentity, NullLogger.Instance); + if (packageInfo != null) { - var projectLibrary = target.Libraries.FirstOrDefault(library => string.Equals(library.Name, projectDependency.Name, StringComparison.OrdinalIgnoreCase)); - - bool isDevelopmentDependency = false; - if (projectLibrary != null) - { - // Determine whether this is a development dependency - var packageIdentity = new PackageIdentity(projectLibrary.Name, projectLibrary.Version); - var packageInfo = LocalFolderUtility.GetPackageV3(packageSpec.RestoreMetadata.PackagesPath, packageIdentity, NullLogger.Instance); - if (packageInfo != null) - { - isDevelopmentDependency = packageInfo.GetReader().GetDevelopmentDependency(); - } - } - - var dependency = new Dependency( - projectDependency.Name, - projectDependency.LibraryRange.VersionRange, - projectLibrary?.Version, - projectDependency.AutoReferenced, - false, - isDevelopmentDependency, - projectDependency.VersionCentrallyManaged); - - targetFramework.Dependencies.Add(dependency); - - // Process transitive dependencies for the library - if (includeTransitiveDependencies) - { - AddDependencies(targetFramework, projectLibrary, target, 1, transitiveDepth, isDevelopmentDependency); - } + isDevelopmentDependency = packageInfo.GetReader().GetDevelopmentDependency(); } + + dependencies.Add(new Dependency(projectDependency.Id, projectDependency.ResolvedVersion, isDevelopmentDependency)); } + + targets.Add(new TargetFramework(targetFrameworkInformation.Framework, dependencies)); } + + projects.Add(new Project(modelProject.Path, targets)); } return projects; } - - private void AddDependencies(TargetFramework targetFramework, LockFileTargetLibrary parentLibrary, LockFileTarget target, int level, int transitiveDepth, bool isDevelopmentDependency) - { - if (parentLibrary?.Dependencies != null) - { - foreach (var packageDependency in parentLibrary.Dependencies) - { - var childLibrary = target.Libraries.FirstOrDefault(library => library.Name == packageDependency.Id); - - // Only add library and process child dependencies if we have not come across this dependency before - if (!targetFramework.Dependencies.Any(dependency => dependency.Name == packageDependency.Id)) - { - var childDependency = new Dependency(packageDependency.Id, packageDependency.VersionRange, childLibrary?.Version, false, true, isDevelopmentDependency, false); - targetFramework.Dependencies.Add(childDependency); - - // Process the dependency for this project dependency - if (level < transitiveDepth) - { - AddDependencies(targetFramework, childLibrary, target, level + 1, transitiveDepth, isDevelopmentDependency); - } - } - } - } - } } diff --git a/tools/DependencyListGenerator/Generator.cs b/tools/DependencyListGenerator/Generator.cs index e747b1fa9f..54df403bc3 100644 --- a/tools/DependencyListGenerator/Generator.cs +++ b/tools/DependencyListGenerator/Generator.cs @@ -2,32 +2,29 @@ // SPDX-License-Identifier: Apache-2.0 using System.IO.Abstractions; +using System.Runtime.Intrinsics.Arm; using DependencyListGenerator.DotNetOutdated.Services; +using NuGet.Packaging; namespace DependencyListGenerator; public static class Generator { - public static IEnumerable EnumerateDependencies(string projectPath, Version version) + public static Dictionary EnumerateDependencies(string projectPath) { var dotNetRunner = new DotNetRunner(); var fileSystem = new FileSystem(); var analysisService = new ProjectAnalysisService( - dependencyGraphService: new DependencyGraphService(dotNetRunner, fileSystem), dotNetRestoreService: new DotNetRestoreService(dotNetRunner, fileSystem), + packageListService: new DotNetPackageListService(dotNetRunner, fileSystem), fileSystem: fileSystem); - var result = analysisService.AnalyzeProject(projectPath, true, true, 1024)[0]; - var net462 = result.TargetFrameworks.First(x => x.Name.ToString() == (version.Build != 0 ? $".NETFramework,Version=v{version.Major}.{version.Minor}.{version.Build}" : $".NETFramework,Version=v{version.Major}.{version.Minor}")); - - foreach (var dep in net462.Dependencies.OrderBy(x => x.Name)) - { - // OpenTelemetry and OpenTracing dependencies are managed directly. - if (dep.IsTransitive && !dep.IsDevelopmentDependency && !dep.Name.StartsWith("OpenTelemetry") && dep.Name != "OpenTracing") - { - yield return new TransientDependency(dep.Name, dep.ResolvedVersion.ToString()); - } - } + var result = analysisService.AnalyzeProject(projectPath, true)[0]; + return result.TargetFrameworks.ToDictionary( + it => it.Name, + it => it.Dependencies.OrderBy(x => x.Name) + .Where(dep => !dep.IsDevelopmentDependency) + .Select(dep => new TransientDependency(dep.Name, dep.ResolvedVersion)).ToArray()); } } From 589f02ac44bbb04164dac59c0748980fe08d1847 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Wed, 15 Oct 2025 11:03:53 -0700 Subject: [PATCH 19/30] Updated dependencies --- .../Directory.Packages.props | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework/Directory.Packages.props b/src/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework/Directory.Packages.props index 4847c39579..219a79d4f1 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework/Directory.Packages.props +++ b/src/OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework/Directory.Packages.props @@ -19,7 +19,7 @@ - + @@ -48,7 +48,7 @@ - + @@ -77,7 +77,7 @@ - + @@ -106,7 +106,7 @@ - + From f9295d520224265f66721e616191e70417cfbc9b Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Wed, 15 Oct 2025 11:48:03 -0700 Subject: [PATCH 20/30] Reverted version override for test application --- .../TestLibrary.InstrumentationTarget.csproj | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/test-applications/integrations/dependency-libs/TestLibrary.InstrumentationTarget/TestLibrary.InstrumentationTarget.csproj b/test/test-applications/integrations/dependency-libs/TestLibrary.InstrumentationTarget/TestLibrary.InstrumentationTarget.csproj index 1e12728fea..5c1a66f03a 100644 --- a/test/test-applications/integrations/dependency-libs/TestLibrary.InstrumentationTarget/TestLibrary.InstrumentationTarget.csproj +++ b/test/test-applications/integrations/dependency-libs/TestLibrary.InstrumentationTarget/TestLibrary.InstrumentationTarget.csproj @@ -1,4 +1,4 @@ - + Library @@ -10,10 +10,4 @@ - - - - - - From 7879ade2ce1e6d9d1e853a01cc9cac5f87158eb2 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Wed, 15 Oct 2025 16:17:54 -0700 Subject: [PATCH 21/30] Removed unused code --- .../Extensions/TargetFrameworksExtensions.cs | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/build/Extensions/TargetFrameworksExtensions.cs b/build/Extensions/TargetFrameworksExtensions.cs index 40dbe3388c..d40acb3619 100644 --- a/build/Extensions/TargetFrameworksExtensions.cs +++ b/build/Extensions/TargetFrameworksExtensions.cs @@ -6,26 +6,4 @@ public static IEnumerable ExceptNetFramework(this IEnumerable Date: Wed, 15 Oct 2025 17:06:26 -0700 Subject: [PATCH 22/30] Updated image pinning to run tests --- docker/centos-stream9.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/centos-stream9.dockerfile b/docker/centos-stream9.dockerfile index d170879f4f..929b342fbf 100644 --- a/docker/centos-stream9.dockerfile +++ b/docker/centos-stream9.dockerfile @@ -1,4 +1,4 @@ -FROM quay.io/centos/centos:stream9@sha256:9b0482e3e8ddedce22b5d841d04d0a73498237d93a0c5d75b8a07cc99222591d +FROM quay.io/centos/centos:stream9@sha256:8e30e9e7ee0afd42477ef1e77d85b5f92493e09c5bc830f721ef5ca2b6863fff # Install dotnet sdk RUN dnf install -y \ From 44d1c3c8f377d7edd457a39b1af5af33b229c5c2 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Thu, 16 Oct 2025 15:55:46 -0700 Subject: [PATCH 23/30] README modified and tests added --- docs/README.md | 10 +- .../OpenTelemetry.DotNet.Auto.psm1.template | 4 +- .../NetFrameworkDistroTests.cs | 106 ++++++++++++++++++ tools/DependencyListGenerator/Generator.cs | 2 - .../TransientDependency.cs | 13 +-- 5 files changed, 118 insertions(+), 17 deletions(-) create mode 100644 test/OpenTelemetry.AutoInstrumentation.Tests/NetFrameworkDistroTests.cs diff --git a/docs/README.md b/docs/README.md index b9f0f2b11d..395a943fc0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,4 +1,4 @@ -# OpenTelemetry .NET Automatic Instrumentation +# OpenTelemetry .NET Automatic Instrumentation [![Slack](https://img.shields.io/badge/slack-@cncf/otel--dotnet--auto--instr-brightgreen.svg?logo=slack)](https://cloud-native.slack.com/archives/C01NR1YLSE7) [![NuGet](https://img.shields.io/nuget/v/OpenTelemetry.AutoInstrumentation.svg)](https://www.nuget.org/packages/OpenTelemetry.AutoInstrumentation) @@ -317,6 +317,14 @@ Unregister-OpenTelemetryForWindowsService -WindowsServiceName MyServiceName Uninstall-OpenTelemetryCore ``` +#### Update .Net Framework version + +By default, `Install-OpenTelemetryCore` and `Update-OpenTelemetryCore` register OpenTelemetry (and dependencies) +assemblies in the Global Assembly Cache (GAC). Some of these assemblies are tightly coupled to specific .NET Framework versions. + +When upgrading from .NET Framework versions older than 4.7.2, these assemblies should be removed from the GAC. +For such upgrade scenarios, it is recommended to uninstall and reinstall OpenTelemetry after the .NET Framework update is complete. + ## Instrument a container You can find our demonstrative example diff --git a/script-templates/OpenTelemetry.DotNet.Auto.psm1.template b/script-templates/OpenTelemetry.DotNet.Auto.psm1.template index 7a0830ffc1..0a31cacc66 100644 --- a/script-templates/OpenTelemetry.DotNet.Auto.psm1.template +++ b/script-templates/OpenTelemetry.DotNet.Auto.psm1.template @@ -1,4 +1,4 @@ -# +# # Copyright The OpenTelemetry Authors # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -480,7 +480,7 @@ function Update-OpenTelemetryCore() { Remove-Module OpenTelemetry.Dotnet.Auto Import-Module $modulePath - Install-OpenTelemetryCore -InstallDir $installDir -RegisterAssembliesInGAC $$RegisterAssembliesInGAC + Install-OpenTelemetryCore -InstallDir $installDir -RegisterAssembliesInGAC $RegisterAssembliesInGAC if ($RegisterIIS) { Register-OpenTelemetryForIIS } diff --git a/test/OpenTelemetry.AutoInstrumentation.Tests/NetFrameworkDistroTests.cs b/test/OpenTelemetry.AutoInstrumentation.Tests/NetFrameworkDistroTests.cs new file mode 100644 index 0000000000..83bb6d7ab9 --- /dev/null +++ b/test/OpenTelemetry.AutoInstrumentation.Tests/NetFrameworkDistroTests.cs @@ -0,0 +1,106 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// This test is defined in NET 9.0 because the tool is written in .NET 9.0 +// The actual test is testing .NET Framework context. +#if NET9_0_OR_GREATER + +using System.Reflection; +using System.Runtime.InteropServices; +using DependencyListGenerator; +using NuGet.Configuration; +using Xunit; +using Xunit.Abstractions; + +namespace OpenTelemetry.AutoInstrumentation.Tests; + +public class NetFrameworkDistroTests +{ + private readonly ITestOutputHelper _output; + + public NetFrameworkDistroTests(ITestOutputHelper output) + { + _output = output; + } + + [SkippableFact] + public void GeneratorDiscoversTransientDependencies() + { + Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Supported only on Windows."); + + var currentTestLocation = Assembly.GetExecutingAssembly().Location; + var testDir = FindParentDir(currentTestLocation, "test"); + var srcDir = Path.Combine(Directory.GetParent(testDir)!.FullName, "src"); + var codeDir = Path.Combine(srcDir, "OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework"); + var projectPath = Path.Combine(codeDir, "OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework.csproj"); + + var dependencies = Generator.EnumerateDependencies(projectPath); + + // Check that every TFM has System.Memory reference. We just selected one transient dependency to test. + Assert.True(dependencies.All(tfm => tfm.Value.Any(dep => dep.Name == "System.Memory"))); + } + + [SkippableFact] + public void ReferencedPackagesNoUnsupportedTfm() + { + Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Supported only on Windows."); + + var currentTestLocation = Assembly.GetExecutingAssembly().Location; + var testDir = FindParentDir(currentTestLocation, "test"); + var srcDir = Path.Combine(Directory.GetParent(testDir)!.FullName, "src"); + var codeDir = Path.Combine(srcDir, "OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework"); + var projectPath = Path.Combine(codeDir, "OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework.csproj"); + + var dependencies = Generator.EnumerateDependencies(projectPath).SelectMany(tfm => tfm.Value).ToHashSet(); + + var packagesFolder = + SettingsUtility.GetGlobalPackagesFolder( + Settings.LoadDefaultSettings(root: codeDir)); + + string[] knownOldPrefix = ["net40", "net45", "net46", "net47"]; + List unexpectedFrameworkFolders = []; + foreach (var dependency in dependencies) + { + var packageFolder = Path.Combine(packagesFolder, dependency.Name, dependency.Version); + foreach (var folder in Directory.EnumerateDirectories(packageFolder, "net4*", SearchOption.AllDirectories)) + { + var tfm = Path.GetFileName(folder); + if (tfm.Contains(".")) + { + // .NET 40.x + continue; + } + + if (knownOldPrefix.Any(prefix => tfm.StartsWith(prefix))) + { + continue; + } + + var path = Path.GetRelativePath(packagesFolder, folder); + unexpectedFrameworkFolders.Add(path); + _output.WriteLine($"Unexpected TFM: {path}"); + } + } + + // We may need add new TFM in OpenTelemetry.AutoInstrumentation.Assemblies.NetFramework + // (and build infrastructure, readme) if referenced dependencies has a custom build for that TFM. + Assert.Empty(unexpectedFrameworkFolders); + } + + private static string FindParentDir(string location, string parentName) + { + var parent = Directory.GetParent(location); + if (parent == null) + { + throw new InvalidOperationException("Could not find parent test directory"); + } + + if (parent.Name == parentName) + { + return parent.FullName; + } + + return FindParentDir(parent.FullName, parentName); + } +} +#endif diff --git a/tools/DependencyListGenerator/Generator.cs b/tools/DependencyListGenerator/Generator.cs index 54df403bc3..6a0b7463bb 100644 --- a/tools/DependencyListGenerator/Generator.cs +++ b/tools/DependencyListGenerator/Generator.cs @@ -2,9 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 using System.IO.Abstractions; -using System.Runtime.Intrinsics.Arm; using DependencyListGenerator.DotNetOutdated.Services; -using NuGet.Packaging; namespace DependencyListGenerator; diff --git a/tools/DependencyListGenerator/TransientDependency.cs b/tools/DependencyListGenerator/TransientDependency.cs index 4e7f20bf4a..35f53fa42f 100644 --- a/tools/DependencyListGenerator/TransientDependency.cs +++ b/tools/DependencyListGenerator/TransientDependency.cs @@ -3,15 +3,4 @@ namespace DependencyListGenerator; -public class TransientDependency -{ - public TransientDependency(string name, string version) - { - Name = name; - Version = version; - } - - public string Name { get; private set; } - - public string Version { get; private set; } -} +public record TransientDependency(string Name, string Version); From d4938a6cf9cee879def4efcb74791ff5baf59bcd Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Thu, 16 Oct 2025 16:13:37 -0700 Subject: [PATCH 24/30] Changelog updated. Fixed BOM. --- CHANGELOG.md | 10 ++++++++++ docs/README.md | 2 +- .../OpenTelemetry.DotNet.Auto.psm1.template | 2 +- src/Directory.Packages.props | 2 +- .../cor_profiler.cpp | 2 +- .../cor_profiler.h | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b7fa1b5f3..ba993d3c0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,16 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h - `System.Text.Encodings.Web` update from `9.0.2` to `9.0.8`. - `System.Text.Json` update from `9.0.2` to `9.0.8`. +#### Dependencies on .Net Framework + +When OpenTelemetry .NET AutoInstrumentation is compiled for .NET Framework, it uses the net462 Target Framework Moniker (TFM). +As a result, the ZIP archive deployment contained dependency assemblies targeted for .NET Framework 4.6.2. +Some of these assemblies were not designed to be used with later versions of .NET Framework. + +Now, when the OpenTelemetry ZIP archive is built, dependency assemblies are included for all supported .NET Framework versions. +OpenTelemetry .NET AutoInstrumentation detects the .NET Framework version at install time and runtime, +then loads the correct version of dependency assemblies. + ## [1.12.0](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v1.12.0) ### Added diff --git a/docs/README.md b/docs/README.md index 395a943fc0..3f6ac54811 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,4 +1,4 @@ -# OpenTelemetry .NET Automatic Instrumentation +# OpenTelemetry .NET Automatic Instrumentation [![Slack](https://img.shields.io/badge/slack-@cncf/otel--dotnet--auto--instr-brightgreen.svg?logo=slack)](https://cloud-native.slack.com/archives/C01NR1YLSE7) [![NuGet](https://img.shields.io/nuget/v/OpenTelemetry.AutoInstrumentation.svg)](https://www.nuget.org/packages/OpenTelemetry.AutoInstrumentation) diff --git a/script-templates/OpenTelemetry.DotNet.Auto.psm1.template b/script-templates/OpenTelemetry.DotNet.Auto.psm1.template index 0a31cacc66..9107a9614c 100644 --- a/script-templates/OpenTelemetry.DotNet.Auto.psm1.template +++ b/script-templates/OpenTelemetry.DotNet.Auto.psm1.template @@ -1,4 +1,4 @@ -# +# # Copyright The OpenTelemetry Authors # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 3f9edcacc4..16ef13c919 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -1,4 +1,4 @@ - + diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp index d7cfd57507..daa7a32cfd 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp +++ b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.cpp @@ -1,4 +1,4 @@ -// Copyright The OpenTelemetry Authors +// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #include "cor_profiler.h" diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.h b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.h index 60485718c4..fb00c47271 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.h +++ b/src/OpenTelemetry.AutoInstrumentation.Native/cor_profiler.h @@ -1,4 +1,4 @@ -/* +/* * Copyright The OpenTelemetry Authors * SPDX-License-Identifier: Apache-2.0 */ From e8330c6d8d1342822a8026a9075a7c602dbc6323 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Thu, 16 Oct 2025 16:27:12 -0700 Subject: [PATCH 25/30] Changelog fixed --- CHANGELOG.md | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba993d3c0a..4d67593e4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,21 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h for details. - Fixed rule engine check for .NET 9 to reflect longer support for [STS channel](https://devblogs.microsoft.com/dotnet/dotnet-sts-releases-supported-for-24-months/). +### Changed + +#### Dependencies on .Net Framework + +When OpenTelemetry .NET AutoInstrumentation is compiled for .NET Framework, +it uses the net462 Target Framework Moniker (TFM). As a result, the ZIP archive +deployment contained dependency assemblies targeted for .NET Framework 4.6.2. +Some of these assemblies were not designed to be used with later versions of +.NET Framework. + +Now, when the OpenTelemetry ZIP archive is built, dependency assemblies are +included for all supported .NET Framework versions. OpenTelemetry .NET +AutoInstrumentation detects the .NET Framework version at install time +and runtime, then loads the correct version of dependency assemblies. + ## [1.13.0-beta.1](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v1.13.0-beta.1) ### Added @@ -70,16 +85,6 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h - `System.Text.Encodings.Web` update from `9.0.2` to `9.0.8`. - `System.Text.Json` update from `9.0.2` to `9.0.8`. -#### Dependencies on .Net Framework - -When OpenTelemetry .NET AutoInstrumentation is compiled for .NET Framework, it uses the net462 Target Framework Moniker (TFM). -As a result, the ZIP archive deployment contained dependency assemblies targeted for .NET Framework 4.6.2. -Some of these assemblies were not designed to be used with later versions of .NET Framework. - -Now, when the OpenTelemetry ZIP archive is built, dependency assemblies are included for all supported .NET Framework versions. -OpenTelemetry .NET AutoInstrumentation detects the .NET Framework version at install time and runtime, -then loads the correct version of dependency assemblies. - ## [1.12.0](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v1.12.0) ### Added From 22524fb094d08a57785ba8957492162386a0965f Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Thu, 16 Oct 2025 16:34:09 -0700 Subject: [PATCH 26/30] Generated files updates --- .../RegexGenerator.g.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry.AutoInstrumentation/Generated/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs b/src/OpenTelemetry.AutoInstrumentation/Generated/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs index 4fd90b8111..35f008320e 100644 --- a/src/OpenTelemetry.AutoInstrumentation/Generated/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs +++ b/src/OpenTelemetry.AutoInstrumentation/Generated/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs @@ -25,7 +25,7 @@ partial class EnvVarTypeConverter /// ○ Match '}'.
/// /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.41914")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.47513")] private static partial global::System.Text.RegularExpressions.Regex GetEnvVarRegex() => global::System.Text.RegularExpressions.Generated.GetEnvVarRegex_0.Instance; } } @@ -43,7 +43,7 @@ namespace System.Text.RegularExpressions.Generated using System.Threading; /// Custom -derived type for the GetEnvVarRegex method. - [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.41914")] + [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.47513")] file sealed class GetEnvVarRegex_0 : Regex { /// Cached, thread-safe singleton instance. @@ -324,7 +324,7 @@ void UncaptureUntil(int capturePosition) } /// Helper methods used by generated -derived implementations. - [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.41914")] + [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.47513")] file static class Utilities { /// Default timeout value set in , or if none was set. From 7ba8086d6744f82f135c18e2a4b9b5d221248351 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Thu, 16 Oct 2025 16:40:20 -0700 Subject: [PATCH 27/30] Changelog fixed --- CHANGELOG.md | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d67593e4b..effa4408ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,19 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h - .NET Framework only, following packages updated - `OpenTelemetry.Instrumentation.AspNet` from `1.12.0-beta.1` to `1.12.0-beta.2`. +#### Dependencies on .Net Framework + +When OpenTelemetry .NET AutoInstrumentation is compiled for .NET Framework, +it uses the net462 Target Framework Moniker (TFM). As a result, the ZIP archive +deployment contained dependency assemblies targeted for .NET Framework 4.6.2. +Some of these assemblies were not designed to be used with later versions of +.NET Framework. + +Now, when the OpenTelemetry ZIP archive is built, dependency assemblies are +included for all supported .NET Framework versions. OpenTelemetry .NET +AutoInstrumentation detects the .NET Framework version at install time +and runtime, then loads the correct version of dependency assemblies. + ### Deprecated ### Removed @@ -37,21 +50,6 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h for details. - Fixed rule engine check for .NET 9 to reflect longer support for [STS channel](https://devblogs.microsoft.com/dotnet/dotnet-sts-releases-supported-for-24-months/). -### Changed - -#### Dependencies on .Net Framework - -When OpenTelemetry .NET AutoInstrumentation is compiled for .NET Framework, -it uses the net462 Target Framework Moniker (TFM). As a result, the ZIP archive -deployment contained dependency assemblies targeted for .NET Framework 4.6.2. -Some of these assemblies were not designed to be used with later versions of -.NET Framework. - -Now, when the OpenTelemetry ZIP archive is built, dependency assemblies are -included for all supported .NET Framework versions. OpenTelemetry .NET -AutoInstrumentation detects the .NET Framework version at install time -and runtime, then loads the correct version of dependency assemblies. - ## [1.13.0-beta.1](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v1.13.0-beta.1) ### Added From 6cea088afc784e19b4152762777a74ab7e0ed914 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Thu, 16 Oct 2025 16:56:27 -0700 Subject: [PATCH 28/30] Generated file update --- .../RegexGenerator.g.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry.AutoInstrumentation/Generated/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs b/src/OpenTelemetry.AutoInstrumentation/Generated/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs index 35f008320e..4fd90b8111 100644 --- a/src/OpenTelemetry.AutoInstrumentation/Generated/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs +++ b/src/OpenTelemetry.AutoInstrumentation/Generated/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs @@ -25,7 +25,7 @@ partial class EnvVarTypeConverter /// ○ Match '}'.
/// /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.47513")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.41914")] private static partial global::System.Text.RegularExpressions.Regex GetEnvVarRegex() => global::System.Text.RegularExpressions.Generated.GetEnvVarRegex_0.Instance; } } @@ -43,7 +43,7 @@ namespace System.Text.RegularExpressions.Generated using System.Threading; /// Custom -derived type for the GetEnvVarRegex method. - [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.47513")] + [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.41914")] file sealed class GetEnvVarRegex_0 : Regex { /// Cached, thread-safe singleton instance. @@ -324,7 +324,7 @@ void UncaptureUntil(int capturePosition) } /// Helper methods used by generated -derived implementations. - [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.47513")] + [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.41914")] file static class Utilities { /// Default timeout value set in , or if none was set. From 57b2d19c1781a96b7744eb48ab919a8da28e56fd Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Thu, 16 Oct 2025 17:18:08 -0700 Subject: [PATCH 29/30] Test with latest .NET SDK --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fea941a745..db53cf2bf6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,8 +36,8 @@ jobs: uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag: v5.0.0 with: dotnet-version: | - 8.0.414 - 9.0.305 + 8.0.415 + 9.0.306 - name: Check for NuGet packages cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # tag: v4.3.0 From 634d4cc5743d24b729a1e21c845ac29f4346a5b1 Mon Sep 17 00:00:00 2001 From: Igor Kiselev Date: Thu, 16 Oct 2025 17:31:49 -0700 Subject: [PATCH 30/30] Test with latest .NET SDK --- .github/workflows/build-nuget-packages.yml | 4 ++-- .github/workflows/check-sdk-versions.yml | 2 +- .github/workflows/ci.yml | 16 ++++++++-------- .github/workflows/codeql-analysis.yml | 4 ++-- .github/workflows/dotnet-format.yml | 2 +- .../release-nextgen-forwarder-packages.yml | 2 +- .github/workflows/release-publish.yml | 8 ++++---- .github/workflows/verify-test.yml | 4 ++-- docker/alpine.dockerfile | 4 ++-- docker/centos-stream9.dockerfile | 4 ++-- docker/debian-arm64.dockerfile | 4 ++-- docker/debian.dockerfile | 2 +- docker/ubuntu1604.dockerfile | 2 +- .../RegexGenerator.g.cs | 6 +++--- 14 files changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build-nuget-packages.yml b/.github/workflows/build-nuget-packages.yml index f91075d8fd..83c7b2ee15 100644 --- a/.github/workflows/build-nuget-packages.yml +++ b/.github/workflows/build-nuget-packages.yml @@ -33,8 +33,8 @@ jobs: uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag: v5.0.0 with: dotnet-version: | - 8.0.414 - 9.0.305 + 8.0.415 + 9.0.306 - name: Check for NuGet packages cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # tag: v4.3.0 diff --git a/.github/workflows/check-sdk-versions.yml b/.github/workflows/check-sdk-versions.yml index de6096a9c3..ae9fb72f52 100644 --- a/.github/workflows/check-sdk-versions.yml +++ b/.github/workflows/check-sdk-versions.yml @@ -21,7 +21,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag: v5.0.0 with: - dotnet-version: 9.0.305 + dotnet-version: 9.0.306 - name: Run VerifySdkVersions run: ./build.cmd VerifySdkVersions diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6b68c1a00..0d86e4bfb2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,8 +71,8 @@ jobs: uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag: v5.0.0 with: dotnet-version: | - 8.0.414 - 9.0.305 + 8.0.415 + 9.0.306 - name: Check for NuGet packages cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # tag: v4.3.0 @@ -130,8 +130,8 @@ jobs: uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag: v5.0.0 with: dotnet-version: | - 8.0.414 - 9.0.305 + 8.0.415 + 9.0.306 - name: Check for NuGet packages cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # tag: v4.3.0 @@ -173,8 +173,8 @@ jobs: uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag: v5.0.0 with: dotnet-version: | - 8.0.414 - 9.0.305 + 8.0.415 + 9.0.306 - name: Check for NuGet packages cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # tag: v4.3.0 @@ -280,8 +280,8 @@ jobs: uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag: v5.0.0 with: dotnet-version: | - 8.0.414 - 9.0.305 + 8.0.415 + 9.0.306 - name: Check for NuGet packages cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # tag: v4.3.0 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7623dcbc05..67b08e50a7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -78,8 +78,8 @@ jobs: uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 with: dotnet-version: | - 8.0.414 - 9.0.305 + 8.0.415 + 9.0.306 # If the analyze step fails for one of the languages you are analyzing with # "We were unable to automatically build your code", modify the matrix above diff --git a/.github/workflows/dotnet-format.yml b/.github/workflows/dotnet-format.yml index cb394a2faf..fc77a9207d 100644 --- a/.github/workflows/dotnet-format.yml +++ b/.github/workflows/dotnet-format.yml @@ -28,7 +28,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag: v5.0.0 with: - dotnet-version: 9.0.305 + dotnet-version: 9.0.306 - name: dotnet format run: dotnet format .\OpenTelemetry.AutoInstrumentation.sln --no-restore --verify-no-changes diff --git a/.github/workflows/release-nextgen-forwarder-packages.yml b/.github/workflows/release-nextgen-forwarder-packages.yml index 9406fdffe3..9c03fcfb08 100644 --- a/.github/workflows/release-nextgen-forwarder-packages.yml +++ b/.github/workflows/release-nextgen-forwarder-packages.yml @@ -32,7 +32,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag: v5.0.0 with: - dotnet-version: 9.0.305 + dotnet-version: 9.0.306 - name: Check for NuGet packages cache uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # tag: v4.3.0 diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 762ca06a7a..f78fdb1f67 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -16,8 +16,8 @@ jobs: uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag: v5.0.0 with: dotnet-version: | - 8.0.414 - 9.0.305 + 8.0.415 + 9.0.306 - name: Test the PowerShell module instructions from README.md shell: powershell @@ -67,8 +67,8 @@ jobs: uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag: v5.0.0 with: dotnet-version: | - 8.0.414 - 9.0.305 + 8.0.415 + 9.0.306 - name: Install MacOS CoreUtils if: ${{ runner.os == 'macOS' }} diff --git a/.github/workflows/verify-test.yml b/.github/workflows/verify-test.yml index 9b742d452b..539bc13683 100644 --- a/.github/workflows/verify-test.yml +++ b/.github/workflows/verify-test.yml @@ -41,8 +41,8 @@ jobs: uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag: v5.0.0 with: dotnet-version: | - 8.0.414 - 9.0.305 + 8.0.415 + 9.0.306 - name: Run BuildTracer and ManagedTests run: ./build.cmd BuildTracer ManagedTests --containers ${{ matrix.containers }} --test-project "${{ github.event.inputs.testProject }}" --test-name '"${{ github.event.inputs.testName }}"' --test-count ${{ github.event.inputs.count }} diff --git a/docker/alpine.dockerfile b/docker/alpine.dockerfile index 97e2f138fe..cde5303814 100644 --- a/docker/alpine.dockerfile +++ b/docker/alpine.dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0.305-alpine3.21@sha256:f47429a125e38d83f5231a78dde18106cb447d541f7ffdc5b8af4d227a323d95 +FROM mcr.microsoft.com/dotnet/sdk:9.0.306-alpine3.21@sha256:331c02eb23ad61e277d8bf9ea615731c1796e81cc3b9c457003482f81ee02d2e RUN apk update \ && apk upgrade \ && apk add --no-cache --update \ @@ -20,7 +20,7 @@ COPY ./scripts/dotnet-install.sh ./dotnet-install.sh # Install older SDKs using the install script RUN chmod +x ./dotnet-install.sh \ - && ./dotnet-install.sh -v 8.0.414 --install-dir /usr/share/dotnet --no-path \ + && ./dotnet-install.sh -v 8.0.415 --install-dir /usr/share/dotnet --no-path \ && rm dotnet-install.sh WORKDIR /project diff --git a/docker/centos-stream9.dockerfile b/docker/centos-stream9.dockerfile index c8d71b688a..1f08ce1aef 100644 --- a/docker/centos-stream9.dockerfile +++ b/docker/centos-stream9.dockerfile @@ -7,8 +7,8 @@ RUN dnf install -y \ COPY ./scripts/dotnet-install.sh ./dotnet-install.sh RUN chmod +x ./dotnet-install.sh \ - && ./dotnet-install.sh -v 9.0.305 --install-dir /usr/share/dotnet --no-path \ - && ./dotnet-install.sh -v 8.0.414 --install-dir /usr/share/dotnet --no-path \ + && ./dotnet-install.sh -v 9.0.306 --install-dir /usr/share/dotnet --no-path \ + && ./dotnet-install.sh -v 8.0.415 --install-dir /usr/share/dotnet --no-path \ && rm dotnet-install.sh ENV PATH="$PATH:/usr/share/dotnet" diff --git a/docker/debian-arm64.dockerfile b/docker/debian-arm64.dockerfile index 4cd2128bd0..a219dd9cb1 100644 --- a/docker/debian-arm64.dockerfile +++ b/docker/debian-arm64.dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0.305-bookworm-slim@sha256:bb42ae2c058609d1746baf24fe6864ecab0686711dfca1f4b7a99e367ab17162 +FROM mcr.microsoft.com/dotnet/sdk:9.0.306-bookworm-slim@sha256:a5dd7352c0c058a6f847c95a1147b060e95a532444f14b34d8fa9aaa0a76702f RUN apt-get update && \ apt-get install -y \ @@ -10,7 +10,7 @@ COPY ./scripts/dotnet-install.sh ./dotnet-install.sh # Install older SDKs using the install script as there are no arm64 SDK packages. RUN chmod +x ./dotnet-install.sh \ - && ./dotnet-install.sh -v 8.0.414 --install-dir /usr/share/dotnet --no-path \ + && ./dotnet-install.sh -v 8.0.415 --install-dir /usr/share/dotnet --no-path \ && rm dotnet-install.sh WORKDIR /project diff --git a/docker/debian.dockerfile b/docker/debian.dockerfile index e4066079a0..7c57d72780 100644 --- a/docker/debian.dockerfile +++ b/docker/debian.dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0.305-bookworm-slim@sha256:bb42ae2c058609d1746baf24fe6864ecab0686711dfca1f4b7a99e367ab17162 +FROM mcr.microsoft.com/dotnet/sdk:9.0.306-bookworm-slim@sha256:a5dd7352c0c058a6f847c95a1147b060e95a532444f14b34d8fa9aaa0a76702f RUN wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \ dpkg -i packages-microsoft-prod.deb && \ diff --git a/docker/ubuntu1604.dockerfile b/docker/ubuntu1604.dockerfile index c6e956026f..9ecba3fd68 100644 --- a/docker/ubuntu1604.dockerfile +++ b/docker/ubuntu1604.dockerfile @@ -34,7 +34,7 @@ RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/nul COPY ./scripts/dotnet-install.sh ./dotnet-install.sh RUN chmod +x ./dotnet-install.sh \ - && ./dotnet-install.sh -v 9.0.305 --install-dir /usr/share/dotnet --no-path \ + && ./dotnet-install.sh -v 9.0.306 --install-dir /usr/share/dotnet --no-path \ && rm dotnet-install.sh WORKDIR /project diff --git a/src/OpenTelemetry.AutoInstrumentation/Generated/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs b/src/OpenTelemetry.AutoInstrumentation/Generated/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs index 4fd90b8111..35f008320e 100644 --- a/src/OpenTelemetry.AutoInstrumentation/Generated/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs +++ b/src/OpenTelemetry.AutoInstrumentation/Generated/net8.0/System.Text.RegularExpressions.Generator/System.Text.RegularExpressions.Generator.RegexGenerator/RegexGenerator.g.cs @@ -25,7 +25,7 @@ partial class EnvVarTypeConverter /// ○ Match '}'.
/// /// - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.41914")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.47513")] private static partial global::System.Text.RegularExpressions.Regex GetEnvVarRegex() => global::System.Text.RegularExpressions.Generated.GetEnvVarRegex_0.Instance; } } @@ -43,7 +43,7 @@ namespace System.Text.RegularExpressions.Generated using System.Threading; /// Custom -derived type for the GetEnvVarRegex method. - [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.41914")] + [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.47513")] file sealed class GetEnvVarRegex_0 : Regex { /// Cached, thread-safe singleton instance. @@ -324,7 +324,7 @@ void UncaptureUntil(int capturePosition) } /// Helper methods used by generated -derived implementations. - [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.41914")] + [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "8.0.12.47513")] file static class Utilities { /// Default timeout value set in , or if none was set.