10 types derived from AssemblyLoadContext
Microsoft.CodeAnalysis (1)
Microsoft.CodeAnalysis.LanguageServer (1)
Microsoft.CodeAnalysis.Scripting (1)
Microsoft.CodeAnalysis.Test.Utilities (2)
Microsoft.CodeAnalysis.Workspaces (1)
System.Private.CoreLib (3)
xunit.console (1)
8 instantiations of AssemblyLoadContext
Microsoft.CodeAnalysis.ExternalAccess.Razor.UnitTests (2)
Microsoft.CodeAnalysis.UnitTests (5)
System.Windows.Forms.Design.Tests (1)
239 references to AssemblyLoadContext
aspire-server (2)
dotnet-svcutil-lib (1)
GetDocument.Insider (1)
illink (1)
Microsoft.AspNetCore.Components.WebAssembly (2)
Microsoft.AspNetCore.Http.Microbenchmarks (1)
Microsoft.AspNetCore.Mvc.Core (5)
Microsoft.AspNetCore.Mvc.Core.Test (1)
Microsoft.CodeAnalysis (20)
Microsoft.CodeAnalysis.ExternalAccess.Razor.Features (5)
RazorAnalyzerAssemblyResolver.cs (5)
32public Assembly? Resolve(AnalyzerAssemblyLoader loader, AssemblyName assemblyName, AssemblyLoadContext directoryContext, string directory) =>
37AssemblyLoadContext.GetLoadContext(typeof(Microsoft.CodeAnalysis.Compilation).Assembly)!,
45internal static Assembly? ResolveCore(AssemblyLoadContext compilerLoadContext, AssemblyName assemblyName, string directory)
61static Assembly? LoadAssemblyByFileName(AssemblyLoadContext compilerLoadContext, string fileName, string directory)
73static Assembly? LoadAssembly(AssemblyLoadContext compilerLoadContext, AssemblyName assemblyName, string directory)
Microsoft.CodeAnalysis.ExternalAccess.Razor.UnitTests (5)
Microsoft.CodeAnalysis.LanguageServer (14)
Services\ExtensionAssemblyManager.cs (13)
32private readonly ImmutableDictionary<string, AssemblyLoadContext> _directoryLoadContexts;
34private readonly ImmutableDictionary<string, AssemblyLoadContext> _assemblyFullNameToLoadContext;
38public ExtensionAssemblyManager(ImmutableDictionary<string, AssemblyLoadContext> directoryLoadContexts,
39ImmutableDictionary<string, AssemblyLoadContext> assemblyFullNameToLoadContext,
56var directoryLoadContexts = new Dictionary<string, AssemblyLoadContext>(StringComparer.Ordinal);
57var assemblyFullNameToLoadContext = new Dictionary<string, AssemblyLoadContext>(StringComparer.Ordinal);
88if (assemblyFullNameToLoadContext.TryGetValue(assemblyFullName, out var existingContext))
101if (!directoryLoadContexts.TryGetValue(directory, out var directoryContext))
110AssemblyLoadContext GetOrCreateDirectoryContext(string directory, string assemblyFilePath)
112if (directoryLoadContexts.TryGetValue(directory, out var directoryContext))
132AssemblyLoadContext.Default.Resolving += (context, assemblyName) =>
158if (_directoryLoadContexts.TryGetValue(directory, out var loadContext))
173if (_assemblyFullNameToLoadContext.TryGetValue(assemblyFullName, out var loadContext))
Microsoft.CodeAnalysis.LanguageServer.UnitTests (2)
Microsoft.CodeAnalysis.Remote.ServiceHub.UnitTests (12)
Microsoft.CodeAnalysis.Remote.Workspaces (1)
Microsoft.CodeAnalysis.UnitTests (12)
AnalyzerAssemblyLoaderTests.cs (6)
1654var alc = new AssemblyLoadContext(nameof(AssemblyResolver_FirstOneWins), isCollectible: false);
1785var alc = new AssemblyLoadContext(nameof(AssemblyResolver_FirstOneWins), isCollectible: true);
1810var alc = new AssemblyLoadContext(nameof(AssemblyResolver_FirstOneWins), isCollectible: true);
1845private class TestAnalyzerAssemblyResolver(Func<AnalyzerAssemblyLoader, AssemblyName, AssemblyLoadContext, string, Assembly?> resolveFunc) : IAnalyzerAssemblyResolver
1847private readonly Func<AnalyzerAssemblyLoader, AssemblyName, AssemblyLoadContext, string, Assembly?> _resolveFunc = resolveFunc;
1851public Assembly? Resolve(AnalyzerAssemblyLoader loader, AssemblyName assemblyName, AssemblyLoadContext directoryContext, string directory)
Microsoft.CodeAnalysis.Workspaces (26)
Microsoft.DotNet.GenFacades (3)
Microsoft.Extensions.Validation.GeneratorTests (1)
System.DirectoryServices.Protocols (1)
System.Private.CoreLib (96)
src\libraries\System.Private.CoreLib\src\System\Runtime\Loader\AssemblyLoadContext.cs (44)
34private static Dictionary<long, WeakReference<AssemblyLoadContext>>? s_allContexts;
38private static Dictionary<long, WeakReference<AssemblyLoadContext>> AllContexts =>
40Interlocked.CompareExchange(ref s_allContexts, new Dictionary<long, WeakReference<AssemblyLoadContext>>(), null) ??
57private event Func<AssemblyLoadContext, AssemblyName, Assembly>? _resolving;
59private event Action<AssemblyLoadContext>? _unloading;
107Dictionary<long, WeakReference<AssemblyLoadContext>> allContexts = AllContexts;
111allContexts.Add(_id, new WeakReference<AssemblyLoadContext>(this, true));
160Dictionary<long, WeakReference<AssemblyLoadContext>> allContexts = AllContexts;
174AssemblyLoadContext? alc = GetLoadContext(a);
211public event Func<AssemblyLoadContext, AssemblyName, Assembly?>? Resolving
226public event Action<AssemblyLoadContext>? Unloading
265public static AssemblyLoadContext Default => DefaultAssemblyLoadContext.s_loadContext;
273public static IEnumerable<AssemblyLoadContext> All
279Dictionary<long, WeakReference<AssemblyLoadContext>>? allContexts = s_allContexts;
282WeakReference<AssemblyLoadContext>[] alcSnapshot;
286alcSnapshot = new WeakReference<AssemblyLoadContext>[allContexts.Count];
288foreach (KeyValuePair<long, WeakReference<AssemblyLoadContext>> item in allContexts)
294foreach (WeakReference<AssemblyLoadContext> weakAlc in alcSnapshot)
296if (weakAlc.TryGetTarget(out AssemblyLoadContext? alc))
473Dictionary<long, WeakReference<AssemblyLoadContext>>? allContexts = s_allContexts;
482foreach (KeyValuePair<long, WeakReference<AssemblyLoadContext>> alcAlive in allContexts)
484if (alcAlive.Value.TryGetTarget(out AssemblyLoadContext? alc))
500private static AsyncLocal<AssemblyLoadContext?>? s_asyncLocalCurrent;
520/// <see cref="AssemblyLoadContext.EnterContextualReflection"/>.
526public static AssemblyLoadContext? CurrentContextualReflectionContext => s_asyncLocalCurrent?.Value;
528private static void SetCurrentContextualReflectionContext(AssemblyLoadContext? value)
532Interlocked.CompareExchange<AsyncLocal<AssemblyLoadContext?>?>(ref s_asyncLocalCurrent, new AsyncLocal<AssemblyLoadContext?>(), null);
566AssemblyLoadContext assemblyLoadContext = GetLoadContext(activating) ??
577/// <see cref="AssemblyLoadContext.EnterContextualReflection"/>
582private readonly AssemblyLoadContext? _activated;
583private readonly AssemblyLoadContext? _predecessor;
586internal ContextualReflectionScope(AssemblyLoadContext? activating)
610AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchAssemblyLoadContext).Target)!;
620foreach (Func<AssemblyLoadContext, AssemblyName, Assembly> handler in Delegate.EnumerateInvocationList(_resolving))
801AssemblyLoadContext context = GCHandle<AssemblyLoadContext>.FromIntPtr(gchAssemblyLoadContext).Target;
815AssemblyLoadContext context = GCHandle<AssemblyLoadContext>.FromIntPtr(gchAssemblyLoadContext).Target;
829AssemblyLoadContext context = GCHandle<AssemblyLoadContext>.FromIntPtr(gchAssemblyLoadContext).Target;
858AssemblyLoadContext parentALC = GetLoadContext(parentAssembly)!;
908internal static readonly AssemblyLoadContext s_loadContext = new DefaultAssemblyLoadContext();
System.Private.DataContractSerialization (4)
System.Private.Xml (13)
System.Reflection.DispatchProxy (5)
System.Runtime.Loader (1)
System.Windows.Forms.Design.Tests (2)
TestDiscoveryWorker (1)
xunit.console (1)