Skip to content

Conversation

@StevenRasmussen
Copy link
Contributor

Pull Request

📖 Description

The methods on the IDialogService interface that create a reference to a dialog (ShowDialog, ShowPanel etc) all return an IDialogReference interface. However, the CloseAsync method accepts a DialogReference concrete type instead of the interface. It makes sense to me that the CloseAsync methods should accept the interface as well.

✅ Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Component-specific

  • I have added a new component
  • I have added Unit Tests for my new component
  • I have modified an existing component
  • I have validated the Unit Tests for an existing component

…ference interace instead of the concrete DialogReference class.
@vnbaaij
Copy link
Collaborator

vnbaaij commented Nov 13, 2025

I'm not opposed to this, but can you elaborate on what we gain from it?

@StevenRasmussen
Copy link
Contributor Author

As mentioned in the description, when you use one of the methods to create a reference to a dialog (e.g. ShowDialog or ShowPanel) then you get back an IDialogReference. If you want to close that dialog via the CloseDialog method, you now have to do some checks to ensure that you actually have an instance of the concrete type DialogReference and not just an object that implements the IDialogReference interface. So your logic is at worst:

var dialogReference = _dialogService.ShowDialog(...);

// Not type safe and could be false and cause an error
_dialogService.CloseDialog(dialogReference as DialogReference)

OR

var dialogReference = _dialogService.ShowDialog(...);

if(dialogReference is DialogReference realDialogReference)
{
    _dialogService.CloseDialog(realDialogReference);
}

Either way... the methods should be consistent in what type they return and accept (unless of course there is a good reason for it which doesn't appear to be the case in this instance). You could change the ShowDialog and ShowPanel methods to return the concrete type of DialogReference or change the CloseDialog methods to accept an IDialogReference as is being suggested by this PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants