-
Notifications
You must be signed in to change notification settings - Fork 937
Closed
Description
Describe the bug
The signature of this method is currently
public virtual Task<dynamic> OpenAsync<T>(string title, Dictionary<string, object>? parameters = null, DialogOptions? options = null) where T : ComponentBaseIt should be
public virtual Task<dynamic> OpenAsync<T>(string title, Dictionary<string, object?>? parameters = null, DialogOptions? options = null) where T : ComponentBaseThe subtle difference here is that the dictionary's value can be a null, and therefore should be defined as object? rather than just object.
Consider this code:
private async Task ShowDetailsPopup(PersonDto? person)
{
PopupClosedArgs<PersonDto>? result = await DialogService.OpenAsync<PersonDetailsPopup>($"Edit Person",
new Dictionary<string, object?>() { { "id", person?.Id } },
new DialogOptions
{
Resizable = true,
Draggable = true,
Width = "700px",
Height = "512px",
});
if (result?.Action == PopupClosedAction.Ok)
{
var actionCompleted = person is null ? "created" : "updated";
NotificationService.Notify(NotificationSeverity.Info, $"Person {result.Data!.Name} {actionCompleted}");
}
}Expected behavior
The compiler shouldn't give you any warnings like it does right now:
Argument of type 'System.Collections.Generic.Dictionary<string,object?>' cannot be used for parameter 'parameters' of type 'System.Collections.Generic.Dictionary<string,object>?' in 'Radzen.DialogService.OpenAsync<T>' because of differences in the nullability of reference types
Note that it's completely acceptable for the passed in parameter to be nullable inside the popup component. E..g. it would be defined there as follows
@code {
[Parameter] public string? Id { get; set; }
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels