using System;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace IntelligentProjectAnalyzer.Editor
{
///
/// Contains all the data structures and models used throughout the dependency build process.
///
public static class DependencyBuilderData
{
///
/// A helper class to map concrete AssetMetadata types to a stable integer index.
///
public static class MetadataTypeHelper
{
// This list defines the stable mapping. Order is important.
private static readonly List Types = new()
{
typeof(ScriptMetadata),
typeof(PrefabMetadata),
typeof(ScriptableObjectMetadata)
};
public static int GetIndexFromType(Type type) => Types.IndexOf(type);
public static Type GetTypeFromIndex(int index) => (index >= 0 && index < Types.Count) ? Types[index] : null;
}
public class RoslynSetupData
{
public string[] SourceFiles { get; set; }
public string[] References { get; set; }
public string[] PreprocessorSymbols { get; set; }
public Dictionary TypeToGuidMap { get; set; }
public List SystemTypePrefixes { get; set; }
}
///
/// A serializable wrapper to store the concrete type and JSON data of our
/// abstract AssetMetadata objects. This allows for correct deserialization.
///
[Serializable]
public class MetadataWrapper
{
public int AssetTypeIndex { get; set; }
public string JsonData { get; set; }
}
///
/// The base class for all asset metadata. It is now the primary serializable object
/// and contains the list of direct dependencies for the asset.
///
[Serializable]
public abstract class AssetMetadata
{
public string Guid { get; set; }
public List DependencyGuids { get; set; } = new();
}
///
/// Metadata for a C# script. Its DependencyGuids will be populated by Roslyn analysis.
///
[Serializable]
public class ScriptMetadata : AssetMetadata
{
[JsonIgnore]
public string FullPath { get; set; }
}
///
/// Metadata for a Prefab. Its DependencyGuids will contain the GUIDs of all scripts attached as components.
///
[Serializable]
public class PrefabMetadata : AssetMetadata { }
///
/// Metadata for a ScriptableObject. Its DependencyGuids will contain the GUID of its backing script.
///
[Serializable]
public class ScriptableObjectMetadata : AssetMetadata { }
}
}