Skip to content

Commit 21abd0f

Browse files
committed
prefer base in rewriters for clarity
1 parent 720ebf2 commit 21abd0f

22 files changed

+86
-69
lines changed

src/SMAPI/Framework/ModLoading/Framework/SuppressReasons.cs

+3
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ internal static class SuppressReasons
88

99
/// <summary>A message indicating the code is used via assembly rewriting.</summary>
1010
public const string UsedViaRewriting = "This code is used via assembly rewriting.";
11+
12+
/// <summary>A message indicating the code is used via assembly rewriting.</summary>
13+
public const string BaseForClarity = "This code deliberately uses 'base' to ensure we're calling the real method instead of a rewritten one.";
1114
}
1215
}

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/BedFurnitureFacade.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public static BedFurniture Constructor(int which, Vector2 tile)
2828

2929
public bool CanModifyBed(GameLocation location, Farmer who)
3030
{
31-
return this.CanModifyBed(who);
31+
return base.CanModifyBed(who);
3232
}
3333

3434
public bool IsBeingSleptIn(GameLocation location)
3535
{
36-
return this.IsBeingSleptIn();
36+
return base.IsBeingSleptIn();
3737
}
3838

3939

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/BreakableContainer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class BreakableContainerFacade : BreakableContainer, IRewriteFacade
1818
*********/
1919
public void releaseContents(GameLocation location, Farmer who)
2020
{
21-
this.releaseContents(who);
21+
base.releaseContents(who);
2222
}
2323

2424

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/BuffFacade.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
1111
/// <remarks>This is public to support SMAPI rewriting and should never be referenced directly by mods. See remarks on <see cref="ReplaceReferencesRewriter"/> for more info.</remarks>
1212
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = SuppressReasons.MatchesOriginal)]
1313
[SuppressMessage("ReSharper", "ParameterHidesMember", Justification = SuppressReasons.MatchesOriginal)]
14+
[SuppressMessage("ReSharper", "RedundantBaseQualifier", Justification = SuppressReasons.BaseForClarity)]
1415
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = SuppressReasons.UsedViaRewriting)]
1516
[SuppressMessage("ReSharper", "UnusedParameter.Local", Justification = SuppressReasons.MatchesOriginal)]
1617
public class BuffFacade : Buff, IRewriteFacade
@@ -46,7 +47,7 @@ public void addBuff()
4647

4748
public void removeBuff()
4849
{
49-
Game1.player.buffs.Remove(this.id);
50+
Game1.player.buffs.Remove(base.id);
5051
}
5152

5253

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/BuildableGameLocationFacade.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
1212
/// <remarks>This is public to support SMAPI rewriting and should never be referenced directly by mods. See remarks on <see cref="ReplaceReferencesRewriter"/> for more info.</remarks>
1313
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = SuppressReasons.MatchesOriginal)]
1414
[SuppressMessage("ReSharper", "ParameterHidesMember", Justification = SuppressReasons.MatchesOriginal)]
15+
[SuppressMessage("ReSharper", "RedundantBaseQualifier", Justification = SuppressReasons.BaseForClarity)]
1516
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = SuppressReasons.UsedViaRewriting)]
1617
public class BuildableGameLocationFacade : GameLocation, IRewriteFacade
1718
{
@@ -45,7 +46,7 @@ public class BuildableGameLocationFacade : GameLocation, IRewriteFacade
4546

4647
public Building? getBuildingUnderConstruction()
4748
{
48-
foreach (Building b in this.buildings)
49+
foreach (Building b in base.buildings)
4950
{
5051
if (b.daysOfConstructionLeft > 0 || b.daysUntilUpgrade > 0)
5152
return b;

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/BuildingFacade.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
1212
/// <summary>Maps Stardew Valley 1.5.6's <see cref="Building"/> methods to their newer form to avoid breaking older mods.</summary>
1313
/// <remarks>This is public to support SMAPI rewriting and should never be referenced directly by mods. See remarks on <see cref="ReplaceReferencesRewriter"/> for more info.</remarks>
1414
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = SuppressReasons.MatchesOriginal)]
15+
[SuppressMessage("ReSharper", "RedundantBaseQualifier", Justification = SuppressReasons.BaseForClarity)]
1516
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = SuppressReasons.UsedViaRewriting)]
1617
public class BuildingFacade : Building, IRewriteFacade
1718
{
1819
/*********
1920
** Accessors
2021
*********/
21-
public NetRef<Chest> input => NetRefWrapperCache<Chest>.GetCachedWrapperFor(this.GetBuildingChest("Input")); // Mill
22-
public NetRef<Chest> output => NetRefWrapperCache<Chest>.GetCachedWrapperFor(this.GetBuildingChest("Output")); // Mill
22+
public NetRef<Chest> input => NetRefWrapperCache<Chest>.GetCachedWrapperFor(base.GetBuildingChest("Input")); // Mill
23+
public NetRef<Chest> output => NetRefWrapperCache<Chest>.GetCachedWrapperFor(base.GetBuildingChest("Output")); // Mill
2324

2425

2526
/*********

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/BushFacade.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
1111
/// <summary>Maps Stardew Valley 1.5.6's <see cref="Bush"/> methods to their newer form to avoid breaking older mods.</summary>
1212
/// <remarks>This is public to support SMAPI rewriting and should never be referenced directly by mods. See remarks on <see cref="ReplaceReferencesRewriter"/> for more info.</remarks>
1313
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = SuppressReasons.MatchesOriginal)]
14+
[SuppressMessage("ReSharper", "RedundantBaseQualifier", Justification = SuppressReasons.BaseForClarity)]
1415
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = SuppressReasons.UsedViaRewriting)]
1516
public class BushFacade : Bush, IRewriteFacade
1617
{
@@ -21,15 +22,15 @@ public bool inBloom(string season, int dayOfMonth)
2122
{
2223
// call new method if possible
2324
if (season == Game1.currentSeason && dayOfMonth == Game1.dayOfMonth)
24-
return this.inBloom();
25+
return base.inBloom();
2526

2627
// else mimic old behavior with 1.6 features
27-
if (this.size == Bush.greenTeaBush)
28+
if (base.size == Bush.greenTeaBush)
2829
{
2930
return
30-
this.getAge() >= Bush.daysToMatureGreenTeaBush
31+
base.getAge() >= Bush.daysToMatureGreenTeaBush
3132
&& dayOfMonth >= 22
32-
&& (season != "winter" || this.IsSheltered());
33+
&& (season != "winter" || base.IsSheltered());
3334
}
3435

3536
switch (season)

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/CaskFacade.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class CaskFacade : Cask, IRewriteFacade
1919
*********/
2020
public bool IsValidCaskLocation(GameLocation location)
2121
{
22-
return this.IsValidCaskLocation();
22+
return base.IsValidCaskLocation();
2323
}
2424

2525

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/CharacterFacade.cs

+8-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
1010
/// <summary>Maps Stardew Valley 1.5.6's <see cref="Character"/> methods to their newer form to avoid breaking older mods.</summary>
1111
/// <remarks>This is public to support SMAPI rewriting and should never be referenced directly by mods. See remarks on <see cref="ReplaceReferencesRewriter"/> for more info.</remarks>
1212
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = SuppressReasons.MatchesOriginal)]
13+
[SuppressMessage("ReSharper", "RedundantBaseQualifier", Justification = SuppressReasons.BaseForClarity)]
1314
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = SuppressReasons.UsedViaRewriting)]
1415
public class CharacterFacade : Character, IRewriteFacade
1516
{
@@ -18,37 +19,37 @@ public class CharacterFacade : Character, IRewriteFacade
1819
*********/
1920
public int getStandingX()
2021
{
21-
return this.StandingPixel.X;
22+
return base.StandingPixel.X;
2223
}
2324

2425
public int getStandingY()
2526
{
26-
return this.StandingPixel.Y;
27+
return base.StandingPixel.Y;
2728
}
2829

2930
public Point getStandingXY()
3031
{
31-
return this.StandingPixel;
32+
return base.StandingPixel;
3233
}
3334

3435
public Vector2 getTileLocation()
3536
{
36-
return this.Tile;
37+
return base.Tile;
3738
}
3839

3940
public Point getTileLocationPoint()
4041
{
41-
return this.TilePoint;
42+
return base.TilePoint;
4243
}
4344

4445
public int getTileX()
4546
{
46-
return this.TilePoint.X;
47+
return base.TilePoint.X;
4748
}
4849

4950
public int getTileY()
5051
{
51-
return this.TilePoint.Y;
52+
return base.TilePoint.Y;
5253
}
5354

5455

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/ChestFacade.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ public ChestFacade(int coins, List<Item> items, Vector2 location, bool giftbox =
5151

5252
public void destroyAndDropContents(Vector2 pointToDropAt, GameLocation location)
5353
{
54-
this.destroyAndDropContents(pointToDropAt);
54+
base.destroyAndDropContents(pointToDropAt);
5555
}
5656

5757
public void dumpContents(GameLocation location)
5858
{
59-
this.dumpContents();
59+
base.dumpContents();
6060
}
6161

6262

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/FarmAnimalFacade.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
1010
/// <summary>Maps Stardew Valley 1.5.6's <see cref="FarmAnimal"/> methods to their newer form to avoid breaking older mods.</summary>
1111
/// <remarks>This is public to support SMAPI rewriting and should never be referenced directly by mods. See remarks on <see cref="ReplaceReferencesRewriter"/> for more info.</remarks>
1212
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = SuppressReasons.MatchesOriginal)]
13+
[SuppressMessage("ReSharper", "RedundantBaseQualifier", Justification = SuppressReasons.BaseForClarity)]
1314
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = SuppressReasons.UsedViaRewriting)]
1415
public class FarmAnimalFacade : FarmAnimal, IRewriteFacade
1516
{
@@ -18,7 +19,7 @@ public class FarmAnimalFacade : FarmAnimal, IRewriteFacade
1819
*********/
1920
public bool isCoopDweller()
2021
{
21-
FarmAnimalData? data = this.GetAnimalData();
22+
FarmAnimalData? data = base.GetAnimalData();
2223
return data?.House == "Coop";
2324
}
2425

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/FarmerFacade.cs

+15-14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
1515
/// <remarks>This is public to support SMAPI rewriting and should never be referenced directly by mods. See remarks on <see cref="ReplaceReferencesRewriter"/> for more info.</remarks>
1616
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = SuppressReasons.MatchesOriginal)]
1717
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = SuppressReasons.UsedViaRewriting)]
18+
[SuppressMessage("ReSharper", "RedundantBaseQualifier", Justification = SuppressReasons.BaseForClarity)]
1819
public class FarmerFacade : Farmer, IRewriteFacade
1920
{
2021
/*********
@@ -34,12 +35,12 @@ public class FarmerFacade : Farmer, IRewriteFacade
3435
*********/
3536
public void addQuest(int questID)
3637
{
37-
this.addQuest(questID.ToString());
38+
base.addQuest(questID.ToString());
3839
}
3940

4041
public void changePants(Color color)
4142
{
42-
this.changePantsColor(color);
43+
base.changePantsColor(color);
4344
}
4445

4546
public void changePantStyle(int whichPants, bool is_customization_screen = false)
@@ -49,27 +50,27 @@ public void changePantStyle(int whichPants, bool is_customization_screen = false
4950

5051
public void changeShirt(int whichShirt, bool is_customization_screen = false)
5152
{
52-
this.changeShirt(whichShirt.ToString());
53+
base.changeShirt(whichShirt.ToString());
5354
}
5455

5556
public void changeShoeColor(int which)
5657
{
57-
this.changeShoeColor(which.ToString());
58+
base.changeShoeColor(which.ToString());
5859
}
5960

6061
public void completeQuest(int questID)
6162
{
62-
this.completeQuest(questID.ToString());
63+
base.completeQuest(questID.ToString());
6364
}
6465

6566
public bool couldInventoryAcceptThisObject(int index, int stack, int quality = 0)
6667
{
67-
return this.couldInventoryAcceptThisItem(index.ToString(), stack, quality);
68+
return base.couldInventoryAcceptThisItem(index.ToString(), stack, quality);
6869
}
6970

7071
public int GetEffectsOfRingMultiplier(int ring_index)
7172
{
72-
return this.GetEffectsOfRingMultiplier(ring_index.ToString());
73+
return base.GetEffectsOfRingMultiplier(ring_index.ToString());
7374
}
7475

7576
public int getItemCount(int item_index, int min_price = 0)
@@ -81,7 +82,7 @@ public int getItemCount(int item_index, int min_price = 0)
8182

8283
public bool hasBuff(int whichBuff)
8384
{
84-
return this.hasBuff(whichBuff.ToString());
85+
return base.hasBuff(whichBuff.ToString());
8586
}
8687

8788
public bool hasItemInInventory(int itemIndex, int quantity, int minPrice = 0)
@@ -91,24 +92,24 @@ public bool hasItemInInventory(int itemIndex, int quantity, int minPrice = 0)
9192
switch (itemIndex)
9293
{
9394
case 858:
94-
return this.QiGems >= quantity;
95+
return base.QiGems >= quantity;
9596

9697
case 73:
9798
return Game1.netWorldState.Value.GoldenWalnuts >= quantity;
9899

99100
default:
100-
return this.getItemCount(ItemRegistry.type_object + itemIndex) >= quantity;
101+
return base.getItemCount(ItemRegistry.type_object + itemIndex) >= quantity;
101102
}
102103
}
103104

104105
public bool hasQuest(int id)
105106
{
106-
return this.hasQuest(id.ToString());
107+
return base.hasQuest(id.ToString());
107108
}
108109

109110
public bool isWearingRing(int ringIndex)
110111
{
111-
return this.isWearingRing(ringIndex.ToString());
112+
return base.isWearingRing(ringIndex.ToString());
112113
}
113114

114115
public bool removeItemsFromInventory(int index, int stack)
@@ -118,7 +119,7 @@ public bool removeItemsFromInventory(int index, int stack)
118119
switch (index)
119120
{
120121
case 858:
121-
this.QiGems -= stack;
122+
base.QiGems -= stack;
122123
return true;
123124

124125
case 73:
@@ -152,7 +153,7 @@ public bool removeItemsFromInventory(int index, int stack)
152153

153154
public void removeQuest(int questID)
154155
{
155-
this.removeQuest(questID.ToString());
156+
base.removeQuest(questID.ToString());
156157
}
157158

158159

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/FarmerTeamFacade.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
1111
/// <summary>Maps Stardew Valley 1.5.6's <see cref="FarmerTeam"/> methods to their newer form to avoid breaking older mods.</summary>
1212
/// <remarks>This is public to support SMAPI rewriting and should never be referenced directly by mods. See remarks on <see cref="ReplaceReferencesRewriter"/> for more info.</remarks>
1313
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = SuppressReasons.MatchesOriginal)]
14+
[SuppressMessage("ReSharper", "RedundantBaseQualifier", Justification = SuppressReasons.BaseForClarity)]
1415
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = SuppressReasons.UsedViaRewriting)]
1516
public class FarmerTeamFacade : FarmerTeam, IRewriteFacade
1617
{
1718
/*********
1819
** Accessors
1920
*********/
20-
public NetObjectList<Item> junimoChest => InventoryToNetObjectList.GetCachedWrapperFor(this.GetOrCreateGlobalInventory(FarmerTeam.GlobalInventoryId_JunimoChest));
21+
public NetObjectList<Item> junimoChest => InventoryToNetObjectList.GetCachedWrapperFor(base.GetOrCreateGlobalInventory(FarmerTeam.GlobalInventoryId_JunimoChest));
2122

2223

2324
/*********

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/FenceFacade.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class FenceFacade : Fence, IRewriteFacade
1717
*********/
1818
public void toggleGate(GameLocation location, bool open, bool is_toggling_counterpart = false, Farmer? who = null)
1919
{
20-
this.toggleGate(open, is_toggling_counterpart, who);
20+
base.toggleGate(open, is_toggling_counterpart, who);
2121
}
2222

2323

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/FruitTreeFacade.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters.StardewValley_1_6
1313
/// <summary>Maps Stardew Valley 1.5.6's <see cref="FruitTree"/> methods to their newer form to avoid breaking older mods.</summary>
1414
/// <remarks>This is public to support SMAPI rewriting and should never be referenced directly by mods. See remarks on <see cref="ReplaceReferencesRewriter"/> for more info.</remarks>
1515
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = SuppressReasons.MatchesOriginal)]
16+
[SuppressMessage("ReSharper", "RedundantBaseQualifier", Justification = SuppressReasons.BaseForClarity)]
1617
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = SuppressReasons.UsedViaRewriting)]
1718
public class FruitTreeFacade : FruitTree, IRewriteFacade
1819
{
@@ -23,7 +24,7 @@ public NetString fruitSeason
2324
{
2425
get
2526
{
26-
List<Season>? seasons = this.GetData()?.Seasons;
27+
List<Season>? seasons = base.GetData()?.Seasons;
2728
string value = seasons?.Count > 0
2829
? string.Join(",", seasons)
2930
: string.Empty;

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/FurnitureFacade.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ public static Furniture Constructor(int which, Vector2 tile)
2929

3030
public void AddLightGlow(GameLocation location)
3131
{
32-
this.AddLightGlow();
32+
base.AddLightGlow();
3333
}
3434

3535
public void addLights(GameLocation environment)
3636
{
37-
this.addLights();
37+
base.addLights();
3838
}
3939

4040
public static Furniture GetFurnitureInstance(int index, Vector2? position = null)
@@ -44,17 +44,17 @@ public static Furniture GetFurnitureInstance(int index, Vector2? position = null
4444

4545
public void removeLights(GameLocation environment)
4646
{
47-
this.removeLights();
47+
base.removeLights();
4848
}
4949

5050
public void RemoveLightGlow(GameLocation location)
5151
{
52-
this.RemoveLightGlow();
52+
base.RemoveLightGlow();
5353
}
5454

5555
public void setFireplace(GameLocation location, bool playSound = true, bool broadcast = false)
5656
{
57-
this.setFireplace(playSound, broadcast);
57+
base.setFireplace(playSound, broadcast);
5858
}
5959

6060

0 commit comments

Comments
 (0)