Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update c# language version to 9 #18830

Merged
merged 10 commits into from
Jun 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- Contains required properties for osu!framework projects. -->
<Project>
<PropertyGroup Label="C#">
<LangVersion>8.0</LangVersion>
<LangVersion>9.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion osu.Android.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.623.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.621.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.624.1" />
</ItemGroup>
<ItemGroup Label="Transitive Dependencies">
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->
Expand Down
2 changes: 1 addition & 1 deletion osu.Desktop/DiscordRichPresence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void load(OsuConfigManager config)
client.OnReady += onReady;

// safety measure for now, until we performance test / improve backoff for failed connections.
client.OnConnectionFailed += (_, __) => client.Deinitialize();
client.OnConnectionFailed += (_, _) => client.Deinitialize();

client.OnError += (_, e) => Logger.Log($"An error occurred with Discord RPC Client: {e.Code} {e.Message}", LoggingTarget.Network);

Expand Down
8 changes: 4 additions & 4 deletions osu.Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,18 @@ private static bool trySendIPCMessage(IIpcHost host, string cwd, string[] args)
[SupportedOSPlatform("windows")]
private static void setupSquirrel()
{
SquirrelAwareApp.HandleEvents(onInitialInstall: (version, tools) =>
SquirrelAwareApp.HandleEvents(onInitialInstall: (_, tools) =>
{
tools.CreateShortcutForThisExe();
tools.CreateUninstallerRegistryEntry();
}, onAppUpdate: (version, tools) =>
}, onAppUpdate: (_, tools) =>
{
tools.CreateUninstallerRegistryEntry();
}, onAppUninstall: (version, tools) =>
}, onAppUninstall: (_, tools) =>
{
tools.RemoveShortcutForThisExe();
tools.RemoveUninstallerRegistryEntry();
}, onEveryRun: (version, tools, firstRun) =>
}, onEveryRun: (_, _, _) =>
{
// While setting the `ProcessAppUserModelId` fixes duplicate icons/shortcuts on the taskbar, it currently
// causes the right-click context menu to function incorrectly.
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Benchmarks/BenchmarkRealmReads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override void SetUp()

realm = new RealmAccess(storage, OsuGameBase.CLIENT_DATABASE_FILENAME);

realm.Run(r =>
realm.Run(_ =>
{
realm.Write(c => c.Add(TestResources.CreateTestBeatmapSetInfo(rulesets: new[] { new OsuRuleset().RulesetInfo })));
});
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Catch.Tests/JuiceStreamPathTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void TestRemoveVertices()
new JuiceStreamPathVertex(20, -5)
}));

removeCount = path.RemoveVertices((_, i) => true);
removeCount = path.RemoveVertices((_, _) => true);
Assert.That(removeCount, Is.EqualTo(1));
Assert.That(path.Vertices, Is.EqualTo(new[]
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Catch.Tests/TestSceneHyperDash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void TestHyperDash()
hyperDashCount = 0;

// this needs to be done within the frame stable context due to how quickly hyperdash state changes occur.
Player.DrawableRuleset.FrameStableComponents.OnUpdate += d =>
Player.DrawableRuleset.FrameStableComponents.OnUpdate += _ =>
{
var catcher = Player.ChildrenOfType<Catcher>().FirstOrDefault();

Expand Down
6 changes: 3 additions & 3 deletions osu.Game.Rulesets.Catch/Edit/CatchHitObjectComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ private PalpableCatchHitObject getDistanceSnapGridSourceHitObject()
{
switch (BlueprintContainer.CurrentTool)
{
case SelectTool _:
case SelectTool:
if (EditorBeatmap.SelectedHitObjects.Count == 0)
return null;

double minTime = EditorBeatmap.SelectedHitObjects.Min(hitObject => hitObject.StartTime);
return getLastSnappableHitObject(minTime);

case FruitCompositionTool _:
case JuiceStreamCompositionTool _:
case FruitCompositionTool:
case JuiceStreamCompositionTool:
if (!CursorInPlacementArea)
return null;

Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Catch/Edit/CatchHitObjectUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public static PositionRange GetPositionRange(HitObject hitObject)
case Droplet droplet:
return droplet is TinyDroplet ? PositionRange.EMPTY : new PositionRange(droplet.OriginalX);

case JuiceStream _:
case JuiceStream:
return GetPositionRange(hitObject.NestedHitObjects);

case BananaShower _:
case BananaShower:
// A banana shower occupies the whole screen width.
return new PositionRange(0, CatchPlayfield.WIDTH);

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private bool handleFlip(PositionRange selectionRange, CatchHitObject hitObject,
{
switch (hitObject)
{
case BananaShower _:
case BananaShower:
return false;

case JuiceStream juiceStream:
Expand Down
6 changes: 3 additions & 3 deletions osu.Game.Rulesets.Catch/UI/Catcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,13 @@ private CaughtObject getCaughtObject(PalpableCatchHitObject source)
{
switch (source)
{
case Fruit _:
case Fruit:
return caughtFruitPool.Get();

case Banana _:
case Banana:
return caughtBananaPool.Get();

case Droplet _:
case Droplet:
return caughtDropletPool.Get();

default:
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private IEnumerable<ManiaHitObject> generateConverted(HitObject original, IBeatm

switch (original)
{
case IHasDistance _:
case IHasDistance:
{
var generator = new DistanceObjectPatternGenerator(Random, original, beatmap, lastPattern, originalBeatmap);
conversion = generator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ private double getScoreMultiplier(Mod[] mods)
{
switch (m)
{
case ManiaModNoFail _:
case ManiaModEasy _:
case ManiaModHalfTime _:
case ManiaModNoFail:
case ManiaModEasy:
case ManiaModHalfTime:
scoreMultiplier *= 0.5;
break;
}
Expand Down
26 changes: 13 additions & 13 deletions osu.Game.Rulesets.Mania/ManiaRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,56 +146,56 @@ public override LegacyMods ConvertToLegacyMods(Mod[] mods)
{
switch (mod)
{
case ManiaModKey1 _:
case ManiaModKey1:
value |= LegacyMods.Key1;
break;

case ManiaModKey2 _:
case ManiaModKey2:
value |= LegacyMods.Key2;
break;

case ManiaModKey3 _:
case ManiaModKey3:
value |= LegacyMods.Key3;
break;

case ManiaModKey4 _:
case ManiaModKey4:
value |= LegacyMods.Key4;
break;

case ManiaModKey5 _:
case ManiaModKey5:
value |= LegacyMods.Key5;
break;

case ManiaModKey6 _:
case ManiaModKey6:
value |= LegacyMods.Key6;
break;

case ManiaModKey7 _:
case ManiaModKey7:
value |= LegacyMods.Key7;
break;

case ManiaModKey8 _:
case ManiaModKey8:
value |= LegacyMods.Key8;
break;

case ManiaModKey9 _:
case ManiaModKey9:
value |= LegacyMods.Key9;
break;

case ManiaModDualStages _:
case ManiaModDualStages:
value |= LegacyMods.KeyCoop;
break;

case ManiaModFadeIn _:
case ManiaModFadeIn:
value |= LegacyMods.FadeIn;
value &= ~LegacyMods.Hidden; // this is toggled on in the base call due to inheritance, but we don't want that.
break;

case ManiaModMirror _:
case ManiaModMirror:
value |= LegacyMods.Mirror;
break;

case ManiaModRandom _:
case ManiaModRandom:
value |= LegacyMods.Random;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Mania/Mods/ManiaModRandom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void ApplyToBeatmap(IBeatmap beatmap)
var rng = new Random((int)Seed.Value);

int availableColumns = ((ManiaBeatmap)beatmap).TotalColumns;
var shuffledColumns = Enumerable.Range(0, availableColumns).OrderBy(item => rng.Next()).ToList();
var shuffledColumns = Enumerable.Range(0, availableColumns).OrderBy(_ => rng.Next()).ToList();

beatmap.HitObjects.OfType<ManiaHitObject>().ForEach(h => h.Column = shuffledColumns[h.Column]);
}
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Mania/Replays/ManiaAutoGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ protected override void GenerateFrames()
{
switch (point)
{
case HitPoint _:
case HitPoint:
actions.Add(columnActions[point.Column]);
break;

case ReleasePoint _:
case ReleasePoint:
actions.Remove(columnActions[point.Column]);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu.Tests/LegacyMainCirclePieceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void TestTexturePriorities(string[] textureFilenames, string priorityLook
skin.Setup(s => s.GetTexture(It.IsAny<string>())).CallBase();

skin.Setup(s => s.GetTexture(It.IsIn(textureFilenames), It.IsAny<WrapMode>(), It.IsAny<WrapMode>()))
.Returns((string componentName, WrapMode _, WrapMode __) => new Texture(1, 1) { AssetName = componentName });
.Returns((string componentName, WrapMode _, WrapMode _) => new Texture(1, 1) { AssetName = componentName });

Child = new DependencyProvidingContainer
{
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModSpunOut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void TestSpinnerAutoCompleted()
lastResult = null;

spinner = nextSpinner;
spinner.OnNewResult += (o, result) => lastResult = result;
spinner.OnNewResult += (_, result) => lastResult = result;
}

return lastResult?.Type == HitResult.Great;
Expand Down Expand Up @@ -116,7 +116,7 @@ public void TestSpinnerGetsNoBonusScore()
return false;

spinner = nextSpinner;
spinner.OnNewResult += (o, result) => results.Add(result);
spinner.OnNewResult += (_, result) => results.Add(result);

results.Clear();
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu.Tests/TestSceneSliderSnaking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private void addEnsureNoSnakingOutStep(Func<double> startTime, int repeatIndex)
=> addCheckPositionChangeSteps(timeAtRepeat(startTime, repeatIndex), positionAtRepeat(repeatIndex), positionRemainsSame);

private Func<double> timeAtRepeat(Func<double> startTime, int repeatIndex) => () => startTime() + 100 + duration_of_span * repeatIndex;
private Func<Vector2> positionAtRepeat(int repeatIndex) => repeatIndex % 2 == 0 ? (Func<Vector2>)getSliderStart : getSliderEnd;
private Func<Vector2> positionAtRepeat(int repeatIndex) => repeatIndex % 2 == 0 ? getSliderStart : getSliderEnd;

private List<Vector2> getSliderCurve() => ((PlaySliderBody)drawableSlider.Body.Drawable).CurrentCurve;
private Vector2 getSliderStart() => getSliderCurve().First();
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void load()
});

selectedHitObjects = EditorBeatmap.SelectedHitObjects.GetBoundCopy();
selectedHitObjects.CollectionChanged += (_, __) => updateDistanceSnapGrid();
selectedHitObjects.CollectionChanged += (_, _) => updateDistanceSnapGrid();

placementObject = EditorBeatmap.PlacementObject.GetBoundCopy();
placementObject.ValueChanged += _ => updateDistanceSnapGrid();
Expand Down Expand Up @@ -204,7 +204,7 @@ private void updateDistanceSnapGrid()

switch (BlueprintContainer.CurrentTool)
{
case SelectTool _:
case SelectTool:
if (!EditorBeatmap.SelectedHitObjects.Any())
return;

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu/Mods/OsuModApproachDifferent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class OsuModApproachDifferent : Mod, IApplicableToDrawableHitObject, IReq

public void ApplyToDrawableHitObject(DrawableHitObject drawable)
{
drawable.ApplyCustomUpdateState += (drawableObject, state) =>
drawable.ApplyCustomUpdateState += (drawableObject, _) =>
{
if (!(drawableObject is DrawableHitCircle drawableHitCircle)) return;

Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void applyHiddenState(DrawableHitObject drawableObject, bool increaseVis

switch (drawableObject)
{
case DrawableSliderTail _:
case DrawableSliderTail:
using (drawableObject.BeginAbsoluteSequence(fadeStartTime))
drawableObject.FadeOut(fadeDuration);

Expand Down Expand Up @@ -165,14 +165,14 @@ private void applyHiddenState(DrawableHitObject drawableObject, bool increaseVis

switch (hitObject)
{
case Slider _:
case Slider:
return (fadeOutStartTime, longFadeDuration);

case SliderTick _:
case SliderTick:
double tickFadeOutDuration = Math.Min(hitObject.TimePreempt - DrawableSliderTick.ANIM_DURATION, 1000);
return (hitObject.StartTime - tickFadeOutDuration, tickFadeOutDuration);

case Spinner _:
case Spinner:
return (fadeOutStartTime + longFadeDuration, fadeOutDuration);

default:
Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Rulesets.Osu/Mods/OsuModObjectScaleTween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ private void applyCustomState(DrawableHitObject drawable, ArmedState state)
// apply grow effect
switch (drawable)
{
case DrawableSliderHead _:
case DrawableSliderTail _:
case DrawableSliderHead:
case DrawableSliderTail:
// special cases we should *not* be scaling.
break;

case DrawableSlider _:
case DrawableHitCircle _:
case DrawableSlider:
case DrawableHitCircle:
{
using (drawable.BeginAbsoluteSequence(h.StartTime - h.TimePreempt))
drawable.ScaleTo(StartScale.Value).Then().ScaleTo(EndScale, h.TimePreempt, Easing.OutSine);
Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ private void applyTransform(DrawableHitObject drawable, ArmedState state)
{
switch (drawable)
{
case DrawableSliderHead _:
case DrawableSliderTail _:
case DrawableSliderTick _:
case DrawableSliderRepeat _:
case DrawableSliderHead:
case DrawableSliderTail:
case DrawableSliderTick:
case DrawableSliderRepeat:
return;

default:
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu/Objects/Slider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public int RepeatCount

public Slider()
{
SamplesBindable.CollectionChanged += (_, __) => UpdateNestedSamples();
SamplesBindable.CollectionChanged += (_, _) => UpdateNestedSamples();
Path.Version.ValueChanged += _ => updateNestedPositions();
}

Expand Down
Loading