Repository navigation
feat: Implemented FileSavePicker on MacOS - #4215
Conversation
| public string CommitButtonText { get; set; } | ||
|
|
||
| public IDictionary<string, IList<string>> FileTypeChoices { get; set; } | ||
| public IDictionary<string, IList<string>> FileTypeChoices { get; set; } = new Dictionary<string, IList<string>>(); |
There was a problem hiding this comment.
In UWP FileTypeChoices is get only: https://docs.microsoft.com/en-us/uwp/api/windows.storage.pickers.filesavepicker.filetypechoices?view=winrt-19041
We should change to { get; } = or { get; private set; } =
There was a problem hiding this comment.
Indeed. This will introduce a breaking change that will need to be flagged in PackageDiffIgnore.xml, and is not supposed to be valid anyways as it can't be used by any UWP compatible codebase.
There was a problem hiding this comment.
Alternatively make the setter obsolete (C# 8) as follows:
private IDictionary<string, IList<string>> fileTypeChoices;
public IDictionary<string, IList<string>> FileTypeChoices
{
get => fileTypeChoices ?? = new Dictionary<string, IList<string>>(); //or initialize backing field
[Obsolete("This setter will be removed in future versions.")]
set = fileTypeChoices = value;
}There was a problem hiding this comment.
@weitzhandler This change may not be acceptable without nullable references, as FileTypeChoices may be null and must be validated at all uses sites. If #nullable enable is added, then yes, it's useful.
There was a problem hiding this comment.
@jeromelaban are you talking about the ??= operator?
There was a problem hiding this comment.
Yes, if the fileTypeChoices member is used elsewhere in the class, it may fail because of a null reference exception.
There was a problem hiding this comment.
Even with nullable reference, the issue still exists, if FileTypeChoices is set to null externally (via the property).
Unless we also ensure initialized in setter.
There was a problem hiding this comment.
Alternatively
private readonly IDictionary<string, IList<string>> fileTypeChoices =
new Dictionary<string, IList<string>>();
public IDictionary<string, IList<string>> FileTypeChoices
{
get => fileTypeChoices;
[Obsolete("This setter will be removed in future versions.")]
set
{
if(value?.Any())
{
fileTypeChoices.Clear();
foreach(var kv in value)
{
fileTypeChoices.Add(kv);
}
}
}
}There was a problem hiding this comment.
@jeromelaban - I'm assuming I need to merge the PackageDiffIgnore.xml from master into my branch and add the setter in and try this the CI again?
| var savePicker = new NSSavePanel(); | ||
| savePicker.DirectoryUrl = new NSUrl(GetStartPath(), true); | ||
| savePicker.AllowedFileTypes = GetFileTypes(); | ||
| if(SuggestedFileName != null) |
There was a problem hiding this comment.
I'm always puzzled by this. It could be that VS4mac does not support the .editorconfig file properly.
There was a problem hiding this comment.
I THINK it is. I just found documentation for it, but it was my fault for not executing a Format Document on everything before committing.
There was a problem hiding this comment.
No worries at all, coding guidelines evolved a bit over the course of time, though reformatting a whole document when modifying an existing one is generally not a good idea for a feature PR as it makes reviewing more complicated. For new files, it's a good idea! (Along with #nullable enable)
| { | ||
| public partial class FileSavePicker | ||
| { | ||
| public PickerLocationId SuggestedStartLocation { get; set; } |
There was a problem hiding this comment.
SuggestedStartLocation should be shared by all implementations. Please move to FileSavePicker.cs
There was a problem hiding this comment.
@robloo Thanks not exactly the case here, as it is defined as not implemented in the generated APIs file. If this members ends up being implemented by all platforms, then it'll have to be moved.
There was a problem hiding this comment.
ah, ok. I assumed it would be implemented on all as it is an enum property (and this PR adds the enum). Shouldn't we just flag it as implemented for all platforms at once? Of course the value can be ignored on a per platform basis.
There was a problem hiding this comment.
We should probably have some clearer directives on such implementations, but for now, properties have more weight than enum values (as enums could be used in different classes). Marking a property implemented just for the platform makes sense here, as it is only used for two platforms (and it's only an autoproperty).
| PickerLocationId.PicturesLibrary => Environment.SpecialFolder.MyPictures, | ||
| PickerLocationId.VideosLibrary => Environment.SpecialFolder.MyVideos, | ||
| _ => Environment.SpecialFolder.Personal | ||
|
|
| @@ -0,0 +1,39 @@ | |||
| namespace Windows.Storage.Pickers | |||
There was a problem hiding this comment.
nit: might want to remove all extra new lines in this file
|
Thanks for your contribution @snickler ! |
|
Thanks everyone! I haven't interacted with the Code Suggestions in GitHub before, I'm assuming that Resolve Conversation will apply the suggestions as it would in Azure DevOps? |
Not for my comments, I didnt make any code edits to be applied. |
Ah, I confused myself. When I first clicked on the comment, the popup help made me think these were code review changes rather than the code I updated. |
In DevOps you'd also need to click "Apply Change" |
|
@snickler There are conflicts now, as PickerLocationId was merged, can you resolve them please :-) ? Also - have you been able to find a way to fix the "Documents" picker location? I remember we didn't resolve that during the live coding :-) |
I haven't done that yet. I'll actually see if I can fix that in this PR. |
jeromelaban
left a comment
There was a problem hiding this comment.
This is looking good! The only thing left is https://github.com/unoplatform/uno/pull/4215/files#r499267336, where the set should be private. Then we'll be able to merge.
|
Congrats on your first pull-request! We ❤ the people who are involved in this project, and we’d love to pay it forward by sending you some swag. If you have any feedback (or ideas how to improve Uno as a open-source project) please open a feedback issue. |

GitHub Issue (If applicable): #3215
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Not implemented
What is the new behavior?
Implemented
PR Checklist
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information
Internal Issue (If applicable):