Use file-scoped namespace

This commit is contained in:
Maksym Koshovyi
2022-02-19 20:27:07 +02:00
parent ea176051c2
commit 45cbe53703
18 changed files with 671 additions and 710 deletions

View File

@@ -5,3 +5,7 @@
indent_style = space
indent_size = 2
[*.cs]
# Namespace preferences
csharp_style_namespace_declarations = file_scoped:warning

View File

@@ -1,7 +1,7 @@
using Mopups.Pages;
namespace Mopups.Interfaces
{
namespace Mopups.Interfaces;
public interface IPopupNavigation
{
event EventHandler<PopupPage> Pushing;
@@ -22,4 +22,3 @@ namespace Mopups.Interfaces
Task RemovePageAsync(PopupPage page);
}
}

View File

@@ -1,11 +1,10 @@
using Mopups.Pages;
namespace Mopups.Interfaces
{
namespace Mopups.Interfaces;
public interface IPopupPlatform
{
Task AddAsync(PopupPage page);
Task RemoveAsync(PopupPage page);
}
}

View File

@@ -1,8 +1,8 @@
using AsyncAwaitBestPractices;
using Mopups.Services;
namespace Mopups.Pages
{
namespace Mopups.Pages;
public partial class PopupPage : ContentPage
{
@@ -75,4 +75,3 @@ namespace Mopups.Pages
}
}
}
}

View File

@@ -1,7 +1,7 @@
using Android.Views;
namespace Mopups.Droid.Gestures
{
namespace Mopups.Droid.Gestures;
internal class MopupGestureDetectorListener : GestureDetector.SimpleOnGestureListener
{
public event EventHandler<MotionEvent>? Clicked;
@@ -13,4 +13,3 @@ namespace Mopups.Droid.Gestures
return false;
}
}
}

View File

@@ -1,9 +1,7 @@
using Mopups.Pages;
using Mopups.Pages;
namespace Mopups.Droid.Extension;
namespace Mopups.Droid.Extension
{
internal static class PlatformExtension
{
public static IViewHandler GetOrCreateHandler(this VisualElement bindable)
@@ -12,10 +10,9 @@ namespace Mopups.Droid.Extension
{
return bindable.Handler ??= new PopupPageHandler();
}
catch (System.Exception ex)
catch (Exception)
{
throw;
}
}
}
}

View File

@@ -8,8 +8,8 @@ using Mopups.Interfaces;
using Mopups.Pages;
using Mopups.Services;
namespace Mopups.Droid.Implementation
{
namespace Mopups.Droid.Implementation;
public class AndroidMopups : IPopupPlatform
{
@@ -88,5 +88,4 @@ namespace Mopups.Droid.Implementation
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.Maui.Handlers;
using Microsoft.Maui.Platform;
using Mopups.Droid.Gestures;
namespace Mopups.Pages
{
namespace Mopups.Pages;
public class PopupPageHandler : ContentViewHandler
{
private readonly MopupGestureDetectorListener _gestureDetectorListener;
@@ -30,7 +30,7 @@ namespace Mopups.Pages
ForceHandlerPauseWaitForVirtualView();
}
catch (Exception ex)
catch (Exception)
{
throw;
}
@@ -140,7 +140,7 @@ namespace Mopups.Pages
}
}
}
catch (Exception ex)
catch (Exception)
{
throw;
@@ -216,13 +216,10 @@ namespace Mopups.Pages
//base.OnLayout(changed, l, t, r, b);
}
catch (Exception ex)
catch (Exception)
{
throw;
}
}
}
}

View File

@@ -1,7 +1,7 @@
using Mopups.Interfaces;
namespace Mopups.Services
{
namespace Mopups.Services;
public static class MopupService
{
static IPopupNavigation? _customNavigation;
@@ -46,6 +46,5 @@ namespace Mopups.Services
internal static Exception NotImplementedInReferenceAssembly() =>
new NotImplementedException("This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.");
}
}

View File

@@ -1,12 +1,9 @@
using AsyncAwaitBestPractices;
using AsyncAwaitBestPractices;
using Mopups.Interfaces;
using Mopups.Pages;
namespace Mopups.Services
{
namespace Mopups.Services;
public class PopupNavigation : IPopupNavigation
{
private readonly object _locker = new();
@@ -113,4 +110,3 @@ namespace Mopups.Services
}
}
}
}

View File

@@ -1,13 +1,9 @@
//using Demo.Pages;
//using Demo.Pages;
using SampleMaui.CSharpMarkup;
using Application = Microsoft.Maui.Controls.Application;
[assembly: XamlCompilation(XamlCompilationOptions.Skip)]
namespace SampleMaui
{
namespace SampleMaui;
public partial class App : Application
{
public App()
@@ -15,4 +11,3 @@ namespace SampleMaui
MainPage = new MainPage();
}
}
}

View File

@@ -1,11 +1,9 @@
using Mopups.Pages;
using Mopups.Pages;
using Mopups.Services;
using ScrollView = Microsoft.Maui.Controls.ScrollView;
namespace SampleMaui.CSharpMarkup;
namespace SampleMaui.CSharpMarkup
{
public partial class LoginPage : PopupPage
{
public Frame FrameContainer { get; set; }
@@ -14,15 +12,11 @@ namespace SampleMaui.CSharpMarkup
public Entry UsernameEntry { get; set; }
public Entry PasswordEntry { get; set; }
public Microsoft.Maui.Controls.Button LoginButton { get; set; }
public Button LoginButton { get; set; }
protected void BuildContent()
{
try
{
this.Content = new ScrollView
{
HorizontalOptions = LayoutOptions.Center,
@@ -51,6 +45,7 @@ namespace SampleMaui.CSharpMarkup
};
return FrameContainer;
}
private StackLayout GenerateFrameContainerContent()
{
var frameContainerContent = new StackLayout
@@ -77,8 +72,8 @@ namespace SampleMaui.CSharpMarkup
{
HorizontalOptions = LayoutOptions.Center,
Placeholder = "Username",
PlaceholderColor = Microsoft.Maui.Graphics.Color.FromHex("#FF9CDAF1"),
TextColor = Microsoft.Maui.Graphics.Color.FromHex("#FF7DBBE6")
PlaceholderColor = Color.FromHex("#FF9CDAF1"),
TextColor = Color.FromHex("#FF7DBBE6")
};
PasswordEntry = new Entry
@@ -86,18 +81,14 @@ namespace SampleMaui.CSharpMarkup
HorizontalOptions = LayoutOptions.Center,
IsPassword = true,
Placeholder = "Password",
PlaceholderColor = Microsoft.Maui.Graphics.Color.FromHex("#FF9CDAF1"),
TextColor = Microsoft.Maui.Graphics.Color.FromHex("#FF7DBBE6")
PlaceholderColor = Color.FromHex("#FF9CDAF1"),
TextColor = Color.FromHex("#FF7DBBE6")
};
LoginButton = new Button
{
Command = new Command(() => MopupService.Instance.PopAllAsync())
}
;
};
//frameContainerContent.Add(DotNetBotImage);
frameContainerContent.Add(UsernameEntry);
@@ -107,4 +98,3 @@ namespace SampleMaui.CSharpMarkup
return frameContainerContent;
}
}
}

View File

@@ -1,14 +1,12 @@
using Mopups.Pages;
using Mopups.Pages;
namespace SampleMaui.CSharpMarkup;
namespace SampleMaui.CSharpMarkup
{
public partial class LoginPage : PopupPage
{
public LoginPage()
{
BuildContent();
}
protected override bool OnBackgroundClicked()
@@ -16,4 +14,3 @@ namespace SampleMaui.CSharpMarkup
return base.OnBackgroundClicked();
}
}
}

View File

@@ -1,12 +1,11 @@
using AsyncAwaitBestPractices.MVVM;
using AsyncAwaitBestPractices.MVVM;
using Mopups.Pages;
using Mopups.Services;
using Button = Microsoft.Maui.Controls.Button;
using ScrollView = Microsoft.Maui.Controls.ScrollView;
namespace SampleMaui.CSharpMarkup
{
namespace SampleMaui.CSharpMarkup;
public partial class MainPage : ContentPage
{
protected void BuildContent()
@@ -58,8 +57,4 @@ namespace SampleMaui.CSharpMarkup
});
}
}
}

View File

@@ -1,8 +1,8 @@
using Mopups.Services;
using System.Diagnostics;
namespace SampleMaui.CSharpMarkup
{
namespace SampleMaui.CSharpMarkup;
public partial class MainPage : ContentPage
{
public MainPage()
@@ -20,4 +20,3 @@ namespace SampleMaui.CSharpMarkup
}
}
}

View File

@@ -1,7 +1,7 @@
using Mopups.Hosting;
namespace SampleMaui
{
namespace SampleMaui;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
@@ -19,4 +19,3 @@ namespace SampleMaui
return builder.Build();
}
}
}

View File

@@ -1,10 +1,9 @@
using Android.App;
using Android.Content.PM;
namespace SampleMaui
{
namespace SampleMaui;
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]
public class MainActivity : MauiAppCompatActivity
{
}
}

View File

@@ -1,8 +1,8 @@
using Android.App;
using Android.Runtime;
namespace SampleMaui
{
namespace SampleMaui;
[Application]
public class MainApplication : MauiApplication
{
@@ -17,4 +17,3 @@ namespace SampleMaui
return MauiProgram.CreateMauiApp();
}
}
}