Skip to content

Commit

Permalink
Merge pull request #1967 from andy840119/apply-file-scope-namespace-i…
Browse files Browse the repository at this point in the history
…n-main-project

Updating main project to use File Scoped Namespaces.
  • Loading branch information
andy840119 authored Apr 30, 2023
2 parents 086eddb + eb34324 commit dcf99d5
Show file tree
Hide file tree
Showing 755 changed files with 31,944 additions and 32,681 deletions.
4 changes: 3 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Partial everything
c3d76bde9f3d78b420ab6a18b8191c00a503b2be
# Make test file file-scope namespace
# Make test project to the file-scope namespace
3546a366f24d23dee1188758df0f8c6744dd1001
# Make main project to the file-scope namespace
5597711949c30a9699c4ab3957c0d98e6ff2212c
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ protected void TriggerHandlerChangedWithChangeForbiddenException(Action<TChangeH
{
TriggerHandlerChangedWithException<HitObjectPropertyChangeHandler<THitObject>.ChangeForbiddenException>(c);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ public void TestImport()
Assert.AreEqual(2, karaokeBeatmap.HitObjects.Count);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ protected IEnumerable<Issue> Run(BeatmapVerifierContext context)
{
return check.Run(context);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ private static IBeatmap createTestingBeatmap(List<CultureInfo>? translateLanguag

private static BeatmapVerifierContext getContext(IBeatmap beatmap)
=> new(beatmap, new TestWorkingBeatmap(beatmap));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ public void TestCheckNotFillLanguage(string? language)

AssertNotOk<LyricIssue, IssueTemplateLyricNotFillLanguage>(lyric);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ public void TestCheckRomajiEmptyText(string text, string[] romajies)

AssertNotOk<LyricRomajiTagIssue, IssueTemplateLyricRomajiEmptyText>(lyric);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ public void TestCheckRubyEmptyText(string text, string[] rubies)

AssertNotOk<LyricRubyTagIssue, IssueTemplateLyricRubyEmptyText>(lyric);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ public void TestCheckNoSinger(int[] singers)

AssertNotOk<LyricIssue, IssueTemplateLyricNoSinger>(lyric);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ public void TestCheckNoText(string text)

AssertNotOk<LyricIssue, IssueTemplateLyricNoText>(lyric);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ public void TestCheckEmptyTime(string text, string[] timeTags)

AssertNotOk<LyricTimeTagIssue, IssueTemplateLyricTimeTagEmptyTime>(lyric);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ public void TestCheckEndTimeInvalid(string lyricText, string[] timeTags)

AssertNotOk<LyricIssue, IssueTemplateLyricEndTimeInvalid>(lyric);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ public void TestCheckTranslationNoText(string text)

AssertNotOk<LyricIssue, IssueTemplateLyricTranslationNoText>(lyric);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ public void TestCheckNoRubyText(string? rubyText)

AssertNotOk<NoteIssue, IssueTemplateNoteNoRubyText>(note);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ private BeatmapVerifierContext getContext(IEnumerable<HitObject> hitObjects)

return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ public void TestGenerateWithRubyLyric()
};
CheckGenerateResult(lyric, expectedTimeTags, config);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,48 @@
using osu.Game.IO.Serialization;
using osu.Game.Rulesets.Karaoke.IO.Serialization;

namespace osu.Game.Rulesets.Karaoke.Beatmaps.Formats
namespace osu.Game.Rulesets.Karaoke.Beatmaps.Formats;

public class KaraokeJsonBeatmapDecoder : JsonBeatmapDecoder
{
public class KaraokeJsonBeatmapDecoder : JsonBeatmapDecoder
public new static void Register()
{
public new static void Register()
{
AddDecoder<Beatmap>("// karaoke json file format v", m => new KaraokeJsonBeatmapDecoder());
AddDecoder<Beatmap>("// karaoke json file format v", m => new KaraokeJsonBeatmapDecoder());

// use this weird way to let all the fall-back beatmap(include karaoke beatmap) become karaoke beatmap.
SetFallbackDecoder<Beatmap>(() => new KaraokeJsonBeatmapDecoder());
}

protected override void ParseStreamInto(LineBufferedReader stream, Beatmap output)
{
var globalSetting = KaraokeJsonSerializableExtensions.CreateGlobalSettings();
globalSetting.ContractResolver = new KaraokeBeatmapContractResolver();
// use this weird way to let all the fall-back beatmap(include karaoke beatmap) become karaoke beatmap.
SetFallbackDecoder<Beatmap>(() => new KaraokeJsonBeatmapDecoder());
}

// create id if object is by reference.
globalSetting.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
protected override void ParseStreamInto(LineBufferedReader stream, Beatmap output)
{
var globalSetting = KaraokeJsonSerializableExtensions.CreateGlobalSettings();
globalSetting.ContractResolver = new KaraokeBeatmapContractResolver();

// should not let json decoder to read this line.
if (stream.PeekLine()?.Contains("// karaoke json file format v") ?? false)
{
stream.ReadLine();
}
// create id if object is by reference.
globalSetting.PreserveReferencesHandling = PreserveReferencesHandling.Objects;

// equal to stream.ReadToEnd().DeserializeInto(output); in the base class.
JsonConvert.PopulateObject(stream.ReadToEnd(), output, globalSetting);
// should not let json decoder to read this line.
if (stream.PeekLine()?.Contains("// karaoke json file format v") ?? false)
{
stream.ReadLine();
}

private class KaraokeBeatmapContractResolver : SnakeCaseKeyContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
var props = base.CreateProperties(type, memberSerialization);
// equal to stream.ReadToEnd().DeserializeInto(output); in the base class.
JsonConvert.PopulateObject(stream.ReadToEnd(), output, globalSetting);
}

if (type == typeof(BeatmapInfo))
{
return props.Where(p => p.PropertyName != "ruleset_id").ToList();
}
private class KaraokeBeatmapContractResolver : SnakeCaseKeyContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
var props = base.CreateProperties(type, memberSerialization);

return props;
if (type == typeof(BeatmapInfo))
{
return props.Where(p => p.PropertyName != "ruleset_id").ToList();
}

return props;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Karaoke.IO.Serialization;

namespace osu.Game.Rulesets.Karaoke.Beatmaps.Formats
namespace osu.Game.Rulesets.Karaoke.Beatmaps.Formats;

public class KaraokeJsonBeatmapEncoder
{
public class KaraokeJsonBeatmapEncoder
public string Encode(Beatmap output)
{
public string Encode(Beatmap output)
{
var globalSetting = KaraokeJsonSerializableExtensions.CreateGlobalSettings();
string json = JsonConvert.SerializeObject(output, globalSetting);
return "// karaoke json file format v1" + '\n' + json;
}
var globalSetting = KaraokeJsonSerializableExtensions.CreateGlobalSettings();
string json = JsonConvert.SerializeObject(output, globalSetting);
return "// karaoke json file format v1" + '\n' + json;
}
}
Loading

0 comments on commit dcf99d5

Please sign in to comment.