Skip to content

Commit

Permalink
Housecleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
DelnarErsike committed May 10, 2024
1 parent 11bc9be commit 7b0e26f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Chummer/Backend/Equipment/Cyberware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ await _objCharacter.OnPropertyChangedAsync(nameof(Character.TotalCarriedWeight),
Maximum = decMax,
Description = string.Format(
GlobalSettings.CultureInfo,
LanguageManager.GetString("String_SelectVariableCost"),
LanguageManager.GetString("String_SelectVariableCost", token: token),
CurrentDisplayNameShort),
AllowCancel = false
}))
Expand Down Expand Up @@ -7183,7 +7183,7 @@ public async Task<string> GetCalculatedCapacityAsync(CancellationToken token = d
{
string[] strValues = strCapacity.TrimStartOnce("FixedValues(", true).TrimEndOnce(')')
.Split(',', StringSplitOptions.RemoveEmptyEntries);
strCapacity = strValues[Math.Max(Math.Min((await GetRatingAsync(token).ConfigureAwait(false)), strValues.Length) - 1, 0)];
strCapacity = strValues[Math.Max(Math.Min(await GetRatingAsync(token).ConfigureAwait(false), strValues.Length) - 1, 0)];
}

if (string.IsNullOrEmpty(strCapacity))
Expand Down
2 changes: 1 addition & 1 deletion Chummer/Backend/Equipment/Drugs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ public async Task GenerateImprovement(CancellationToken token = default)
Augmented = objAttribute.Value,
ImprovedName = objAttribute.Key,
CustomName =
strNamePrefix + LanguageManager.GetString("String_Attribute" + objAttribute.Key + "Short")
strNamePrefix + LanguageManager.GetString("String_Attribute" + objAttribute.Key + "Short", token: token)
+ strSpace +
objAttribute.Value.ToString("+#,0;-#,0;0", GlobalSettings.CultureInfo)
}).ToList();
Expand Down
10 changes: 5 additions & 5 deletions Chummer/Backend/Equipment/Gear.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2304,7 +2304,7 @@ private async Task<int> ProcessRatingStringAsync(string strExpression, Cancellat
{
string[] strValues = strExpression.TrimStartOnce("FixedValues(", true).TrimEndOnce(')')
.Split(',', StringSplitOptions.RemoveEmptyEntries);
strExpression = strValues[Math.Max(Math.Min((await GetRatingAsync(token).ConfigureAwait(false)), strValues.Length) - 1, 0)].Trim('[', ']');
strExpression = strValues[Math.Max(Math.Min(await GetRatingAsync(token).ConfigureAwait(false), strValues.Length) - 1, 0)].Trim('[', ']');
}

if (strExpression.IndexOfAny('{', '+', '-', '*', ',') != -1 || strExpression.Contains("div"))
Expand Down Expand Up @@ -2878,7 +2878,7 @@ public async Task<int> GetBaseMatrixAttributeAsync(string strAttributeName, Canc
{
string[] strValues = strExpression.TrimStartOnce("FixedValues(", true).TrimEndOnce(')')
.Split(',', StringSplitOptions.RemoveEmptyEntries);
strExpression = strValues[Math.Max(Math.Min((await GetRatingAsync(token).ConfigureAwait(false)), strValues.Length) - 1, 0)].Trim('[', ']');
strExpression = strValues[Math.Max(Math.Min(await GetRatingAsync(token).ConfigureAwait(false), strValues.Length) - 1, 0)].Trim('[', ']');
}

if (Name == "Living Persona")
Expand Down Expand Up @@ -3411,7 +3411,7 @@ public async Task<AvailabilityValue> TotalAvailTupleAsync(bool blnCheckChildren
{
string[] strValues = strAvail.TrimStartOnce("FixedValues(", true).TrimEndOnce(')')
.Split(',', StringSplitOptions.RemoveEmptyEntries);
strAvail = strValues[Math.Max(Math.Min((await GetRatingAsync(token).ConfigureAwait(false)), strValues.Length) - 1, 0)];
strAvail = strValues[Math.Max(Math.Min(await GetRatingAsync(token).ConfigureAwait(false), strValues.Length) - 1, 0)];
}

chrLastAvailChar = strAvail[strAvail.Length - 1];
Expand Down Expand Up @@ -3839,7 +3839,7 @@ public async Task<decimal> GetOwnCostPreMultipliersAsync(CancellationToken token
{
string[] strValues = strCostExpression.TrimStartOnce("FixedValues(", true).TrimEndOnce(')')
.Split(',', StringSplitOptions.RemoveEmptyEntries);
strCostExpression = strValues[Math.Max(Math.Min((await GetRatingAsync(token).ConfigureAwait(false)), strValues.Length) - 1, 0)].Trim('[', ']');
strCostExpression = strValues[Math.Max(Math.Min(await GetRatingAsync(token).ConfigureAwait(false), strValues.Length) - 1, 0)].Trim('[', ']');
}

decimal decGearCost = 0;
Expand Down Expand Up @@ -5566,7 +5566,7 @@ public async Task BuildChildrenGearTree(TreeNode objParentNode, ContextMenuStrip
{
objParentNode.Nodes.Add(objChildNode);
if (objChild.ParentID != InternalId ||
(await this.GetNodeXPathAsync(token: token).ConfigureAwait(false))?.SelectSingleNodeAndCacheExpression("gears/@startcollapsed")?.Value !=
(await this.GetNodeXPathAsync(token: token).ConfigureAwait(false))?.SelectSingleNodeAndCacheExpression("gears/@startcollapsed", token)?.Value !=
bool.TrueString)
blnExpandNode = true;
}
Expand Down
14 changes: 7 additions & 7 deletions Chummer/Controls/Shared/BindingListDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ private async Task<Control> CreateControlAsync(bool blnAddControlAfterCreation =
{
x.Visible = false;
intHeight = Math.Max(_parent.ListItemControlHeight, intHeight);
int intWidth = _parent.DisplayPanel.DoThreadSafeFunc(y => y.Width);
int intWidth = _parent.DisplayPanel.DoThreadSafeFunc(y => y.Width, token);
if (x.AutoSize)
{
x.MinimumSize = new Size(intWidth, intHeight);
Expand Down Expand Up @@ -1091,7 +1091,7 @@ public async Task ResetAsync(CancellationToken token = default)
{
x.Visible = false;
x.Location = new Point(0, 0);
int intWidth = _parent.DisplayPanel.DoThreadSafeFunc(y => y.Width);
int intWidth = _parent.DisplayPanel.DoThreadSafeFunc(y => y.Width, token);
int intHeight = _parent.ListItemControlHeight;
if (x.AutoSize)
{
Expand Down Expand Up @@ -1234,9 +1234,9 @@ private sealed class IndexComparer : IComparer<TType>

public int Compare(TType x, TType y)
{
if (x != null && _dicIndeces.TryGetValue(x, out int xindex))
if (!Equals(x, default(TType)) && _dicIndeces.TryGetValue(x, out int xindex))
{
if (y != null && _dicIndeces.TryGetValue(y, out int yindex))
if (!Equals(y, default(TType)) && _dicIndeces.TryGetValue(y, out int yindex))
{
return xindex.CompareTo(yindex);
}
Expand All @@ -1246,7 +1246,7 @@ public int Compare(TType x, TType y)
}

Utils.BreakIfDebug();
if (y != null && (x == null || _dicIndeces.ContainsKey(y)))
if (!Equals(y, default(TType)) && (Equals(x, default(TType)) || _dicIndeces.ContainsKey(y)))
return -1;

return 0;
Expand All @@ -1267,7 +1267,7 @@ public void Reset(IReadOnlyList<TType> source)
}
}

private Task<int> DefaultCompareAsync(IComparer<TType> objComparer, TType x, TType y, CancellationToken token = default)
private static Task<int> DefaultCompareAsync(IComparer<TType> objComparer, TType x, TType y, CancellationToken token = default)
{
return token.IsCancellationRequested
? Task.FromCanceled<int>(token)
Expand All @@ -1279,7 +1279,7 @@ private static Task<bool> DefaultVisibleAsync(TType x, CancellationToken token =
return token.IsCancellationRequested ? Task.FromCanceled<bool>(token) : Task.FromResult(true);
}

private Task<bool> DefaultVisibleAsync(Predicate<TType> predicate, TType x, CancellationToken token = default)
private static Task<bool> DefaultVisibleAsync(Predicate<TType> predicate, TType x, CancellationToken token = default)
{
return token.IsCancellationRequested
? Task.FromCanceled<bool>(token)
Expand Down
12 changes: 6 additions & 6 deletions Chummer/Controls/Shared/ObservableCollectionDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ private async Task<Control> CreateControlAsync(bool blnAddControlAfterCreation =
{
x.Visible = false;
intHeight = Math.Max(_parent.ListItemControlHeight, intHeight);
int intWidth = _parent.DisplayPanel.DoThreadSafeFunc(y => y.Width);
int intWidth = _parent.DisplayPanel.DoThreadSafeFunc(y => y.Width, token);
if (x.AutoSize)
{
x.MinimumSize = new Size(intWidth, intHeight);
Expand Down Expand Up @@ -1123,7 +1123,7 @@ public async Task ResetAsync(CancellationToken token = default)
{
x.Visible = false;
x.Location = new Point(0, 0);
int intWidth = _parent.DisplayPanel.DoThreadSafeFunc(y => y.Width);
int intWidth = _parent.DisplayPanel.DoThreadSafeFunc(y => y.Width, token);
int intHeight = _parent.ListItemControlHeight;
if (x.AutoSize)
{
Expand Down Expand Up @@ -1266,9 +1266,9 @@ private sealed class IndexComparer : IComparer<TType>

public int Compare(TType x, TType y)
{
if (x != null && _dicIndeces.TryGetValue(x, out int xindex))
if (!Equals(x, default(TType)) && _dicIndeces.TryGetValue(x, out int xindex))
{
if (y != null && _dicIndeces.TryGetValue(y, out int yindex))
if (!Equals(y, default(TType)) && _dicIndeces.TryGetValue(y, out int yindex))
{
return xindex.CompareTo(yindex);
}
Expand All @@ -1278,7 +1278,7 @@ public int Compare(TType x, TType y)
}

Utils.BreakIfDebug();
if (y != null && (x == null || _dicIndeces.ContainsKey(y)))
if (!Equals(y, default(TType)) && (Equals(x, default(TType)) || _dicIndeces.ContainsKey(y)))
return -1;

return 0;
Expand All @@ -1299,7 +1299,7 @@ public void Reset(IReadOnlyList<TType> source)
}
}

private Task<int> DefaultCompareAsync(IComparer<TType> objComparer, TType x, TType y, CancellationToken token = default)
private static Task<int> DefaultCompareAsync(IComparer<TType> objComparer, TType x, TType y, CancellationToken token = default)
{
return token.IsCancellationRequested
? Task.FromCanceled<int>(token)
Expand Down
2 changes: 1 addition & 1 deletion Chummer/Controls/Skills/SkillControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ public void MoveControls(int intNewNameWidth)
x => x.MinimumSize =
new Size(
intNewNameWidth - x.Margin.Right -
pnlAttributes.DoThreadSafeFunc(y => y.Margin.Left + y.Width),
pnlAttributes.DoThreadSafeFunc(y => y.Margin.Left + y.Width, token: _objMyToken),
x.MinimumSize.Height), token: _objMyToken);
}
catch (OperationCanceledException)
Expand Down
2 changes: 1 addition & 1 deletion Chummer/Controls/Table/SpinnerTableCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected internal override void UpdateValue(object newValue)
return;
try
{
_spinner.Value = Utils.SafelyRunSynchronously(() => ValueGetter(tValue, _objMyToken));
_spinner.Value = Utils.SafelyRunSynchronously(() => ValueGetter(tValue, _objMyToken), _objMyToken);
}
finally
{
Expand Down

0 comments on commit 7b0e26f

Please sign in to comment.