From 54e1b24fe9814e2348b307b8f6978d49d6675ea3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Mar 2017 13:41:50 +0900 Subject: [PATCH] Enforce readonly private members where possible. --- osu.Desktop.Deploy/Program.cs | 2 +- .../Beatmaps/TestWorkingBeatmap.cs | 2 +- osu.Desktop.VisualTests/Benchmark.cs | 2 +- .../Tests/TestCaseHitObjects.cs | 4 ++-- .../Tests/TestCaseNotificationManager.cs | 2 +- osu.Desktop/OsuGameDesktop.cs | 2 +- .../Objects/Drawable/DrawableFruit.cs | 2 +- .../Objects/Drawables/DrawableHitCircle.cs | 14 +++++++------- .../Objects/Drawables/DrawableSlider.cs | 14 +++++++------- .../Objects/Drawables/DrawableSliderTick.cs | 2 +- .../Objects/Drawables/DrawableSpinner.cs | 12 ++++++------ .../Objects/Drawables/HitExplosion.cs | 4 ++-- .../Objects/Drawables/Pieces/ApproachCircle.cs | 2 +- .../Objects/Drawables/Pieces/CirclePiece.cs | 2 +- .../Objects/Drawables/Pieces/GlowPiece.cs | 2 +- .../Objects/Drawables/Pieces/NumberPiece.cs | 2 +- .../Objects/Drawables/Pieces/SliderBall.cs | 2 +- .../Objects/Drawables/Pieces/SliderBody.cs | 8 ++++---- .../Objects/Drawables/Pieces/SliderBouncer.cs | 2 +- .../Objects/OsuHitObjectDifficulty.cs | 6 +++--- osu.Game.Modes.Osu/OsuAutoReplay.cs | 6 +++--- osu.Game.Modes.Osu/UI/OsuPlayfield.cs | 6 +++--- .../Objects/Drawable/DrawableTaikoHit.cs | 2 +- osu.Game/Beatmaps/Drawables/BeatmapPanel.cs | 6 +++--- .../Beatmaps/Drawables/BeatmapSetHeader.cs | 7 ++++--- osu.Game/Beatmaps/Drawables/Panel.cs | 2 +- osu.Game/Beatmaps/IO/OszArchiveReader.cs | 6 +++--- osu.Game/Beatmaps/WorkingBeatmap.cs | 6 +++--- osu.Game/Database/BeatmapDatabase.cs | 2 +- osu.Game/Graphics/Backgrounds/Background.cs | 2 +- .../Graphics/Containers/ParallaxContainer.cs | 2 +- osu.Game/Graphics/Cursor/CursorTrail.cs | 6 +++--- .../Graphics/UserInterface/DialogButton.cs | 11 ++++++++--- osu.Game/Graphics/UserInterface/Nub.cs | 2 +- osu.Game/Graphics/UserInterface/OsuCheckbox.cs | 4 ++-- osu.Game/Graphics/UserInterface/OsuDropdown.cs | 4 ++-- .../UserInterface/OsuPasswordTextBox.cs | 2 +- .../Graphics/UserInterface/OsuSliderBar.cs | 5 +++-- .../Graphics/UserInterface/OsuTabControl.cs | 4 ++-- osu.Game/Graphics/UserInterface/StarCounter.cs | 2 +- .../Graphics/UserInterface/TwoLayerButton.cs | 8 ++++---- .../UserInterface/Volume/VolumeControl.cs | 6 +++--- .../UserInterface/Volume/VolumeMeter.cs | 2 +- osu.Game/IO/Legacy/SerializationReader.cs | 2 +- osu.Game/IPC/BeatmapIPCChannel.cs | 2 +- osu.Game/IPC/ScoreIPCChannel.cs | 2 +- osu.Game/Modes/Objects/BezierApproximator.cs | 8 ++++---- .../Modes/Objects/CircularArcApproximator.cs | 6 +++--- osu.Game/Modes/Objects/SliderCurve.cs | 4 ++-- osu.Game/Modes/Ruleset.cs | 8 ++++---- osu.Game/Modes/UI/HitRenderer.cs | 2 +- osu.Game/Modes/UI/ModIcon.cs | 3 ++- osu.Game/Modes/UI/Playfield.cs | 2 +- osu.Game/Modes/UI/StandardHealthDisplay.cs | 2 +- osu.Game/Online/API/APIAccess.cs | 8 ++++---- .../Online/API/Requests/GetMessagesRequest.cs | 2 +- .../Online/Chat/Drawables/DrawableChannel.cs | 4 ++-- osu.Game/OsuGame.cs | 2 +- osu.Game/Overlays/ChatOverlay.cs | 4 ++-- osu.Game/Overlays/Dialog/PopupDialog.cs | 10 ++++++---- osu.Game/Overlays/DialogOverlay.cs | 2 +- osu.Game/Overlays/DragBar.cs | 2 +- osu.Game/Overlays/Mods/ModButton.cs | 4 ++-- osu.Game/Overlays/Mods/ModSection.cs | 2 +- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 7 ++++--- osu.Game/Overlays/MusicController.cs | 6 +++--- .../Overlays/Notifications/Notification.cs | 4 ++-- .../Notifications/NotificationSection.cs | 2 +- .../Notifications/ProgressNotification.cs | 4 ++-- .../Notifications/SimpleNotification.cs | 4 ++-- osu.Game/Overlays/Options/OptionDropdown.cs | 4 ++-- osu.Game/Overlays/Options/OptionSlider.cs | 4 ++-- osu.Game/Overlays/Options/OptionsSection.cs | 2 +- osu.Game/Overlays/Options/OptionsSubsection.cs | 2 +- osu.Game/Overlays/Options/Sidebar.cs | 2 +- osu.Game/Overlays/Options/SidebarButton.cs | 10 +++++----- osu.Game/Overlays/Toolbar/Toolbar.cs | 8 ++++---- osu.Game/Overlays/Toolbar/ToolbarButton.cs | 6 +++--- .../Overlays/Toolbar/ToolbarModeSelector.cs | 4 ++-- .../Toolbar/ToolbarOverlayToggleButton.cs | 2 +- osu.Game/Overlays/Toolbar/ToolbarUserArea.cs | 2 +- osu.Game/Overlays/Toolbar/ToolbarUserButton.cs | 2 +- osu.Game/Overlays/WaveOverlayContainer.cs | 7 +++++-- .../Backgrounds/BackgroundScreenBeatmap.cs | 2 +- osu.Game/Screens/GameScreenWhiteBox.cs | 6 +++--- osu.Game/Screens/Menu/Button.cs | 14 +++++++------- osu.Game/Screens/Menu/ButtonSystem.cs | 18 +++++++++--------- osu.Game/Screens/Menu/Disclaimer.cs | 2 +- osu.Game/Screens/Menu/Intro.cs | 2 +- osu.Game/Screens/Menu/MainMenu.cs | 4 ++-- osu.Game/Screens/Menu/OsuLogo.cs | 16 ++++++++-------- osu.Game/Screens/Play/KeyCounterCollection.cs | 2 +- .../Screens/Play/Pause/PauseProgressBar.cs | 6 +++--- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/PlayerInputManager.cs | 2 +- osu.Game/Screens/Play/PlayerLoader.cs | 2 +- osu.Game/Screens/Select/BeatmapCarousel.cs | 8 ++++---- osu.Game/Screens/Select/FilterControl.cs | 6 +++--- osu.Game/Screens/Select/Footer.cs | 4 ++-- osu.Game/Screens/Select/FooterButton.cs | 6 +++--- .../Select/Leaderboards/DrawableRank.cs | 2 +- .../Screens/Select/Leaderboards/Leaderboard.cs | 4 ++-- .../Select/Leaderboards/LeaderboardScore.cs | 18 ++++++++++-------- .../Select/Options/BeatmapOptionsButton.cs | 10 ++++++---- .../Select/Options/BeatmapOptionsOverlay.cs | 4 ++-- osu.Game/Screens/Select/PlaySongSelect.cs | 4 ++-- osu.Game/Screens/Select/SongSelect.cs | 7 +++---- .../Components/VisualiserContainer.cs | 2 +- osu.Game/Screens/Tournament/Drawings.cs | 2 +- osu.Game/Screens/Tournament/Group.cs | 10 +++++----- osu.Game/Screens/Tournament/GroupContainer.cs | 4 ++-- .../Tournament/ScrollingTeamContainer.cs | 6 +++--- .../Tournament/Teams/StorageBackedTeamList.cs | 2 +- osu.Game/Users/Country.cs | 2 +- osu.sln.DotSettings | 4 +++- 115 files changed, 278 insertions(+), 259 deletions(-) diff --git a/osu.Desktop.Deploy/Program.cs b/osu.Desktop.Deploy/Program.cs index 00ec215e8a..37776b329f 100644 --- a/osu.Desktop.Deploy/Program.cs +++ b/osu.Desktop.Deploy/Program.cs @@ -53,7 +53,7 @@ namespace osu.Desktop.Deploy private static string nupkgFilename(string ver) => $"{PackageName}.{ver}.nupkg"; private static string nupkgDistroFilename(string ver) => $"{PackageName}-{ver}-full.nupkg"; - private static Stopwatch sw = new Stopwatch(); + private static readonly Stopwatch sw = new Stopwatch(); private static string codeSigningPassword; diff --git a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs index babca8ee06..f135a6affa 100644 --- a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs @@ -15,7 +15,7 @@ namespace osu.Desktop.VisualTests.Beatmaps this.beatmap = beatmap; } - private Beatmap beatmap; + private readonly Beatmap beatmap; protected override Beatmap GetBeatmap() => beatmap; protected override Texture GetBackground() => null; diff --git a/osu.Desktop.VisualTests/Benchmark.cs b/osu.Desktop.VisualTests/Benchmark.cs index 3847b6f00f..01a6e749f3 100644 --- a/osu.Desktop.VisualTests/Benchmark.cs +++ b/osu.Desktop.VisualTests/Benchmark.cs @@ -10,7 +10,7 @@ namespace osu.Desktop.VisualTests { public class Benchmark : OsuGameBase { - private double timePerTest = 200; + private readonly double timePerTest = 200; [BackgroundDependencyLoader] private void load() diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index eeebc7faa8..f302330346 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -21,7 +21,7 @@ namespace osu.Desktop.VisualTests.Tests { internal class TestCaseHitObjects : TestCase { - private FramedClock framedClock; + private readonly FramedClock framedClock; private bool auto; @@ -34,7 +34,7 @@ namespace osu.Desktop.VisualTests.Tests private HitObjectType mode = HitObjectType.Slider; - private BindableNumber playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 }; + private readonly BindableNumber playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 }; private Container playfieldContainer; private Container approachContainer; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs index c3a9064e69..13f89153e9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs @@ -95,7 +95,7 @@ namespace osu.Desktop.VisualTests.Tests progressingNotifications.Add(n); } - private List progressingNotifications = new List(); + private readonly List progressingNotifications = new List(); private void sendProgress1() { diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index da3e7b704a..95870125e3 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -17,7 +17,7 @@ namespace osu.Desktop { internal class OsuGameDesktop : OsuGame { - private VersionManager versionManager; + private readonly VersionManager versionManager; public OsuGameDesktop(string[] args = null) : base(args) diff --git a/osu.Game.Modes.Catch/Objects/Drawable/DrawableFruit.cs b/osu.Game.Modes.Catch/Objects/Drawable/DrawableFruit.cs index 5d19d902b1..4ea310f083 100644 --- a/osu.Game.Modes.Catch/Objects/Drawable/DrawableFruit.cs +++ b/osu.Game.Modes.Catch/Objects/Drawable/DrawableFruit.cs @@ -12,7 +12,7 @@ namespace osu.Game.Modes.Catch.Objects.Drawable { internal class DrawableFruit : Sprite { - private CatchBaseHit h; + private readonly CatchBaseHit h; public DrawableFruit(CatchBaseHit h) { diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs index e8c74d4f8d..fe5b2f9859 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -13,15 +13,15 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { public class DrawableHitCircle : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach { - private OsuHitObject osuObject; + private readonly OsuHitObject osuObject; public ApproachCircle ApproachCircle; - private CirclePiece circle; - private RingPiece ring; - private FlashPiece flash; - private ExplodePiece explode; - private NumberPiece number; - private GlowPiece glow; + private readonly CirclePiece circle; + private readonly RingPiece ring; + private readonly FlashPiece flash; + private readonly ExplodePiece explode; + private readonly NumberPiece number; + private readonly GlowPiece glow; public DrawableHitCircle(OsuHitObject h) : base(h) { diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs index a2a52c7d94..f730d55e21 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs @@ -13,18 +13,18 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { public class DrawableSlider : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach { - private Slider slider; + private readonly Slider slider; - private DrawableHitCircle initialCircle; + private readonly DrawableHitCircle initialCircle; - private List components = new List(); + private readonly List components = new List(); - private Container ticks; + private readonly Container ticks; - private SliderBody body; - private SliderBall ball; + private readonly SliderBody body; + private readonly SliderBall ball; - private SliderBouncer bouncer2; + private readonly SliderBouncer bouncer2; public DrawableSlider(Slider s) : base(s) { diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs index fff08b9f60..988eab45b5 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -18,7 +18,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { public class DrawableSliderTick : DrawableOsuHitObject { - private SliderTick sliderTick; + private readonly SliderTick sliderTick; public double FadeInTime; public double FadeOutTime; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs index 8098e87b12..2d701b3eeb 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs @@ -15,12 +15,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { public class DrawableSpinner : DrawableOsuHitObject { - private Spinner spinner; + private readonly Spinner spinner; - private SpinnerDisc disc; - private SpinnerBackground background; - private Container circleContainer; - private DrawableHitCircle circle; + private readonly SpinnerDisc disc; + private readonly SpinnerBackground background; + private readonly Container circleContainer; + private readonly DrawableHitCircle circle; public DrawableSpinner(Spinner s) : base(s) { @@ -108,7 +108,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables private Vector2 scaleToCircle => circle.Scale * circle.DrawWidth / DrawWidth * 0.95f; - private float spinsPerMinuteNeeded = 100 + 5 * 15; //TODO: read per-map OD and place it on the 5 + private readonly float spinsPerMinuteNeeded = 100 + 5 * 15; //TODO: read per-map OD and place it on the 5 private float rotationsNeeded => (float)(spinsPerMinuteNeeded * (spinner.EndTime - spinner.StartTime) / 60000f); diff --git a/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs b/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs index ab34d49ecf..f2ccf554d9 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs @@ -17,8 +17,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables public class HitExplosion : FillFlowContainer { private readonly OsuJudgementInfo judgement; - private SpriteText line1; - private SpriteText line2; + private readonly SpriteText line1; + private readonly SpriteText line2; public HitExplosion(OsuJudgementInfo judgement, OsuHitObject h = null) { diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/ApproachCircle.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/ApproachCircle.cs index b0b1e81fca..fd4ef64350 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/ApproachCircle.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/ApproachCircle.cs @@ -11,7 +11,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { public class ApproachCircle : Container { - private Sprite approachCircle; + private readonly Sprite approachCircle; public ApproachCircle() { diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/CirclePiece.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/CirclePiece.cs index 2a503e3dec..704a6b7490 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/CirclePiece.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/CirclePiece.cs @@ -14,7 +14,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { public class CirclePiece : Container { - private Sprite disc; + private readonly Sprite disc; public Func Hit; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/GlowPiece.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/GlowPiece.cs index 1a16eae48c..6cffa370cf 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/GlowPiece.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/GlowPiece.cs @@ -11,7 +11,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { public class GlowPiece : Container { - private Sprite layer; + private readonly Sprite layer; public GlowPiece() { diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/NumberPiece.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/NumberPiece.cs index 750f203a8d..0ebd274246 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/NumberPiece.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/NumberPiece.cs @@ -12,7 +12,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { public class NumberPiece : Container { - private SpriteText number; + private readonly SpriteText number; public string Text { diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBall.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBall.cs index 0b1a3aa751..cccd10469d 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBall.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBall.cs @@ -13,7 +13,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces public class SliderBall : CircularContainer, ISliderProgress { private readonly Slider slider; - private Box follow; + private readonly Box follow; private const float width = 128; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBody.cs index b923d05713..c541a861d4 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBody.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -18,8 +18,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { public class SliderBody : Container, ISliderProgress { - private Path path; - private BufferedContainer container; + private readonly Path path; + private readonly BufferedContainer container; public float PathWidth { @@ -33,7 +33,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces public double? SnakedStart { get; private set; } public double? SnakedEnd { get; private set; } - private Slider slider; + private readonly Slider slider; public SliderBody(Slider s) { slider = s; @@ -122,7 +122,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces path.Texture = texture; } - private List currentCurve = new List(); + private readonly List currentCurve = new List(); private bool updateSnaking(double p0, double p1) { if (SnakedStart == p0 && SnakedEnd == p1) return false; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBouncer.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBouncer.cs index 1a78e5d85f..196b9fb521 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBouncer.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SliderBouncer.cs @@ -11,7 +11,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { private readonly Slider slider; private readonly bool isEnd; - private TextAwesome icon; + private readonly TextAwesome icon; public SliderBouncer(Slider slider, bool isEnd) { diff --git a/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs b/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs index 926e5132bd..322f6b077a 100644 --- a/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs +++ b/osu.Game.Modes.Osu/Objects/OsuHitObjectDifficulty.cs @@ -47,11 +47,11 @@ namespace osu.Game.Modes.Osu.Objects internal int MaxCombo = 1; - private float scalingFactor; + private readonly float scalingFactor; private float lazySliderLength; - private Vector2 startPosition; - private Vector2 endPosition; + private readonly Vector2 startPosition; + private readonly Vector2 endPosition; internal OsuHitObjectDifficulty(OsuHitObject baseHitObject) { diff --git a/osu.Game.Modes.Osu/OsuAutoReplay.cs b/osu.Game.Modes.Osu/OsuAutoReplay.cs index 6b543cb98f..61b7466d86 100644 --- a/osu.Game.Modes.Osu/OsuAutoReplay.cs +++ b/osu.Game.Modes.Osu/OsuAutoReplay.cs @@ -20,7 +20,7 @@ namespace osu.Game.Modes.Osu private const float spin_radius = 50; - private Beatmap beatmap; + private readonly Beatmap beatmap; public OsuAutoReplay(Beatmap beatmap) { @@ -37,11 +37,11 @@ namespace osu.Game.Modes.Osu } } - private static IComparer replayFrameComparer = new LegacyReplayFrameComparer(); + private static readonly IComparer replay_frame_comparer = new LegacyReplayFrameComparer(); private int findInsertionIndex(LegacyReplayFrame frame) { - int index = Frames.BinarySearch(frame, replayFrameComparer); + int index = Frames.BinarySearch(frame, replay_frame_comparer); if (index < 0) { diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index 5caaaafb13..87c80f94bc 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -17,9 +17,9 @@ namespace osu.Game.Modes.Osu.UI { public class OsuPlayfield : Playfield { - private Container approachCircles; - private Container judgementLayer; - private ConnectionRenderer connectionLayer; + private readonly Container approachCircles; + private readonly Container judgementLayer; + private readonly ConnectionRenderer connectionLayer; public override Vector2 Size { diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableTaikoHit.cs b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableTaikoHit.cs index 760977ef5b..cdf1e600d5 100644 --- a/osu.Game.Modes.Taiko/Objects/Drawable/DrawableTaikoHit.cs +++ b/osu.Game.Modes.Taiko/Objects/Drawable/DrawableTaikoHit.cs @@ -12,7 +12,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable { internal class DrawableTaikoHit : Sprite { - private TaikoHitObject h; + private readonly TaikoHitObject h; public DrawableTaikoHit(TaikoHitObject h) { diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index 67ebb2fcb9..34e4ebf8ac 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -21,12 +21,12 @@ namespace osu.Game.Beatmaps.Drawables public class BeatmapPanel : Panel { public BeatmapInfo Beatmap; - private Sprite background; + private readonly Sprite background; public Action GainedSelection; public Action StartRequested; - private Triangles triangles; - private StarCounter starCounter; + private readonly Triangles triangles; + private readonly StarCounter starCounter; protected override void Selected() { diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index 3dc5fdedc9..2d032f0ea4 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -20,11 +20,12 @@ namespace osu.Game.Beatmaps.Drawables public class BeatmapSetHeader : Panel { public Action GainedSelection; - private SpriteText title, artist; + private readonly SpriteText title; + private readonly SpriteText artist; private OsuConfigManager config; private Bindable preferUnicode; - private WorkingBeatmap beatmap; - private FillFlowContainer difficultyIcons; + private readonly WorkingBeatmap beatmap; + private readonly FillFlowContainer difficultyIcons; public BeatmapSetHeader(WorkingBeatmap beatmap) { diff --git a/osu.Game/Beatmaps/Drawables/Panel.cs b/osu.Game/Beatmaps/Drawables/Panel.cs index c51ae8680e..2a5564bc71 100644 --- a/osu.Game/Beatmaps/Drawables/Panel.cs +++ b/osu.Game/Beatmaps/Drawables/Panel.cs @@ -18,7 +18,7 @@ namespace osu.Game.Beatmaps.Drawables public override bool RemoveWhenNotAlive => false; - private Container nestedContainer; + private readonly Container nestedContainer; protected override Container Content => nestedContainer; diff --git a/osu.Game/Beatmaps/IO/OszArchiveReader.cs b/osu.Game/Beatmaps/IO/OszArchiveReader.cs index 8a1d071cfc..5c0f29fb86 100644 --- a/osu.Game/Beatmaps/IO/OszArchiveReader.cs +++ b/osu.Game/Beatmaps/IO/OszArchiveReader.cs @@ -21,9 +21,9 @@ namespace osu.Game.Beatmaps.IO OsuLegacyDecoder.Register(); } - private Stream archiveStream; - private ZipFile archive; - private Beatmap firstMap; + private readonly Stream archiveStream; + private readonly ZipFile archive; + private readonly Beatmap firstMap; public OszArchiveReader(Stream archiveStream) { diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 2a2de1b6ef..74c8866596 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -42,7 +42,7 @@ namespace osu.Game.Beatmaps protected abstract Track GetTrack(); private Beatmap beatmap; - private object beatmapLock = new object(); + private readonly object beatmapLock = new object(); public Beatmap Beatmap { get @@ -54,7 +54,7 @@ namespace osu.Game.Beatmaps } } - private object backgroundLock = new object(); + private readonly object backgroundLock = new object(); private Texture background; public Texture Background { @@ -68,7 +68,7 @@ namespace osu.Game.Beatmaps } private Track track; - private object trackLock = new object(); + private readonly object trackLock = new object(); public Track Track { get diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 317467d792..dfc916a136 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -21,7 +21,7 @@ namespace osu.Game.Database public class BeatmapDatabase { private SQLiteConnection connection { get; } - private Storage storage; + private readonly Storage storage; public event Action BeatmapSetAdded; public event Action BeatmapSetRemoved; diff --git a/osu.Game/Graphics/Backgrounds/Background.cs b/osu.Game/Graphics/Backgrounds/Background.cs index 5bafc8cd64..7c47635276 100644 --- a/osu.Game/Graphics/Backgrounds/Background.cs +++ b/osu.Game/Graphics/Backgrounds/Background.cs @@ -14,7 +14,7 @@ namespace osu.Game.Graphics.Backgrounds { public Sprite Sprite; - private string textureName; + private readonly string textureName; public Background(string textureName = @"") { diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index c4cd1777e1..9dfc26dd3c 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -31,7 +31,7 @@ namespace osu.Game.Graphics.Containers }); } - private Container content; + private readonly Container content; private InputManager input; protected override Container Content => content; diff --git a/osu.Game/Graphics/Cursor/CursorTrail.cs b/osu.Game/Graphics/Cursor/CursorTrail.cs index ffd96d9622..e804b506cc 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -31,10 +31,10 @@ namespace osu.Game.Graphics.Cursor private float time; - private TrailDrawNodeSharedData trailDrawNodeSharedData = new TrailDrawNodeSharedData(); + private readonly TrailDrawNodeSharedData trailDrawNodeSharedData = new TrailDrawNodeSharedData(); private const int max_sprites = 2048; - private TrailPart[] parts = new TrailPart[max_sprites]; + private readonly TrailPart[] parts = new TrailPart[max_sprites]; private Vector2? lastPosition; @@ -163,7 +163,7 @@ namespace osu.Game.Graphics.Cursor public float Time; public TrailDrawNodeSharedData Shared; - public TrailPart[] Parts = new TrailPart[max_sprites]; + public readonly TrailPart[] Parts = new TrailPart[max_sprites]; public Vector2 Size; public TrailDrawNode() diff --git a/osu.Game/Graphics/UserInterface/DialogButton.cs b/osu.Game/Graphics/UserInterface/DialogButton.cs index 49b5f1e509..6015f56d6c 100644 --- a/osu.Game/Graphics/UserInterface/DialogButton.cs +++ b/osu.Game/Graphics/UserInterface/DialogButton.cs @@ -81,9 +81,14 @@ namespace osu.Game.Graphics.UserInterface public SampleChannel SampleClick, SampleHover; - private Container backgroundContainer, colourContainer, glowContainer; - private Box leftGlow, centerGlow, rightGlow, background; - private SpriteText spriteText; + private readonly Container backgroundContainer; + private readonly Container colourContainer; + private readonly Container glowContainer; + private readonly Box leftGlow; + private readonly Box centerGlow; + private readonly Box rightGlow; + private readonly Box background; + private readonly SpriteText spriteText; private Vector2 hoverSpacing => new Vector2(3f, 0f); private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's when clicking diff --git a/osu.Game/Graphics/UserInterface/Nub.cs b/osu.Game/Graphics/UserInterface/Nub.cs index a32e047af9..71060fbd09 100644 --- a/osu.Game/Graphics/UserInterface/Nub.cs +++ b/osu.Game/Graphics/UserInterface/Nub.cs @@ -18,7 +18,7 @@ namespace osu.Game.Graphics.UserInterface public const float COLLAPSED_SIZE = 20; public const float EXPANDED_SIZE = 40; - private Box fill; + private readonly Box fill; private const float border_width = 3; private Color4 glowingColour, idleColour; diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index a2469afb53..2209c96689 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -64,8 +64,8 @@ namespace osu.Game.Graphics.UserInterface } } - private Nub nub; - private SpriteText labelSpriteText; + private readonly Nub nub; + private readonly SpriteText labelSpriteText; private SampleChannel sampleChecked; private SampleChannel sampleUnchecked; diff --git a/osu.Game/Graphics/UserInterface/OsuDropdown.cs b/osu.Game/Graphics/UserInterface/OsuDropdown.cs index 7a31337660..3466fb1a60 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropdown.cs @@ -85,7 +85,7 @@ namespace osu.Game.Graphics.UserInterface private Color4? accentColour; - private TextAwesome chevron; + private readonly TextAwesome chevron; protected override void FormatForeground(bool hover = false) { @@ -116,7 +116,7 @@ namespace osu.Game.Graphics.UserInterface protected class OsuDropdownHeader : DropdownHeader { - private SpriteText label; + private readonly SpriteText label; protected override string Label { get { return label.Text; } diff --git a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs index c9d8f936f6..d0072af0eb 100644 --- a/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs @@ -18,7 +18,7 @@ namespace osu.Game.Graphics.UserInterface public class PasswordMaskChar : Container { - private CircularContainer circle; + private readonly CircularContainer circle; public PasswordMaskChar(float size) { diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index 58fe24a9e6..81a1b5ca1b 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -19,8 +19,9 @@ namespace osu.Game.Graphics.UserInterface private SampleChannel sample; private double lastSampleTime; - private Nub nub; - private Box leftBox, rightBox; + private readonly Nub nub; + private readonly Box leftBox; + private readonly Box rightBox; public OsuSliderBar() { diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 8283c1baa0..5f6de4bee4 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -59,8 +59,8 @@ namespace osu.Game.Graphics.UserInterface private class OsuTabItem : TabItem { - private SpriteText text; - private Box box; + private readonly SpriteText text; + private readonly Box box; private Color4? accentColour; public Color4 AccentColour diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index c46eda6582..c0d55fa608 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -147,7 +147,7 @@ namespace osu.Game.Graphics.UserInterface private class Star : Container { - public TextAwesome Icon; + public readonly TextAwesome Icon; public Star() { Size = new Vector2(star_size); diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 0d4e72f92c..daf4df657b 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface { public class TwoLayerButton : ClickableContainer { - private TextAwesome icon; + private readonly TextAwesome icon; public Box IconLayer; public Box TextLayer; @@ -29,11 +29,11 @@ namespace osu.Game.Graphics.UserInterface public static readonly Vector2 SIZE_EXTENDED = new Vector2(140, 50); public static readonly Vector2 SIZE_RETRACTED = new Vector2(100, 50); public SampleChannel ActivationSound; - private SpriteText text; + private readonly SpriteText text; public Color4 HoverColour; - private Container c1; - private Container c2; + private readonly Container c1; + private readonly Container c2; public Color4 BackgroundColour { diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs index a9f09ce86c..374385e351 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -15,7 +15,7 @@ namespace osu.Game.Graphics.UserInterface.Volume { internal class VolumeControl : OverlayContainer { - private VolumeMeter volumeMeterMaster; + private readonly VolumeMeter volumeMeterMaster; protected override bool HideOnEscape => false; @@ -89,8 +89,8 @@ namespace osu.Game.Graphics.UserInterface.Volume private ScheduledDelegate popOutDelegate; - private VolumeMeter volumeMeterEffect; - private VolumeMeter volumeMeterMusic; + private readonly VolumeMeter volumeMeterEffect; + private readonly VolumeMeter volumeMeterMusic; protected override void PopIn() { diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs index 4d68177fef..4d83805b83 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs @@ -15,7 +15,7 @@ namespace osu.Game.Graphics.UserInterface.Volume { internal class VolumeMeter : Container { - private Box meterFill; + private readonly Box meterFill; public BindableDouble Bindable { get; } = new BindableDouble(); public VolumeMeter(string meterName) diff --git a/osu.Game/IO/Legacy/SerializationReader.cs b/osu.Game/IO/Legacy/SerializationReader.cs index 6cab5c534d..6bb6c3bbbf 100644 --- a/osu.Game/IO/Legacy/SerializationReader.cs +++ b/osu.Game/IO/Legacy/SerializationReader.cs @@ -18,7 +18,7 @@ namespace osu.Game.IO.Legacy /// handle null strings and simplify use with ISerializable. public class SerializationReader : BinaryReader { - private Stream stream; + private readonly Stream stream; public SerializationReader(Stream s) : base(s, Encoding.UTF8) diff --git a/osu.Game/IPC/BeatmapIPCChannel.cs b/osu.Game/IPC/BeatmapIPCChannel.cs index 2b98d5254f..61e6cc76cc 100644 --- a/osu.Game/IPC/BeatmapIPCChannel.cs +++ b/osu.Game/IPC/BeatmapIPCChannel.cs @@ -10,7 +10,7 @@ namespace osu.Game.IPC { public class BeatmapIPCChannel : IpcChannel { - private BeatmapDatabase beatmaps; + private readonly BeatmapDatabase beatmaps; public BeatmapIPCChannel(IIpcHost host, BeatmapDatabase beatmaps = null) : base(host) diff --git a/osu.Game/IPC/ScoreIPCChannel.cs b/osu.Game/IPC/ScoreIPCChannel.cs index 0a49f4cd8f..7a509ee0e8 100644 --- a/osu.Game/IPC/ScoreIPCChannel.cs +++ b/osu.Game/IPC/ScoreIPCChannel.cs @@ -10,7 +10,7 @@ namespace osu.Game.IPC { public class ScoreIPCChannel : IpcChannel { - private ScoreDatabase scores; + private readonly ScoreDatabase scores; public ScoreIPCChannel(IIpcHost host, ScoreDatabase scores = null) : base(host) diff --git a/osu.Game/Modes/Objects/BezierApproximator.cs b/osu.Game/Modes/Objects/BezierApproximator.cs index b0f17afc7e..ee8e9b0e06 100644 --- a/osu.Game/Modes/Objects/BezierApproximator.cs +++ b/osu.Game/Modes/Objects/BezierApproximator.cs @@ -8,10 +8,10 @@ namespace osu.Game.Modes.Objects { public class BezierApproximator { - private int count; - private List controlPoints; - private Vector2[] subdivisionBuffer1; - private Vector2[] subdivisionBuffer2; + private readonly int count; + private readonly List controlPoints; + private readonly Vector2[] subdivisionBuffer1; + private readonly Vector2[] subdivisionBuffer2; private const float tolerance = 0.25f; private const float tolerance_sq = tolerance * tolerance; diff --git a/osu.Game/Modes/Objects/CircularArcApproximator.cs b/osu.Game/Modes/Objects/CircularArcApproximator.cs index af15f99e43..310b923b0b 100644 --- a/osu.Game/Modes/Objects/CircularArcApproximator.cs +++ b/osu.Game/Modes/Objects/CircularArcApproximator.cs @@ -10,9 +10,9 @@ namespace osu.Game.Modes.Objects { public class CircularArcApproximator { - private Vector2 a; - private Vector2 b; - private Vector2 c; + private readonly Vector2 a; + private readonly Vector2 b; + private readonly Vector2 c; private int amountPoints; diff --git a/osu.Game/Modes/Objects/SliderCurve.cs b/osu.Game/Modes/Objects/SliderCurve.cs index 8ab5097257..642a65af21 100644 --- a/osu.Game/Modes/Objects/SliderCurve.cs +++ b/osu.Game/Modes/Objects/SliderCurve.cs @@ -19,8 +19,8 @@ namespace osu.Game.Modes.Objects public Vector2 Offset; - private List calculatedPath = new List(); - private List cumulativeLength = new List(); + private readonly List calculatedPath = new List(); + private readonly List cumulativeLength = new List(); private List calculateSubpath(List subControlPoints) { diff --git a/osu.Game/Modes/Ruleset.cs b/osu.Game/Modes/Ruleset.cs index 013ea1d4fc..886b49f26b 100644 --- a/osu.Game/Modes/Ruleset.cs +++ b/osu.Game/Modes/Ruleset.cs @@ -21,9 +21,9 @@ namespace osu.Game.Modes public abstract class Ruleset { - private static ConcurrentDictionary availableRulesets = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary available_rulesets = new ConcurrentDictionary(); - public static IEnumerable PlayModes => availableRulesets.Keys; + public static IEnumerable PlayModes => available_rulesets.Keys; public virtual IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { }; @@ -35,7 +35,7 @@ namespace osu.Game.Modes public abstract ScoreProcessor CreateScoreProcessor(); - public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType()); + public static void Register(Ruleset ruleset) => available_rulesets.TryAdd(ruleset.PlayMode, ruleset.GetType()); protected abstract PlayMode PlayMode { get; } @@ -49,7 +49,7 @@ namespace osu.Game.Modes { Type type; - if (!availableRulesets.TryGetValue(mode, out type)) + if (!available_rulesets.TryGetValue(mode, out type)) return null; return Activator.CreateInstance(type) as Ruleset; diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index b82e3ada51..05b02a77b3 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -155,7 +155,7 @@ namespace osu.Game.Modes.UI /// protected Playfield Playfield; - private Container content; + private readonly Container content; protected HitRenderer(WorkingBeatmap beatmap) : base(beatmap) diff --git a/osu.Game/Modes/UI/ModIcon.cs b/osu.Game/Modes/UI/ModIcon.cs index 65a570fea7..35459985c9 100644 --- a/osu.Game/Modes/UI/ModIcon.cs +++ b/osu.Game/Modes/UI/ModIcon.cs @@ -10,7 +10,8 @@ namespace osu.Game.Modes.UI { public class ModIcon : Container { - private TextAwesome modIcon, background; + private readonly TextAwesome modIcon; + private readonly TextAwesome background; private float iconSize = 80; public float IconSize diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index e5babecad9..4e4e1ed2fa 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -23,7 +23,7 @@ namespace osu.Game.Modes.UI internal Container ScaledContent; protected override Container Content => content; - private Container content; + private readonly Container content; /// /// A container for keeping track of DrawableHitObjects. diff --git a/osu.Game/Modes/UI/StandardHealthDisplay.cs b/osu.Game/Modes/UI/StandardHealthDisplay.cs index c639f3d482..58b44eabd3 100644 --- a/osu.Game/Modes/UI/StandardHealthDisplay.cs +++ b/osu.Game/Modes/UI/StandardHealthDisplay.cs @@ -15,7 +15,7 @@ namespace osu.Game.Modes.UI { public class StandardHealthDisplay : HealthDisplay { - private Container fill; + private readonly Container fill; public StandardHealthDisplay() { diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 6bb61ca83c..f39dec47e1 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -17,7 +17,7 @@ namespace osu.Game.Online.API { public class APIAccess : IUpdateable { - private OAuth authentication; + private readonly OAuth authentication; public string Endpoint = @"https://new.ppy.sh"; private const string client_id = @"5"; @@ -44,9 +44,9 @@ namespace osu.Game.Online.API protected bool HasLogin => Token != null || !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password); // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable (should dispose of this or at very least keep a reference). - private Thread thread; + private readonly Thread thread; - private Logger log; + private readonly Logger log; public APIAccess() { @@ -57,7 +57,7 @@ namespace osu.Game.Online.API thread.Start(); } - private List components = new List(); + private readonly List components = new List(); public void Register(IOnlineComponent component) { diff --git a/osu.Game/Online/API/Requests/GetMessagesRequest.cs b/osu.Game/Online/API/Requests/GetMessagesRequest.cs index af5a96a66a..cf52f9ccd3 100644 --- a/osu.Game/Online/API/Requests/GetMessagesRequest.cs +++ b/osu.Game/Online/API/Requests/GetMessagesRequest.cs @@ -9,7 +9,7 @@ namespace osu.Game.Online.API.Requests { public class GetMessagesRequest : APIRequest> { - private List channels; + private readonly List channels; private long? since; public GetMessagesRequest(List channels, long? sinceId) diff --git a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs index eb8653976a..e3101e8fd7 100644 --- a/osu.Game/Online/Chat/Drawables/DrawableChannel.cs +++ b/osu.Game/Online/Chat/Drawables/DrawableChannel.cs @@ -14,8 +14,8 @@ namespace osu.Game.Online.Chat.Drawables public class DrawableChannel : Container { private readonly Channel channel; - private FillFlowContainer flow; - private ScrollContainer scroll; + private readonly FillFlowContainer flow; + private readonly ScrollContainer scroll; public DrawableChannel(Channel channel) { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 5e7c47c9a9..1fca318149 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -60,7 +60,7 @@ namespace osu.Game public Bindable PlayMode; - private string[] args; + private readonly string[] args; private OptionsOverlay options; diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index efd366adb1..73ecf20891 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -31,11 +31,11 @@ namespace osu.Game.Overlays private ScheduledDelegate messageRequest; - private Container content; + private readonly Container content; protected override Container Content => content; - private FocusedTextBox inputTextBox; + private readonly FocusedTextBox inputTextBox; private APIAccess api; diff --git a/osu.Game/Overlays/Dialog/PopupDialog.cs b/osu.Game/Overlays/Dialog/PopupDialog.cs index 7936339e0c..bbac5ca786 100644 --- a/osu.Game/Overlays/Dialog/PopupDialog.cs +++ b/osu.Game/Overlays/Dialog/PopupDialog.cs @@ -27,10 +27,12 @@ namespace osu.Game.Overlays.Dialog private readonly Vector2 ringMinifiedSize = new Vector2(20f); private readonly Vector2 buttonsEnterSpacing = new Vector2(0f, 50f); - private Container content, ring; - private FillFlowContainer buttonsContainer; - private TextAwesome iconText; - private SpriteText header, body; + private readonly Container content; + private readonly Container ring; + private readonly FillFlowContainer buttonsContainer; + private readonly TextAwesome iconText; + private readonly SpriteText header; + private readonly SpriteText body; public FontAwesome Icon { diff --git a/osu.Game/Overlays/DialogOverlay.cs b/osu.Game/Overlays/DialogOverlay.cs index 12cca5275a..1769702c40 100644 --- a/osu.Game/Overlays/DialogOverlay.cs +++ b/osu.Game/Overlays/DialogOverlay.cs @@ -13,7 +13,7 @@ namespace osu.Game.Overlays { public class DialogOverlay : FocusedOverlayContainer { - private Container dialogContainer; + private readonly Container dialogContainer; private PopupDialog currentDialog; public void Push(PopupDialog dialog) diff --git a/osu.Game/Overlays/DragBar.cs b/osu.Game/Overlays/DragBar.cs index 2e8eb272d8..a9cf735171 100644 --- a/osu.Game/Overlays/DragBar.cs +++ b/osu.Game/Overlays/DragBar.cs @@ -11,7 +11,7 @@ namespace osu.Game.Overlays { public class DragBar : Container { - private Box fill; + private readonly Box fill; public Action SeekRequested; private bool isDragging; diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index acd5f37092..cd045aae41 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -23,8 +23,8 @@ namespace osu.Game.Overlays.Mods public class ModButton : FillFlowContainer { private ModIcon foregroundIcon { get; set; } - private SpriteText text; - private Container iconsContainer; + private readonly SpriteText text; + private readonly Container iconsContainer; private SampleChannel sampleOn, sampleOff; public Action Action; // Passed the selected mod or null if none diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index 489af21ef4..0e93a5520d 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Mods { public abstract class ModSection : Container { - private OsuSpriteText headerLabel; + private readonly OsuSpriteText headerLabel; public FillFlowContainer ButtonsContainer { get; } diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 3a685be7fa..d4ceb29c23 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -30,10 +30,11 @@ namespace osu.Game.Overlays.Mods private Color4 lowMultiplierColour, highMultiplierColour; - private OsuSpriteText rankedLabel, multiplierLabel; - private FillFlowContainer rankedMultiplerContainer; + private readonly OsuSpriteText rankedLabel; + private readonly OsuSpriteText multiplierLabel; + private readonly FillFlowContainer rankedMultiplerContainer; - private FillFlowContainer modSectionsContainer; + private readonly FillFlowContainer modSectionsContainer; public readonly Bindable> SelectedMods = new Bindable>(); diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 32061974ad..a45dcaacb8 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -35,7 +35,7 @@ namespace osu.Game.Overlays private SpriteText title, artist; private List playList; - private List playHistory = new List(); + private readonly List playHistory = new List(); private int playListIndex; private int playHistoryIndex = -1; @@ -415,8 +415,8 @@ namespace osu.Game.Overlays private class MusicControllerBackground : BufferedContainer { - private Sprite sprite; - private WorkingBeatmap beatmap; + private readonly Sprite sprite; + private readonly WorkingBeatmap beatmap; public MusicControllerBackground(WorkingBeatmap beatmap = null) { diff --git a/osu.Game/Overlays/Notifications/Notification.cs b/osu.Game/Overlays/Notifications/Notification.cs index e003a0e9dd..961e83e958 100644 --- a/osu.Game/Overlays/Notifications/Notification.cs +++ b/osu.Game/Overlays/Notifications/Notification.cs @@ -35,9 +35,9 @@ namespace osu.Game.Overlays.Notifications public virtual bool DisplayOnTop => true; protected NotificationLight Light; - private CloseButton closeButton; + private readonly CloseButton closeButton; protected Container IconContent; - private Container content; + private readonly Container content; protected override Container Content => content; diff --git a/osu.Game/Overlays/Notifications/NotificationSection.cs b/osu.Game/Overlays/Notifications/NotificationSection.cs index e5debc9c9b..ee74c5e2cb 100644 --- a/osu.Game/Overlays/Notifications/NotificationSection.cs +++ b/osu.Game/Overlays/Notifications/NotificationSection.cs @@ -135,7 +135,7 @@ namespace osu.Game.Overlays.Notifications private class ClearAllButton : ClickableContainer { - private OsuSpriteText text; + private readonly OsuSpriteText text; public ClearAllButton() { diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index 9dcee5c8af..5179e85df1 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -104,12 +104,12 @@ namespace osu.Game.Overlays.Notifications public override bool DisplayOnTop => false; - private ProgressBar progressBar; + private readonly ProgressBar progressBar; private Color4 colourQueued; private Color4 colourActive; private Color4 colourCancelled; - private SpriteText textDrawable; + private readonly SpriteText textDrawable; public ProgressNotification() { diff --git a/osu.Game/Overlays/Notifications/SimpleNotification.cs b/osu.Game/Overlays/Notifications/SimpleNotification.cs index 19034d6d1c..ba2ec02651 100644 --- a/osu.Game/Overlays/Notifications/SimpleNotification.cs +++ b/osu.Game/Overlays/Notifications/SimpleNotification.cs @@ -34,8 +34,8 @@ namespace osu.Game.Overlays.Notifications } } - private SpriteText textDrawable; - private TextAwesome iconDrawable; + private readonly SpriteText textDrawable; + private readonly TextAwesome iconDrawable; protected Box IconBackgound; diff --git a/osu.Game/Overlays/Options/OptionDropdown.cs b/osu.Game/Overlays/Options/OptionDropdown.cs index d46e786bca..9ae02a17d3 100644 --- a/osu.Game/Overlays/Options/OptionDropdown.cs +++ b/osu.Game/Overlays/Options/OptionDropdown.cs @@ -15,8 +15,8 @@ namespace osu.Game.Overlays.Options { public class OptionDropdown : FillFlowContainer { - private Dropdown dropdown; - private SpriteText text; + private readonly Dropdown dropdown; + private readonly SpriteText text; public string LabelText { diff --git a/osu.Game/Overlays/Options/OptionSlider.cs b/osu.Game/Overlays/Options/OptionSlider.cs index 2f09c51655..772d2c37e6 100644 --- a/osu.Game/Overlays/Options/OptionSlider.cs +++ b/osu.Game/Overlays/Options/OptionSlider.cs @@ -14,8 +14,8 @@ namespace osu.Game.Overlays.Options { public class OptionSlider : FillFlowContainer where T : struct { - private SliderBar slider; - private SpriteText text; + private readonly SliderBar slider; + private readonly SpriteText text; public string LabelText { diff --git a/osu.Game/Overlays/Options/OptionsSection.cs b/osu.Game/Overlays/Options/OptionsSection.cs index 25e891b5c9..777a4fe703 100644 --- a/osu.Game/Overlays/Options/OptionsSection.cs +++ b/osu.Game/Overlays/Options/OptionsSection.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Options public abstract FontAwesome Icon { get; } public abstract string Header { get; } - private SpriteText headerLabel; + private readonly SpriteText headerLabel; protected OptionsSection() { diff --git a/osu.Game/Overlays/Options/OptionsSubsection.cs b/osu.Game/Overlays/Options/OptionsSubsection.cs index a6baf0a6cd..9fd2e8fb1e 100644 --- a/osu.Game/Overlays/Options/OptionsSubsection.cs +++ b/osu.Game/Overlays/Options/OptionsSubsection.cs @@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Options { protected override Container Content => content; - private Container content; + private readonly Container content; protected abstract string Header { get; } diff --git a/osu.Game/Overlays/Options/Sidebar.cs b/osu.Game/Overlays/Options/Sidebar.cs index b0618ed3a6..e66c6de742 100644 --- a/osu.Game/Overlays/Options/Sidebar.cs +++ b/osu.Game/Overlays/Options/Sidebar.cs @@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Options { public class Sidebar : Container { - private FillFlowContainer content; + private readonly FillFlowContainer content; internal const float DEFAULT_WIDTH = ToolbarButton.WIDTH; internal const int EXPANDED_WIDTH = 200; protected override Container Content => content; diff --git a/osu.Game/Overlays/Options/SidebarButton.cs b/osu.Game/Overlays/Options/SidebarButton.cs index 729a9be326..7c0049e8c7 100644 --- a/osu.Game/Overlays/Options/SidebarButton.cs +++ b/osu.Game/Overlays/Options/SidebarButton.cs @@ -16,11 +16,11 @@ namespace osu.Game.Overlays.Options { public class SidebarButton : Container { - private TextAwesome drawableIcon; - private SpriteText headerText; - private Box backgroundBox; - private Box selectionIndicator; - private Container text; + private readonly TextAwesome drawableIcon; + private readonly SpriteText headerText; + private readonly Box backgroundBox; + private readonly Box selectionIndicator; + private readonly Container text; public Action Action; private OptionsSection section; diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 657334d1bb..ff1e37aafb 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -23,8 +23,8 @@ namespace osu.Game.Overlays.Toolbar public Action OnHome; public Action OnPlayModeChange; - private ToolbarModeSelector modeSelector; - private ToolbarUserArea userArea; + private readonly ToolbarModeSelector modeSelector; + private readonly ToolbarUserArea userArea; protected override bool HideOnEscape => false; @@ -90,8 +90,8 @@ namespace osu.Game.Overlays.Toolbar public class ToolbarBackground : Container { - private Box solidBackground; - private Box gradientBackground; + private readonly Box solidBackground; + private readonly Box gradientBackground; public ToolbarBackground() { diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index be4a23722f..fa1e1abf2a 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -63,9 +63,9 @@ namespace osu.Game.Overlays.Toolbar protected TextAwesome DrawableIcon; protected SpriteText DrawableText; protected Box HoverBackground; - private FillFlowContainer tooltipContainer; - private SpriteText tooltip1; - private SpriteText tooltip2; + private readonly FillFlowContainer tooltipContainer; + private readonly SpriteText tooltip1; + private readonly SpriteText tooltip2; protected FillFlowContainer Flow; private SampleChannel sampleClick; diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 30474ad796..a6df237f20 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -19,8 +19,8 @@ namespace osu.Game.Overlays.Toolbar { private const float padding = 10; - private FillFlowContainer modeButtons; - private Drawable modeButtonLine; + private readonly FillFlowContainer modeButtons; + private readonly Drawable modeButtonLine; private ToolbarModeButton activeButton; public Action OnPlayModeChange; diff --git a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs index 991c76e164..023d9cfea7 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarOverlayToggleButton.cs @@ -11,7 +11,7 @@ namespace osu.Game.Overlays.Toolbar { internal class ToolbarOverlayToggleButton : ToolbarButton { - private Box stateBackground; + private readonly Box stateBackground; private OverlayContainer stateContainer; diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs index 7f28764b17..1928c0fc1f 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs @@ -11,7 +11,7 @@ namespace osu.Game.Overlays.Toolbar internal class ToolbarUserArea : Container { public LoginOverlay LoginOverlay; - private ToolbarUserButton button; + private readonly ToolbarUserButton button; public override RectangleF BoundingBox => button.BoundingBox; diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs index 52c9ab5aa4..7e266a2b43 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs @@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Toolbar { internal class ToolbarUserButton : ToolbarButton, IOnlineComponent { - private Avatar avatar; + private readonly Avatar avatar; public ToolbarUserButton() { diff --git a/osu.Game/Overlays/WaveOverlayContainer.cs b/osu.Game/Overlays/WaveOverlayContainer.cs index 747b46aecc..07b76c188d 100644 --- a/osu.Game/Overlays/WaveOverlayContainer.cs +++ b/osu.Game/Overlays/WaveOverlayContainer.cs @@ -20,9 +20,12 @@ namespace osu.Game.Overlays private const EasingTypes easing_show = EasingTypes.OutSine; private const EasingTypes easing_hide = EasingTypes.InSine; - private Wave firstWave, secondWave, thirdWave, fourthWave; + private readonly Wave firstWave; + private readonly Wave secondWave; + private readonly Wave thirdWave; + private readonly Wave fourthWave; - private Container wavesContainer; + private readonly Container wavesContainer; private readonly Container contentContainer; diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 9c352aad80..81319553ba 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -72,7 +72,7 @@ namespace osu.Game.Screens.Backgrounds private class BeatmapBackground : Background { - private WorkingBeatmap beatmap; + private readonly WorkingBeatmap beatmap; public BeatmapBackground(WorkingBeatmap beatmap) { diff --git a/osu.Game/Screens/GameScreenWhiteBox.cs b/osu.Game/Screens/GameScreenWhiteBox.cs index f659d3681e..60e8edb6e1 100644 --- a/osu.Game/Screens/GameScreenWhiteBox.cs +++ b/osu.Game/Screens/GameScreenWhiteBox.cs @@ -19,14 +19,14 @@ namespace osu.Game.Screens { public class ScreenWhiteBox : OsuScreen { - private BackButton popButton; + private readonly BackButton popButton; private const double transition_time = 1000; protected virtual IEnumerable PossibleChildren => null; - private Container textContainer; - private Box box; + private readonly Container textContainer; + private readonly Box box; protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg2"); diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 52872c858b..5f62f382c0 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -26,13 +26,13 @@ namespace osu.Game.Screens.Menu /// public class Button : Container, IStateful { - private Container iconText; - private Container box; - private Box boxHoverLayer; - private TextAwesome icon; - private string internalName; - private Action clickAction; - private Key triggerKey; + private readonly Container iconText; + private readonly Container box; + private readonly Box boxHoverLayer; + private readonly TextAwesome icon; + private readonly string internalName; + private readonly Action clickAction; + private readonly Key triggerKey; private SampleChannel sampleClick; protected override bool InternalContains(Vector2 screenSpacePos) => box.Contains(screenSpacePos); diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 7903062929..ac7e419765 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -32,7 +32,7 @@ namespace osu.Game.Screens.Menu private Toolbar toolbar; - private FlowContainerWithOrigin buttonFlow; + private readonly FlowContainerWithOrigin buttonFlow; //todo: make these non-internal somehow. internal const float BUTTON_AREA_HEIGHT = 100; @@ -41,16 +41,16 @@ namespace osu.Game.Screens.Menu public const int EXIT_DELAY = 3000; - private OsuLogo osuLogo; - private Drawable iconFacade; - private Container buttonArea; - private Box buttonAreaBackground; + private readonly OsuLogo osuLogo; + private readonly Drawable iconFacade; + private readonly Container buttonArea; + private readonly Box buttonAreaBackground; - private Button backButton; - private Button settingsButton; + private readonly Button backButton; + private readonly Button settingsButton; - private List