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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 5 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 8 additions & 7 deletions
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

Lines changed: 2 additions & 2 deletions
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

0 commit comments

Comments
 (0)