fix(scripts): memoize missing-assembly resolution on the site compile path
This commit is contained in:
@@ -89,9 +89,21 @@ public class ScriptCompilationService
|
||||
/// <c>ScriptAnalysisService.DefaultOptions</c> and
|
||||
/// <c>ScriptTrustPolicy.DefaultReferences</c> already follow this pattern.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Static options alone are NOT enough: every <c>script.Compile()</c> binds the
|
||||
/// transitive closure of these references, and Roslyn's default resolver
|
||||
/// re-resolves that closure through <c>MetadataReference.CreateFromFile</c> on
|
||||
/// EVERY compile (~74–105 fresh native metadata copies per compiled script,
|
||||
/// confirmed live post-5a781c70 on 2026-08-12: 21 scripts held 6,640
|
||||
/// AssemblyMetadata/PEReader/MetadataImageReference objects). The shared
|
||||
/// <see cref="CachingScriptMetadataResolver"/> memoizes those resolutions
|
||||
/// process-wide; see its doc for the full mechanism.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
private static readonly ScriptOptions SharedScriptOptions = ScriptOptions.Default
|
||||
.WithReferences(ScriptAssemblies)
|
||||
.WithMetadataResolver(CachingScriptMetadataResolver.Instance)
|
||||
.WithImports(
|
||||
"System",
|
||||
"System.Collections.Generic",
|
||||
|
||||
Reference in New Issue
Block a user