-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eed23a0
commit 4d728dc
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...test-applications/regression/AssemblyLoadContextResolve/AssemblyLoadContextResolve.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp2.1;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
</Project> |
56 changes: 56 additions & 0 deletions
56
tracer/test/test-applications/regression/AssemblyLoadContextResolve/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Runtime.Loader; | ||
|
||
namespace AssemblyLoadContextResolve; | ||
|
||
internal class Program | ||
{ | ||
private static ConcurrentStack<string> _assemblyResolveCalls = new(); | ||
|
||
private const string TestAssemblyName = "datadog_test_assembly"; | ||
|
||
static void Main(string[] args) | ||
{ | ||
AssemblyLoadContext.Default.Resolving += AssemblyResolving; | ||
|
||
var traceAssembly = Assembly.Load("Datadog.Trace"); | ||
var alc = AssemblyLoadContext.GetLoadContext(traceAssembly); | ||
|
||
if (alc.GetType().FullName != "Datadog.Trace.ClrProfiler.Managed.Loader.ManagedProfilerAssemblyLoadContext") | ||
{ | ||
throw new InvalidOperationException($"Datadog.Trace was loaded in the wrong ALC: {alc.GetType()}"); | ||
} | ||
|
||
try | ||
{ | ||
var testAssembly = Assembly.Load(TestAssemblyName); | ||
throw new InvalidOperationException($"Test assembly was found, this shouldn't happen: {testAssembly}"); | ||
} | ||
catch (FileNotFoundException) | ||
{ | ||
// Expected | ||
} | ||
|
||
var resolvedAssemblies = _assemblyResolveCalls.ToList(); | ||
|
||
if (!resolvedAssemblies.Contains(TestAssemblyName)) | ||
{ | ||
throw new InvalidOperationException($"AssemblyResolving should have been called for {TestAssemblyName}: {string.Join(", ", resolvedAssemblies)}"); | ||
} | ||
|
||
if (resolvedAssemblies.Contains("Datadog.Trace")) | ||
{ | ||
throw new InvalidOperationException($"AssemblyResolving shouldn't have been called for Datadog.Trace: {string.Join(", ", resolvedAssemblies)}"); | ||
} | ||
} | ||
|
||
private static Assembly AssemblyResolving(AssemblyLoadContext alc, AssemblyName assemblyname) | ||
{ | ||
_assemblyResolveCalls.Push(assemblyname?.Name); | ||
return null; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...st/test-applications/regression/AssemblyLoadContextResolve/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"profiles": { | ||
"AssemblyLoadContextResolve": { | ||
"commandName": "Project", | ||
"environmentVariables": { | ||
"CORECLR_ENABLE_PROFILING": "1", | ||
"CORECLR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", | ||
"CORECLR_PROFILER_PATH": "$(SolutionDir)shared\\bin\\monitoring-home\\tracer\\win-$(Platform)\\Datadog.Trace.ClrProfiler.Native.dll", | ||
|
||
"DD_DOTNET_TRACER_HOME": "$(SolutionDir)shared\\bin\\monitoring-home\\tracer", | ||
"DD_VERSION": "1.0.0" | ||
}, | ||
"nativeDebugging": true | ||
} | ||
} | ||
} |