From 87b84fb8e632181d517395f77daec48d0810d799 Mon Sep 17 00:00:00 2001 From: "Mattias Kindborg @FantasticFiasco" Date: Mon, 16 Nov 2020 23:07:47 +0100 Subject: [PATCH] feat: release v8 draft (#129) * feat: IDialogService.Close returns boolean indicating success (#116) IDialogService.Close returns false instead of throwing an exception when failing to close a dialog. This behavior aligns with the behavior of IDialogService.Activate. * release v8.0.0-beta.1 * release v8.0.0-beta.2 * release v8.0.0-beta.3 * release v8.0.0-beta.4 * chore: update assembly version Co-authored-by: Roberto Giardi --- CHANGELOG.md | 6 ++++-- Directory.Build.props | 4 ++-- SolutionInfo.cs | 2 +- src/net/DialogService.cs | 15 ++++++++++----- src/net/IDialogService.cs | 8 ++++---- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4616e3a..1f8cbc53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,14 @@ This project adheres to [Semantic Versioning](http://semver.org/) and is followi ## Unreleased -NOTE: Features with breaking changes are found on branch [releases/v8](https://github.com/FantasticFiasco/mvvm-dialogs/tree/releases/v8) and will stay there until a new major version is released. Until then the features have been published to [www.nuget.org](https://www.nuget.org/packages/MvvmDialogs/) as pre-releases to v8. - ### :zap: Added - Support for .NET Core 3.1 +### :syringe: Changed + +- [#116](https://github.com/FantasticFiasco/mvvm-dialogs/issues/116) [BREAKING CHANGE] `IDialogService.Close` returns `false` instead of throwing an exception when failing to close a dialog. This behavior aligns with the behavior of `IDialogService.Activate`. + ### :skull: Removed - [BREAKING CHANGE] Support for .NET Core 3.0 due to [deprecation as of March 3, 2020](https://dotnet.microsoft.com/platform/support/policy/dotnet-core) diff --git a/Directory.Build.props b/Directory.Build.props index 88b52363..147e8d31 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,8 +1,8 @@ - 7.1.1 - + 8.0.0 + beta.4 Mattias Kindborg FantasticFiasco MVVM Dialogs diff --git a/SolutionInfo.cs b/SolutionInfo.cs index c62443ae..6e00f5a4 100644 --- a/SolutionInfo.cs +++ b/SolutionInfo.cs @@ -10,4 +10,4 @@ [assembly: AssemblyCulture("")] // Assembly version -[assembly: AssemblyVersion("7.1.1")] +[assembly: AssemblyVersion("8.0.0")] diff --git a/src/net/DialogService.cs b/src/net/DialogService.cs index 0be5e06c..3eab37b8 100644 --- a/src/net/DialogService.cs +++ b/src/net/DialogService.cs @@ -154,25 +154,30 @@ select window.Activate() } /// - public void Close(INotifyPropertyChanged viewModel) + public bool Close(INotifyPropertyChanged viewModel) { if (viewModel == null) throw new ArgumentNullException(nameof(viewModel)); foreach (Window? window in Application.Current.Windows) { - if (window == null) + if (window == null || !viewModel.Equals(window.DataContext)) { continue; } - if (viewModel.Equals(window.DataContext)) + try { window.Close(); - return; + return true; + } + catch (Exception e) + { + Logger.Write($"Failed to close dialog: {e}"); + break; } } - throw new DialogNotFoundException(); + return false; } /// diff --git a/src/net/IDialogService.cs b/src/net/IDialogService.cs index b802b263..de200cf1 100644 --- a/src/net/IDialogService.cs +++ b/src/net/IDialogService.cs @@ -134,10 +134,10 @@ void Show( /// or . /// /// The view model of the dialog to close. - /// - /// No dialog is found with specified view model as data context. - /// - void Close(INotifyPropertyChanged viewModel); + /// + /// true if the was successfully closed; otherwise, false. + /// + bool Close(INotifyPropertyChanged viewModel); /// /// Displays a message box that has a message, title bar caption, button, and icon; and