c#9 is not sugar

This commit is contained in:
Kurt 2020-12-22 21:24:41 -08:00
parent e34c8df044
commit 7e4eb86e93
24 changed files with 54 additions and 54 deletions

View file

@ -49,7 +49,7 @@ namespace PKHeX.WinForms.Controls
private void Update255_MTB(object sender, EventArgs e)
{
if (!(sender is MaskedTextBox tb)) return;
if (sender is not MaskedTextBox tb) return;
if (Util.ToInt32(tb.Text) > byte.MaxValue)
tb.Text = "255";
}

View file

@ -7,7 +7,7 @@ namespace PKHeX.WinForms.Controls
{
private void PopulateFieldsPK1()
{
if (!(Entity is PK1 pk1))
if (Entity is not PK1 pk1)
throw new FormatException(nameof(Entity));
LoadMisc1(pk1);
@ -23,7 +23,7 @@ namespace PKHeX.WinForms.Controls
private PK1 PreparePK1()
{
if (!(Entity is PK1 pk1))
if (Entity is not PK1 pk1)
throw new FormatException(nameof(Entity));
SaveMisc1(pk1);

View file

@ -7,7 +7,7 @@ namespace PKHeX.WinForms.Controls
{
private void PopulateFieldsPK2()
{
if (!(Entity is GBPKM pk2) || !(Entity is ICaughtData2 c2))
if (Entity is not GBPKM pk2 || Entity is not ICaughtData2 c2)
throw new FormatException(nameof(Entity));
if (Entity is SK2 sk2)
@ -47,7 +47,7 @@ namespace PKHeX.WinForms.Controls
private GBPKM PreparePK2()
{
if (!(Entity is GBPKM pk2) || !(Entity is ICaughtData2 c2))
if (Entity is not GBPKM pk2 || Entity is not ICaughtData2 c2)
throw new FormatException(nameof(Entity));
SaveMisc1(pk2);

View file

@ -7,7 +7,7 @@ namespace PKHeX.WinForms.Controls
{
private void PopulateFieldsPK3()
{
if (!(Entity is G3PKM pk3))
if (Entity is not G3PKM pk3)
throw new FormatException(nameof(Entity));
LoadMisc1(pk3);
@ -24,7 +24,7 @@ namespace PKHeX.WinForms.Controls
private G3PKM PreparePK3()
{
if (!(Entity is G3PKM pk3))
if (Entity is not G3PKM pk3)
throw new FormatException(nameof(Entity));
SaveMisc1(pk3);

View file

@ -7,7 +7,7 @@ namespace PKHeX.WinForms.Controls
{
private void PopulateFieldsPK4()
{
if (!(Entity is G4PKM pk4))
if (Entity is not G4PKM pk4)
throw new FormatException(nameof(Entity));
LoadMisc1(pk4);
@ -32,7 +32,7 @@ namespace PKHeX.WinForms.Controls
private G4PKM PreparePK4()
{
if (!(Entity is G4PKM pk4))
if (Entity is not G4PKM pk4)
throw new FormatException(nameof(Entity));
SaveMisc1(pk4);

View file

@ -7,7 +7,7 @@ namespace PKHeX.WinForms.Controls
{
private void PopulateFieldsPK5()
{
if (!(Entity is PK5 pk5))
if (Entity is not PK5 pk5)
throw new FormatException(nameof(Entity));
LoadMisc1(pk5);
@ -31,7 +31,7 @@ namespace PKHeX.WinForms.Controls
private PK5 PreparePK5()
{
if (!(Entity is PK5 pk5))
if (Entity is not PK5 pk5)
throw new FormatException(nameof(Entity));
SaveMisc1(pk5);

View file

@ -7,7 +7,7 @@ namespace PKHeX.WinForms.Controls
{
private void PopulateFieldsPK6()
{
if (!(Entity is PK6 pk6))
if (Entity is not PK6 pk6)
throw new FormatException(nameof(Entity));
LoadMisc1(pk6);
@ -25,7 +25,7 @@ namespace PKHeX.WinForms.Controls
private PK6 PreparePK6()
{
if (!(Entity is PK6 pk6))
if (Entity is not PK6 pk6)
throw new FormatException(nameof(Entity));
SaveMisc1(pk6);

View file

@ -7,7 +7,7 @@ namespace PKHeX.WinForms.Controls
{
private void PopulateFieldsPK7()
{
if (!(Entity is PK7 pk7))
if (Entity is not PK7 pk7)
throw new FormatException(nameof(Entity));
LoadMisc1(pk7);
@ -22,7 +22,7 @@ namespace PKHeX.WinForms.Controls
private PK7 PreparePK7()
{
if (!(Entity is PK7 pk7))
if (Entity is not PK7 pk7)
throw new FormatException(nameof(Entity));
SaveMisc1(pk7);
@ -51,7 +51,7 @@ namespace PKHeX.WinForms.Controls
private void PopulateFieldsPB7()
{
if (!(Entity is PB7 pk7))
if (Entity is not PB7 pk7)
throw new FormatException(nameof(Entity));
LoadMisc1(pk7);
@ -68,7 +68,7 @@ namespace PKHeX.WinForms.Controls
private PB7 PreparePB7()
{
if (!(Entity is PB7 pk7))
if (Entity is not PB7 pk7)
throw new FormatException(nameof(Entity));
SaveMisc1(pk7);

View file

@ -7,7 +7,7 @@ namespace PKHeX.WinForms.Controls
{
private void PopulateFieldsPK8()
{
if (!(Entity is PK8 pk8))
if (Entity is not PK8 pk8)
throw new FormatException(nameof(Entity));
LoadMisc1(pk8);
@ -24,7 +24,7 @@ namespace PKHeX.WinForms.Controls
private PK8 PreparePK8()
{
if (!(Entity is PK8 pk8))
if (Entity is not PK8 pk8)
throw new FormatException(nameof(Entity));
SaveMisc1(pk8);

View file

@ -628,7 +628,7 @@ namespace PKHeX.WinForms.Controls
private void ClickTRGender(object sender, EventArgs e)
{
if (!(sender is Label lbl))
if (sender is not Label lbl)
return;
if (string.IsNullOrWhiteSpace(lbl.Text))
return;
@ -933,7 +933,7 @@ namespace PKHeX.WinForms.Controls
private void Update255_MTB(object sender, EventArgs e)
{
if (!(sender is MaskedTextBox tb))
if (sender is not MaskedTextBox tb)
return;
if (Util.ToInt32(tb.Text) > byte.MaxValue)
tb.Text = "255";
@ -1030,7 +1030,7 @@ namespace PKHeX.WinForms.Controls
private void UpdatePP(object sender, EventArgs e)
{
if (!(sender is ComboBox cb))
if (sender is not ComboBox cb)
return;
int index = Array.IndexOf(Moves, cb);
if (index < 0)
@ -1226,7 +1226,7 @@ namespace PKHeX.WinForms.Controls
private void UpdateExtraByteValue(object sender, EventArgs e)
{
if (CB_ExtraBytes.Items.Count == 0 || !(sender is MaskedTextBox mtb))
if (CB_ExtraBytes.Items.Count == 0 || sender is not MaskedTextBox mtb)
return;
// Changed Extra Byte's Value
if (Util.ToInt32(mtb.Text) > byte.MaxValue)
@ -1577,7 +1577,7 @@ namespace PKHeX.WinForms.Controls
private void ValidateComboBox(object sender, CancelEventArgs e)
{
if (!(sender is ComboBox cb))
if (sender is not ComboBox cb)
return;
ValidateComboBox(cb);

View file

@ -38,7 +38,7 @@ namespace PKHeX.WinForms.Controls
private void UpdateFlagState(object sender, EventArgs e)
{
if (!(sender is CheckBox c))
if (sender is not CheckBox c)
return;
Image resource;

View file

@ -60,7 +60,7 @@ namespace PKHeX.WinForms.Controls
private void ClickIV(object sender, EventArgs e)
{
if (!(sender is MaskedTextBox t))
if (sender is not MaskedTextBox t)
return;
switch (ModifierKeys)
@ -89,7 +89,7 @@ namespace PKHeX.WinForms.Controls
private void ClickEV(object sender, EventArgs e)
{
if (!(sender is MaskedTextBox t))
if (sender is not MaskedTextBox t)
return;
if ((ModifierKeys & Keys.Control) != 0) // Max
@ -106,7 +106,7 @@ namespace PKHeX.WinForms.Controls
private void ClickAV(object sender, EventArgs e)
{
if (!(sender is MaskedTextBox t))
if (sender is not MaskedTextBox t)
return;
if ((ModifierKeys & Keys.Control) != 0) // Max
@ -192,7 +192,7 @@ namespace PKHeX.WinForms.Controls
private void UpdateAVs(object sender, EventArgs e)
{
if (!(Entity is IAwakened a))
if (Entity is not IAwakened a)
return;
if (sender is MaskedTextBox m)
{
@ -229,7 +229,7 @@ namespace PKHeX.WinForms.Controls
private void UpdateHackedStatText(object sender, EventArgs e)
{
if (!CHK_HackedStats.Checked || !(sender is TextBox tb))
if (!CHK_HackedStats.Checked || sender is not TextBox tb)
return;
string text = tb.Text;
@ -288,7 +288,7 @@ namespace PKHeX.WinForms.Controls
private void LoadHyperTraining()
{
if (!(Entity is IHyperTrain h))
if (Entity is not IHyperTrain h)
{
foreach (var iv in MT_IVs)
iv.ResetBackColor();
@ -301,7 +301,7 @@ namespace PKHeX.WinForms.Controls
private void UpdateAVTotals()
{
if (!(Entity is IAwakened a))
if (Entity is not IAwakened a)
return;
var total = a.AwakeningSum();
TB_AVTotal.Text = total.ToString();
@ -364,7 +364,7 @@ namespace PKHeX.WinForms.Controls
private void UpdateRandomAVs(object sender, EventArgs e)
{
if (!(Entity is IAwakened a))
if (Entity is not IAwakened a)
return;
switch (ModifierKeys)

View file

@ -115,7 +115,7 @@ namespace PKHeX.WinForms.Controls
private void Update_ID(object sender, EventArgs e)
{
if (!(sender is MaskedTextBox mt))
if (sender is not MaskedTextBox mt)
return;
if (!int.TryParse(mt.Text, out var val))

View file

@ -77,7 +77,7 @@ namespace PKHeX.WinForms.Controls
public void NotifySlotOld(ISlotInfo previous)
{
if (!(previous is SlotInfoBox b) || b.Box != CurrentBox)
if (previous is not SlotInfoBox b || b.Box != CurrentBox)
return;
var pb = SlotPictureBoxes[previous.Slot];
@ -96,7 +96,7 @@ namespace PKHeX.WinForms.Controls
public int GetViewIndex(ISlotInfo slot)
{
if (!(slot is SlotInfoBox b) || b.Box != CurrentBox)
if (slot is not SlotInfoBox b || b.Box != CurrentBox)
return -1;
return slot.Slot;
}

View file

@ -56,7 +56,7 @@ namespace PKHeX.WinForms.Controls
public void NotifySlotOld(ISlotInfo previous)
{
if (!(previous is SlotInfoParty p))
if (previous is not SlotInfoParty p)
return;
var pb = SlotPictureBoxes[p.Slot];
@ -81,7 +81,7 @@ namespace PKHeX.WinForms.Controls
public int GetViewIndex(ISlotInfo slot)
{
if (!(slot is SlotInfoParty p))
if (slot is not SlotInfoParty p)
return -1;
return p.Slot;
}

View file

@ -421,7 +421,7 @@ namespace PKHeX.WinForms.Controls
private void UpdateSaveSlot(object sender, EventArgs e)
{
if (!(SAV is SAV4BR br))
if (SAV is not SAV4BR br)
return;
br.CurrentSlot = WinFormsUtil.GetIndex(CB_SaveSlot);
Box.ResetBoxNames(); // fix box names
@ -434,7 +434,7 @@ namespace PKHeX.WinForms.Controls
if (!FieldsLoaded)
return;
if (!(sender is TextBox tb))
if (sender is not TextBox tb)
return;
if (string.IsNullOrWhiteSpace(tb.Text))
@ -550,7 +550,7 @@ namespace PKHeX.WinForms.Controls
private void B_OpenRaids_Click(object sender, EventArgs e)
{
if (!(SAV is SAV8SWSH swsh))
if (SAV is not SAV8SWSH swsh)
return;
if (sender == B_Raids)
OpenDialog(new SAV_Raid8(swsh, swsh.Raid));
@ -616,7 +616,7 @@ namespace PKHeX.WinForms.Controls
private void B_OpenFriendSafari_Click(object sender, EventArgs e)
{
if (!(SAV is SAV6XY xy))
if (SAV is not SAV6XY xy)
return;
var dr = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgSaveGen6FriendSafari, MsgSaveGen6FriendSafariCheatDesc);

View file

@ -41,7 +41,7 @@ namespace PKHeX.WinForms.Controls
public void NotifySlotOld(ISlotInfo previous)
{
if (!(previous is SlotInfoMisc m))
if (previous is not SlotInfoMisc m)
return;
var index = SlotOffsets.FindIndex(z => m.Equals(z));
if (index < 0)
@ -52,7 +52,7 @@ namespace PKHeX.WinForms.Controls
public void NotifySlotChanged(ISlotInfo slot, SlotTouchType type, PKM pkm)
{
if (!(slot is SlotInfoMisc m))
if (slot is not SlotInfoMisc m)
return;
var index = GetViewIndex(m);
if (index < 0)

View file

@ -85,7 +85,7 @@ namespace PKHeX.WinForms
private void UpdateBoxSlotCopies(object sender, EventArgs e)
{
if (!(pkm is PK7 pk7))
if (pkm is not PK7 pk7)
throw new ArgumentException("Can't update QR7 if pkm isn't a PK7!");
qr = ReloadQRData(pk7);
RefreshImage();

View file

@ -311,7 +311,7 @@ namespace PKHeX.WinForms
private void ChangeCountryText(object sender, EventArgs e)
{
if (!(sender is ComboBox cb) || !string.IsNullOrWhiteSpace(cb.Text))
if (sender is not ComboBox cb || !string.IsNullOrWhiteSpace(cb.Text))
return;
cb.SelectedValue = 0;
ChangeCountryIndex(sender, e);
@ -319,7 +319,7 @@ namespace PKHeX.WinForms
private void Update255_MTB(object sender, EventArgs e)
{
if (!(sender is MaskedTextBox tb)) return;
if (sender is not MaskedTextBox tb) return;
if (Util.ToInt32(tb.Text) > byte.MaxValue)
tb.Text = "255";
}

View file

@ -119,7 +119,7 @@ namespace PKHeX.WinForms
return;
editing = true;
// build bytes
if (!(sender is NumericUpDown nud))
if (sender is not NumericUpDown nud)
throw new Exception();
int index = Bytes.IndexOf(nud);
Raw[index] = (byte)nud.Value;

View file

@ -122,7 +122,7 @@ namespace PKHeX.WinForms
if (index < 0)
return;
var gift = Results[index];
if (!(gift is DataMysteryGift g)) // e.g. WC3
if (gift is not DataMysteryGift g) // e.g. WC3
{
WinFormsUtil.Alert(MsgExportWC3DataFail);
return;

View file

@ -187,10 +187,10 @@ namespace PKHeX.WinForms
return;
var s1 = SaveUtil.GetVariantSAV(p1);
if (!(s1 is SAV8SWSH w1))
if (s1 is not SAV8SWSH w1)
return;
var s2 = SaveUtil.GetVariantSAV(p2);
if (!(s2 is SAV8SWSH w2))
if (s2 is not SAV8SWSH w2)
return;
var compare = new SCBlockCompare(w1.Blocks, w2.Blocks);

View file

@ -163,7 +163,7 @@ namespace PKHeX.WinForms
public static void PanelScroll(object? sender, ScrollEventArgs e)
{
if (!(sender is ScrollableControl p) || e.NewValue < 0)
if (sender is not ScrollableControl p || e.NewValue < 0)
return;
switch (e.ScrollOrientation)
{

View file

@ -21,9 +21,9 @@ namespace PKHeX.Tests.Legality
if (gen <= 4)
continue;
if (!(t.GetValue(typeof(EvolutionTree)) is EvolutionTree fTree))
if (t.GetValue(typeof(EvolutionTree)) is not EvolutionTree fTree)
throw new ArgumentException(nameof(fTree));
if (!(fEntries.GetValue(fTree) is IReadOnlyList<EvolutionMethod[]> entries))
if (fEntries.GetValue(fTree) is not IReadOnlyList<EvolutionMethod[]> entries)
throw new ArgumentException(nameof(entries));
var feebas = entries[(int)Species.Feebas];