Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions docs/linux-port/compat-off-baseline.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
# Compiler error keys of: dotnet build src/Files.App -f net10.0-desktop -p:FilesWin32Compat=false
# One "file: error CODE: message" per line. Regenerate with scripts/linux/compat-off-check.sh --update.
src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs: error CS0246: The type or namespace name 'ContextMenu' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Data/Items/ContextMenu.cs: error CS0246: The type or namespace name 'MENU_ITEM_TYPE' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Data/Items/ListedItem.cs: error CS0246: The type or namespace name 'SHOW_WINDOW_CMD' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Data/Items/ShellLinkItem.cs: error CS0246: The type or namespace name 'SHOW_WINDOW_CMD' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Data/Items/WidgetRecentItem.cs: error CS0246: The type or namespace name 'IShellItem' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Data/Models/RemovableDevice.cs: error CS0234: The type or namespace name 'FileSystem' does not exist in the namespace 'Windows.Win32.Storage' (are you missing an assembly reference?)
src/Files.App/Data/Models/RemovableDevice.cs: error CS0234: The type or namespace name 'Win32PInvoke' does not exist in the namespace 'Files.App.Helpers' (are you missing an assembly reference?)
src/Files.App/Helpers/UI/UIFilesystemHelpers.cs: error CS0246: The type or namespace name 'SHOW_WINDOW_CMD' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/UserControls/Toolbar.xaml.cs: error CS0246: The type or namespace name 'OpenWithMenu' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs: error CS0246: The type or namespace name 'Win32PInvoke' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Utils/Storage/Helpers/FileTypesHelper.cs: error CS0234: The type or namespace name 'FileSystem' does not exist in the namespace 'Windows.Win32.Storage' (are you missing an assembly reference?)
src/Files.App/Utils/Storage/Helpers/FilesystemResult.cs: error CS0122: 'BOOL' is inaccessible due to its protection level
src/Files.App/Utils/Storage/Helpers/FolderHelpers.cs: error CS0234: The type or namespace name 'FileSystem' does not exist in the namespace 'Windows.Win32.Storage' (are you missing an assembly reference?)
src/Files.App/Utils/Storage/Helpers/StorageHelpers.cs: error CS0234: The type or namespace name 'FileSystem' does not exist in the namespace 'Windows.Win32.Storage' (are you missing an assembly reference?)
src/Files.App/Utils/Storage/Helpers/SyncRootHelpers.cs: error CS0234: The type or namespace name 'WinRT' does not exist in the namespace 'Windows.Win32.System' (are you missing an assembly reference?)
src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs: error CS0103: The name 'SHOW_WINDOW_CMD' does not exist in the current context
src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs: error CS0122: 'HRESULT' is inaccessible due to its protection level
src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs: error CS0122: 'HWND' is inaccessible due to its protection level
src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs: error CS0234: The type or namespace name 'FILEOPERATION_FLAGS' does not exist in the namespace 'Windows.Win32.UI.Shell' (are you missing an assembly reference?)
src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs: error CS0234: The type or namespace name 'PROPERTYKEY' does not exist in the namespace 'Windows.Win32.Foundation' (are you missing an assembly reference?)
src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs: error CS0234: The type or namespace name 'SLR_FLAGS' does not exist in the namespace 'Windows.Win32.UI.Shell' (are you missing an assembly reference?)
src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs: error CS0246: The type or namespace name 'Disposable' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs: error CS0246: The type or namespace name 'SHOW_WINDOW_CMD' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs: error CS0246: The type or namespace name 'ShellFileOperations2' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs: error CS0246: The type or namespace name 'ShellItem' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Utils/Storage/Operations/FilesystemHelpers.cs: error CS0234: The type or namespace name 'FileSystem' does not exist in the namespace 'Windows.Win32.Storage' (are you missing an assembly reference?)
src/Files.App/Utils/Storage/Search/FolderSearch.cs: error CS0234: The type or namespace name 'FileSystem' does not exist in the namespace 'Windows.Win32.Storage' (are you missing an assembly reference?)
src/Files.App/Utils/Storage/Search/FolderSearch.cs: error CS0246: The type or namespace name 'FindCloseSafeHandle' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Utils/Storage/Search/FolderSearch.cs: error CS0246: The type or namespace name 'WIN32_FIND_DATAW' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Utils/Storage/StorageItems/ShellStorageFile.cs: error CS0246: The type or namespace name 'SHOW_WINDOW_CMD' could not be found (are you missing a using directive or an assembly reference?)
src/Files.App/Utils/Storage/StorageItems/ShellStorageFolder.cs: error CS0246: The type or namespace name 'SHOW_WINDOW_CMD' could not be found (are you missing a using directive or an assembly reference?)
Expand All @@ -35,4 +17,3 @@ src/Files.App/Utils/Storage/StorageItems/StreamWithContentType.cs: error CS0122:
src/Files.App/Utils/Storage/StorageItems/StreamWithContentType.cs: error CS0122: 'STGMEDIUM' is inaccessible due to its protection level
src/Files.App/Utils/Storage/StorageItems/VirtualStorageItem.cs: error CS0234: The type or namespace name 'FileSystem' does not exist in the namespace 'Windows.Win32.Storage' (are you missing an assembly reference?)
src/Files.App/ViewModels/ShellViewModel.cs: error CS0234: The type or namespace name 'Win32PInvoke' does not exist in the namespace 'Files.App.Helpers' (are you missing an assembly reference?)
src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs: error CS0234: The type or namespace name 'FileSystem' does not exist in the namespace 'Windows.Win32.Storage' (are you missing an assembly reference?)
4 changes: 4 additions & 0 deletions src/Files.App/Data/Items/IListedItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ public interface IListedItem
DateTimeOffset ItemDateCreatedReal { get; set; }
string? ItemDateModified { get; }
DateTimeOffset ItemDateModifiedReal { get; set; }
#if WINDOWS
BaseStorageFile? ItemFile { get; set; }
#else
IFile? ItemFile { get; set; }
#endif
string? ItemNameRaw { get; set; }
string? ItemPath { get; set; }
ObservableCollection<FileProperty>? ItemProperties { get; set; }
Expand Down
24 changes: 24 additions & 0 deletions src/Files.App/Data/Items/ListedItem.Windows.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

using System.IO;
using Windows.Storage;

namespace Files.App.Utils
{
public sealed partial class FtpItem
{
public async Task<IStorageItem> ToStorageItem()
{
var path = this.GetRequiredPath();
var name = ItemNameRaw ?? throw new InvalidOperationException("The FTP item does not have a name.");

return PrimaryItemAttribute switch
{
StorageItemTypes.File => await new Utils.Storage.FtpStorageFile(path, name, ItemDateCreatedReal).ToStorageFileAsync(),
StorageItemTypes.Folder => new Utils.Storage.FtpStorageFolder(path, name, ItemDateCreatedReal),
_ => throw new InvalidDataException("The FTP item has an unsupported storage type."),
};
}
}
}
23 changes: 8 additions & 15 deletions src/Files.App/Data/Items/ListedItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using System.IO;
using System.Text;
using Windows.Storage;
using Windows.Win32.UI.WindowsAndMessaging;
using ByteSize = ByteSizeLib.ByteSize;

#pragma warning disable CS0618 // Type or member is obsolete
Expand Down Expand Up @@ -496,8 +495,13 @@ public override string ToString()
public bool IsDriveRoot => ItemPath == PathNormalization.GetPathRoot(ItemPath);
public bool IsElevationRequired { get; set; }

#if WINDOWS
private BaseStorageFile? itemFile;
public BaseStorageFile? ItemFile
#else
private IFile? itemFile;
public IFile? ItemFile
#endif
{
get => itemFile;
set => SetProperty(ref itemFile, value);
Expand Down Expand Up @@ -607,18 +611,7 @@ public FtpItem(FtpListItem item, string folder) : base(null)
IsHiddenItem = false;
}

public async Task<IStorageItem> ToStorageItem()
{
var path = this.GetRequiredPath();
var name = ItemNameRaw ?? throw new InvalidOperationException("The FTP item does not have a name.");

return PrimaryItemAttribute switch
{
StorageItemTypes.File => await new Utils.Storage.FtpStorageFile(path, name, ItemDateCreatedReal).ToStorageFileAsync(),
StorageItemTypes.Folder => new Utils.Storage.FtpStorageFolder(path, name, ItemDateCreatedReal),
_ => throw new InvalidDataException("The FTP item has an unsupported storage type."),
};
}
}

public sealed partial class ShortcutItem : ListedItem, IShortcutItem
Expand All @@ -640,7 +633,7 @@ public override string? Name
public string? Arguments { get; set; }
public string? WorkingDirectory { get; set; }
public bool RunAsAdmin { get; set; }
public SHOW_WINDOW_CMD ShowWindowCommand { get; set; }
public ShowWindowCommand ShowWindowCommand { get; set; }
public bool IsUrl { get; set; }
public bool IsSymLink { get; set; }
public override bool IsScriptFile => FileExtensionHelpers.IsScriptFile(TargetPath);
Expand Down Expand Up @@ -842,7 +835,7 @@ public override string Name
public string? Arguments { get; set; }
public string? WorkingDirectory { get; set; }
public bool RunAsAdmin { get; set; }
public SHOW_WINDOW_CMD ShowWindowCommand { get; set; }
public ShowWindowCommand ShowWindowCommand { get; set; }
public bool IsUrl { get; set; }
public bool IsSymLink { get; set; }
public override bool IsScriptFile => FileExtensionHelpers.IsScriptFile(TargetPath);
Expand Down Expand Up @@ -875,7 +868,7 @@ public interface IShortcutItem : IListedItem
public string? Arguments { get; set; }
public string? WorkingDirectory { get; set; }
public bool RunAsAdmin { get; set; }
public SHOW_WINDOW_CMD ShowWindowCommand { get; set; }
public ShowWindowCommand ShowWindowCommand { get; set; }
public bool IsUrl { get; set; }
public bool IsSymLink { get; set; }
}
Expand Down
43 changes: 0 additions & 43 deletions src/Files.App/Extensions/ShowWindowCommandExtensions.Windows.cs

This file was deleted.

41 changes: 41 additions & 0 deletions src/Files.App/Extensions/ShowWindowCommandExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

namespace Files.App.Extensions
{
/// <summary>
/// Converts between <see cref="ShowWindowCommand"/> and the Win32 SHOW_WINDOW_CMD values (as ints, so no Win32 types are needed).
/// </summary>
public static class ShowWindowCommandExtensions
{
/// <summary>
/// Converts a Win32 show command (SHOW_WINDOW_CMD) to a <see cref="ShowWindowCommand"/>; unknown values map to <see cref="ShowWindowCommand.Normal"/>.
/// </summary>
public static ShowWindowCommand ToShowWindowCommand(this int command)
{
return command switch
{
3 => ShowWindowCommand.Maximized,
2 or
6 or
7 or
11 => ShowWindowCommand.Minimized,
_ => ShowWindowCommand.Normal,
};
}

/// <summary>
/// Converts a <see cref="ShowWindowCommand"/> to the Win32 show command value stored in shortcuts;
/// <see cref="ShowWindowCommand.Default"/> maps to SW_NORMAL (1).
/// </summary>
public static int ToWin32(this ShowWindowCommand command)
{
return command switch
{
ShowWindowCommand.Maximized => 3,
ShowWindowCommand.Minimized => 7,
_ => 1,
};
}
}
}
105 changes: 105 additions & 0 deletions src/Files.App/Helpers/ShareItemHelpers.Windows.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright (c) Files Community
// Licensed under the MIT License.

using Microsoft.UI.Xaml.Controls;
using Windows.ApplicationModel.DataTransfer;
using Windows.Foundation.Metadata;
using Windows.Storage;

namespace Files.App.Helpers
{
public static partial class ShareItemHelpers
{
public static async Task ShareItemsAsync(IEnumerable<ListedItem> itemsToShare)
{
if (itemsToShare is null)
return;

var interop = DataTransferManager.As<IDataTransferManagerInterop>();
IntPtr result = interop.GetForWindow(MainWindow.Instance.WindowHandle, Win32PInvoke.DataTransferManagerInteropIID);

var manager = WinRT.MarshalInterface<DataTransferManager>.FromAbi(result);
manager.DataRequested += Manager_DataRequested;

try
{
interop.ShowShareUIForWindow(MainWindow.Instance.WindowHandle);
}
catch (Exception ex)
{
manager.DataRequested -= Manager_DataRequested;

var errorDialog = new ContentDialog()
{
Title = Strings.FaildToShareItems.GetLocalizedResource(),
Content = ex.Message,
PrimaryButtonText = Strings.OK.GetLocalizedResource(),
};

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
errorDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

await errorDialog.TryShowAsync();
}

async void Manager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
sender.DataRequested -= Manager_DataRequested;

DataRequestDeferral dataRequestDeferral = args.Request.GetDeferral();
List<IStorageItem> items = [];
DataRequest dataRequest = args.Request;

foreach (ListedItem item in itemsToShare)
{
if (item is IShortcutItem shItem)
{
if (shItem.IsLinkItem && !string.IsNullOrEmpty(shItem.TargetPath))
{
dataRequest.Data.Properties.Title = string.Format(Strings.ShareDialogTitle.GetLocalizedResource(), item.Name);
dataRequest.Data.Properties.Description = Strings.ShareDialogSingleItemDescription.GetLocalizedResource();
dataRequest.Data.SetWebLink(new Uri(shItem.TargetPath));
dataRequestDeferral.Complete();

return;
}
}
else if (item.PrimaryItemAttribute == StorageItemTypes.Folder && !item.IsArchive)
{
if (await StorageHelpers.ToStorageItem<BaseStorageFolder>(item.ItemPath!) is BaseStorageFolder folder)
items.Add(folder);
}
else
{
if (await StorageHelpers.ToStorageItem<BaseStorageFile>(item.ItemPath!) is BaseStorageFile file)
items.Add(file);
}
}

if (items.Count == 1)
{
dataRequest.Data.Properties.Title = string.Format(Strings.ShareDialogTitle.GetLocalizedResource(), items.First().Name);
dataRequest.Data.Properties.Description = Strings.ShareDialogSingleItemDescription.GetLocalizedResource();
}
else if (items.Count == 0)
{
dataRequest.FailWithDisplayText(Strings.ShareDialogFailMessage.GetLocalizedResource());
dataRequestDeferral.Complete();

return;
}
else
{
dataRequest.Data.Properties.Title = string.Format(
Strings.ShareDialogTitleMultipleItems.GetLocalizedResource(),
items.Count,
"ItemsCount.Text".GetLocalizedResource());
dataRequest.Data.Properties.Description = Strings.ShareDialogMultipleItemsDescription.GetLocalizedResource();
}

dataRequest.Data.SetStorageItems(items, false);
dataRequestDeferral.Complete();
}
}
}
}
Loading
Loading