Skip to content

Commit

Permalink
Merge branch 'master' into monomod-reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco authored Dec 20, 2023
2 parents a68c607 + e457977 commit 449b92d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Harmony/Harmony.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<PackageProjectUrl>https://github.com/BepInEx/HarmonyX</PackageProjectUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>Harmony,Mono,Patch,Patching,Runtime,Detour,Detours,Aspect,Aspects</PackageTags>
<AssemblyVersion>2.10.1.0</AssemblyVersion>
<FileVersion>2.10.1.0</FileVersion>
<AssemblyVersion>2.10.2.0</AssemblyVersion>
<FileVersion>2.10.2.0</FileVersion>
<PackageIcon>logo_mini.png</PackageIcon>
<PackageIconUrl>https://raw.githubusercontent.com/BepInEx/HarmonyX/master/logo_mini.png</PackageIconUrl>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
25 changes: 17 additions & 8 deletions Harmony/Public/PatchClassProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,29 @@ List<MethodBase> GetBulkMethods()
return list;
}

static string FailOnResult(IEnumerable<MethodBase> res)
var result = new List<MethodBase>();

var targetMethods = RunMethod<HarmonyTargetMethods, IEnumerable<MethodBase>>(null, null);
if (targetMethods is object)
{
if (res is null) return "null";
if (res.Any(m => m is null)) return "some element was null";
return null;
string error = null;
result = targetMethods.ToList();
if (result is null) error = "null";
else if (result.Any(m => m is null)) error = "some element was null";
if (error != null)
{
if (auxilaryMethods.TryGetValue(typeof(HarmonyTargetMethods), out var method))
throw new Exception($"Method {method.FullDescription()} returned an unexpected result: {error}");
else
throw new Exception($"Some method returned an unexpected result: {error}");
}
return result;
}
var targetMethods = RunMethod<HarmonyTargetMethods, IEnumerable<MethodBase>>(null, null, FailOnResult);
if (targetMethods is object)
return targetMethods.ToList();

var result = new List<MethodBase>();
var targetMethod = RunMethod<HarmonyTargetMethod, MethodBase>(null, null, method => method is null ? "null" : null);
if (targetMethod is object)
result.Add(targetMethod);

return result;
}

Expand Down
2 changes: 2 additions & 0 deletions Harmony/Tools/FileLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public static string LogPath
}
finally { }
}
else
_logPath += ".obsolete";
}
return _logPath;
}
Expand Down
2 changes: 1 addition & 1 deletion Harmony/Tools/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static void ToggleDebug()
if (Enabled)
{
if (Writer == null)
Writer = new StreamWriter(File.Create(Path.GetFullPath(FileWriterPath)));
Writer = new StreamWriter(new FileStream(Path.GetFullPath(FileWriterPath),FileMode.Create, FileAccess.Write, FileShare.ReadWrite | FileShare.Delete));
Logger.MessageReceived += OnMessage;
}
else
Expand Down

0 comments on commit 449b92d

Please sign in to comment.