11 types derived from AssemblyLoadContext
Microsoft.CodeAnalysis (1)
Microsoft.CodeAnalysis.LanguageServer (1)
Microsoft.CodeAnalysis.Scripting (1)
Microsoft.CodeAnalysis.Test.Utilities (2)
Microsoft.CodeAnalysis.Workspaces (1)
rzc (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)
262 references to AssemblyLoadContext
dotnet-svcutil-lib (1)
dotnet-watch (1)
dotnet-watch.Tests (2)
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)
33private readonly ImmutableDictionary<string, AssemblyLoadContext> _directoryLoadContexts;
35private readonly ImmutableDictionary<string, AssemblyLoadContext> _assemblyFullNameToLoadContext;
39public ExtensionAssemblyManager(ImmutableDictionary<string, AssemblyLoadContext> directoryLoadContexts,
40ImmutableDictionary<string, AssemblyLoadContext> assemblyFullNameToLoadContext,
57var directoryLoadContexts = new Dictionary<string, AssemblyLoadContext>(StringComparer.Ordinal);
58var assemblyFullNameToLoadContext = new Dictionary<string, AssemblyLoadContext>(StringComparer.Ordinal);
101if (assemblyFullNameToLoadContext.TryGetValue(assemblyFullName, out var existingContext))
114if (!directoryLoadContexts.TryGetValue(directory, out var directoryContext))
123AssemblyLoadContext GetOrCreateDirectoryContext(string directory, string assemblyFilePath)
125if (directoryLoadContexts.TryGetValue(directory, out var directoryContext))
145AssemblyLoadContext.Default.Resolving += (context, assemblyName) =>
171if (_directoryLoadContexts.TryGetValue(directory, out var loadContext))
186if (_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.ApiCompat.Tool (3)
Microsoft.DotNet.GenFacades (3)
Microsoft.DotNet.HotReload.Agent.Package (5)
Microsoft.DotNet.HotReload.WebAssembly.Browser (5)
Microsoft.DotNet.NativeWrapper (1)
Microsoft.Extensions.DotNetDeltaApplier (6)
rzc (5)
System.DirectoryServices.Protocols (1)
System.Private.CoreLib (94)
src\libraries\System.Private.CoreLib\src\System\Runtime\Loader\AssemblyLoadContext.cs (38)
33private static Dictionary<long, WeakReference<AssemblyLoadContext>>? s_allContexts;
37private static Dictionary<long, WeakReference<AssemblyLoadContext>> AllContexts =>
39Interlocked.CompareExchange(ref s_allContexts, new Dictionary<long, WeakReference<AssemblyLoadContext>>(), null) ??
56private event Func<AssemblyLoadContext, AssemblyName, Assembly>? _resolving;
58private event Action<AssemblyLoadContext>? _unloading;
106Dictionary<long, WeakReference<AssemblyLoadContext>> allContexts = AllContexts;
110allContexts.Add(_id, new WeakReference<AssemblyLoadContext>(this, true));
159Dictionary<long, WeakReference<AssemblyLoadContext>> allContexts = AllContexts;
173AssemblyLoadContext? alc = GetLoadContext(a);
210public event Func<AssemblyLoadContext, AssemblyName, Assembly?>? Resolving
225public event Action<AssemblyLoadContext>? Unloading
264public static AssemblyLoadContext Default => DefaultAssemblyLoadContext.s_loadContext;
272public static IEnumerable<AssemblyLoadContext> All
278Dictionary<long, WeakReference<AssemblyLoadContext>>? allContexts = s_allContexts;
281WeakReference<AssemblyLoadContext>[] alcSnapshot;
285alcSnapshot = new WeakReference<AssemblyLoadContext>[allContexts.Count];
287foreach (KeyValuePair<long, WeakReference<AssemblyLoadContext>> item in allContexts)
293foreach (WeakReference<AssemblyLoadContext> weakAlc in alcSnapshot)
295if (weakAlc.TryGetTarget(out AssemblyLoadContext? alc))
472Dictionary<long, WeakReference<AssemblyLoadContext>>? allContexts = s_allContexts;
481foreach (KeyValuePair<long, WeakReference<AssemblyLoadContext>> alcAlive in allContexts)
483if (alcAlive.Value.TryGetTarget(out AssemblyLoadContext? alc))
499private static AsyncLocal<AssemblyLoadContext?>? s_asyncLocalCurrent;
519/// <see cref="AssemblyLoadContext.EnterContextualReflection"/>.
525public static AssemblyLoadContext? CurrentContextualReflectionContext => s_asyncLocalCurrent?.Value;
527private static void SetCurrentContextualReflectionContext(AssemblyLoadContext? value)
531Interlocked.CompareExchange<AsyncLocal<AssemblyLoadContext?>?>(ref s_asyncLocalCurrent, new AsyncLocal<AssemblyLoadContext?>(), null);
565AssemblyLoadContext assemblyLoadContext = GetLoadContext(activating) ??
576/// <see cref="AssemblyLoadContext.EnterContextualReflection"/>
581private readonly AssemblyLoadContext? _activated;
582private readonly AssemblyLoadContext? _predecessor;
585internal ContextualReflectionScope(AssemblyLoadContext? activating)
609AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchAssemblyLoadContext).Target)!;
619foreach (Func<AssemblyLoadContext, AssemblyName, Assembly> handler in Delegate.EnumerateInvocationList(_resolving))
760AssemblyLoadContext parentALC = GetLoadContext(parentAssembly)!;
810internal 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)