Skip to content
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

[iOS] Make Environment.GetFolderPathCore Xamarin.iOS compatible #41959

Merged
merged 2 commits into from
Sep 10, 2020

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Sep 8, 2020

@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@@ -78,7 +78,7 @@ private static string GetFolderPathCore(SpecialFolder folder, SpecialFolderOptio
return CombineSearchPath(NSSearchPathDirectory.NSLibraryDirectory, "Favorites");

case SpecialFolder.ProgramFiles:
return Interop.Sys.SearchPath(NSSearchPathDirectory.NSApplicationDirectory);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doea this API not give the correct result on iOS? Does Apple intend that code that wants to run on both should hard code it instead?

Copy link
Member Author

@EgorBo EgorBo Sep 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danmosemsft these are different folders as far as I understand, e.g. /Applications on iOS simulator returns actual /Applications from the host (I guess on a device it's a symlink). And our goal is to be compatible with whatever current Xamarin.IOS returns (based on mono/mono impl)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we detect when we're on macOS and continue to use NSApplicationDirectory? I'm just having trouble understanding why Apple offers an API if the correct answer is always /Applications. Even if that's what Mono offers - we should try to do the right thing, and Mono compat on macOS (rather than iOS) perhaps is less important. If they move it in future, presumably NSApplicationDirectory protects us?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe compatibility with existing code is quite important, which is why I believe we should continue returning the same values as mono does.

That being said, the /Applications directory is quite useless on Apple's mobile platforms, because apps don't have read access to it (presumably that's why NSApplicationDirectory returns something else, even though Apple has it documented to return /Applications). I'm not sure what the best option here is, but returning NSApplicationDirectory doesn't seem like a bad choice.

On macOS I'd be fine with using NSApplicationDirectory, if that returns /Applications today.

On a separate note, the values mono returns are different in some cases for tvOS: mono/mono@77fb5c9#diff-ba633813d1681ae2aabd0a6bbd741f87R21-R30, and it doesn't look like .NET does that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regarding the tvOS (we don't support it yet) - we have a note in the code.
So should a leave it as is or bring back NSApplicationDirectory?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, bring back NSApplicationDirectory for ProgramFiles.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably makes sense to leave it until later and file an issue.

@EgorBo EgorBo merged commit 537155c into dotnet:master Sep 10, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS: Some of the Environment.SpecialFolders values are incorrect with regards to Xamarin.iOS
6 participants