Skip to content

Commit e98f550

Browse files
committed
Mark the old Show methods as obsolete
1 parent 5ff9626 commit e98f550

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/MaterialDesignThemes.Wpf/DialogHost.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ public class DialogHost : ContentControl
9999
private IInputElement? _restoreFocusDialogClose;
100100
private Action? _currentSnackbarMessageQueueUnPauseAction;
101101

102+
private const string OBSOLETE_SHOW_API_MESSAGE = $"""
103+
This method is obsolete and will be removed in a future version.
104+
Please use a different overload of this method which accepts {nameof(DialogOptions)} instead.
105+
""";
106+
102107
static DialogHost()
103108
{
104109
DefaultStyleKeyProperty.OverrideMetadata(typeof(DialogHost), new FrameworkPropertyMetadata(typeof(DialogHost)));
@@ -111,6 +116,7 @@ static DialogHost()
111116
/// </summary>
112117
/// <param name="content">Content to show (can be a control or view model).</param>
113118
/// <returns>Task result is the parameter used to close the dialog, typically what is passed to the <see cref="CloseDialogCommand"/> command.</returns>
119+
[Obsolete(OBSOLETE_SHOW_API_MESSAGE)]
114120
public static Task<object?> Show(object content)
115121
=> Show(content, null, null);
116122

@@ -120,6 +126,7 @@ static DialogHost()
120126
/// <param name="content">Content to show (can be a control or view model).</param>
121127
/// <param name="openedEventHandler">Allows access to opened event which would otherwise have been subscribed to on a instance.</param>
122128
/// <returns>Task result is the parameter used to close the dialog, typically what is passed to the <see cref="CloseDialogCommand"/> command.</returns>
129+
[Obsolete(OBSOLETE_SHOW_API_MESSAGE)]
123130
public static Task<object?> Show(object content, DialogOpenedEventHandler? openedEventHandler)
124131
=> Show(content, null, openedEventHandler, null);
125132

@@ -129,6 +136,7 @@ static DialogHost()
129136
/// <param name="content">Content to show (can be a control or view model).</param>
130137
/// <param name="closingEventHandler">Allows access to closing event which would otherwise have been subscribed to on a instance.</param>
131138
/// <returns>Task result is the parameter used to close the dialog, typically what is passed to the <see cref="CloseDialogCommand"/> command.</returns>
139+
[Obsolete(OBSOLETE_SHOW_API_MESSAGE)]
132140
public static Task<object?> Show(object content, DialogClosingEventHandler? closingEventHandler)
133141
=> Show(content, null, null, closingEventHandler);
134142

@@ -139,6 +147,7 @@ static DialogHost()
139147
/// <param name="openedEventHandler">Allows access to opened event which would otherwise have been subscribed to on a instance.</param>
140148
/// <param name="closingEventHandler">Allows access to closing event which would otherwise have been subscribed to on a instance.</param>
141149
/// <returns>Task result is the parameter used to close the dialog, typically what is passed to the <see cref="CloseDialogCommand"/> command.</returns>
150+
[Obsolete(OBSOLETE_SHOW_API_MESSAGE)]
142151
public static Task<object?> Show(object content, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler)
143152
=> Show(content, null, openedEventHandler, closingEventHandler);
144153

@@ -150,6 +159,7 @@ static DialogHost()
150159
/// <param name="closingEventHandler">Allows access to closing event which would otherwise have been subscribed to on a instance.</param>
151160
/// <param name="closedEventHandler">Allows access to closed event which would otherwise have been subscribed to on a instance.</param>
152161
/// <returns>Task result is the parameter used to close the dialog, typically what is passed to the <see cref="CloseDialogCommand"/> command.</returns>
162+
[Obsolete(OBSOLETE_SHOW_API_MESSAGE)]
153163
public static Task<object?> Show(object content, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler, DialogClosedEventHandler? closedEventHandler)
154164
=> Show(content, null, openedEventHandler, closingEventHandler, closedEventHandler);
155165

@@ -159,6 +169,7 @@ static DialogHost()
159169
/// <param name="content">Content to show (can be a control or view model).</param>
160170
/// <param name="dialogIdentifier"><see cref="Identifier"/> of the instance where the dialog should be shown. Typically this will match an identifier set in XAML. <c>null</c> is allowed.</param>
161171
/// <returns>Task result is the parameter used to close the dialog, typically what is passed to the <see cref="CloseDialogCommand"/> command.</returns>
172+
[Obsolete(OBSOLETE_SHOW_API_MESSAGE)]
162173
public static Task<object?> Show(object content, object dialogIdentifier)
163174
=> Show(content, dialogIdentifier, null, null);
164175

@@ -169,6 +180,7 @@ static DialogHost()
169180
/// <param name="dialogIdentifier"><see cref="Identifier"/> of the instance where the dialog should be shown. Typically this will match an identifier set in XAML. <c>null</c> is allowed.</param>
170181
/// <param name="openedEventHandler">Allows access to opened event which would otherwise have been subscribed to on a instance.</param>
171182
/// <returns>Task result is the parameter used to close the dialog, typically what is passed to the <see cref="CloseDialogCommand"/> command.</returns>
183+
[Obsolete(OBSOLETE_SHOW_API_MESSAGE)]
172184
public static Task<object?> Show(object content, object dialogIdentifier, DialogOpenedEventHandler? openedEventHandler)
173185
=> Show(content, dialogIdentifier, openedEventHandler, null);
174186

@@ -179,6 +191,7 @@ static DialogHost()
179191
/// <param name="dialogIdentifier"><see cref="Identifier"/> of the instance where the dialog should be shown. Typically this will match an identifier set in XAML. <c>null</c> is allowed.</param>
180192
/// <param name="closingEventHandler">Allows access to closing event which would otherwise have been subscribed to on a instance.</param>
181193
/// <returns>Task result is the parameter used to close the dialog, typically what is passed to the <see cref="CloseDialogCommand"/> command.</returns>
194+
[Obsolete(OBSOLETE_SHOW_API_MESSAGE)]
182195
public static Task<object?> Show(object content, object dialogIdentifier, DialogClosingEventHandler? closingEventHandler)
183196
=> Show(content, dialogIdentifier, null, closingEventHandler);
184197

@@ -190,6 +203,7 @@ static DialogHost()
190203
/// <param name="openedEventHandler">Allows access to opened event which would otherwise have been subscribed to on a instance.</param>
191204
/// <param name="closingEventHandler">Allows access to closing event which would otherwise have been subscribed to on a instance.</param>
192205
/// <returns>Task result is the parameter used to close the dialog, typically what is passed to the <see cref="CloseDialogCommand"/> command.</returns>
206+
[Obsolete(OBSOLETE_SHOW_API_MESSAGE)]
193207
public static Task<object?> Show(object content, object? dialogIdentifier, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler)
194208
=> Show(content, dialogIdentifier, openedEventHandler, closingEventHandler, null);
195209

@@ -202,6 +216,7 @@ static DialogHost()
202216
/// <param name="closingEventHandler">Allows access to closing event which would otherwise have been subscribed to on a instance.</param>
203217
/// <param name="closedEventHandler">Allows access to closed event which would otherwise have been subscribed to on a instance.</param>
204218
/// <returns>Task result is the parameter used to close the dialog, typically what is passed to the <see cref="CloseDialogCommand"/> command.</returns>
219+
[Obsolete(OBSOLETE_SHOW_API_MESSAGE)]
205220
public static async Task<object?> Show(object content, object? dialogIdentifier, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler, DialogClosedEventHandler? closedEventHandler)
206221
{
207222
#if NET7_0_OR_GREATER
@@ -292,6 +307,7 @@ private static DialogHost GetInstance(object? dialogIdentifier)
292307
return targets[0];
293308
}
294309

310+
[Obsolete(OBSOLETE_SHOW_API_MESSAGE)]
295311
internal async Task<object?> ShowInternal(object content, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler, DialogClosedEventHandler? closedEventHandler)
296312
{
297313
if (IsOpen)

0 commit comments

Comments
 (0)