Skip to content

Commit

Permalink
Clean up warnings for docs and potential error sources like missing h…
Browse files Browse the repository at this point in the history
…armony instance
  • Loading branch information
Banane9 committed Jun 5, 2024
1 parent a2a78ca commit b7b6464
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 27 deletions.
7 changes: 7 additions & 0 deletions MonkeyLoader.GamePacks.ResoniteModLoader/ModConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ public ISet<ModConfigurationKey> ConfigurationItemDefinitions
/// <inheritdoc/>
public Version Version { get; private set; }

/// <summary>
/// Creates a new <see cref="ModConfiguration"/> definition.
/// </summary>
/// <param name="owner">The mod owning the config.</param>
/// <param name="configVersion">The version of the config.</param>
/// <param name="keys">The config keys for the config.</param>
/// <param name="autoSaveConfig">Whether to automatically save the config.</param>
public ModConfigurationDefinition(ResoniteModBase owner, Version configVersion, HashSet<ModConfigurationKey> keys, bool autoSaveConfig)
{
Owner = owner;
Expand Down
15 changes: 15 additions & 0 deletions MonkeyLoader.GamePacks.ResoniteModLoader/ModConfigurationKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,20 @@ public abstract class ModConfigurationKey
public string Name => NameProxy;

internal abstract IDefiningConfigKey UntypedKey { get; }

/// <summary>
/// Gets the proxied description from the <see cref="ModConfigurationKey{T}.Key"/>.
/// </summary>
protected abstract string? DescriptionProxy { get; }

/// <summary>
/// Gets the proxied internal access only value from the <see cref="ModConfigurationKey{T}.Key"/>.
/// </summary>
protected abstract bool InternalAccessOnlyProxy { get; }

/// <summary>
/// Gets the proxied name from the <see cref="ModConfigurationKey{T}.Key"/>.
/// </summary>
protected abstract string NameProxy { get; }

internal ModConfigurationKey()
Expand Down Expand Up @@ -96,6 +108,9 @@ public class ModConfigurationKey<T> : ModConfigurationKey
{
private static int _replacementCounter = 0;

/// <summary>
/// Gets the internal MonkeyLoader config key.
/// </summary>
public DefiningConfigKey<T> Key { get; }

internal override IDefiningConfigKey UntypedKey => Key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MonkeyLoader" Version="0.17.1-beta" />
<PackageReference Include="MonkeyLoader.GamePacks.Resonite" Version="0.15.2-beta" GeneratePathProperty="True" />
<PackageReference Include="MonkeyLoader" Version="0.17.2-beta" />
<PackageReference Include="MonkeyLoader.GamePacks.Resonite" Version="0.15.3-beta" GeneratePathProperty="True" />
<PackageReference Include="PolySharp" Version="1.14.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Resonite.Elements.Core" Version="1.0.2" />
<PackageReference Include="Resonite.FrooxEngine" Version="2024.5.31.202" />
<PackageReference Include="Resonite.FrooxEngine" Version="2024.6.5.198" />
<PackageReference Include="Zio" Version="0.18.0" />
</ItemGroup>

Expand Down
37 changes: 19 additions & 18 deletions MonkeyLoader.GamePacks.ResoniteModLoader/ResoniteMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public abstract class ResoniteMod : ResoniteModBase
/// <inheritdoc/>
protected override ModConfiguration? Configuration => _configuration.Value;

/// <inheritdoc/>
protected ResoniteMod()
{
_configuration = new(() =>
Expand Down Expand Up @@ -86,7 +87,7 @@ public static void Msg(object message)
/// Logs the given objects as regular lines in the log.
/// </summary>
/// <param name="messages">The objects to log.</param>
public static void Msg(params object[] messages)
public static void Msg(params object[] messages)
=> GetLoggerFromStackTrace(new(1)).Info(Wrap(messages));

/// <summary>
Expand Down Expand Up @@ -140,23 +141,6 @@ public override bool Run()
}
}

/// <summary>
/// Build the defined configuration for this mod.
/// </summary>
/// <returns>This mod's configuration definition.</returns>
internal ModConfigurationDefinition? BuildConfigurationDefinition()
{
ModConfigurationDefinitionBuilder builder = new(this);
builder.ProcessAttributes();
DefineConfiguration(builder);
return builder.Build();
}

private static Func<object> Wrap(object message) => () => message;

private static IEnumerable<Func<object>> Wrap(IEnumerable<object> messages)
=> messages.Select(Wrap);

/// <summary>
/// Get the Logger for the mod from a stack trace.
/// </summary>
Expand All @@ -178,5 +162,22 @@ internal static Logger GetLoggerFromStackTrace(StackTrace stackTrace)
}
return ModLoader.Logger;
}

/// <summary>
/// Build the defined configuration for this mod.
/// </summary>
/// <returns>This mod's configuration definition.</returns>
internal ModConfigurationDefinition? BuildConfigurationDefinition()
{
ModConfigurationDefinitionBuilder builder = new(this);
builder.ProcessAttributes();
DefineConfiguration(builder);
return builder.Build();
}

private static Func<object> Wrap(object message) => () => message;

private static IEnumerable<Func<object>> Wrap(IEnumerable<object> messages)
=> messages.Select(Wrap);
}
}
22 changes: 16 additions & 6 deletions MonkeyLoader.GamePacks.ResoniteModLoader/ResoniteModBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@

namespace ResoniteModLoader
{
/// <summary>
/// Base class for <see cref="ResoniteMod"/>s.
/// </summary>
public abstract class ResoniteModBase : IMonkey
{
private Mod _mod;

Mod INestedIdentifiable<Mod>.Parent => _mod;

IIdentifiable INestedIdentifiable.Parent => _mod;
private Mod _mod = null!;

/// <inheritdoc/>
public AssemblyName AssemblyName { get; }
Expand All @@ -46,7 +45,7 @@ public bool Enabled
public bool Failed { get; private set; }

/// <inheritdoc/>
public IEnumerable<IFeaturePatch> FeaturePatches { get; }
public IEnumerable<IFeaturePatch> FeaturePatches { get; } = Array.Empty<IFeaturePatch>();

/// <inheritdoc/>
public string FullId { get; }
Expand Down Expand Up @@ -91,6 +90,10 @@ internal set
/// </summary>
public abstract string Name { get; }

Mod INestedIdentifiable<Mod>.Parent => _mod;

IIdentifiable INestedIdentifiable.Parent => _mod;

/// <inheritdoc/>
public bool Ran { get; private set; }

Expand All @@ -108,14 +111,21 @@ internal set
/// </summary>
public abstract string Version { get; }

/// <summary>
/// Gets the Mod's configuration.
/// </summary>
protected abstract ModConfiguration? Configuration { get; }

/// <summary>
/// Creates a new Resonite Mod instance.
/// </summary>
protected ResoniteModBase()
{
Type = GetType();
AssemblyName = new(Type.Assembly.GetName().Name);

FullId = $"RML.{Name}";
Harmony = new(FullId);
}

/// <inheritdoc/>
Expand Down

0 comments on commit b7b6464

Please sign in to comment.