Skip to content

Commit 42e5029

Browse files
committed
Fix to workaround a Roslyn issue leaking instances of the InteractiveAssemblyLoader
1 parent 46b2b1f commit 42e5029

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/WebJobs.Script/Description/CSharp/CSharpFunctionInvoker.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Microsoft.CodeAnalysis.CSharp;
2020
using Microsoft.CodeAnalysis.CSharp.Scripting;
2121
using Microsoft.CodeAnalysis.Scripting;
22+
using Microsoft.CodeAnalysis.Scripting.Hosting;
2223

2324
namespace Microsoft.Azure.WebJobs.Script.Description
2425
{
@@ -42,6 +43,9 @@ public class CSharpFunctionInvoker : ScriptFunctionInvokerBase
4243
private Action<MethodInfo, object[], object> _resultProcessor;
4344
private FunctionValueLoader _functionValueLoader;
4445

46+
private static readonly Lazy<InteractiveAssemblyLoader> AssemblyLoader
47+
= new Lazy<InteractiveAssemblyLoader>(() => new InteractiveAssemblyLoader(), LazyThreadSafetyMode.ExecutionAndPublication);
48+
4549
private static readonly string[] WatchedFileTypes = { ".cs", ".csx", ".dll", ".exe" };
4650

4751
internal CSharpFunctionInvoker(ScriptHost host, FunctionMetadata functionMetadata,
@@ -407,7 +411,7 @@ private Compilation GetScriptCompilation(Script<object> script, bool debug)
407411
private Script<object> CreateScript()
408412
{
409413
string code = GetFunctionSource();
410-
return CSharpScript.Create(code, options: _metadataResolver.FunctionScriptOptions);
414+
return CSharpScript.Create(code, options: _metadataResolver.FunctionScriptOptions, assemblyLoader: AssemblyLoader.Value);
411415
}
412416

413417
private static object GetTaskResult(Task task)

0 commit comments

Comments
 (0)