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

Commit 4e0c9c5

Browse files
authored
Merge pull request #59 from neos-modding-group/chore/lint-fix
Propper unified formatting
2 parents 1c01173 + 6df8975 commit 4e0c9c5

25 files changed

+2117
-2108
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# https://EditorConfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
charset = utf-8

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
repository: neos-modding-group/Reference-Assemblies
2121
path: Libs
2222
ssh-key: ${{ secrets.REFERENCE_ASSEMBLIES_AUTH }}
23+
- name: lint
24+
run: dotnet format --verbosity detailed --verify-no-changes ./NeosModLoader.sln
2325
- name: build
2426
run: dotnet build ./NeosModLoader.sln
25-
- name: lint
26-
run: dotnet format --verify-no-changes --include-generated ./NeosModLoader.sln

NeosModLoader.sln

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NeosModLoader", "NeosModLoader\NeosModLoader.csproj", "{D4627C7F-8091-477A-ABDC-F1465D94D8D9}"
77
EndProject
88
Global
9-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10-
Debug|Any CPU = Debug|Any CPU
11-
Release|Any CPU = Release|Any CPU
12-
EndGlobalSection
13-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Release|Any CPU.Build.0 = Release|Any CPU
18-
EndGlobalSection
19-
GlobalSection(SolutionProperties) = preSolution
20-
HideSolutionNode = FALSE
21-
EndGlobalSection
22-
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {757072E6-E985-4EC2-AB38-C4D1588F6A15}
24-
EndGlobalSection
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {757072E6-E985-4EC2-AB38-C4D1588F6A15}
24+
EndGlobalSection
2525
EndGlobal

NeosModLoader/AssemblyFile.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
using System.Reflection;
1+
using System.Reflection;
22

33
namespace NeosModLoader
44
{
5-
internal class AssemblyFile
5+
internal class AssemblyFile
6+
{
7+
internal string File { get; }
8+
internal Assembly Assembly { get; set; }
9+
internal AssemblyFile(string file, Assembly assembly)
610
{
7-
internal string File { get; }
8-
internal Assembly Assembly { get; set; }
9-
internal AssemblyFile(string file, Assembly assembly)
10-
{
11-
File = file;
12-
Assembly = assembly;
13-
}
11+
File = file;
12+
Assembly = assembly;
1413
}
14+
}
1515
}

NeosModLoader/AssemblyLoader.cs

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -5,87 +5,87 @@
55

66
namespace NeosModLoader
77
{
8-
internal static class AssemblyLoader
8+
internal static class AssemblyLoader
9+
{
10+
private static string[]? GetAssemblyPathsFromDir(string dirName)
911
{
10-
private static string[]? GetAssemblyPathsFromDir(string dirName)
11-
{
12-
string assembliesDirectory = Path.Combine(Directory.GetCurrentDirectory(), dirName);
12+
string assembliesDirectory = Path.Combine(Directory.GetCurrentDirectory(), dirName);
1313

14-
Logger.MsgInternal($"loading assemblies from {dirName}");
14+
Logger.MsgInternal($"loading assemblies from {dirName}");
1515

16-
string[]? assembliesToLoad = null;
17-
try
18-
{
19-
assembliesToLoad = Directory.GetFiles(assembliesDirectory, "*.dll", SearchOption.AllDirectories);
20-
Array.Sort(assembliesToLoad, (a, b) => string.CompareOrdinal(a, b));
21-
}
22-
catch (Exception e)
23-
{
24-
if (e is DirectoryNotFoundException)
25-
{
26-
Logger.MsgInternal($"{dirName} directory not found, creating it now.");
27-
try
28-
{
29-
Directory.CreateDirectory(assembliesDirectory);
30-
}
31-
catch (Exception e2)
32-
{
33-
Logger.ErrorInternal($"Error creating ${dirName} directory:\n{e2}");
34-
}
35-
}
36-
else
37-
{
38-
Logger.ErrorInternal($"Error enumerating ${dirName} directory:\n{e}");
39-
}
40-
}
41-
return assembliesToLoad;
16+
string[]? assembliesToLoad = null;
17+
try
18+
{
19+
assembliesToLoad = Directory.GetFiles(assembliesDirectory, "*.dll", SearchOption.AllDirectories);
20+
Array.Sort(assembliesToLoad, (a, b) => string.CompareOrdinal(a, b));
21+
}
22+
catch (Exception e)
23+
{
24+
if (e is DirectoryNotFoundException)
25+
{
26+
Logger.MsgInternal($"{dirName} directory not found, creating it now.");
27+
try
28+
{
29+
Directory.CreateDirectory(assembliesDirectory);
30+
}
31+
catch (Exception e2)
32+
{
33+
Logger.ErrorInternal($"Error creating ${dirName} directory:\n{e2}");
34+
}
4235
}
43-
44-
private static Assembly? LoadAssembly(string filepath)
36+
else
4537
{
46-
string filename = Path.GetFileName(filepath);
47-
SplashChanger.SetCustom($"Loading file: {filename}");
48-
Assembly assembly;
49-
try
50-
{
51-
Logger.MsgInternal( $"load assembly {filename} with sha256hash: {Util.GenerateSHA256(filepath)}");
52-
assembly = Assembly.LoadFile(filepath);
53-
}
54-
catch (Exception e)
55-
{
56-
Logger.ErrorInternal($"error loading assembly from {filepath}: {e}");
57-
return null;
58-
}
59-
if (assembly == null)
60-
{
61-
Logger.ErrorInternal($"unexpected null loading assembly from {filepath}");
62-
return null;
63-
}
64-
return assembly;
38+
Logger.ErrorInternal($"Error enumerating ${dirName} directory:\n{e}");
6539
}
40+
}
41+
return assembliesToLoad;
42+
}
43+
44+
private static Assembly? LoadAssembly(string filepath)
45+
{
46+
string filename = Path.GetFileName(filepath);
47+
SplashChanger.SetCustom($"Loading file: {filename}");
48+
Assembly assembly;
49+
try
50+
{
51+
Logger.MsgInternal($"load assembly {filename} with sha256hash: {Util.GenerateSHA256(filepath)}");
52+
assembly = Assembly.LoadFile(filepath);
53+
}
54+
catch (Exception e)
55+
{
56+
Logger.ErrorInternal($"error loading assembly from {filepath}: {e}");
57+
return null;
58+
}
59+
if (assembly == null)
60+
{
61+
Logger.ErrorInternal($"unexpected null loading assembly from {filepath}");
62+
return null;
63+
}
64+
return assembly;
65+
}
6666

67-
internal static AssemblyFile[] LoadAssembliesFromDir(string dirName)
67+
internal static AssemblyFile[] LoadAssembliesFromDir(string dirName)
68+
{
69+
List<AssemblyFile> assemblyFiles = new();
70+
if (GetAssemblyPathsFromDir(dirName) is string[] assemblyPaths)
71+
{
72+
foreach (string assemblyFilepath in assemblyPaths)
6873
{
69-
List<AssemblyFile> assemblyFiles = new();
70-
if (GetAssemblyPathsFromDir(dirName) is string[] assemblyPaths)
74+
try
75+
{
76+
if (LoadAssembly(assemblyFilepath) is Assembly assembly)
7177
{
72-
foreach (string assemblyFilepath in assemblyPaths)
73-
{
74-
try
75-
{
76-
if (LoadAssembly(assemblyFilepath) is Assembly assembly)
77-
{
78-
assemblyFiles.Add(new AssemblyFile(assemblyFilepath, assembly));
79-
}
80-
}
81-
catch (Exception e)
82-
{
83-
Logger.ErrorInternal($"Unexpected exception loading assembly from {assemblyFilepath}:\n{e}");
84-
}
85-
}
78+
assemblyFiles.Add(new AssemblyFile(assemblyFilepath, assembly));
8679
}
87-
88-
return assemblyFiles.ToArray();
80+
}
81+
catch (Exception e)
82+
{
83+
Logger.ErrorInternal($"Unexpected exception loading assembly from {assemblyFilepath}:\n{e}");
84+
}
8985
}
86+
}
87+
88+
return assemblyFiles.ToArray();
9089
}
90+
}
9191
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
1+
using System;
22

33
namespace NeosModLoader
44
{
5-
[AttributeUsage(AttributeTargets.Field)]
6-
public class AutoRegisterConfigKeyAttribute : Attribute
7-
{
8-
}
5+
[AttributeUsage(AttributeTargets.Field)]
6+
public class AutoRegisterConfigKeyAttribute : Attribute
7+
{
8+
}
99
}
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
namespace NeosModLoader
1+
namespace NeosModLoader
22
{
3-
public class ConfigurationChangedEvent
4-
{
5-
/// <summary>
6-
/// The configuration the change occurred in
7-
/// </summary>
8-
public ModConfiguration Config { get; private set; }
3+
public class ConfigurationChangedEvent
4+
{
5+
/// <summary>
6+
/// The configuration the change occurred in
7+
/// </summary>
8+
public ModConfiguration Config { get; private set; }
99

10-
/// <summary>
11-
/// The specific key who's value changed
12-
/// </summary>
13-
public ModConfigurationKey Key { get; private set; }
10+
/// <summary>
11+
/// The specific key who's value changed
12+
/// </summary>
13+
public ModConfigurationKey Key { get; private set; }
1414

15-
/// <summary>
16-
/// A custom label that may be set by whoever changed the configuration
17-
/// </summary>
18-
public string? Label { get; private set; }
15+
/// <summary>
16+
/// A custom label that may be set by whoever changed the configuration
17+
/// </summary>
18+
public string? Label { get; private set; }
1919

20-
internal ConfigurationChangedEvent(ModConfiguration config, ModConfigurationKey key, string? label)
21-
{
22-
Config = config;
23-
Key = key;
24-
Label = label;
25-
}
20+
internal ConfigurationChangedEvent(ModConfiguration config, ModConfigurationKey key, string? label)
21+
{
22+
Config = config;
23+
Key = key;
24+
Label = label;
2625
}
26+
}
2727
}

NeosModLoader/DebugInfo.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
using System;
1+
using System;
22
using System.Reflection;
33
using System.Runtime.Versioning;
44

55
namespace NeosModLoader
66
{
7-
internal class DebugInfo
7+
internal class DebugInfo
8+
{
9+
internal static void Log()
810
{
9-
internal static void Log()
10-
{
11-
Logger.MsgInternal($"NeosModLoader v{ModLoader.VERSION} starting up!{(ModLoaderConfiguration.Get().Debug ? " Debug logs will be shown." : "")}");
12-
Logger.MsgInternal($"CLR v{Environment.Version}");
13-
Logger.DebugFuncInternal(() => $"Using .NET Framework: \"{AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName}\"");
14-
Logger.DebugFuncInternal(() => $"Using .NET Core: \"{Assembly.GetEntryAssembly()?.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName}\"");
15-
Logger.MsgInternal($"Using Harmony v{GetAssemblyVersion(typeof(HarmonyLib.Harmony))}");
16-
Logger.MsgInternal($"Using BaseX v{GetAssemblyVersion(typeof(BaseX.floatQ))}");
17-
Logger.MsgInternal($"Using FrooxEngine v{GetAssemblyVersion(typeof(FrooxEngine.IComponent))}");
18-
Logger.MsgInternal($"Using Json.NET v{GetAssemblyVersion(typeof(Newtonsoft.Json.JsonSerializer))}");
19-
}
11+
Logger.MsgInternal($"NeosModLoader v{ModLoader.VERSION} starting up!{(ModLoaderConfiguration.Get().Debug ? " Debug logs will be shown." : "")}");
12+
Logger.MsgInternal($"CLR v{Environment.Version}");
13+
Logger.DebugFuncInternal(() => $"Using .NET Framework: \"{AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName}\"");
14+
Logger.DebugFuncInternal(() => $"Using .NET Core: \"{Assembly.GetEntryAssembly()?.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName}\"");
15+
Logger.MsgInternal($"Using Harmony v{GetAssemblyVersion(typeof(HarmonyLib.Harmony))}");
16+
Logger.MsgInternal($"Using BaseX v{GetAssemblyVersion(typeof(BaseX.floatQ))}");
17+
Logger.MsgInternal($"Using FrooxEngine v{GetAssemblyVersion(typeof(FrooxEngine.IComponent))}");
18+
Logger.MsgInternal($"Using Json.NET v{GetAssemblyVersion(typeof(Newtonsoft.Json.JsonSerializer))}");
19+
}
2020

21-
private static string? GetAssemblyVersion(Type typeFromAssembly)
22-
{
23-
return typeFromAssembly.Assembly.GetName()?.Version?.ToString();
24-
}
21+
private static string? GetAssemblyVersion(Type typeFromAssembly)
22+
{
23+
return typeFromAssembly.Assembly.GetName()?.Version?.ToString();
2524
}
25+
}
2626
}

0 commit comments

Comments
 (0)