Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit 1a68a8c

Browse files
committed
Bump version, stop abusing string.Format
1 parent 1f6dc16 commit 1a68a8c

File tree

6 files changed

+26
-25
lines changed

6 files changed

+26
-25
lines changed

NeosModLoader/Configuration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal static Configuration get()
1515
if (_configuration == null)
1616
{
1717
// the config file can just sit next to the dll. Simple.
18-
string path = string.Format("{0}\\{1}", GetAssemblyDirectory(), CONFIG_FILENAME);
18+
string path = $"{GetAssemblyDirectory()}\\{CONFIG_FILENAME}";
1919
_configuration = new Configuration();
2020

2121
// .NET's ConfigurationManager is some hot trash to the point where I'm just done with it.
@@ -42,7 +42,7 @@ internal static Configuration get()
4242
{
4343
if (e is FileNotFoundException)
4444
{
45-
Logger.MsgInternal(string.Format("{0} is missing! This is probably fine.", CONFIG_FILENAME));
45+
Logger.MsgInternal($"{CONFIG_FILENAME} is missing! This is probably fine.");
4646
}
4747
else if (e is DirectoryNotFoundException || e is IOException || e is UnauthorizedAccessException)
4848
{

NeosModLoader/ExecutionHook.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ static ExecutionHook()
1515
{
1616
try
1717
{
18-
Logger.DebugInternal("execution hook running");
18+
Logger.DebugInternal($"NeosModLoader v{ModLoader.VERSION} starting up!");
1919
NeosVersionReset.Initialize();
2020
ModLoader.LoadMods();
2121
}
2222
catch (Exception e) // it's important that this doesn't send exceptions back to Neos
2323
{
24-
Logger.ErrorInternal(string.Format("Exception in execution hook!\n{0}\n{1}", e.ToString(), e.StackTrace.ToString()));
24+
Logger.ErrorInternal($"Exception in execution hook!\n{e}");
2525
}
2626
}
2727

NeosModLoader/Logger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ private static void LogInternal(LogType logType, string message, string source =
5252
{
5353
if (source == null)
5454
{
55-
UniLog.Log(string.Format("[NeosModLoader][{0}] {1}", LogTypeName(logType), message));
55+
UniLog.Log($"[NeosModLoader][{LogTypeName(logType)}] {message}");
5656
}
5757
else
5858
{
59-
UniLog.Log(string.Format("[NeosModLoader/{0}][{1}] {2}", source, LogTypeName(logType), message));
59+
UniLog.Log($"[NeosModLoader/{source}][{LogTypeName(logType)}] {message}");
6060
}
6161
}
6262

NeosModLoader/ModLoader.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ namespace NeosModLoader
1010
{
1111
internal class ModLoader
1212
{
13+
public static readonly string VERSION = "1.1.0";
1314
private static readonly Type NEOS_MOD_TYPE = typeof(NeosMod);
1415
internal static Dictionary<Assembly, NeosMod> LoadedMods { get; } = new Dictionary<Assembly, NeosMod>();
1516

1617
internal static void LoadMods()
1718
{
1819
string modDirectory = Directory.GetParent(Process.GetCurrentProcess().MainModule.FileName).FullName + "\\nml_mods";
19-
Logger.DebugInternal(string.Format("loading mods from {0}", modDirectory));
20+
Logger.DebugInternal($"loading mods from {modDirectory}");
2021

2122
ModAssembly[] modsToLoad = null;
2223
try
@@ -36,12 +37,12 @@ internal static void LoadMods()
3637
}
3738
catch (Exception e2)
3839
{
39-
Logger.ErrorInternal(string.Format("Error creating mod directory:\n{0}\n{1}", e2.ToString(), e2.StackTrace.ToString()));
40+
Logger.ErrorInternal($"Error creating mod directory:\n{e2}");
4041
}
4142
}
4243
else
4344
{
44-
Logger.ErrorInternal(string.Format("Error enumerating mod directory:\n{0}\n{1}", e.ToString(), e.StackTrace.ToString()));
45+
Logger.ErrorInternal($"Error enumerating mod directory:\n{e}");
4546
}
4647
return;
4748
}
@@ -54,7 +55,7 @@ internal static void LoadMods()
5455
}
5556
catch (Exception e)
5657
{
57-
Logger.ErrorInternal(string.Format("Unexpected exception loading mod assembly from {0}:\n{1}\n{2}", mod.File, e.ToString(), e.StackTrace.ToString()));
58+
Logger.ErrorInternal($"Unexpected exception loading mod assembly from {mod.File}:\n{e}");
5859
}
5960
}
6061

@@ -66,7 +67,7 @@ internal static void LoadMods()
6667
}
6768
catch (Exception e)
6869
{
69-
Logger.ErrorInternal(string.Format("Unexpected exception loading mod from {0}:\n{1}\n{2}", mod.File, e.ToString(), e.StackTrace.ToString()));
70+
Logger.ErrorInternal($"Unexpected exception loading mod from {mod.File}:\n{e}");
7071
}
7172
}
7273
}
@@ -80,12 +81,12 @@ private static void LoadAssembly(ModAssembly mod)
8081
}
8182
catch (Exception e)
8283
{
83-
Logger.ErrorInternal(string.Format("error loading assembly from {0}: {1}", mod.File, e.ToString()));
84+
Logger.ErrorInternal($"error loading assembly from {mod.File}: {e}");
8485
return;
8586
}
8687
if (assembly == null)
8788
{
88-
Logger.ErrorInternal(string.Format("unexpected null loading assembly from {0}", mod.File));
89+
Logger.ErrorInternal($"unexpected null loading assembly from {mod.File}");
8990
return;
9091
}
9192
mod.Assembly = assembly;
@@ -101,10 +102,10 @@ private static void HookMod(ModAssembly mod)
101102
Type[] modClasses = mod.Assembly.GetTypes().Where(t => t.IsClass && !t.IsAbstract && NEOS_MOD_TYPE.IsAssignableFrom(t)).ToArray();
102103
if (modClasses.Length == 0)
103104
{
104-
Logger.ErrorInternal(string.Format("no mods found in {0}", mod.File));
105+
Logger.ErrorInternal($"no mods found in {mod.File}");
105106
} else if (modClasses.Length != 1)
106107
{
107-
Logger.ErrorInternal(string.Format("more than one mod found in {0}. no mods will be loaded.", mod.File));
108+
Logger.ErrorInternal($"more than one mod found in {mod.File}. no mods will be loaded.");
108109
}
109110
else
110111
{
@@ -116,23 +117,23 @@ private static void HookMod(ModAssembly mod)
116117
}
117118
catch (Exception e)
118119
{
119-
Logger.ErrorInternal(string.Format("error instantiating mod {0} from {1}:\n{2}\n{3}", modClass.FullName, mod.File, e.ToString(), e.StackTrace.ToString()));
120+
Logger.ErrorInternal($"error instantiating mod {modClass.FullName} from {mod.File}:\n{e}");
120121
return;
121122
}
122123
if (neosMod == null)
123124
{
124-
Logger.ErrorInternal(string.Format("unexpected null instantiating mod {0} from {1}", modClass.FullName, mod.File));
125+
Logger.ErrorInternal($"unexpected null instantiating mod {modClass.FullName} from {mod.File}");
125126
return;
126127
}
127128
LoadedMods.Add(mod.Assembly, neosMod);
128-
Logger.MsgInternal(string.Format("loaded mod {0} {1} from {2}", neosMod.Name, neosMod.Version, mod.File));
129+
Logger.MsgInternal($"loaded mod {neosMod.Name} {neosMod.Version} from {mod.File}");
129130
try
130131
{
131132
neosMod.OnEngineInit();
132133
}
133134
catch (Exception e)
134135
{
135-
Logger.ErrorInternal(string.Format("mod {0} from {1} threw error from OnEngineInit():\n{2}\n{3}", modClass.FullName, mod.File, e.ToString(), e.StackTrace.ToString()));
136+
Logger.ErrorInternal($"mod {modClass.FullName} from {mod.File} threw error from OnEngineInit():\n{e}");
136137
}
137138
}
138139
}

NeosModLoader/NeosVersionReset.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal static void Initialize()
4040
int? vanillaProtocolVersionMaybe = GetVanillaProtocolVersion();
4141
if (vanillaProtocolVersionMaybe is int vanillaProtocolVersion)
4242
{
43-
Logger.DebugInternal(string.Format("vanilla protocol version is {0}", vanillaProtocolVersion));
43+
Logger.DebugInternal($"vanilla protocol version is {vanillaProtocolVersion}");
4444
vanillaCompatibilityHash = CalculateCompatibilityHash(vanillaProtocolVersion);
4545
}
4646
else
@@ -82,7 +82,7 @@ private static bool SetCompatibilityHash(Engine engine, string Target)
8282
// This is super sketchy and liable to break with new compiler versions.
8383
// I have a good reason for doing it though... if I just called the setter it would recursively
8484
// end up calling itself, because I'm HOOKINGthe CompatibilityHash setter.
85-
FieldInfo field = AccessTools.DeclaredField(typeof(Engine), string.Format("<{0}>k__BackingField", nameof(Engine.CompatibilityHash)));
85+
FieldInfo field = AccessTools.DeclaredField(typeof(Engine), $"<{nameof(Engine.CompatibilityHash)}>k__BackingField");
8686

8787
if (field == null)
8888
{
@@ -91,7 +91,7 @@ private static bool SetCompatibilityHash(Engine engine, string Target)
9191
}
9292
else
9393
{
94-
Logger.DebugInternal(string.Format("changing compatibility hash from {0} to {1}", engine.CompatibilityHash, Target));
94+
Logger.DebugInternal($"changing compatibility hash from {engine.CompatibilityHash} to {Target}");
9595
field.SetValue(engine, Target);
9696
return true;
9797
}
@@ -109,7 +109,7 @@ private static bool SetVersionString(Engine engine)
109109
Logger.WarnInternal("unable to write Engine._versionString");
110110
return false;
111111
}
112-
Logger.DebugInternal(string.Format("changing version string from {0} to {1}", engine.VersionString, target));
112+
Logger.DebugInternal($"changing version string from {engine.VersionString} to {target}");
113113
field.SetValue(engine, target);
114114
}
115115
return true;

NeosModLoader/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.0.0.0")]
35-
[assembly: AssemblyFileVersion("1.0.0.0")]
34+
[assembly: AssemblyVersion("1.1.0.0")]
35+
[assembly: AssemblyFileVersion("1.1.0.0")]

0 commit comments

Comments
 (0)