using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using Mono.Cecil;
namespace StardewModdingAPI.Framework.ModLoading
{
/// Metadata about a parsed assembly definition.
internal class AssemblyParseResult
{
/*********
** Accessors
*********/
/// The original assembly file.
public readonly FileInfo File;
/// The assembly definition.
public readonly AssemblyDefinition? Definition;
/// The result of the assembly load.
public AssemblyLoadStatus Status;
/// Whether the is loaded and ready (i.e. the is not or ).
[MemberNotNullWhen(true, nameof(AssemblyParseResult.Definition))]
public bool HasDefinition => this.Status == AssemblyLoadStatus.Okay;
/*********
** Public methods
*********/
/// Construct an instance.
/// The original assembly file.
/// The assembly definition.
/// The result of the assembly load.
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.");
}
}
}