Skip to content

Commit

Permalink
update to net8
Browse files Browse the repository at this point in the history
  • Loading branch information
laolarou726 committed Nov 14, 2023
1 parent 567bfcc commit 0e9260f
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion ProjBobcat/ProjBobcat/Class/Helper/GameRegexHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static partial class GameRegexHelper
"forge-[0-9]{1,}.[0-9]{1,}[.]?[0-9]{0,}-[0-9]{1,}.[0-9]{1,}.[0-9]{1,}.[0-9]{4}-[0-9]{1,}.[0-9]{1,}[.]?[0-9]{0,}-universal.jar";


#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
[GeneratedRegex("[0-9]{1,}.[0-9]{1,}[.]?[0-9]{0,}")]
public static partial Regex GameVersionRegex();

Expand Down
4 changes: 2 additions & 2 deletions ProjBobcat/ProjBobcat/Class/Helper/HttpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static partial class HttpHelper
const string UriRegexStr =
"((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[-;:&=\\+$,\\w]+@)?[A-Za-z0-9.-]+(:[0-9]+)?|(?:ww‌​w.|[-;:&=\\+$,\\w]+@)[A-Za-z0-9.-]+)((?:\\/[\\+~%\\/.\\w-_]*)?\\??(?:[-\\+=&;%@.\\w_]*)#?‌​(?:[\\w]*))?)";

#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
[GeneratedRegex("((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[-;:&=\\+$,\\w]+@)?[A-Za-z0-9.-]+(:[0-9]+)?|(?:ww‌​w.|[-;:&=\\+$,\\w]+@)[A-Za-z0-9.-]+)((?:\\/[\\+~%\\/.\\w-_]*)?\\??(?:[-\\+=&;%@.\\w_]*)#?‌​(?:[\\w]*))?)")]
private static partial Regex UriRegex();

Expand All @@ -36,7 +36,7 @@ public static partial class HttpHelper
/// <returns>匹配的Uri</returns>
public static string RegexMatchUri(string uri)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
return UriRegex().Match(uri).Value;
#else
return UriRegex.Match(uri).Value;
Expand Down
4 changes: 2 additions & 2 deletions ProjBobcat/ProjBobcat/Class/Helper/MavenHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ProjBobcat.Class.Helper;
/// </summary>
public static partial class MavenHelper
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
[GeneratedRegex("\\.")]
private static partial Regex GroupPathRegex();
#else
Expand Down Expand Up @@ -71,7 +71,7 @@ public static partial class MavenHelper
/// <returns>处理好的Group Path</returns>
public static string GetGroupPath(this string artifactId)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
return GroupPathRegex().Replace(artifactId, "/");
#else
return GroupPathRegex.Replace(artifactId, "/");
Expand Down
8 changes: 4 additions & 4 deletions ProjBobcat/ProjBobcat/Class/Helper/TOMLParser/TomlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@ public static bool IsNaN(string s)

public static bool IsInteger(string s)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
return IntegerPattern().IsMatch(s);
#else
return IntegerPattern.IsMatch(s);
Expand All @@ -1910,7 +1910,7 @@ public static bool IsInteger(string s)

public static bool IsFloat(string s)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
return FloatPattern().IsMatch(s);
#else
return FloatPattern.IsMatch(s);
Expand All @@ -1921,7 +1921,7 @@ public static bool IsIntegerWithBase(string s, out int numberBase)
{
numberBase = 10;

#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
var match = BasedIntegerPattern().Match(s);
#else
var match = BasedIntegerPattern.Match(s);
Expand Down Expand Up @@ -2052,7 +2052,7 @@ public static bool IsValueSeparator(char c)
return c is ITEM_SEPARATOR or ARRAY_END_SYMBOL or INLINE_TABLE_END_SYMBOL;
}

#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
[GeneratedRegex("^(\\+|-)?(?!_)(0|(?!0)(_?\\d)*)$")]
private static partial Regex IntegerPattern();

Expand Down
2 changes: 1 addition & 1 deletion ProjBobcat/ProjBobcat/Class/Model/DownloadSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task<byte[]> HashDataAsync(string filePath, CancellationToken? toke
{
token ??= CancellationToken.None;

#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
await using var fs = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);

return HashType switch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace ProjBobcat.DefaultComponent.Installer.ForgeInstaller;

public partial class HighVersionForgeInstaller : InstallerBase, IForgeInstaller
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
[GeneratedRegex(@"^\[.+\]$")]
private static partial Regex PathRegex();

Expand Down Expand Up @@ -299,7 +299,7 @@ public async Task<ForgeInstallResult> InstallForgeTaskAsync()

string ResolvePathRegex(string val)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
if (string.IsNullOrEmpty(val) || string.IsNullOrEmpty(PathRegex().Match(val).Value)) return val;
#else
if (string.IsNullOrEmpty(val) || string.IsNullOrEmpty(PathRegex.Match(val).Value)) return val;
Expand Down Expand Up @@ -333,7 +333,7 @@ string ResolvePathRegex(string val)

string ResolveVariableRegex(string val)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
if (string.IsNullOrEmpty(val) || string.IsNullOrEmpty(VariableRegex().Match(val).Value)) return val;
#else
if (string.IsNullOrEmpty(val) || string.IsNullOrEmpty(VariableRegex.Match(val).Value)) return val;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace ProjBobcat.DefaultComponent.LogAnalysis;

public partial class DefaultLogAnalyzer : ILogAnalyzer
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
[GeneratedRegex(@"(?<=\]: Warnings were found! ?[\n]+)[\w\W]+?(?=[\n]+\[)")]
private static partial Regex WarningsMatch();

Expand Down Expand Up @@ -171,7 +171,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs(IReadOnlyDictionary<LogFileType
foreach (var (fileName, subLogs) in gameLogs!)
{
// 找不到或无法加载主类
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
if (MainClassMatch1().IsMatch(subLogs) ||
(MainClassMatch2().IsMatch(subLogs) &&
!subLogs.Contains("at net.")) || (subLogs.Contains("/INFO]") &&
Expand Down Expand Up @@ -217,7 +217,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
if (log.Contains("]: Warnings were found!"))
yield return new AnalysisReport.AnalysisReport(CrashCauses.FabricError)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[] { WarningsMatch().Match(log).Value },
#else
Details = new[] { WarningsMatch.Match(log).Value },
Expand All @@ -231,7 +231,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
{
Details = new[]
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
ModInstanceMatch1().Match(log).Value,
ModInstanceMatch2().Match(log).Value
#else
Expand All @@ -251,7 +251,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
{
Details = new[]
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
BlockMatch().Match(log).Value,
BlockLocationMatch().Match(log).Value
#else
Expand All @@ -267,7 +267,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
{
Details = new[]
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
EntityMatch().Match(log).Value,
EntityLocationMatch().Match(log).Value
#else
Expand Down Expand Up @@ -334,7 +334,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
}
};

#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
[GeneratedRegex("(?<=class \")[^']+(?=\"'s signer information)")]
private static partial Regex PackSignerMatch();

Expand Down Expand Up @@ -419,7 +419,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
if (logs.Contains("signer information does not match signer information of other classes in the same package"))
yield return new AnalysisReport.AnalysisReport(CrashCauses.ContentValidationFailed)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[] { PackSignerMatch().Match(logs).Value }
#else
Details = new[] { PackSignerMatch.Match(logs).Value }
Expand All @@ -429,7 +429,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
if (logs.Contains("An exception was thrown, the game will display an error screen and halt."))
yield return new AnalysisReport.AnalysisReport(CrashCauses.ForgeError)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[] { ForgeErrorMatch().Match(logs).Value }
#else
Details = new[] { ForgeErrorMatch.Match(logs).Value }
Expand All @@ -439,7 +439,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
if (logs.Contains("A potential solution has been determined:"))
yield return new AnalysisReport.AnalysisReport(CrashCauses.FabricErrorWithSolution)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[] { FabricSolutionMatch().Match(logs).Value }
#else
Details = new[] { FabricSolutionMatch.Match(logs).Value }
Expand All @@ -463,7 +463,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
if (logs.Contains("DuplicateModsFoundException"))
yield return new AnalysisReport.AnalysisReport(CrashCauses.DuplicateMod)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[] { GameModMatch1().Match(logs).Value }
#else
Details = new[] { GameModMatch1.Match(logs).Value }
Expand All @@ -474,7 +474,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
if (logs.Contains("Found a duplicate mod"))
yield return new AnalysisReport.AnalysisReport(CrashCauses.DuplicateMod)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[] { GameModMatch2().Match(logs).Value }
#else
Details = new[] { GameModMatch2.Match(logs).Value }
Expand All @@ -484,7 +484,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
if (logs.Contains("ModResolutionException: Duplicate"))
yield return new AnalysisReport.AnalysisReport(CrashCauses.DuplicateMod)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[] { GameModMatch3().Match(logs).Value }
#else
Details = new[] { GameModMatch3.Match(logs).Value }
Expand All @@ -497,7 +497,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
|| logs.Contains("mixin.injection.throwables.")
|| logs.Contains(".mixins.json] FAILED during )"))
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
var modId = ModIdMatch1().Match(logs).Value;

if (string.IsNullOrEmpty(modId))
Expand Down Expand Up @@ -567,7 +567,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
{ "Manually triggered debug crash", CrashCauses.ManuallyTriggeredDebugCrash }
};

#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
[GeneratedRegex("(?<=Mod File: ).+")]
private static partial Regex ModFileMatch();

Expand Down Expand Up @@ -627,7 +627,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
if (modLogs.Contains("Failure message: MISSING"))
yield return new AnalysisReport.AnalysisReport(CrashCauses.ModCausedGameCrash)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[] { ModFileMatch().Match(logs).Value }
#else
Details = new[] { ModFileMatch.Match(logs).Value }
Expand All @@ -636,7 +636,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
else
yield return new AnalysisReport.AnalysisReport(CrashCauses.ModLoaderError)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[] { ModLoaderMatch().Match(logs).Value }
#else
Details = new[] { ModLoaderMatch.Match(logs).Value }
Expand All @@ -647,7 +647,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
if (logs.Contains("Multiple entries with same key: "))
yield return new AnalysisReport.AnalysisReport(CrashCauses.ModCausedGameCrash)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[] { MultipleEntriesMatch().Match(logs).Value }
#else
Details = new[] { MultipleEntriesMatch.Match(logs).Value }
Expand All @@ -656,7 +656,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
if (logs.Contains("due to errors, provided by "))
yield return new AnalysisReport.AnalysisReport(CrashCauses.ModCausedGameCrash)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[] { ProvidedByMatch().Match(logs).Value }
#else
Details = new[] { ProvidedByMatch.Match(logs).Value }
Expand All @@ -665,7 +665,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
if (logs.Contains("LoaderExceptionModCrash: Caught exception from "))
yield return new AnalysisReport.AnalysisReport(CrashCauses.ModCausedGameCrash)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[] { ModCausedCrashMatch().Match(logs).Value }
#else
Details = new[] { ModCausedCrashMatch.Match(logs).Value }
Expand All @@ -674,7 +674,7 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(Dictionary<LogFileType, List<(
if (logs.Contains("Failed loading config file "))
yield return new AnalysisReport.AnalysisReport(CrashCauses.IncorrectModConfig)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
Details = new[]
{
ConfigFileMatch1().Match(logs).Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public partial class DefaultGameLogResolver : IGameLogResolver
const string LogDateRegex = $"\\[{LogTimeRegexStr}\\]";
const string LogTotalPrefixRegex = $"\\[{LogTimeRegexStr}\\] \\[{LogSourceAndTypeRegex}\\]";

#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
[GeneratedRegex(LogSourceAndTypeRegex)]
private static partial Regex SourceAndTypeRegex();

Expand Down Expand Up @@ -59,7 +59,7 @@ public GameLogType ResolveLogType(string log)
if (!string.IsNullOrEmpty(ResolveStackTrace(log)))
return GameLogType.StackTrace;

#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
return TypeRegex().Match(log).Value switch
{
"FATAL" => GameLogType.Fatal,
Expand All @@ -84,7 +84,7 @@ public GameLogType ResolveLogType(string log)

public string ResolveStackTrace(string log)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
var stackTrace = StackTraceAtRegex().Match(log).Value;
#else
var stackTrace = StackTraceAtRegex.Match(log).Value;
Expand All @@ -95,7 +95,7 @@ public string ResolveStackTrace(string log)

public string ResolveExceptionMsg(string log)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
var exceptionMsg = ExceptionRegex().Match(log).Value;
#else
var exceptionMsg = ExceptionRegex.Match(log).Value;
Expand All @@ -106,7 +106,7 @@ public string ResolveExceptionMsg(string log)

public string ResolveSource(string log)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
var content = SourceAndTypeRegex().Match(log).Value.Split('/').FirstOrDefault();
var date = TimeFullRegex().Match(log).Value;
#else
Expand All @@ -121,7 +121,7 @@ public string ResolveSource(string log)

public string ResolveTime(string log)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
return TimeRegex().Match(log).Value;
#else
return TimeRegex.Match(log).Value;
Expand All @@ -130,7 +130,7 @@ public string ResolveTime(string log)

public string ResolveTotalPrefix(string log)
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
return TotalPrefixRegex().Match(log).Value;
#else
return TotalPrefixRegex.Match(log).Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public override async IAsyncEnumerable<IGameResource> ResolveResourceAsync()

if (File.Exists(filePath))
{
#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
await using var fs = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
var computedHash = (await SHA1.HashDataAsync(fs)).BytesToString();
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public override async IAsyncEnumerable<IGameResource> ResolveResourceAsync()
{
if (string.IsNullOrEmpty(VersionInfo.Logging?.Client?.File?.Sha1)) yield break;

#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
await using var fs = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
var computedHash = (await SHA1.HashDataAsync(fs)).BytesToString();
#else
Expand Down
Loading

0 comments on commit 0e9260f

Please sign in to comment.