Skip to content

Commit

Permalink
Merge pull request #8187 from AvaloniaUI/fixes/save-file-dialog-filte…
Browse files Browse the repository at this point in the history
…rs-nullable

OSX: fix file dialog filter nullable annotation, and osx platform.
  • Loading branch information
danwalmsley authored May 25, 2022
2 parents 194ddc5 + af237c6 commit 8ad9205
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion samples/ControlCatalog/ControlCatalog.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">
Expand Down
3 changes: 1 addition & 2 deletions samples/ControlCatalog/Pages/DialogsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Avalonia.Layout;
using Avalonia.Markup.Xaml;
#pragma warning disable 4014

namespace ControlCatalog.Pages
{
public class DialogsPage : UserControl
Expand All @@ -22,7 +21,7 @@ public DialogsPage()

string lastSelectedDirectory = null;

List<FileDialogFilter> GetFilters()
List<FileDialogFilter>? GetFilters()
{
if (this.FindControl<CheckBox>("UseFilters").IsChecked != true)
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Controls/SystemDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class FileDialog : FileSystemDialog
/// Gets or sets a collection of filters which determine the types of files displayed in an
/// <see cref="OpenFileDialog"/> or an <see cref="SaveFileDialog"/>.
/// </summary>
public List<FileDialogFilter> Filters { get; set; } = new List<FileDialogFilter>();
public List<FileDialogFilter>? Filters { get; set; } = new List<FileDialogFilter>();

/// <summary>
/// Gets or sets initial file name that is displayed when the dialog is opened.
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Native/SystemDialogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Task<string[]> ShowFileDialogAsync(FileDialog dialog, Window parent)
ofd.Title ?? "",
ofd.Directory ?? "",
ofd.InitialFileName ?? "",
string.Join(";", dialog.Filters.SelectMany(f => f.Extensions)));
string.Join(";", dialog.Filters?.SelectMany(f => f.Extensions) ?? Array.Empty<string>()));
}
else
{
Expand All @@ -39,7 +39,7 @@ public Task<string[]> ShowFileDialogAsync(FileDialog dialog, Window parent)
dialog.Title ?? "",
dialog.Directory ?? "",
dialog.InitialFileName ?? "",
string.Join(";", dialog.Filters.SelectMany(f => f.Extensions)));
string.Join(";", dialog.Filters?.SelectMany(f => f.Extensions) ?? Array.Empty<string>()));
}

return events.Task.ContinueWith(t => { events.Dispose(); return t.Result; });
Expand Down

0 comments on commit 8ad9205

Please sign in to comment.