fix(scripts): memoize missing-assembly resolution on inbound API method compiles
This commit is contained in:
@@ -10,6 +10,7 @@ using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Services;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Messages.InboundApi;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Observability;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types;
|
||||
using ZB.MOM.WW.ScadaBridge.ScriptAnalysis;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.InboundAPI;
|
||||
|
||||
@@ -220,6 +221,17 @@ public class InboundScriptExecutor
|
||||
/// Same defect, same shape as the Site-side one confirmed from a live dump on 2026-08-12
|
||||
/// (<c>SiteRuntime.Scripts.ScriptCompilationService.SharedScriptOptions</c>).
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Static options alone are NOT enough: every method compile binds the
|
||||
/// transitive closure of these references, and Roslyn's default resolver
|
||||
/// re-resolves that closure through <c>MetadataReference.CreateFromFile</c> on
|
||||
/// EVERY compile (confirmed live post-5a781c70 on 2026-08-12: 6 inbound
|
||||
/// methods held 2,699 AssemblyMetadata/PEReader/MetadataImageReference
|
||||
/// objects, ~150 per compile — and method revisions recompile, so growth was
|
||||
/// unbounded). The shared <see cref="CachingScriptMetadataResolver"/>
|
||||
/// memoizes those resolutions process-wide.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
private static readonly ScriptOptions SharedScriptOptions = ScriptOptions.Default
|
||||
.WithReferences(
|
||||
@@ -229,6 +241,7 @@ public class InboundScriptExecutor
|
||||
typeof(RouteHelper).Assembly,
|
||||
typeof(ScriptParameters).Assembly,
|
||||
typeof(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo).Assembly)
|
||||
.WithMetadataResolver(CachingScriptMetadataResolver.Instance)
|
||||
.WithImports(
|
||||
"System",
|
||||
"System.Collections.Generic",
|
||||
|
||||
Reference in New Issue
Block a user