-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #829 from andy840119/upgrade-to-csharp-9
Upgrade to csharp 9
- Loading branch information
Showing
161 changed files
with
360 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
|
@@ -31,7 +30,7 @@ public static RubyTag ParseRubyTag(string str) | |
var regex = new Regex("(?<start>[-0-9]+),(?<end>[-0-9]+)]:(?<ruby>.*$)"); | ||
var result = regex.Match(str); | ||
if (!result.Success) | ||
throw new ArgumentException(null, nameof(str)); | ||
throw new RegexMatchTimeoutException(nameof(str)); | ||
|
||
var startIndex = int.Parse(result.Groups["start"].Value); | ||
var endIndex = int.Parse(result.Groups["end"].Value); | ||
|
@@ -61,7 +60,7 @@ public static RomajiTag ParseRomajiTag(string str) | |
var regex = new Regex("(?<start>[-0-9]+),(?<end>[-0-9]+)]:(?<romaji>.*$)"); | ||
var result = regex.Match(str); | ||
if (!result.Success) | ||
throw new ArgumentException(null, nameof(str)); | ||
throw new RegexMatchTimeoutException(nameof(str)); | ||
|
||
var startIndex = int.Parse(result.Groups["start"].Value); | ||
var endIndex = int.Parse(result.Groups["end"].Value); | ||
|
@@ -91,7 +90,7 @@ public static TimeTag ParseTimeTag(string str) | |
var regex = new Regex("(?<index>[-0-9]+),(?<state>start|end)]:(?<time>[-0-9]+|s*|)"); | ||
var result = regex.Match(str); | ||
if (!result.Success) | ||
throw new ArgumentException(null, nameof(str)); | ||
throw new RegexMatchTimeoutException(nameof(str)); | ||
|
||
var index = int.Parse(result.Groups["index"].Value); | ||
var state = result.Groups["state"].Value == "start" ? TextIndex.IndexState.Start : TextIndex.IndexState.End; | ||
|
@@ -117,7 +116,7 @@ public static TextIndex ParseTextIndex(string str) | |
var regex = new Regex("(?<index>[-0-9]+),(?<state>start|end)]"); | ||
var result = regex.Match(str); | ||
if (!result.Success) | ||
throw new ArgumentException(null, nameof(str)); | ||
throw new RegexMatchTimeoutException(nameof(str)); | ||
|
||
var index = int.Parse(result.Groups["index"].Value); | ||
var state = result.Groups["state"].Value == "start" ? TextIndex.IndexState.Start : TextIndex.IndexState.End; | ||
|
@@ -141,7 +140,7 @@ public static Lyric ParseLyric(string str) | |
var regex = new Regex("(?<startTime>[-0-9]+),(?<endTime>[-0-9]+)]:(?<lyric>.*$)"); | ||
var result = regex.Match(str); | ||
if (!result.Success) | ||
throw new ArgumentException(null, nameof(str)); | ||
throw new RegexMatchTimeoutException(nameof(str)); | ||
|
||
var startTime = double.Parse(result.Groups["startTime"].Value); | ||
var endTime = double.Parse(result.Groups["endTime"].Value); | ||
|
@@ -206,7 +205,7 @@ public static Singer ParseSinger(string str) | |
var regex = new Regex("(?<id>[-0-9]+)]"); | ||
var result = regex.Match(str); | ||
if (!result.Success) | ||
throw new ArgumentException(null, nameof(str)); | ||
throw new RegexMatchTimeoutException(nameof(str)); | ||
|
||
// todo : implementation | ||
var id = int.Parse(result.Groups["id"].Value); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
|
@@ -13,9 +14,9 @@ namespace osu.Game.Rulesets.Karaoke.Beatmaps | |
{ | ||
public class KaraokeBeatmap : Beatmap<KaraokeHitObject> | ||
{ | ||
public CultureInfo[] AvailableTranslates { get; set; } = { }; | ||
public CultureInfo[] AvailableTranslates { get; set; } = Array.Empty<CultureInfo>(); | ||
|
||
public Singer[] Singers { get; set; } = { }; | ||
public Singer[] Singers { get; set; } = Array.Empty<Singer>(); | ||
|
||
public int TotalColumns { get; set; } = 9; | ||
|
||
|
@@ -26,13 +27,13 @@ public override IEnumerable<BeatmapStatistic> GetStatistics() | |
|
||
var defaultStatistic = new List<BeatmapStatistic> | ||
{ | ||
new BeatmapStatistic | ||
new() | ||
{ | ||
Name = @"Singer", | ||
Content = singers.ToString(), | ||
CreateIcon = () => new SpriteIcon { Icon = FontAwesome.Solid.User } | ||
}, | ||
new BeatmapStatistic | ||
new() | ||
{ | ||
Name = @"Lyric", | ||
Content = lyrics.ToString(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Globalization; | ||
using System.Linq; | ||
using osu.Game.Beatmaps; | ||
|
@@ -13,7 +14,7 @@ public static class KaraokeBeatmapExtension | |
{ | ||
public static bool IsScorable(this IBeatmap beatmap) => beatmap?.HitObjects.OfType<Note>().Any(x => x.Display) ?? false; | ||
|
||
public static CultureInfo[] AvailableTranslates(this IBeatmap beatmap) => (beatmap as KaraokeBeatmap)?.AvailableTranslates ?? new CultureInfo[] { }; | ||
public static CultureInfo[] AvailableTranslates(this IBeatmap beatmap) => (beatmap as KaraokeBeatmap)?.AvailableTranslates ?? Array.Empty<CultureInfo>(); | ||
|
||
public static bool AnyTranslate(this IBeatmap beatmap) => beatmap?.AvailableTranslates()?.Any() ?? false; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
|
@@ -16,7 +17,7 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Checks | |
{ | ||
public class CheckTranslate : ICheck | ||
{ | ||
public CheckMetadata Metadata => new CheckMetadata(CheckCategory.HitObjects, "Unfinished translate language."); | ||
public CheckMetadata Metadata => new(CheckCategory.HitObjects, "Unfinished translate language."); | ||
|
||
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[] | ||
{ | ||
|
@@ -26,7 +27,7 @@ public class CheckTranslate : ICheck | |
|
||
public IEnumerable<Issue> Run(BeatmapVerifierContext context) | ||
{ | ||
var languages = availableTranslateInBeatmap(context.Beatmap) ?? new CultureInfo[] { }; | ||
var languages = availableTranslateInBeatmap(context.Beatmap) ?? Array.Empty<CultureInfo>(); | ||
|
||
var lyrics = context.Beatmap.HitObjects.OfType<Lyric>().ToList(); | ||
if (lyrics.Count == 0) | ||
|
@@ -79,7 +80,7 @@ public IssueTemplateMissingTranslate(ICheck check) | |
} | ||
|
||
public Issue Create(IEnumerable<HitObject> hitObjects, CultureInfo cultureInfo) | ||
=> new Issue(hitObjects, this, cultureInfo); | ||
=> new(hitObjects, this, cultureInfo); | ||
} | ||
|
||
public class IssueTemplateMissingPartialTranslate : IssueTemplate | ||
|
@@ -90,7 +91,7 @@ public IssueTemplateMissingPartialTranslate(ICheck check) | |
} | ||
|
||
public Issue Create(IEnumerable<HitObject> hitObjects, CultureInfo cultureInfo) | ||
=> new Issue(hitObjects, this, cultureInfo); | ||
=> new(hitObjects, this, cultureInfo); | ||
} | ||
|
||
public class IssueTemplateContainsNotListedLanguage : IssueTemplate | ||
|
@@ -101,7 +102,7 @@ public IssueTemplateContainsNotListedLanguage(ICheck check) | |
} | ||
|
||
public Issue Create(IEnumerable<HitObject> hitObjects, CultureInfo cultureInfo) | ||
=> new Issue(hitObjects, this, cultureInfo); | ||
=> new(hitObjects, this, cultureInfo); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.