blob: b133f8d60691f7a4b70618b62a83e2e72978bafa (
plain)
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
|
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using Mono.Cecil;
namespace StardewModdingAPI.Framework.ModLoading
{
/// <summary>Metadata about a parsed assembly definition.</summary>
internal class AssemblyParseResult
{
/*********
** Accessors
*********/
/// <summary>The original assembly file.</summary>
public readonly FileInfo File;
/// <summary>The assembly definition.</summary>
public readonly AssemblyDefinition? Definition;
/// <summary>The result of the assembly load.</summary>
public AssemblyLoadStatus Status;
/// <summary>Whether the <see cref="Definition"/> is loaded and ready (i.e. the <see cref="Status"/> is not <see cref="AssemblyLoadStatus.AlreadyLoaded"/> or <see cref="AssemblyLoadStatus.Failed"/>).</summary>
[MemberNotNullWhen(true, nameof(AssemblyParseResult.Definition))]
public bool HasDefinition => this.Status == AssemblyLoadStatus.Okay;
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
/// <param name="file">The original assembly file.</param>
/// <param name="assembly">The assembly definition.</param>
/// <param name="status">The result of the assembly load.</param>
public AssemblyParseResult(FileInfo file, AssemblyDefinition? assembly, AssemblyLoadStatus status)
{
this.File = file;
this.Definition = assembly;
this.Status = status;
if (status == AssemblyLoadStatus.Okay && assembly == null)
throw new InvalidOperationException($"Invalid assembly parse result: load status {status} with a null assembly.");
}
}
}
|