-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[mono] Implement Environment.GetFolderPath on iOS #34022
Conversation
src/mono/netcore/System.Private.CoreLib/src/System/Environment.iOS.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Environment.Unix.cs
Outdated
Show resolved
Hide resolved
src/mono/netcore/System.Private.CoreLib/src/System/Environment.iOS.cs
Outdated
Show resolved
Hide resolved
src/mono/netcore/System.Private.CoreLib/src/System/Environment.iOS.cs
Outdated
Show resolved
Hide resolved
src/mono/netcore/System.Private.CoreLib/src/System/Environment.iOS.cs
Outdated
Show resolved
Hide resolved
src/mono/netcore/System.Private.CoreLib/src/System/Environment.iOS.cs
Outdated
Show resolved
Hide resolved
src/mono/netcore/System.Private.CoreLib/src/System/Environment.Unix.Mono.cs
Outdated
Show resolved
Hide resolved
# Conflicts: # src/mono/netcore/System.Private.CoreLib/src/System/Environment.Unix.Mono.cs
src/mono/netcore/System.Private.CoreLib/src/System/Environment.iOS.cs
Outdated
Show resolved
Hide resolved
src/mono/netcore/System.Private.CoreLib/src/System/Environment.iOS.cs
Outdated
Show resolved
Hide resolved
src/mono/netcore/System.Private.CoreLib/src/System/Environment.iOS.cs
Outdated
Show resolved
Hide resolved
src/mono/netcore/System.Private.CoreLib/src/System/Environment.iOS.cs
Outdated
Show resolved
Hide resolved
src/mono/netcore/System.Private.CoreLib/src/System/Environment.iOS.cs
Outdated
Show resolved
Hide resolved
src/mono/netcore/System.Private.CoreLib/src/System/Environment.iOS.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion, looks fine otherwise :)
src/mono/netcore/System.Private.CoreLib/src/System/Environment.iOS.cs
Outdated
Show resolved
Hide resolved
while (pos < line.Length && char.IsWhiteSpace(line[pos])) pos++; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the code here was modified, it just moved files, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Could you please approve it if it looks ok, thanks
internal static partial class Sys | ||
{ | ||
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SearchPath")] | ||
internal static extern string SearchPath(NSSearchPathDirectory folderId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's this can return null, it should be string?
. Same for other places it might propagate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephentoub should I also add #nullability enable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if Interlocked.CompareExchange(ref s_specialFolders, new Dictionary<SpecialFolder, string>(), null);
tells Roslyn it's not null anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should I also add #nullability enable ?
You shouldn't need to.
<Nullable>enable</Nullable> |
Wonder if Interlocked.CompareExchange(ref s_specialFolders, new Dictionary<SpecialFolder, string>(), null); tells Roslyn it's not null anymore
That will inform the compiler that, immediately after this call, s_specialFolders isn't null.
Unfortunately it looks like mono's Corelib.csproj is disabling all nullability warnings:
runtime/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj
Lines 123 to 125 in be469ad
<!-- Disable nullability-related warnings --> | |
<NoWarn>$(NoWarn),CS8597,CS8600,CS8601,CS8602,CS8603,CS8604,CS8609,CS8611,CS8618,CS8620,CS8625,CS8631,CS8632,CS8634</NoWarn> | |
<NoWarn>$(NoWarn),618,67</NoWarn> |
I'll take a look at fixing that.
Implements #34007
Now
Environment.GetFolderPath(...)
is fully compatible with Xamarin.iOS, e.g. on my device:fully matches with what I get via current Xamarin.iOS.
In theory it's possible to implement it on top of
getenv("HOME")
but our ios team insisted we should keep using the native API (NSFileManager) since Apple tends to change things.Also, fix
Environment.GetEnvironmentVariable
for iOS, it used to return "" always./cc @rolfbjarne