question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IStorageProvider.OpenFilePickerAsync does not return

See original GitHub issue

Describe the bug In some cases the file picker dialog never returns from the IStorageProvider.OpenFilePickerAsync method on Linux using the DBus file picker.

To Reproduce Open a file picker with an extension starting with a numeric value:

        var storageProvider =  TopLevel.GetTopLevel(_visual)!.StorageProvider;
        var myFile    = new FilePickerFileType("My file starting with a numeric extension");
        myFile.Patterns = new []{"*.123file"};
        
        var startingLocation = (await storageProvider.TryGetWellKnownFolderAsync(WellKnownFolder.Downloads))
            ?? (await storageProvider.TryGetWellKnownFolderAsync(WellKnownFolder.Documents));

        var selection = await storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
        {
            AllowMultiple          = false,
            FileTypeFilter         = new[] { myFile },
            Title                  = "Please select a file to open",
            SuggestedStartLocation = startingLocation
        });
         
        var file = selection.SingleOrDefault();

Run and select a file matching your filter.

The last line var file = selection.SingleOrDefault(); will never be reached and no exceptions are thrown. The call to OpenFilePickerAsync just never returns.

When cancelling or selecting a file using either a filter not starting with a number extension or just no filter at all, then the method returns.

Expected behavior Either return a value, null or throw an exception but the method should not block when the file picker closes. Ideally one would expect the file picker to work and return the selected file info, even if the filter’s extension starts with a number.

Desktop (please complete the following information):

  • OS: Linux
  • Distribution: OpenSUSE Tumbleweed 20230515
  • Graphics Platform: X11
  • Desktop Environment: KDE Plasma 5.27.5
  • Kernel: 6.3.1-2-default (64-bit)
  • Version 11.0.0-preview-8

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
maxkatz6commented, May 26, 2023

@dirkackerman https://github.com/AvaloniaUI/Avalonia/pull/11526 PR should fix this issue, or at least throw a proper error.

0reactions
dirkackermancommented, Jun 5, 2023

Tested on RC1.1 and it does not throw an error, its actually fixed the issue. My KDE dialog is now accepting the file extension starting with a numeric value. (I did update my OS in the mean time, don’t know if that helped).

Thanks a lot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

FreeDesktop folder picker doesn't work · Issue #9383
Describe the bug. Instead of OpenFolderDialog shows OpenFileDialog and in resalt returns null. To Reproduce var window = this.
Read more >
ManagedFileDialogExtensions.cs
Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET Foundation community project. - Avalonia/src/Avalonia.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found