Skip to content

Commit

Permalink
Avalonia cleanup, reducing warnings and added XML documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianSuess committed Oct 23, 2024
1 parent 7e2ea53 commit a8c8338
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 56 deletions.
7 changes: 3 additions & 4 deletions src/Avalonia/Prism.Avalonia/Dialogs/Dialog.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using Avalonia;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Styling;
using Prism.Extensions;

namespace Prism.Dialogs
{
/// <summary>
/// This class contains <see cref="IDialogWindow"/> attached properties.
/// </summary>
/// <summary>This class contains <see cref="IDialogWindow"/> attached properties.</summary>
public class Dialog
{
/// <summary>Identifies the WindowStyle attached property.</summary>
Expand All @@ -22,6 +20,7 @@ public class Dialog
name: "WindowStartupLocation",
ownerType: typeof(Dialog));

/// <summary>Creates an instance of the Dialog class.</summary>
public Dialog()
{
WindowStartupLocationProperty.Changed.Subscribe(args => OnWindowStartupLocationChanged(args?.Sender, args));
Expand Down
6 changes: 5 additions & 1 deletion src/Avalonia/Prism.Avalonia/Dialogs/DialogService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
Expand All @@ -20,6 +20,10 @@ public DialogService(IContainerExtension containerExtension)
_containerExtension = containerExtension;
}

/// <summary>Show dialog.</summary>
/// <param name="name">Name of the dialog window to show.</param>
/// <param name="parameters"><see cref="IDialogParameters"/>.</param>
/// <param name="callback">The action to perform when the dialog is closed.</param>
public void ShowDialog(string name, IDialogParameters parameters, DialogCallback callback)
{
parameters ??= new DialogParameters();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Avalonia.Controls;

namespace Prism.Dialogs
Expand All @@ -9,6 +9,8 @@ public static class IDialogServiceCompatExtensions
/// <summary>Shows a non-modal dialog.</summary>
/// <param name="dialogService">The DialogService</param>
/// <param name="name">The name of the dialog to show.</param>
/// <param name="parameters">Parameters that the dialog can use for custom functionality.</param>
/// <param name="callback">The action to be invoked upon successful or failed completion of displaying the dialog.</param>
public static void Show(this IDialogService dialogService, string name, IDialogParameters parameters, Action<IDialogResult> callback)
{
parameters = EnsureShowNonModalParameter(parameters);
Expand Down
35 changes: 14 additions & 21 deletions src/Avalonia/Prism.Avalonia/Dialogs/IDialogWindow.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System;
using System.ComponentModel;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Styling;

#nullable enable
namespace Prism.Dialogs
{
/// <summary>
Expand All @@ -25,46 +26,38 @@ public interface IDialogWindow
void Show();

/// <summary>Show a modal dialog.</summary>
/// <returns></returns>
/// <returns>Task.</returns>
Task ShowDialog(Window owner);

/// <summary>
/// The data context of the window.
/// </summary>
/// <remarks>
/// The data context must implement <see cref="IDialogAware"/>.
/// </remarks>
/// <summary>The data context of the window.</summary>
/// <remarks>The data context must implement <see cref="IDialogAware"/>.</remarks>
object DataContext { get; set; }

/// <summary>Called when the window is loaded.</summary>
/// <remarks>
/// WPF: event RoutedEventHandler Loaded;
/// Avalonia currently doesn't implement the Loaded event like WPF.
/// Window > WindowBase > TopLevel.Opened
/// Window > WindowBase > TopLevel > Control > InputElement > Interactive > layout > Visual > StyledElement.Initialized
/// </remarks>
//// WPF: event RoutedEventHandler Loaded;
event EventHandler Opened;

/// <summary>
/// Called when the window is closed.
/// </summary>
event EventHandler Closed;

/// <summary>
/// Called when the window is closing.
/// </summary>
// WPF: event CancelEventHandler Closing;
// Ava: ...
/// <summary>Called when the window is closing.</summary>
event EventHandler<WindowClosingEventArgs>? Closing;

/// <summary>
/// The result of the dialog.
/// </summary>
/// <summary>The result of the dialog.</summary>
IDialogResult Result { get; set; }

/// <summary>The window style.</summary>
// WPF: Window > ContentControl > FrameworkElement
// Ava: Window > WindowBase > TopLevel > ContentControl > TemplatedControl > Control
//Style Style { get; set; }
/////// <summary>The window style.</summary>
/////// <remarks>
/////// WPF: Window > ContentControl > FrameworkElement
/////// Ava: Window > WindowBase > TopLevel > ContentControl > TemplatedControl > Control
/////// </remarks>
////Style Style { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Avalonia;
using Avalonia;
using Avalonia.Controls;
using Prism.Navigation.Regions;
using System;
Expand Down Expand Up @@ -52,9 +52,7 @@ public static void SetClearChildViews(AvaloniaObject target, bool value)
target.SetValue(ClearChildViewsRegionBehavior.ClearChildViewsProperty, value);
}

/// <summary>
/// Subscribes to the <see cref="Region"/>'s PropertyChanged method to monitor its <see cref="RegionManager"> property.
/// </summary>
/// <summary>Subscribes to the <see cref="Region"/>'s PropertyChanged method to monitor its <see cref="RegionManager"/> property.</summary>
protected override void OnAttach()
{
Region.PropertyChanged += Region_PropertyChanged;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public void RequestNavigate(string regionName, Uri source, Action<NavigationResu
/// <param name="regionName">The name of the region where the navigation will occur.</param>
/// <param name="target">A Uri that represents the target where the region will navigate.</param>
/// <param name="navigationCallback">The navigation callback that will be executed after the navigation is completed.</param>
/// <param name="navigationParameters">An instance of <see cref="NavigationParameters">, which holds a collection of object parameters.</param>
/// <param name="navigationParameters">An instance of <see cref="NavigationParameters"/>, which holds a collection of object parameters.</param>
public void RequestNavigate(string regionName, Uri target, Action<NavigationResult> navigationCallback, INavigationParameters navigationParameters)
{
if (navigationCallback == null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand Down Expand Up @@ -62,18 +62,18 @@ public bool Contains(object value)
return filteredItems.Contains(value);
}

///<summary>Returns an enumerator that iterates through the collection.summary>
///<summary>Returns an enumerator that iterates through the collection.</summary>
///<returns>
///A <see cref="T:System.Collections.Generic.IEnumerator`1" /> that can be used to iterate through the collection.
///A <see cref="System.Collections.Generic.IEnumerable{T}"/> that can be used to iterate through the collection.
///</returns>
public IEnumerator<object> GetEnumerator()
{
return filteredItems.GetEnumerator();
}

///<summary>Returns an enumerator that iterates through a collection.summary>
///<summary>Returns an enumerator that iterates through a collection.</summary>
///<returns>
///An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.
///An <see cref="System.Collections.IEnumerator" /> object that can be used to iterate through the collection.
///</returns>
IEnumerator IEnumerable.GetEnumerator()
{
Expand Down
27 changes: 8 additions & 19 deletions src/Avalonia/Prism.Avalonia/PrismApplicationBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ public abstract class PrismApplicationBase : Application
private IContainerExtension _containerExtension;
private IModuleCatalog _moduleCatalog;

// FROM Prism.Avalonia7.1.2
/// <summary>Main window.</summary>
public AvaloniaObject MainWindow { get; private set; }

/// <summary>
/// The dependency injection container used to resolve objects
/// </summary>
/// <summary>The dependency injection container used to resolve objects.</summary>
public IContainerProvider Container => _containerExtension;

/// <summary>
/// Configures the <see cref="Prism.Mvvm.ViewModelLocator"/> used by Prism.
/// </summary>
/// <summary>Configures the <see cref="Prism.Mvvm.ViewModelLocator"/> used by Prism.</summary>
protected virtual void ConfigureViewModelLocator()
{
PrismInitializationExtensions.ConfigureViewModelLocator();
Expand Down Expand Up @@ -75,6 +71,7 @@ public override void Initialize()
OnInitialized();
}

/// <summary>Framework initialization has completed.</summary>
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime)
Expand All @@ -85,26 +82,18 @@ public override void OnFrameworkInitializationCompleted()
base.OnFrameworkInitializationCompleted();
}

/// <summary>
/// Creates the container used by Prism.
/// </summary>
/// <summary>Creates the container used by Prism.</summary>
/// <returns>The container</returns>
protected abstract IContainerExtension CreateContainerExtension();

/// <summary>
/// Creates the <see cref="IModuleCatalog"/> used by Prism.
/// </summary>
/// <remarks>
/// The base implementation returns a new ModuleCatalog.
/// </remarks>
/// <summary>Creates the <see cref="IModuleCatalog"/> used by Prism.</summary>
/// <remarks>The base implementation returns a new ModuleCatalog.</remarks>
protected virtual IModuleCatalog CreateModuleCatalog()
{
return new ModuleCatalog();
}

/// <summary>
/// Registers all types that are required by Prism to function with the container.
/// </summary>
/// <summary>Registers all types that are required by Prism to function with the container.</summary>
/// <param name="containerRegistry"></param>
protected virtual void RegisterRequiredTypes(IContainerRegistry containerRegistry)
{
Expand Down

0 comments on commit a8c8338

Please sign in to comment.