diff --git a/.editorconfig b/.editorconfig index 6e035a0..507f1f6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -191,6 +191,9 @@ csharp_style_prefer_index_operator = true:warning csharp_style_prefer_range_operator = true:warning csharp_style_prefer_switch_expression = false:none +#Style - C# 10 features +csharp_style_namespace_declarations = file_scoped:warning + [*.{yaml,yml}] insert_final_newline = true indent_style = space diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index bdd28a8..c93b468 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,2 +1,4 @@ # Make everything partial -35abcde7a4eeb823067b9cd0ef4b84c81e4e35cd \ No newline at end of file +35abcde7a4eeb823067b9cd0ef4b84c81e4e35cd +# Apply the file-scope namespace +4f9de16847716c1d51ba84ef4a5ceba373908842 \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index f6c7a5e..107a00a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 9.0 + 10.0 true enable diff --git a/osu.Framework.Microphone.Android.props b/osu.Framework.Microphone.Android.props index c998d01..089ae08 100644 --- a/osu.Framework.Microphone.Android.props +++ b/osu.Framework.Microphone.Android.props @@ -1,6 +1,6 @@ - 9.0 + 10.0 21.0 android-x86;android-arm;android-arm64 apk diff --git a/osu.Framework.Microphone.Tests.Android/TestGameActivity.cs b/osu.Framework.Microphone.Tests.Android/TestGameActivity.cs index 087c0b4..ed775f3 100644 --- a/osu.Framework.Microphone.Tests.Android/TestGameActivity.cs +++ b/osu.Framework.Microphone.Tests.Android/TestGameActivity.cs @@ -5,12 +5,11 @@ using Android.Content.PM; using osu.Framework.Android; -namespace osu.Framework.Tests.Android +namespace osu.Framework.Tests.Android; + +[Activity(MainLauncher = true, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, Theme = "@android:style/Theme.NoTitleBar")] +public class TestGameActivity : AndroidGameActivity { - [Activity(MainLauncher = true, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize, Theme = "@android:style/Theme.NoTitleBar")] - public class TestGameActivity : AndroidGameActivity - { - protected override Game CreateGame() - => new VisualTestGame(); - } + protected override Game CreateGame() + => new VisualTestGame(); } diff --git a/osu.Framework.Microphone.Tests.iOS/AppDelegate.cs b/osu.Framework.Microphone.Tests.iOS/AppDelegate.cs index 5b13f12..39db88a 100644 --- a/osu.Framework.Microphone.Tests.iOS/AppDelegate.cs +++ b/osu.Framework.Microphone.Tests.iOS/AppDelegate.cs @@ -4,11 +4,10 @@ using Foundation; using osu.Framework.iOS; -namespace osu.Framework.Tests +namespace osu.Framework.Tests; + +[Register("AppDelegate")] +public class AppDelegate : GameAppDelegate { - [Register("AppDelegate")] - public class AppDelegate : GameAppDelegate - { - protected override Game CreateGame() => new VisualTestGame(); - } + protected override Game CreateGame() => new VisualTestGame(); } diff --git a/osu.Framework.Microphone.Tests.iOS/Application.cs b/osu.Framework.Microphone.Tests.iOS/Application.cs index 6eda2af..51eb9ec 100644 --- a/osu.Framework.Microphone.Tests.iOS/Application.cs +++ b/osu.Framework.Microphone.Tests.iOS/Application.cs @@ -3,13 +3,12 @@ using UIKit; -namespace osu.Framework.Tests +namespace osu.Framework.Tests; + +public static class Application { - public static class Application + public static void Main(string[] args) { - public static void Main(string[] args) - { - UIApplication.Main(args, null, typeof(AppDelegate)); - } + UIApplication.Main(args, null, typeof(AppDelegate)); } } diff --git a/osu.Framework.Microphone.Tests/AutomatedVisualTestGame.cs b/osu.Framework.Microphone.Tests/AutomatedVisualTestGame.cs index 58cf312..67bc1c2 100644 --- a/osu.Framework.Microphone.Tests/AutomatedVisualTestGame.cs +++ b/osu.Framework.Microphone.Tests/AutomatedVisualTestGame.cs @@ -3,13 +3,12 @@ using osu.Framework.Testing; -namespace osu.Framework.Tests +namespace osu.Framework.Tests; + +internal partial class AutomatedVisualTestGame : TestGame { - internal partial class AutomatedVisualTestGame : TestGame + public AutomatedVisualTestGame() { - public AutomatedVisualTestGame() - { - Add(new TestBrowserTestRunner(new TestBrowser())); - } + Add(new TestBrowserTestRunner(new TestBrowser())); } } diff --git a/osu.Framework.Microphone.Tests/Program.cs b/osu.Framework.Microphone.Tests/Program.cs index eea8f30..ac22265 100644 --- a/osu.Framework.Microphone.Tests/Program.cs +++ b/osu.Framework.Microphone.Tests/Program.cs @@ -4,22 +4,21 @@ using System; using osu.Framework.Platform; -namespace osu.Framework.Tests +namespace osu.Framework.Tests; + +public static class Program { - public static class Program + [STAThread] + public static void Main(string[] args) { - [STAThread] - public static void Main(string[] args) - { - bool benchmark = args.Length > 0 && args[0] == @"-benchmark"; + bool benchmark = args.Length > 0 && args[0] == @"-benchmark"; - using (GameHost host = Host.GetSuitableDesktopHost(@"microphone-tests")) - { - if (benchmark) - host.Run(new AutomatedVisualTestGame()); - else - host.Run(new VisualTestGame()); - } + using (GameHost host = Host.GetSuitableDesktopHost(@"microphone-tests")) + { + if (benchmark) + host.Run(new AutomatedVisualTestGame()); + else + host.Run(new VisualTestGame()); } } } diff --git a/osu.Framework.Microphone.Tests/TestGame.cs b/osu.Framework.Microphone.Tests/TestGame.cs index 848bd1a..bc4b451 100644 --- a/osu.Framework.Microphone.Tests/TestGame.cs +++ b/osu.Framework.Microphone.Tests/TestGame.cs @@ -4,14 +4,13 @@ using osu.Framework.Allocation; using osu.Framework.IO.Stores; -namespace osu.Framework.Tests +namespace osu.Framework.Tests; + +internal partial class TestGame : Game { - internal partial class TestGame : Game + [BackgroundDependencyLoader] + private void load() { - [BackgroundDependencyLoader] - private void load() - { - Resources.AddStore(new NamespacedResourceStore(new DllResourceStore(typeof(TestGame).Assembly), "Resources")); - } + Resources.AddStore(new NamespacedResourceStore(new DllResourceStore(typeof(TestGame).Assembly), "Resources")); } } diff --git a/osu.Framework.Microphone.Tests/Visual/FrameworkTestScene.cs b/osu.Framework.Microphone.Tests/Visual/FrameworkTestScene.cs index d387366..21c9109 100644 --- a/osu.Framework.Microphone.Tests/Visual/FrameworkTestScene.cs +++ b/osu.Framework.Microphone.Tests/Visual/FrameworkTestScene.cs @@ -5,19 +5,18 @@ using osu.Framework.IO.Stores; using osu.Framework.Testing; -namespace osu.Framework.Tests.Visual +namespace osu.Framework.Tests.Visual; + +public abstract partial class FrameworkTestScene : TestScene { - public abstract partial class FrameworkTestScene : TestScene - { - protected override ITestSceneTestRunner CreateRunner() => new FrameworkTestSceneTestRunner(); + protected override ITestSceneTestRunner CreateRunner() => new FrameworkTestSceneTestRunner(); - private partial class FrameworkTestSceneTestRunner : TestSceneTestRunner + private partial class FrameworkTestSceneTestRunner : TestSceneTestRunner + { + [BackgroundDependencyLoader] + private void load() { - [BackgroundDependencyLoader] - private void load() - { - Resources.AddStore(new NamespacedResourceStore(new DllResourceStore(typeof(FrameworkTestScene).Assembly), "Resources")); - } + Resources.AddStore(new NamespacedResourceStore(new DllResourceStore(typeof(FrameworkTestScene).Assembly), "Resources")); } } } diff --git a/osu.Framework.Microphone.Tests/Visual/Input/TestSceneGetMicrophoneList.cs b/osu.Framework.Microphone.Tests/Visual/Input/TestSceneGetMicrophoneList.cs index d52a173..6daf0dd 100644 --- a/osu.Framework.Microphone.Tests/Visual/Input/TestSceneGetMicrophoneList.cs +++ b/osu.Framework.Microphone.Tests/Visual/Input/TestSceneGetMicrophoneList.cs @@ -5,21 +5,20 @@ using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; -namespace osu.Framework.Tests.Visual.Input +namespace osu.Framework.Tests.Visual.Input; + +[TestFixture] +public partial class TestSceneGetMicrophoneList : FrameworkTestScene { - [TestFixture] - public partial class TestSceneGetMicrophoneList : FrameworkTestScene + public TestSceneGetMicrophoneList() { - public TestSceneGetMicrophoneList() + var manager = new MicrophoneManager(); + Child = new BasicDropdown { - var manager = new MicrophoneManager(); - Child = new BasicDropdown - { - X = 100, - Y = 100, - Width = 300, - Items = manager.MicrophoneDeviceNames - }; - } + X = 100, + Y = 100, + Width = 300, + Items = manager.MicrophoneDeviceNames + }; } } diff --git a/osu.Framework.Microphone.Tests/Visual/Input/TestSceneMicrophone.cs b/osu.Framework.Microphone.Tests/Visual/Input/TestSceneMicrophone.cs index 3a12746..511a7f0 100644 --- a/osu.Framework.Microphone.Tests/Visual/Input/TestSceneMicrophone.cs +++ b/osu.Framework.Microphone.Tests/Visual/Input/TestSceneMicrophone.cs @@ -12,143 +12,142 @@ using osu.Framework.Input.Handlers.Microphone; using osuTK.Graphics; -namespace osu.Framework.Tests.Visual.Input +namespace osu.Framework.Tests.Visual.Input; + +[TestFixture] +public partial class TestSceneMicrophone : FrameworkTestScene { - [TestFixture] - public partial class TestSceneMicrophone : FrameworkTestScene + public TestSceneMicrophone() { - public TestSceneMicrophone() + var manager = new TestMicrophoneInputManager { - var manager = new TestMicrophoneInputManager + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] + new MicrophonePitchVisualization + { + X = 50 + }, + new MicrophoneDecibelVisualization { - new MicrophonePitchVisualization - { - X = 50 - }, - new MicrophoneDecibelVisualization - { - X = 200, - } + X = 200, } - }; - AddSliderStep("sensitive", 0f, 100, 10, blur => - { - var sensitive = manager.MicrophoneHandler.Sensitivity; - sensitive.Value = blur; - }); + } + }; + AddSliderStep("sensitive", 0f, 100, 10, blur => + { + var sensitive = manager.MicrophoneHandler.Sensitivity; + sensitive.Value = blur; + }); - Child = manager; - } + Child = manager; + } + + private partial class TestMicrophoneInputManager : MicrophoneInputManager + { + public MicrophoneHandler MicrophoneHandler => InputHandlers.OfType().First(); + } - private partial class TestMicrophoneInputManager : MicrophoneInputManager + private partial class MicrophonePitchVisualization : MicrophoneVisualization + { + protected override bool OnMicrophoneStartSinging(MicrophoneStartPitchingEvent e) { - public MicrophoneHandler MicrophoneHandler => InputHandlers.OfType().First(); + float pitch = e.CurrentState.Microphone.Voice.Pitch; + BoxText.Text = "Pitch start : " + pitch; + return base.OnMicrophoneStartSinging(e); } - private partial class MicrophonePitchVisualization : MicrophoneVisualization + protected override bool OnMicrophoneEndSinging(MicrophoneEndPitchingEvent e) { - protected override bool OnMicrophoneStartSinging(MicrophoneStartPitchingEvent e) - { - float pitch = e.CurrentState.Microphone.Voice.Pitch; - BoxText.Text = "Pitch start : " + pitch; - return base.OnMicrophoneStartSinging(e); - } - - protected override bool OnMicrophoneEndSinging(MicrophoneEndPitchingEvent e) - { - float pitch = e.CurrentState.Microphone.Voice.Pitch; - BoxText.Text = "Pitch end : " + pitch; - return base.OnMicrophoneEndSinging(e); - } - - protected override bool OnMicrophoneSinging(MicrophonePitchingEvent e) - { - float pitch = e.CurrentState.Microphone.Voice.Pitch; - Y = -(pitch - 50); - BoxText.Text = "Pitching : " + pitch; - return base.OnMicrophoneSinging(e); - } + float pitch = e.CurrentState.Microphone.Voice.Pitch; + BoxText.Text = "Pitch end : " + pitch; + return base.OnMicrophoneEndSinging(e); } - private partial class MicrophoneDecibelVisualization : MicrophoneVisualization + protected override bool OnMicrophoneSinging(MicrophonePitchingEvent e) { - protected override bool OnMicrophoneStartSinging(MicrophoneStartPitchingEvent e) - { - float decibel = e.CurrentState.Microphone.Voice.Decibel; - BoxText.Text = "Decibel start : " + decibel; - return base.OnMicrophoneStartSinging(e); - } + float pitch = e.CurrentState.Microphone.Voice.Pitch; + Y = -(pitch - 50); + BoxText.Text = "Pitching : " + pitch; + return base.OnMicrophoneSinging(e); + } + } - protected override bool OnMicrophoneEndSinging(MicrophoneEndPitchingEvent e) - { - float decibel = e.CurrentState.Microphone.Voice.Decibel; - BoxText.Text = "Decibel end : " + decibel; - return base.OnMicrophoneEndSinging(e); - } + private partial class MicrophoneDecibelVisualization : MicrophoneVisualization + { + protected override bool OnMicrophoneStartSinging(MicrophoneStartPitchingEvent e) + { + float decibel = e.CurrentState.Microphone.Voice.Decibel; + BoxText.Text = "Decibel start : " + decibel; + return base.OnMicrophoneStartSinging(e); + } - protected override bool OnMicrophoneSinging(MicrophonePitchingEvent e) - { - float decibel = e.CurrentState.Microphone.Voice.Decibel; - Y = -(decibel - 50) * 5; - BoxText.Text = "Decibel : " + decibel; - return base.OnMicrophoneSinging(e); - } + protected override bool OnMicrophoneEndSinging(MicrophoneEndPitchingEvent e) + { + float decibel = e.CurrentState.Microphone.Voice.Decibel; + BoxText.Text = "Decibel end : " + decibel; + return base.OnMicrophoneEndSinging(e); } - private partial class MicrophoneVisualization : CompositeDrawable + protected override bool OnMicrophoneSinging(MicrophonePitchingEvent e) { - private readonly Box background; + float decibel = e.CurrentState.Microphone.Voice.Decibel; + Y = -(decibel - 50) * 5; + BoxText.Text = "Decibel : " + decibel; + return base.OnMicrophoneSinging(e); + } + } - protected SpriteText BoxText { get; } + private partial class MicrophoneVisualization : CompositeDrawable + { + private readonly Box background; + + protected SpriteText BoxText { get; } - protected MicrophoneVisualization() + protected MicrophoneVisualization() + { + Width = 100; + Height = 100; + Anchor = Anchor.CentreLeft; + InternalChildren = new Drawable[] { - Width = 100; - Height = 100; - Anchor = Anchor.CentreLeft; - InternalChildren = new Drawable[] + background = new Box { - background = new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Blue - }, - BoxText = new SpriteText - { - Text = "detecting" - } - }; - } - - protected override bool Handle(UIEvent e) => - e switch + RelativeSizeAxes = Axes.Both, + Colour = Color4.Blue + }, + BoxText = new SpriteText { - MicrophoneStartPitchingEvent microphoneStartPitching => OnMicrophoneStartSinging(microphoneStartPitching), - MicrophoneEndPitchingEvent microphoneEndPitching => OnMicrophoneEndSinging(microphoneEndPitching), - MicrophonePitchingEvent microphonePitching => OnMicrophoneSinging(microphonePitching), - _ => base.Handle(e) - }; + Text = "detecting" + } + }; + } - protected virtual bool OnMicrophoneStartSinging(MicrophoneStartPitchingEvent e) + protected override bool Handle(UIEvent e) => + e switch { - background.Colour = Color4.Red; - return false; - } + MicrophoneStartPitchingEvent microphoneStartPitching => OnMicrophoneStartSinging(microphoneStartPitching), + MicrophoneEndPitchingEvent microphoneEndPitching => OnMicrophoneEndSinging(microphoneEndPitching), + MicrophonePitchingEvent microphonePitching => OnMicrophoneSinging(microphonePitching), + _ => base.Handle(e) + }; - protected virtual bool OnMicrophoneEndSinging(MicrophoneEndPitchingEvent e) - { - background.Colour = Color4.Yellow; - return false; - } + protected virtual bool OnMicrophoneStartSinging(MicrophoneStartPitchingEvent e) + { + background.Colour = Color4.Red; + return false; + } - protected virtual bool OnMicrophoneSinging(MicrophonePitchingEvent e) - { - background.Colour = Color4.Blue; - return false; - } + protected virtual bool OnMicrophoneEndSinging(MicrophoneEndPitchingEvent e) + { + background.Colour = Color4.Yellow; + return false; + } + + protected virtual bool OnMicrophoneSinging(MicrophonePitchingEvent e) + { + background.Colour = Color4.Blue; + return false; } } } diff --git a/osu.Framework.Microphone.Tests/VisualTestGame.cs b/osu.Framework.Microphone.Tests/VisualTestGame.cs index 74acb97..bfbe97a 100644 --- a/osu.Framework.Microphone.Tests/VisualTestGame.cs +++ b/osu.Framework.Microphone.Tests/VisualTestGame.cs @@ -8,27 +8,26 @@ using osu.Framework.Platform; using osu.Framework.Testing; -namespace osu.Framework.Tests +namespace osu.Framework.Tests; + +internal partial class VisualTestGame : TestGame { - internal partial class VisualTestGame : TestGame + [BackgroundDependencyLoader] + private void load() { - [BackgroundDependencyLoader] - private void load() + Child = new DrawSizePreservingFillContainer { - Child = new DrawSizePreservingFillContainer + Children = new Drawable[] { - Children = new Drawable[] - { - new TestBrowser(), - new CursorContainer() - } - }; - } + new TestBrowser(), + new CursorContainer() + } + }; + } - public override void SetHost(GameHost host) - { - base.SetHost(host); - host.Window.CursorState |= CursorState.Hidden; - } + public override void SetHost(GameHost host) + { + base.SetHost(host); + host.Window.CursorState |= CursorState.Hidden; } } diff --git a/osu.Framework.Microphone.Tests/osu.Framework.Microphone.Tests.csproj b/osu.Framework.Microphone.Tests/osu.Framework.Microphone.Tests.csproj index e130f2d..41ca597 100644 --- a/osu.Framework.Microphone.Tests/osu.Framework.Microphone.Tests.csproj +++ b/osu.Framework.Microphone.Tests/osu.Framework.Microphone.Tests.csproj @@ -2,7 +2,6 @@ net6.0 WinExe - enable false diff --git a/osu.Framework.Microphone.iOS.props b/osu.Framework.Microphone.iOS.props index 9c7b34b..720a62a 100644 --- a/osu.Framework.Microphone.iOS.props +++ b/osu.Framework.Microphone.iOS.props @@ -1,7 +1,7 @@  iPhone Developer - 9.0 + 10.0 true