using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
namespace Robust.Shared.Reflection
{
///
/// Manages common reflection operations, such as iterating over all subtypes of something.
/// This is distinctly different from IoC: IoC manages services and DI.
///
///
///
/// By default, all classes are "discoverable" by .
/// This can be overriden by assigning a and disabling discoverability.
/// Classes which cannot be instantiated are also ignored (interfaces, abstracts)
///
///
/// Types only become accessible when loaded using .
/// This is to prevent non-game assemblies from cluttering everything.
///
///
///
///
public interface IReflectionManager
{
///
/// Gets all known types that are assignable to .
///
///
///
/// When true, include in the returned results
/// if it is a known type.
///
/// An enumerable over all the types. Order is in no way guaranteed.
IEnumerable GetAllChildren(bool inclusive = false);
///
/// Gets all known types that are assignable to the given type.
///
/// The base type to search for.
/// When true, include in the
/// returned results if it is a known type.
/// An enumerable over all the types. Order is in no way guaranteed.
IEnumerable GetAllChildren(Type baseType, bool inclusive = false);
///
/// All loaded assemblies.
///
IReadOnlyList Assemblies { get; }
///
/// Attempts to get a type by string name in the loaded assemblies.
///
///
/// The type name to look up. Anything accepted by works.
/// However, if the type does not start with Robust.* and cannot be found,
/// it will add Robust.Client, Robust.Shared, etc... in front of it.
///
///
Type? GetType(string name);
Type LooseGetType(string name);
bool TryLooseGetType(string name, [NotNullWhen(true)] out Type? type);
///
/// Finds all Types in all Assemblies that have a specific Attribute.
///
/// Attribute to search for.
/// Enumeration of all types with the specified attribute.
IEnumerable FindTypesWithAttribute() where T : Attribute;
///
/// Finds all Types in all Assemblies that have a specific Attribute.
///
/// Attribute to search for.
/// Enumeration of all types with the specified attribute.
IEnumerable FindTypesWithAttribute(Type attributeType);
///
/// Loads assemblies into the manager and get all the types.
///
void LoadAssemblies(IEnumerable assemblies);
///
/// Loads assemblies into the manager and get all the types.
///
void LoadAssemblies(params Assembly[] args);
///
/// Fired whenever an assembly is added through ,
/// this means more types might be available from and
///
event EventHandler? OnAssemblyAdded;
///
/// Tries to parse an enum in the form "enum.PowerStorageAppearance.Charge", for use in prototyping.
///
///
/// The string enum reference, including the "enum." prefix.
/// If this prefix does not exist, it is assumed to not be a reference and ignored.
///
///
/// True if the string was an enum reference that parsed correctly, false if it was not a reference.
/// Note that if it was a reference and it could not be resolved, the function throws a instead.
///
///
/// Thrown if this string is an enum reference, but the enum could not be resolved.
///
bool TryParseEnumReference(string reference, [NotNullWhen(true)] out Enum? @enum);
Type? YamlTypeTagLookup(Type baseType, string typeName);
}
}