diff --git a/osu.Desktop.Deploy/Program.cs b/osu.Desktop.Deploy/Program.cs index e13b63f602..3c1d532c0f 100644 --- a/osu.Desktop.Deploy/Program.cs +++ b/osu.Desktop.Deploy/Program.cs @@ -310,12 +310,12 @@ namespace osu.Desktop.Deploy foreach (var tag in toUpdate) { - int startIndex = l.IndexOf(tag); + int startIndex = l.IndexOf(tag, StringComparison.InvariantCulture); if (startIndex == -1) continue; startIndex += tag.Length; - int endIndex = l.IndexOf("<", startIndex); + int endIndex = l.IndexOf("<", startIndex, StringComparison.InvariantCulture); line = $"{l.Substring(0, startIndex)}{version}{l.Substring(endIndex)}"; } diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index b8eeeb1a5b..ff4b37a8fb 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -5,13 +5,16 @@ using System; using System.IO; using System.Linq; using System.Threading.Tasks; -using Microsoft.Win32; using osu.Desktop.Overlays; using osu.Framework.Graphics.Containers; using osu.Framework.Platform; using osu.Game; using OpenTK.Input; +#if NET461 +using Microsoft.Win32; +#endif + namespace osu.Desktop { internal class OsuGameDesktop : OsuGame @@ -45,9 +48,9 @@ namespace osu.Desktop { Func checkExists = p => Directory.Exists(Path.Combine(p, "Songs")); +#if NET461 string stableInstallPath; -#if NET461 try { using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("osu")) @@ -61,7 +64,11 @@ namespace osu.Desktop } #endif +#if NET461 stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"osu!"); +#else + var stableInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"osu!"); +#endif if (checkExists(stableInstallPath)) return stableInstallPath; diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 8bb9d596d1..fef7e6d52a 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -1,9 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.Diagnostics; -using System.Net.Http; using osu.Framework.Allocation; using osu.Framework.Development; using osu.Framework.Graphics; @@ -12,7 +10,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Framework.Logging; using osu.Game; using osu.Game.Configuration; using osu.Game.Graphics; @@ -23,6 +20,9 @@ using OpenTK; using OpenTK.Graphics; #if NET461 +using System; +using System.Net.Http; +using osu.Framework.Logging; using Squirrel; #endif @@ -101,8 +101,10 @@ namespace osu.Desktop.Overlays } }; +#if NET461 if (game.IsDeployedBuild) checkForUpdateAsync(); +#endif } protected override void LoadComplete() @@ -150,9 +152,9 @@ namespace osu.Desktop.Overlays #endif } +#if NET461 private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { -#if NET461 //should we schedule a retry on completion of this check? bool scheduleRetry = true; @@ -223,8 +225,8 @@ namespace osu.Desktop.Overlays notification.State = ProgressNotificationState.Cancelled; } } -#endif } +#endif protected override void PopIn() { diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index a5be6a7952..793a9b73ad 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -128,6 +128,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor { Trace.Assert(lastPosition.HasValue); + // ReSharper disable once PossibleInvalidOperationException Vector2 pos1 = lastPosition.Value; Vector2 diff = pos2 - pos1; float distance = diff.Length; diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 4bce2a96da..13cefc6a73 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -307,6 +307,7 @@ namespace osu.Game.Beatmaps context.ChangeTracker.AutoDetectChangesEnabled = false; // re-fetch the beatmap set on the import context. + // ReSharper disable once AccessToModifiedClosure beatmapSet = context.BeatmapSetInfo.Include(s => s.Files).ThenInclude(f => f.FileInfo).First(s => s.ID == beatmapSet.ID); // create local stores so we can isolate and thread safely, and share a context/transaction. diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index da117a94c1..451422038f 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -33,6 +33,7 @@ namespace osu.Game.Graphics.Cursor // don't start rotating until we're moved a minimum distance away from the mouse down location, // else it can have an annoying effect. + // ReSharper disable once PossibleInvalidOperationException startRotation |= Vector2Extensions.Distance(state.Mouse.Position, state.Mouse.PositionMouseDown.Value) > 30; if (startRotation) diff --git a/osu.Game/IO/Legacy/SerializationReader.cs b/osu.Game/IO/Legacy/SerializationReader.cs index e79eef4e2b..393a13448e 100644 --- a/osu.Game/IO/Legacy/SerializationReader.cs +++ b/osu.Game/IO/Legacy/SerializationReader.cs @@ -186,6 +186,7 @@ namespace osu.Game.IO.Legacy Debug.Assert(formatter != null, "formatter != null"); + // ReSharper disable once PossibleNullReferenceException return formatter.Deserialize(stream); } diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index ca38f72904..198c71f0c1 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.cs @@ -96,6 +96,7 @@ namespace osu.Game.Online.API // if not, let's try using our refresh token to request a new access token. if (!string.IsNullOrEmpty(Token?.RefreshToken)) + // ReSharper disable once PossibleNullReferenceException AuthenticateWithRefresh(Token.RefreshToken); return accessTokenValid; diff --git a/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs b/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs index a66799f404..923ae0e269 100644 --- a/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs @@ -19,6 +19,7 @@ namespace osu.Game.Online.API.Requests this.type = type; } + // ReSharper disable once ImpureMethodCallOnReadonlyValueField protected override string Target => $@"users/{userId}/beatmapsets/{type.ToString().Underscore()}?offset={offset}"; } diff --git a/osu.Game/Online/API/Requests/GetUserScoresRequest.cs b/osu.Game/Online/API/Requests/GetUserScoresRequest.cs index 98db234196..e30a449978 100644 --- a/osu.Game/Online/API/Requests/GetUserScoresRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserScoresRequest.cs @@ -18,6 +18,7 @@ namespace osu.Game.Online.API.Requests this.offset = offset; } + // ReSharper disable once ImpureMethodCallOnReadonlyValueField protected override string Target => $@"users/{userId}/scores/{type.ToString().ToLower()}?offset={offset}"; } @@ -27,4 +28,4 @@ namespace osu.Game.Online.API.Requests Firsts, Recent } -} \ No newline at end of file +} diff --git a/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs index 56858b3d56..b949bf35f0 100644 --- a/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs +++ b/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs @@ -27,6 +27,7 @@ namespace osu.Game.Online.API.Requests this.direction = direction; } + // ReSharper disable once ImpureMethodCallOnReadonlyValueField protected override string Target => $@"beatmapsets/search?q={query}&m={ruleset.ID ?? 0}&s={(int)rankStatus}&sort={sortCriteria.ToString().ToLower()}_{directionString}"; } } diff --git a/osu.Game/Online/Chat/Message.cs b/osu.Game/Online/Chat/Message.cs index 79b5c4fc1a..972e4755c9 100644 --- a/osu.Game/Online/Chat/Message.cs +++ b/osu.Game/Online/Chat/Message.cs @@ -57,6 +57,7 @@ namespace osu.Game.Online.Chat public virtual bool Equals(Message other) => Id == other?.Id; + // ReSharper disable once ImpureMethodCallOnReadonlyValueField public override int GetHashCode() => Id.GetHashCode(); } diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 24fc322199..ef514c95fd 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -207,6 +207,7 @@ namespace osu.Game.Overlays { Trace.Assert(state.Mouse.PositionMouseDown != null); + // ReSharper disable once PossibleInvalidOperationException double targetChatHeight = startDragChatHeight - (state.Mouse.Position.Y - state.Mouse.PositionMouseDown.Value.Y) / Parent.DrawSize.Y; // If the channel selection screen is shown, mind its minimum height @@ -380,6 +381,7 @@ namespace osu.Game.Overlays { if (channel == null) return; + // ReSharper disable once AccessToModifiedClosure var existing = careChannels.Find(c => c.Id == channel.Id); if (existing != null) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index a99ce89a36..cf8946e399 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -71,6 +71,7 @@ namespace osu.Game.Overlays { Trace.Assert(state.Mouse.PositionMouseDown != null, "state.Mouse.PositionMouseDown != null"); + // ReSharper disable once PossibleInvalidOperationException Vector2 change = state.Mouse.Position - state.Mouse.PositionMouseDown.Value; // Diminish the drag distance as we go further to simulate "rubber band" feeling. diff --git a/osu.Game/Rulesets/Timing/MultiplierControlPoint.cs b/osu.Game/Rulesets/Timing/MultiplierControlPoint.cs index 4f1a85cf2d..ba0e66e04c 100644 --- a/osu.Game/Rulesets/Timing/MultiplierControlPoint.cs +++ b/osu.Game/Rulesets/Timing/MultiplierControlPoint.cs @@ -60,6 +60,7 @@ namespace osu.Game.Rulesets.Timing DifficultyPoint = other.DifficultyPoint; } + // ReSharper disable once ImpureMethodCallOnReadonlyValueField public int CompareTo(MultiplierControlPoint other) => StartTime.CompareTo(other?.StartTime); } } diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 278814ea7e..b627db8aff 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -157,6 +157,7 @@ namespace osu.Game.Rulesets.UI WorkingBeatmap = workingBeatmap; IsForCurrentRuleset = isForCurrentRuleset; + // ReSharper disable once PossibleNullReferenceException Mods = workingBeatmap.Mods.Value; RelativeSizeAxes = Axes.Both; diff --git a/osu.Game/Rulesets/UI/ScrollingPlayfield.cs b/osu.Game/Rulesets/UI/ScrollingPlayfield.cs index 395248b2fd..cff3a029e6 100644 --- a/osu.Game/Rulesets/UI/ScrollingPlayfield.cs +++ b/osu.Game/Rulesets/UI/ScrollingPlayfield.cs @@ -255,6 +255,7 @@ namespace osu.Game.Rulesets.UI var sX = (SpeedAdjustmentContainer)x; var sY = (SpeedAdjustmentContainer)y; + // ReSharper disable once ImpureMethodCallOnReadonlyValueField int result = sY.ControlPoint.StartTime.CompareTo(sX.ControlPoint.StartTime); if (result != 0) return result; diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs index 9044938a75..6ddafe085e 100644 --- a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs @@ -123,6 +123,7 @@ namespace osu.Game.Screens.Select.Leaderboards Origin = Anchor.CentreLeft, Font = @"Exo2.0-MediumItalic", TextSize = 22, + // ReSharper disable once ImpureMethodCallOnReadonlyValueField Text = RankPosition.ToString(), }, }, diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index e540782fc1..269b206a78 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -326,6 +326,7 @@ namespace osu.Game.Screens.Tournament if (line.ToUpper().StartsWith("GROUP")) continue; + // ReSharper disable once AccessToModifiedClosure DrawingsTeam teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line); if (teamToAdd == null) diff --git a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs index 2eb0dacec3..5bae30458e 100644 --- a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs +++ b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs @@ -13,9 +13,9 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Threading; +using osu.Game.Screens.Tournament.Teams; using OpenTK; using OpenTK.Graphics; -using osu.Game.Screens.Tournament.Teams; namespace osu.Game.Screens.Tournament { @@ -118,16 +118,18 @@ namespace osu.Game.Screens.Tournament if (!Children.Any()) break; - Drawable closest = null; + ScrollingTeam closest = null; foreach (var c in Children) { - if (!(c is ScrollingTeam)) + var stc = c as ScrollingTeam; + + if (stc == null) continue; if (closest == null) { - closest = c; + closest = stc; continue; } @@ -135,14 +137,15 @@ namespace osu.Game.Screens.Tournament float lastOffset = Math.Abs(closest.Position.X + closest.DrawWidth / 2f - DrawWidth / 2f); if (o < lastOffset) - closest = c; + closest = stc; } Trace.Assert(closest != null, "closest != null"); + // ReSharper disable once PossibleNullReferenceException offset += DrawWidth / 2f - (closest.Position.X + closest.DrawWidth / 2f); - ScrollingTeam st = closest as ScrollingTeam; + ScrollingTeam st = closest; availableTeams.RemoveAll(at => at == st.Team); diff --git a/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs b/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs index 1b2d84a666..ce3b5ed941 100644 --- a/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs +++ b/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs @@ -38,6 +38,7 @@ namespace osu.Game.Screens.Tournament.Teams if (string.IsNullOrEmpty(line)) continue; + // ReSharper disable once PossibleNullReferenceException string[] split = line.Split(':'); if (split.Length < 2)