Repository navigation
Expand file tree
/
Copy pathScriptCompilationResult.cs
More file actions
106 lines (92 loc) · 3.93 KB
/
Copy pathScriptCompilationResult.cs
File metadata and controls
106 lines (92 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Inno.Extensibility.Modules;
namespace Inno.Scripting.Compiler;
/// <summary>
/// Reports the outputs and diagnostics of one authoring-generation or runtime-deployment script compilation.
/// </summary>
public sealed class ScriptCompilationResult
{
internal ScriptCompilationResult(
bool success,
IReadOnlyList<ScriptDiagnostic> diagnostics,
string? outputDirectory,
IReadOnlyList<ScriptModuleDeployment>? moduleDeployments,
IReadOnlyList<string>? compiledAssemblies = null,
IReadOnlyList<string>? reusedAssemblies = null,
IReadOnlyList<ScriptCompilationStageTiming>? stageTimings = null
) {
this.success = success;
this.diagnostics = diagnostics;
this.outputDirectory = outputDirectory;
this.moduleDeployments = Array.AsReadOnly((moduleDeployments ?? []).ToArray());
runtimeAssemblyPaths = this.moduleDeployments
.SelectMany(static request =>
new[] { request.mainAssemblyPath }.Concat(request.preloadAssemblyPaths)
.Where(path => request.assemblyScopes.TryGetValue(
Path.GetFileNameWithoutExtension(path),
out AssemblyScope scope)
? scope == AssemblyScope.Runtime
: request.scope == AssemblyScope.Runtime))
.Distinct(StringComparer.OrdinalIgnoreCase)
.Order(StringComparer.OrdinalIgnoreCase)
.ToArray();
this.compiledAssemblies = compiledAssemblies ?? [];
this.reusedAssemblies = reusedAssemblies ?? [];
this.stageTimings = stageTimings ?? [];
}
/// <summary>
/// Gets whether every discovered script assembly compiled or reused successfully.
/// </summary>
public bool success { get; }
/// <summary>
/// Gets all diagnostics produced by the compilation.
/// </summary>
public IReadOnlyList<ScriptDiagnostic> diagnostics { get; }
/// <summary>
/// Gets the generation output directory when one was created.
/// </summary>
public string? outputDirectory { get; }
/// <summary>
/// Gets completed compiler stage timings in execution order.
/// </summary>
public IReadOnlyList<ScriptCompilationStageTiming> stageTimings { get; }
/// <summary>
/// Gets exact runtime-scope managed assemblies suitable for a deployed Player.
/// </summary>
public IReadOnlyList<string> runtimeAssemblyPaths { get; }
/// <summary>
/// Gets the immutable module artifacts and dependency topology produced by this compilation.
/// </summary>
public IReadOnlyList<ScriptModuleDeployment> moduleDeployments { get; }
/// <summary>
/// Gets assembly names compiled during this request instead of reused from the artifact cache.
/// </summary>
public IReadOnlyList<string> compiledAssemblyNames => compiledAssemblies;
/// <summary>
/// Gets assembly names reused from the deterministic artifact cache.
/// </summary>
public IReadOnlyList<string> reusedAssemblyNames => reusedAssemblies;
/// <summary>
/// Creates a failed result for an exception intercepted at an orchestration boundary.
/// </summary>
/// <param name="diagnostic">
/// The diagnostic describing why no candidate generation was produced.
/// </param>
/// <returns>
/// A failed immutable result with no output directory or module deployments.
/// </returns>
public static ScriptCompilationResult Failure(ScriptDiagnostic diagnostic)
{
ArgumentNullException.ThrowIfNull(diagnostic);
return new ScriptCompilationResult(
success: false,
[diagnostic],
outputDirectory: null,
moduleDeployments: null);
}
internal IReadOnlyList<string> compiledAssemblies { get; }
internal IReadOnlyList<string> reusedAssemblies { get; }
}