1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:07:25 +08:00

Move some suggestions to warnings, resolve issues

This commit is contained in:
smoogipoo 2020-06-03 16:48:44 +09:00
parent 5f1d44a2be
commit f3b5149648
22 changed files with 34 additions and 58 deletions

View File

@ -48,7 +48,7 @@ namespace osu.Desktop.Updater
try try
{ {
if (updateManager == null) updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true); updateManager ??= await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true);
var info = await updateManager.CheckForUpdate(!useDeltaPatching); var info = await updateManager.CheckForUpdate(!useDeltaPatching);
if (info.ReleasesToApply.Count == 0) if (info.ReleasesToApply.Count == 0)

View File

@ -35,8 +35,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty.Skills
{ {
var catchCurrent = (CatchDifficultyHitObject)current; var catchCurrent = (CatchDifficultyHitObject)current;
if (lastPlayerPosition == null) lastPlayerPosition ??= catchCurrent.LastNormalizedPosition;
lastPlayerPosition = catchCurrent.LastNormalizedPosition;
float playerPosition = Math.Clamp( float playerPosition = Math.Clamp(
lastPlayerPosition.Value, lastPlayerPosition.Value,

View File

@ -135,8 +135,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
fp.Alpha = 0; fp.Alpha = 0;
fp.Scale = new Vector2(1.5f * osuEnd.Scale); fp.Scale = new Vector2(1.5f * osuEnd.Scale);
if (firstTransformStartTime == null) firstTransformStartTime ??= fadeInTime;
firstTransformStartTime = fadeInTime;
fp.AnimationStartTime = fadeInTime; fp.AnimationStartTime = fadeInTime;

View File

@ -175,7 +175,7 @@ namespace osu.Game.Tests.Beatmaps.IO
var breakTemp = TestResources.GetTestBeatmapForImport(); var breakTemp = TestResources.GetTestBeatmapForImport();
MemoryStream brokenOsu = new MemoryStream(); MemoryStream brokenOsu = new MemoryStream();
MemoryStream brokenOsz = new MemoryStream(File.ReadAllBytes(breakTemp)); MemoryStream brokenOsz = new MemoryStream(await File.ReadAllBytesAsync(breakTemp));
File.Delete(breakTemp); File.Delete(breakTemp);
@ -522,7 +522,7 @@ namespace osu.Game.Tests.Beatmaps.IO
using (var resourceForkFile = File.CreateText(resourceForkFilePath)) using (var resourceForkFile = File.CreateText(resourceForkFilePath))
{ {
resourceForkFile.WriteLine("adding content so that it's not empty"); await resourceForkFile.WriteLineAsync("adding content so that it's not empty");
} }
try try

View File

@ -183,11 +183,8 @@ namespace osu.Game.Tests.Scores.IO
{ {
var beatmapManager = osu.Dependencies.Get<BeatmapManager>(); var beatmapManager = osu.Dependencies.Get<BeatmapManager>();
if (score.Beatmap == null) score.Beatmap ??= beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
score.Beatmap = beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First(); score.Ruleset ??= new OsuRuleset().RulesetInfo;
if (score.Ruleset == null)
score.Ruleset = new OsuRuleset().RulesetInfo;
var scoreManager = osu.Dependencies.Get<ScoreManager>(); var scoreManager = osu.Dependencies.Get<ScoreManager>();
await scoreManager.Import(score, archive); await scoreManager.Import(score, archive);

View File

@ -24,8 +24,7 @@ namespace osu.Game.Tournament.Tests
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
if (Ladder.Ruleset.Value == null) Ladder.Ruleset.Value ??= rulesetStore.AvailableRulesets.First();
Ladder.Ruleset.Value = rulesetStore.AvailableRulesets.First();
Ruleset.BindTo(Ladder.Ruleset); Ruleset.BindTo(Ladder.Ruleset);
} }

View File

@ -47,8 +47,7 @@ namespace osu.Game.Tournament.Screens.Drawings
this.storage = storage; this.storage = storage;
if (TeamList == null) TeamList ??= new StorageBackedTeamList(storage);
TeamList = new StorageBackedTeamList(storage);
if (!TeamList.Teams.Any()) if (!TeamList.Teams.Any())
{ {

View File

@ -150,11 +150,8 @@ namespace osu.Game.Tournament
ladder = JsonConvert.DeserializeObject<LadderInfo>(sr.ReadToEnd()); ladder = JsonConvert.DeserializeObject<LadderInfo>(sr.ReadToEnd());
} }
if (ladder == null) ladder ??= new LadderInfo();
ladder = new LadderInfo(); ladder.Ruleset.Value ??= RulesetStore.AvailableRulesets.First();
if (ladder.Ruleset.Value == null)
ladder.Ruleset.Value = RulesetStore.AvailableRulesets.First();
Ruleset.BindTo(ladder.Ruleset); Ruleset.BindTo(ladder.Ruleset);

View File

@ -239,8 +239,7 @@ namespace osu.Game.Beatmaps
if (working == null) if (working == null)
{ {
if (beatmapInfo.Metadata == null) beatmapInfo.Metadata ??= beatmapInfo.BeatmapSet.Metadata;
beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata;
workingCache.Add(working = new BeatmapManagerWorkingBeatmap(Files.Store, workingCache.Add(working = new BeatmapManagerWorkingBeatmap(Files.Store,
new LargeTextureStore(host?.CreateTextureLoaderStore(Files.Store)), beatmapInfo, audioManager)); new LargeTextureStore(host?.CreateTextureLoaderStore(Files.Store)), beatmapInfo, audioManager));

View File

@ -425,8 +425,7 @@ namespace osu.Game.Beatmaps.Formats
private void handleHitObject(string line) private void handleHitObject(string line)
{ {
// If the ruleset wasn't specified, assume the osu!standard ruleset. // If the ruleset wasn't specified, assume the osu!standard ruleset.
if (parser == null) parser ??= new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser(getOffsetTime(), FormatVersion);
parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser(getOffsetTime(), FormatVersion);
var obj = parser.Parse(line); var obj = parser.Parse(line);
if (obj != null) if (obj != null)

View File

@ -114,8 +114,7 @@ namespace osu.Game.Online.Chat
/// <param name="target">An optional target channel. If null, <see cref="CurrentChannel"/> will be used.</param> /// <param name="target">An optional target channel. If null, <see cref="CurrentChannel"/> will be used.</param>
public void PostMessage(string text, bool isAction = false, Channel target = null) public void PostMessage(string text, bool isAction = false, Channel target = null)
{ {
if (target == null) target ??= CurrentChannel.Value;
target = CurrentChannel.Value;
if (target == null) if (target == null)
return; return;
@ -198,8 +197,7 @@ namespace osu.Game.Online.Chat
/// <param name="target">An optional target channel. If null, <see cref="CurrentChannel"/> will be used.</param> /// <param name="target">An optional target channel. If null, <see cref="CurrentChannel"/> will be used.</param>
public void PostCommand(string text, Channel target = null) public void PostCommand(string text, Channel target = null)
{ {
if (target == null) target ??= CurrentChannel.Value;
target = CurrentChannel.Value;
if (target == null) if (target == null)
return; return;
@ -378,8 +376,7 @@ namespace osu.Game.Online.Chat
} }
} }
if (CurrentChannel.Value == null) CurrentChannel.Value ??= channel;
CurrentChannel.Value = channel;
return channel; return channel;
} }

View File

@ -73,8 +73,7 @@ namespace osu.Game.Online.Chat
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(ChannelManager manager) private void load(ChannelManager manager)
{ {
if (ChannelManager == null) ChannelManager ??= manager;
ChannelManager = manager;
} }
protected virtual StandAloneDrawableChannel CreateDrawableChannel(Channel channel) => protected virtual StandAloneDrawableChannel CreateDrawableChannel(Channel channel) =>

View File

@ -164,7 +164,7 @@ namespace osu.Game
dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore<byte[]>(Resources, "Skins/Legacy"))); dependencies.Cache(SkinManager = new SkinManager(Storage, contextFactory, Host, Audio, new NamespacedResourceStore<byte[]>(Resources, "Skins/Legacy")));
dependencies.CacheAs<ISkinSource>(SkinManager); dependencies.CacheAs<ISkinSource>(SkinManager);
if (API == null) API = new APIAccess(LocalConfig); API ??= new APIAccess(LocalConfig);
dependencies.CacheAs(API); dependencies.CacheAs(API);
@ -311,11 +311,10 @@ namespace osu.Game
{ {
base.SetHost(host); base.SetHost(host);
if (Storage == null) // may be non-null for certain tests // may be non-null for certain tests
Storage = new OsuStorage(host); Storage ??= new OsuStorage(host);
if (LocalConfig == null) LocalConfig ??= new OsuConfigManager(Storage);
LocalConfig = new OsuConfigManager(Storage);
} }
private readonly List<ICanAcceptFiles> fileImporters = new List<ICanAcceptFiles>(); private readonly List<ICanAcceptFiles> fileImporters = new List<ICanAcceptFiles>();

View File

@ -68,8 +68,7 @@ namespace osu.Game.Overlays.Chat.Tabs
if (!Items.Contains(channel)) if (!Items.Contains(channel))
AddItem(channel); AddItem(channel);
if (Current.Value == null) Current.Value ??= channel;
Current.Value = channel;
} }
/// <summary> /// <summary>

View File

@ -133,8 +133,7 @@ namespace osu.Game.Rulesets.Objects
{ {
Kiai = controlPointInfo.EffectPointAt(StartTime + control_point_leniency).KiaiMode; Kiai = controlPointInfo.EffectPointAt(StartTime + control_point_leniency).KiaiMode;
if (HitWindows == null) HitWindows ??= CreateHitWindows();
HitWindows = CreateHitWindows();
HitWindows?.SetDifficulty(difficulty.OverallDifficulty); HitWindows?.SetDifficulty(difficulty.OverallDifficulty);
} }

View File

@ -181,8 +181,7 @@ namespace osu.Game.Rulesets.UI
private void setClock() private void setClock()
{ {
// in case a parent gameplay clock isn't available, just use the parent clock. // in case a parent gameplay clock isn't available, just use the parent clock.
if (parentGameplayClock == null) parentGameplayClock ??= Clock;
parentGameplayClock = Clock;
Clock = GameplayClock; Clock = GameplayClock;
ProcessCustomClock = false; ProcessCustomClock = false;

View File

@ -115,9 +115,7 @@ namespace osu.Game.Scoring
get => User?.Username; get => User?.Username;
set set
{ {
if (User == null) User ??= new User();
User = new User();
User.Username = value; User.Username = value;
} }
} }
@ -129,9 +127,7 @@ namespace osu.Game.Scoring
get => User?.Id ?? 1; get => User?.Id ?? 1;
set set
{ {
if (User == null) User ??= new User();
User = new User();
User.Id = value ?? 1; User.Id = value ?? 1;
} }
} }

View File

@ -57,7 +57,7 @@ namespace osu.Game.Screens.Edit.Timing
{ {
checkbox = new OsuCheckbox checkbox = new OsuCheckbox
{ {
LabelText = typeof(T).Name.Replace(typeof(ControlPoint).Name, string.Empty) LabelText = typeof(T).Name.Replace(nameof(Beatmaps.ControlPoints.ControlPoint), string.Empty)
} }
} }
}, },

View File

@ -34,8 +34,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
if (filter == null) filter ??= new Bindable<FilterCriteria>();
filter = new Bindable<FilterCriteria>();
} }
protected override void LoadComplete() protected override void LoadComplete()

View File

@ -607,10 +607,7 @@ namespace osu.Game.Screens.Select
// todo: remove the need for this. // todo: remove the need for this.
foreach (var b in beatmapSet.Beatmaps) foreach (var b in beatmapSet.Beatmaps)
{ b.Metadata ??= beatmapSet.Metadata;
if (b.Metadata == null)
b.Metadata = beatmapSet.Metadata;
}
var set = new CarouselBeatmapSet(beatmapSet) var set = new CarouselBeatmapSet(beatmapSet)
{ {

View File

@ -43,7 +43,7 @@ namespace osu.Game.Users.Drawables
Texture texture = null; Texture texture = null;
if (user != null && user.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}"); if (user != null && user.Id > 1) texture = textures.Get($@"https://a.ppy.sh/{user.Id}");
if (texture == null) texture = textures.Get(@"Online/avatar-guest"); texture ??= textures.Get(@"Online/avatar-guest");
ClickableArea clickableArea; ClickableArea clickableArea;
Add(clickableArea = new ClickableArea Add(clickableArea = new ClickableArea

View File

@ -60,6 +60,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertClosureToMethodGroup/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertClosureToMethodGroup/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertIfDoToWhile/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertIfDoToWhile/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertIfStatementToConditionalTernaryExpression/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertIfStatementToConditionalTernaryExpression/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertIfStatementToNullCoalescingAssignment/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertIfStatementToNullCoalescingExpression/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertIfStatementToNullCoalescingExpression/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertIfToOrExpression/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertIfToOrExpression/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertNullableToShortForm/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConvertNullableToShortForm/@EntryIndexedValue">WARNING</s:String>
@ -105,6 +106,8 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MergeCastWithTypeCheck/@EntryIndexedValue">HINT</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MergeCastWithTypeCheck/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MergeConditionalExpression/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MergeConditionalExpression/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MergeSequentialChecks/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MergeSequentialChecks/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MethodHasAsyncOverload/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MethodHasAsyncOverloadWithCancellation/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MethodSupportsCancellation/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MethodSupportsCancellation/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MissingBlankLines/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MissingBlankLines/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MissingIndent/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MissingIndent/@EntryIndexedValue">WARNING</s:String>
@ -222,6 +225,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseFormatSpecifierInInterpolation/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseFormatSpecifierInInterpolation/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseIndexFromEndExpression/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseIndexFromEndExpression/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNameofExpression/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNameofExpression/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNameOfInsteadOfTypeOf/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNegatedPatternMatching/@EntryIndexedValue"></s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNegatedPatternMatching/@EntryIndexedValue"></s:String>
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNegatedPatternMatching/@EntryIndexRemoved">True</s:Boolean> <s:Boolean x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNegatedPatternMatching/@EntryIndexRemoved">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNullPropagation/@EntryIndexedValue">WARNING</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseNullPropagation/@EntryIndexedValue">WARNING</s:String>