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

Commit

Permalink
What if we used tabs, though? (#65)
Browse files Browse the repository at this point in the history
* Update contributing.md to match editorconfig

* What if we used TABS though?

* run dotnet format

* dotnet format doesn't run on csproj or sln files so I've formatted them manually
  • Loading branch information
zkxs authored Aug 20, 2022
1 parent 4e0c9c5 commit 321ac86
Show file tree
Hide file tree
Showing 26 changed files with 2,338 additions and 2,351 deletions.
5 changes: 3 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
root = true

[*]
indent_style = space
indent_size = 2
indent_style = tab
indent_size = 4
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
16 changes: 1 addition & 15 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,7 @@ If you want your PR to be approved and merged quickly, please read the following

### Code Style

If your PR does not follow the project's code style it **will not be approved**. I expect contributors to be capable of fixing code style issues on their own.

Code style should match Microsoft convention. If you aren't sure, run Analyze > Code Cleanup on the file using Visual Studio.

#### Whitespace

- *.cs files
- Lines MUST be indented using four spaces. Tabs are not acceptable.
- MUST use unix-style (LF) line endings. CR or CRLF are not acceptable.
- *.sln files: use the Visual Studio defaults
- indent using tabs
- CRLF line endings
- *.csproj files: use the Visual Studio defaults
- indent using two spaces
- CRLF line endings
If your PR does not follow the project's code style it **will not be approved**. Code style should match our [editor config](../.editorconfig). If you aren't sure, use your IDE's formatter (Analyze > Code Cleanup in Visual Studio).

### New Features

Expand Down
50 changes: 25 additions & 25 deletions NeosModLoader.sln
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31410.357
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NeosModLoader", "NeosModLoader\NeosModLoader.csproj", "{D4627C7F-8091-477A-ABDC-F1465D94D8D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {757072E6-E985-4EC2-AB38-C4D1588F6A15}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31410.357
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NeosModLoader", "NeosModLoader\NeosModLoader.csproj", "{D4627C7F-8091-477A-ABDC-F1465D94D8D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4627C7F-8091-477A-ABDC-F1465D94D8D9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {757072E6-E985-4EC2-AB38-C4D1588F6A15}
EndGlobalSection
EndGlobal
20 changes: 10 additions & 10 deletions NeosModLoader/AssemblyFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace NeosModLoader
{
internal class AssemblyFile
{
internal string File { get; }
internal Assembly Assembly { get; set; }
internal AssemblyFile(string file, Assembly assembly)
{
File = file;
Assembly = assembly;
}
}
internal class AssemblyFile
{
internal string File { get; }
internal Assembly Assembly { get; set; }
internal AssemblyFile(string file, Assembly assembly)
{
File = file;
Assembly = assembly;
}
}
}
156 changes: 78 additions & 78 deletions NeosModLoader/AssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,87 @@

namespace NeosModLoader
{
internal static class AssemblyLoader
{
private static string[]? GetAssemblyPathsFromDir(string dirName)
{
string assembliesDirectory = Path.Combine(Directory.GetCurrentDirectory(), dirName);
internal static class AssemblyLoader
{
private static string[]? GetAssemblyPathsFromDir(string dirName)
{
string assembliesDirectory = Path.Combine(Directory.GetCurrentDirectory(), dirName);

Logger.MsgInternal($"loading assemblies from {dirName}");
Logger.MsgInternal($"loading assemblies from {dirName}");

string[]? assembliesToLoad = null;
try
{
assembliesToLoad = Directory.GetFiles(assembliesDirectory, "*.dll", SearchOption.AllDirectories);
Array.Sort(assembliesToLoad, (a, b) => string.CompareOrdinal(a, b));
}
catch (Exception e)
{
if (e is DirectoryNotFoundException)
{
Logger.MsgInternal($"{dirName} directory not found, creating it now.");
try
{
Directory.CreateDirectory(assembliesDirectory);
}
catch (Exception e2)
{
Logger.ErrorInternal($"Error creating ${dirName} directory:\n{e2}");
}
}
else
{
Logger.ErrorInternal($"Error enumerating ${dirName} directory:\n{e}");
}
}
return assembliesToLoad;
}
string[]? assembliesToLoad = null;
try
{
assembliesToLoad = Directory.GetFiles(assembliesDirectory, "*.dll", SearchOption.AllDirectories);
Array.Sort(assembliesToLoad, (a, b) => string.CompareOrdinal(a, b));
}
catch (Exception e)
{
if (e is DirectoryNotFoundException)
{
Logger.MsgInternal($"{dirName} directory not found, creating it now.");
try
{
Directory.CreateDirectory(assembliesDirectory);
}
catch (Exception e2)
{
Logger.ErrorInternal($"Error creating ${dirName} directory:\n{e2}");
}
}
else
{
Logger.ErrorInternal($"Error enumerating ${dirName} directory:\n{e}");
}
}
return assembliesToLoad;
}

private static Assembly? LoadAssembly(string filepath)
{
string filename = Path.GetFileName(filepath);
SplashChanger.SetCustom($"Loading file: {filename}");
Assembly assembly;
try
{
Logger.MsgInternal($"load assembly {filename} with sha256hash: {Util.GenerateSHA256(filepath)}");
assembly = Assembly.LoadFile(filepath);
}
catch (Exception e)
{
Logger.ErrorInternal($"error loading assembly from {filepath}: {e}");
return null;
}
if (assembly == null)
{
Logger.ErrorInternal($"unexpected null loading assembly from {filepath}");
return null;
}
return assembly;
}
private static Assembly? LoadAssembly(string filepath)
{
string filename = Path.GetFileName(filepath);
SplashChanger.SetCustom($"Loading file: {filename}");
Assembly assembly;
try
{
Logger.MsgInternal($"load assembly {filename} with sha256hash: {Util.GenerateSHA256(filepath)}");
assembly = Assembly.LoadFile(filepath);
}
catch (Exception e)
{
Logger.ErrorInternal($"error loading assembly from {filepath}: {e}");
return null;
}
if (assembly == null)
{
Logger.ErrorInternal($"unexpected null loading assembly from {filepath}");
return null;
}
return assembly;
}

internal static AssemblyFile[] LoadAssembliesFromDir(string dirName)
{
List<AssemblyFile> assemblyFiles = new();
if (GetAssemblyPathsFromDir(dirName) is string[] assemblyPaths)
{
foreach (string assemblyFilepath in assemblyPaths)
{
try
{
if (LoadAssembly(assemblyFilepath) is Assembly assembly)
{
assemblyFiles.Add(new AssemblyFile(assemblyFilepath, assembly));
}
}
catch (Exception e)
{
Logger.ErrorInternal($"Unexpected exception loading assembly from {assemblyFilepath}:\n{e}");
}
}
}
internal static AssemblyFile[] LoadAssembliesFromDir(string dirName)
{
List<AssemblyFile> assemblyFiles = new();
if (GetAssemblyPathsFromDir(dirName) is string[] assemblyPaths)
{
foreach (string assemblyFilepath in assemblyPaths)
{
try
{
if (LoadAssembly(assemblyFilepath) is Assembly assembly)
{
assemblyFiles.Add(new AssemblyFile(assemblyFilepath, assembly));
}
}
catch (Exception e)
{
Logger.ErrorInternal($"Unexpected exception loading assembly from {assemblyFilepath}:\n{e}");
}
}
}

return assemblyFiles.ToArray();
}
}
return assemblyFiles.ToArray();
}
}
}
8 changes: 4 additions & 4 deletions NeosModLoader/AutoRegisterConfigKeyAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace NeosModLoader
{
[AttributeUsage(AttributeTargets.Field)]
public class AutoRegisterConfigKeyAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Field)]
public class AutoRegisterConfigKeyAttribute : Attribute
{
}
}
42 changes: 21 additions & 21 deletions NeosModLoader/ConfigurationChangedEvent.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
namespace NeosModLoader
{
public class ConfigurationChangedEvent
{
/// <summary>
/// The configuration the change occurred in
/// </summary>
public ModConfiguration Config { get; private set; }
public class ConfigurationChangedEvent
{
/// <summary>
/// The configuration the change occurred in
/// </summary>
public ModConfiguration Config { get; private set; }

/// <summary>
/// The specific key who's value changed
/// </summary>
public ModConfigurationKey Key { get; private set; }
/// <summary>
/// The specific key who's value changed
/// </summary>
public ModConfigurationKey Key { get; private set; }

/// <summary>
/// A custom label that may be set by whoever changed the configuration
/// </summary>
public string? Label { get; private set; }
/// <summary>
/// A custom label that may be set by whoever changed the configuration
/// </summary>
public string? Label { get; private set; }

internal ConfigurationChangedEvent(ModConfiguration config, ModConfigurationKey key, string? label)
{
Config = config;
Key = key;
Label = label;
}
}
internal ConfigurationChangedEvent(ModConfiguration config, ModConfigurationKey key, string? label)
{
Config = config;
Key = key;
Label = label;
}
}
}
36 changes: 18 additions & 18 deletions NeosModLoader/DebugInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@

namespace NeosModLoader
{
internal class DebugInfo
{
internal static void Log()
{
Logger.MsgInternal($"NeosModLoader v{ModLoader.VERSION} starting up!{(ModLoaderConfiguration.Get().Debug ? " Debug logs will be shown." : "")}");
Logger.MsgInternal($"CLR v{Environment.Version}");
Logger.DebugFuncInternal(() => $"Using .NET Framework: \"{AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName}\"");
Logger.DebugFuncInternal(() => $"Using .NET Core: \"{Assembly.GetEntryAssembly()?.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName}\"");
Logger.MsgInternal($"Using Harmony v{GetAssemblyVersion(typeof(HarmonyLib.Harmony))}");
Logger.MsgInternal($"Using BaseX v{GetAssemblyVersion(typeof(BaseX.floatQ))}");
Logger.MsgInternal($"Using FrooxEngine v{GetAssemblyVersion(typeof(FrooxEngine.IComponent))}");
Logger.MsgInternal($"Using Json.NET v{GetAssemblyVersion(typeof(Newtonsoft.Json.JsonSerializer))}");
}
internal class DebugInfo
{
internal static void Log()
{
Logger.MsgInternal($"NeosModLoader v{ModLoader.VERSION} starting up!{(ModLoaderConfiguration.Get().Debug ? " Debug logs will be shown." : "")}");
Logger.MsgInternal($"CLR v{Environment.Version}");
Logger.DebugFuncInternal(() => $"Using .NET Framework: \"{AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName}\"");
Logger.DebugFuncInternal(() => $"Using .NET Core: \"{Assembly.GetEntryAssembly()?.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName}\"");
Logger.MsgInternal($"Using Harmony v{GetAssemblyVersion(typeof(HarmonyLib.Harmony))}");
Logger.MsgInternal($"Using BaseX v{GetAssemblyVersion(typeof(BaseX.floatQ))}");
Logger.MsgInternal($"Using FrooxEngine v{GetAssemblyVersion(typeof(FrooxEngine.IComponent))}");
Logger.MsgInternal($"Using Json.NET v{GetAssemblyVersion(typeof(Newtonsoft.Json.JsonSerializer))}");
}

private static string? GetAssemblyVersion(Type typeFromAssembly)
{
return typeFromAssembly.Assembly.GetName()?.Version?.ToString();
}
}
private static string? GetAssemblyVersion(Type typeFromAssembly)
{
return typeFromAssembly.Assembly.GetName()?.Version?.ToString();
}
}
}
Loading

0 comments on commit 321ac86

Please sign in to comment.