-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standardizing basic file properties #23
Comments
For core properties, like Attributes, Size, etc, I would propsose staying with what people know/expect; either as BasicFileProperties (the UWP way) or via class properties (for example SystemFile.Attributes), the latter being my preference as this is what I would expect if I were coming from WinForms, WPF, WinUI, and most languages. I have discussed this in issue #27 For all other properties, I see 3 ways to implement: (1 & 2 allow for easy property update events as required)
|
@HEIC-to-JPEG-Dev Please note that this is for standardized properties across all implementations, not for any single implementation like You can get properties today if you use the underlying libray (see here). We're crafting a contract that all implementations can share to supply properties, without type checks or dropping to the underlying library.
Property retrieval needs to happen asynchronously, so we'll most likely go with the object approach. See OP for details on how we might do this.
We use optional interfaces to indicate support, which reduces the work needed from the implementor and enables a compile-time feature support flag. Since they're split across multiple interfaces, enumeration of all properties is going to be tricky. Interestingly, Windows.Storage uses a Enumeration of all properties will require a clever and creative approach, and is best saved for later. We want a strongly typed option to be our primary method of interacting with properties. @HEIC-to-JPEG-Dev Happy to bring you (and our watchers) up to speed - but we've actually already touched on all these things in our Discord thread for basic file properties here. We've got a first draft and some open questions, let's continue our discussion there :) |
Providing inbox interfaces takes careful consideration, even for things that have existed in other APIs for a long time, like For the most part, the problem of generalizing this can be solved in an application without having an inbox standard by passing a delegate in as a method parameter, like so: public static async Task CopyToAsync(this IFolder sourceFolder, IModifiableFolder destinationFolder, Func<IStorable, DateTime>? getLastUpdateTime = null, CancellationToken cancellationToken = default)
{
} Where await nomadFolder.CopyToAsync(workingFolder, storable => storable switch
{
ReadOnlyKuboNomadFile nFile => nFile.EventStreamEntries.Where(x => x.Id == nFile.Id).Max(x => x.TimestampUtc) ?? ThrowHelper.ThrowNotSupportedException<DateTime>("Unhandled code path"),
ReadOnlyKuboNomadFolder nFolder => nFolder.EventStreamEntries.Where(x => x.Id == nFolder.Id).Max(x => x.TimestampUtc) ?? ThrowHelper.ThrowNotSupportedException<DateTime>("Unhandled code path"),
SystemFolder systemFolder => systemFolder.Info.LastWriteTimeUtc,
SystemFile systemFile => systemFile.Info.LastWriteTimeUtc,
_ => throw new ArgumentOutOfRangeException(nameof(storable), storable, null),
}, cancellationToken); Notably, when the information is available, it should already be exposed or available to the file/folder implementation. This means we could have the implementation provide it via an optional interface instead (but no extension method/default behavior). I'd like to use this opportunity to also reassess the @yoshiask @d2dyno1 Before I proceed, do you have any examples where you've implemented |
I think IStoragePropery should derive from IStorable and we should create a new kind in StorableKind: File, Folder, Property. Standard properties Extra properties Get notified Write |
Moving the conversation here from Discord, replying to #23 (comment): @Arlodotexe said:
@itsWindows11 said:
@Arlodotexe said:
|
Still no definitive answer on enumerable properties, but we should look at implementing standard interfaces for the most common properties, specifically starting with |
We're still missing basic file properties like size and modified dates though, nobody has drafted an API in this area yet. You can extend the existing implementations and implement your own 'file property' interface, but we should really get this spec'd out.
We're going to discuss this on Discord and hash out what this might look like, then return with a rough draft.
This ticket filed for tracking.
Additional information
Storage properties
"Storage properties" are the additional information about a resource provided by most file systems. It's everything from the name to the "Last modified" date to the Thumbnail, and the majority of them can change / be changed.
In AbstractStorage, we simply copied the c# properties and recreated
StorageFileContentProperties
, and even though we only addedGetMusicPropertiesAsync
and made the property nullable, it caused a lot of confusion for everyone else who implemented it.We'll continue using our strategy of "separate interfaces" for this. However, there are a LOT of storage properties we can add, so as long as we separate them into different interfaces, can safely leave "which" for later and instead figure out the "how".
There are 3 requirements
This gives us 2 options:
SetThingAsync
methods, on an object retrieved from an async method.GetThingAsync
Methods +SetThingAsync
methodsAfter some brainstorming, we have a basic skeleton that serves as a guide for any property set.
Doing it this way means
UpdateMusicPropertiesAsync()
vsChangeNameAsync()
).The text was updated successfully, but these errors were encountered: