mono / mono

Mono open source ECMA CLI, C# and .NET implementation.
https://www.mono-project.com
Other
10.94k stars 3.81k forks source link

System.IO didn't implement Hidden attribute flag on macOS #17304

Open Odirb opened 4 years ago

Odirb commented 4 years ago

On macOS, a file is considered hidden if: 1) it starts by "." (like on every unix system) 2) it has a macOS hidden flag 3) it has an HFS+ hidden flag

The Xamarin object NSUrl can be used to read/write (at least for cases 2 and 3) these hidden flags, but the standard .Net library System.IO did not:

Steps to Reproduce

  1. Hide a file using macOS flags with command "chflags hidden secret1.txt"

  2. Hide a file using HFS+ hidden flag with command "setfile -a V secret2.txt"

  3. Set hidden file to "secret3.txt" file using SetAttributes function File.SetAttributes("secret3.txt", FileAttributes.Hidden);

  4. Call function System.IO.File.GetAttributes on both files

        var attr1 = System.IO.File.GetAttributes("secret1.txt");
        var attr2 = System.IO.File.GetAttributes("secret2.txt");
        var attr3 = System.IO.File.GetAttributes("secret3.txt");

Current Behavior

All variables attr1, attr2 and attr3 are set to System.IO.FileAttributes.Normal

Expected Behavior

Attr1, attr2 and attr3 should be equals to System.IO.FileAttributes.Hidden

On which platforms did you notice this

[ X] macOS [ ] Linux [ ] Windows

Version Used:

=== Visual Studio Professional 2019 for Mac ===

Version 8.3.3 (build 8) Installation UUID: 75bd4b72-ac43-4f4b-8f2b-8a152358eb1b GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 5.16.1.24 (d16-3 / 08809f5b)

Package version: 604000208

=== Mono Framework MDK ===

Runtime: Mono 6.4.0.208 (2019-06/07c23f2ca43) (64-bit) Package version: 604000208

=== NuGet ===

Version: 5.3.0.6192

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.0.100/Sdks SDK Versions: 3.0.100 2.1.701 2.1.700 2.1.4 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 3.0.0 2.1.13 2.1.12 2.1.11 2.0.5

=== Xamarin.Profiler ===

Version: 1.6.12.26 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin.Android ===

Version: 10.0.3.0 (Visual Studio Professional) Commit: xamarin-android/d16-3/4d45b41 Android SDK: /Users/christophe/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: None installed

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 28.0.2 SDK Build Tools Version: 28.0.3

Build Information: Mono: mono/mono/2019-06@5608fe0abb3 Java.Interop: xamarin/java.interop/d16-3@5836f58 LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94 LibZip: nih-at/libzip/rel-1-5-1@b95cf3fd ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.27.1@8212a2d Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-3@cb41333

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/christophe/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25 1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 1.4.0.65 Hash: c33b107 Branch: remotes/origin/d16-3 Build date: 2019-10-08 23:36:20 UTC

=== Android Device Manager ===

Version: 1.2.0.116 Hash: d2b2af0 Branch: remotes/origin/d16-3 Build date: 2019-10-08 23:36:44 UTC

=== Xamarin Designer ===

Version: 16.3.0.247 Hash: 52eac1a9e Branch: remotes/origin/d16-3 Build date: 2019-10-03 23:04:28 UTC

=== Apple Developer Tools ===

Xcode 11.1 (15405) Build 11A1027

=== Xamarin.Mac ===

Version: 6.4.0.2 (Visual Studio Professional) Hash: e37549bc Branch: xcode11.1 Build date: 2019-10-07 22:43:23-0400

=== Xamarin.iOS ===

Version: 13.4.0.2 (Visual Studio Professional) Hash: e37549bc Branch: xcode11.1 Build date: 2019-10-07 22:43:23-0400

=== Xamarin Inspector ===

Version: 1.4.3 Hash: db27525 Branch: 1.4-release Build date: Mon, 09 Jul 2018 21:20:18 GMT Client compatibility: 1

=== Build Information ===

Release ID: 803030008 Git revision: fb0d3af49f0ea88661a4f469b9dfd1018dc099cd Build date: 2019-10-10 10:53:35+00 Build branch: release-8.3 Xamarin extensions: 3f8e699ba26ed5f69b7a6466ba679f4a328fadb4

=== Operating System ===

Mac OS X 10.15.0 Darwin 19.0.0 Darwin Kernel Version 19.0.0 Wed Sep 25 20:18:50 PDT 2019 root:xnu-6153.11.26~2/RELEASE_X86_64 x86_64

Stacktrace

n/a

marek-safar commented 4 years ago

@steveisok we could check corefx upstream first

steveisok commented 4 years ago

So, it works in .net core 3, but does not in 2.2.

It seems like we need to pull in this change https://github.com/dotnet/corefx/pull/34560

Odirb commented 4 years ago

Hello @steveisok, This pull request partially fix the problem: the macOS hidden flag (changed by "chflags" command) works with .Net core 3, but the HFS+ flag (changed by "setfile" command) still didn't works.

You can reproduce the problem with this sample project: https://github.com/Odirb/BugHiddenFiles

steveisok commented 4 years ago

@Odirb Thanks for the info.