Skip to content

Commit

Permalink
Fix compiler warnings after updating net8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Xian55 committed Nov 14, 2023
1 parent 29a5c60 commit 1c8181c
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 29 deletions.
16 changes: 8 additions & 8 deletions Core/AddonComponent/BuffStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void Update(IAddonDataProvider reader)
public bool Mark_of_the_Wild() => v[Mask._10];
public bool Thorns() => v[Mask._11];

[Names(new[] { "Tiger's Fury" })]
[Names(["Tiger's Fury"])]
public bool Tigers_Fury() => v[Mask._12];
public bool Prowl() => v[Mask._13];
public bool Rejuvenation() => v[Mask._14];
Expand Down Expand Up @@ -74,11 +74,11 @@ public void Update(IAddonDataProvider reader)
public bool Divine_Shield() => v[Mask._23];

// Mage
[Names(new[] {
[Names([
"Frost Armor",
"Ice Armor",
"Molten Armor",
"Mage Armor" })]
"Mage Armor"])]
public bool Frost_Armor() => v[Mask._10];
public bool Arcane_Intellect() => v[Mask._11];
public bool Ice_Barrier() => v[Mask._12];
Expand All @@ -97,9 +97,9 @@ public void Update(IAddonDataProvider reader)
public bool Bloodrage() => v[Mask._11];

// Warlock
[Names(new[] {
[Names([
"Demon Skin",
"Demon Armor" })]
"Demon Armor"])]
public bool Demon_Skin() => v[Mask._10]; //Skin and Armor
public bool Soul_Link() => v[Mask._11];
public bool Soulstone_Resurrection() => v[Mask._12];
Expand All @@ -112,9 +112,9 @@ public void Update(IAddonDataProvider reader)
// Shaman
public bool Lightning_Shield() => v[Mask._10];
public bool Water_Shield() => v[Mask._11];
[Names(new[] {
[Names([
"Shamanistic Focus",
"Focused" })]
"Focused"])]
public bool Shamanistic_Focus() => v[Mask._12];
public bool Stoneskin() => v[Mask._13];

Expand All @@ -135,7 +135,7 @@ public void Update(IAddonDataProvider reader)
public bool Horn_of_Winter() => v[Mask._11];
public bool Icebound_Fortitude() => v[Mask._12];
public bool Path_of_Frost() => v[Mask._13];
[Names(new[] { "Anti-Magic Shell" })]
[Names(["Anti-Magic Shell"])]
public bool Anti_Magic_Shell() => v[Mask._14];
public bool Army_of_the_Dead() => v[Mask._15];
public bool Vampiric_Blood() => v[Mask._16];
Expand Down
8 changes: 4 additions & 4 deletions Core/AddonComponent/TargetDebuffStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override string ToString()
}

// Priest
[Names(new[] { "Shadow Word: Pain" })]
[Names(["Shadow Word: Pain"])]
public bool Shadow_Word_Pain() => v[Mask._0];

// Druid
Expand Down Expand Up @@ -53,21 +53,21 @@ public override string ToString()
public bool Charge_Stun() => v[Mask._3];

// Warlock
[Names(new[] {
[Names([
"Curse of Weakness",
"Curse of Elements",
"Curse of Recklessness",
"Curse of Shadow",
"Curse of Agony",
"Curse of" })]
"Curse of"])]
public bool Curse_of() => v[Mask._0];
public bool Corruption() => v[Mask._1];
public bool Immolate() => v[Mask._2];
public bool Siphon_Life() => v[Mask._3];

// Hunter
public bool Serpent_Sting() => v[Mask._0];
[Names(new[] { "Hunter's Mark" })]
[Names(["Hunter's Mark"])]
public bool Hunters_Mark() => v[Mask._1];
public bool Viper_Sting() => v[Mask._2];
public bool Explosive_Shot() => v[Mask._3];
Expand Down
14 changes: 10 additions & 4 deletions Core/Configurator/AddonConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Core;

public sealed class AddonConfigurator
public sealed partial class AddonConfigurator
{
private readonly ILogger<AddonConfigurator> logger;
private readonly WowProcess process;
Expand Down Expand Up @@ -56,7 +56,7 @@ public bool Validate()
// this will appear in the lua code so
// special character not allowed
// also numbers not allowed
Config.Title = Regex.Replace(Config.Title, @"[^\u0000-\u007F]+", string.Empty);
Config.Title = RegexTitle().Replace(Config.Title, string.Empty);
Config.Title = new string(Config.Title.Where(char.IsLetter).ToArray());
Config.Title =
Config.Title.Trim()
Expand Down Expand Up @@ -197,7 +197,7 @@ private void EditMainLua()
.Replace("dc", Config.Command)
.Replace("DC", Config.Command);

Regex cellSizeRegex = new(@"^local CELL_SIZE = (?<SIZE>[0-9]+)", RegexOptions.Multiline);
Regex cellSizeRegex = RegexCellSize();
text = text.Replace(cellSizeRegex, "SIZE", Config.CellSize);

File.WriteAllText(mainLuaPath, text);
Expand Down Expand Up @@ -313,12 +313,18 @@ public bool UpdateAvailable()
return null;

string begin = "## Version: ";
var line = File
string? line = File
.ReadLines(tocPath)
.SkipWhile(line => !line.StartsWith(begin))
.FirstOrDefault();

string? versionStr = line?.Split(begin)[1];
return Version.TryParse(versionStr, out Version? version) ? version : null;
}

[GeneratedRegex(@"[^\u0000-\u007F]+")]
private static partial Regex RegexTitle();

[GeneratedRegex(@"^local CELL_SIZE = (?<SIZE>[0-9]+)", RegexOptions.Multiline)]
private static partial Regex RegexCellSize();
}
7 changes: 5 additions & 2 deletions Core/Goals/GoapGoal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Core.Goals;

public abstract class GoapGoal
public abstract partial class GoapGoal
{
public Dictionary<GoapKey, bool> Preconditions { get; } = new();
public Dictionary<GoapKey, bool> Effects { get; } = new();
Expand All @@ -33,7 +33,7 @@ protected set

protected GoapGoal(string name)
{
string output = Regex.Replace(name.Replace("Goal", ""), @"\p{Lu}", m => " " + m.Value.ToUpperInvariant());
string output = RegexGoalName().Replace(name.Replace("Goal", ""), m => " " + m.Value.ToUpperInvariant());
DisplayName = Name = string.Concat(output[0].ToString().ToUpper(), output.AsSpan(1));
}

Expand All @@ -58,4 +58,7 @@ protected void AddEffect(GoapKey key, bool value)
{
Effects[key] = value;
}

[GeneratedRegex(@"\p{Lu}")]
private static partial Regex RegexGoalName();
}
4 changes: 2 additions & 2 deletions Core/Requirement/RequirementFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ public Requirement CreateRequirement(string requirement)
return r;
}

if (!boolVariables.ContainsKey(requirement))
if (!boolVariables.TryGetValue(requirement, out Func<bool>? value))
{
LogUnknown(logger, requirement, string.Join(", ", boolVariables.Keys));
return new Requirement
Expand All @@ -694,7 +694,7 @@ public Requirement CreateRequirement(string requirement)
string s() => requirement;
Requirement req = new()
{
HasRequirement = boolVariables[requirement],
HasRequirement = value,
LogMessage = s
};

Expand Down
2 changes: 1 addition & 1 deletion Core/Session/LocalGrindSessionDAO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public IEnumerable<GrindSession> Load()
.OrderByDescending(grindingSession => grindingSession.SessionStart)
.ToList();

if (sessions.Any())
if (sessions.Count != 0)
{
int[] expList = ExperienceProvider.Get(dataConfig);
foreach (GrindSession? s in sessions)
Expand Down
10 changes: 7 additions & 3 deletions CoreTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public static void Main()
});

// its expected to have at least 2 DataFrame
DataFrame[] mockFrames = new DataFrame[2]
{
DataFrame[] mockFrames =
[
new DataFrame(0, 0, 0),
new DataFrame(1, 0, 0),
};
];

cts = new CancellationTokenSource();
process = new(cts);
Expand Down Expand Up @@ -83,6 +83,8 @@ private static void Test_NPCNameFinder()

Log.Logger.Information($"running {count} samples...");

screen.Enabled = true;

while (i < count)
{
if (LogOverallTimes)
Expand All @@ -97,6 +99,8 @@ private static void Test_NPCNameFinder()
Thread.Sleep(4);
}

screen.Enabled = false;

if (LogOverallTimes)
{
Log.Logger.Information($"overall | sample: {count:D4} | avg: {sample.Average():F2} | min: {sample.Min():F2} | max: {sample.Max():000.000} | total: {sample.Sum():F2}");
Expand Down
6 changes: 3 additions & 3 deletions Game/Input/WowProcessInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public sealed partial class WowProcessInput : IMouseInput

private readonly WowProcess process;
private readonly InputWindowsNative nativeInput;
private readonly IInput simulatorInput;
private readonly InputSimulator simulatorInput;

private readonly BitArray keysDown;

Expand All @@ -39,8 +39,8 @@ public WowProcessInput(ILogger<WowProcessInput> logger, CancellationTokenSource

keysDown = new((int)ConsoleKey.OemClear);

nativeInput = new InputWindowsNative(process, cts, InputDuration.FastPress);
simulatorInput = new InputSimulator(process, cts, InputDuration.FastPress);
nativeInput = new(process, cts, InputDuration.FastPress);
simulatorInput = new(process, cts, InputDuration.FastPress);
}

public void Reset()
Expand Down
4 changes: 2 additions & 2 deletions PPather/Graph/GraphChunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public bool Load()
{
long timestamp = Stopwatch.GetTimestamp();

using Stream stream = File.OpenRead(filePath);
using FileStream stream = File.OpenRead(filePath);
using BinaryReader br = new(stream);

if (br.ReadUInt32() != FILE_MAGIC)
Expand Down Expand Up @@ -221,7 +221,7 @@ public void Save()

try
{
using Stream stream = File.Create(filePath);
using FileStream stream = File.Create(filePath);
using BinaryWriter bw = new(stream);
bw.Write(FILE_MAGIC);

Expand Down

0 comments on commit 1c8181c

Please sign in to comment.