Skip to content

[Mac, Linux] refactor Mac platform into POSIX base#926

Merged
jrbriggs merged 11 commits intomicrosoft:masterfrom
github:refactor-mac-posix
Apr 9, 2019
Merged

[Mac, Linux] refactor Mac platform into POSIX base#926
jrbriggs merged 11 commits intomicrosoft:masterfrom
github:refactor-mac-posix

Conversation

@kivikakk
Copy link
Contributor

Here's a refactor of the Mac platform into a POSIX base. (On my end, I did the full refactor of Mac and Linux platforms, then rebased away the Linux changes.) This PR does so without introducing the Mono dependency; just moving code around.

/cc @jrbiggs, #810
/cc @chrisd8088 fyi!

Copy link
Member

@jrbriggs jrbriggs left a comment

Choose a reason for hiding this comment

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

Just one small thing.

@wilbaker can you take a look too?

public const int ReadOnly = 0x0000;
public const int WriteOnly = 0x0001;

public const int Create = 0x0200;
Copy link
Contributor

Choose a reason for hiding this comment

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

We have the same problem here as in the file-lock code; this is 0x0040 on Linux, and the various chmod-related calls should use an uint. There may be other Linux vs. BSD changes here as well, so this probably needs to be refactored into a POSIX base with Linux and Mac extensions.

Copy link
Member

Choose a reason for hiding this comment

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

There may be other Linux vs. BSD changes here as well, so this probably needs to be refactored into a POSIX base with Linux and Mac extensions.

@kivikakk, @chrisd8088, are you planning to make this change in this PR, or in a follow up PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

@kivikakk is away for a bit and as this is their work, I'm not looking to make any major changes to it right now. My own feeling at the moment is summarized by in my review comment:

To that end, the #810 PR (still a WIP) has a number of these modifications in it now, so using that as a basis for refactoring (maybe refactoring after that code has landed?) might be useful.

But I'll defer to @kivikakk to decide if they want to try to get the POSIX changes in first. For my part, I'm focused on looking at blockers to running gvfs mount on Linux, which is somewhat orthogonal work to this refactoring.

Copy link
Member

Choose a reason for hiding this comment

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

@chrisd8088 ok thanks!

Regarding the status of this PR, I think it's close being ready to merge, there are just a few open comments left from the first round of review.

/cc: @jrbriggs @kivikakk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to perform these changes later when we add the Linux platform in -- at that point we should refactor so that e.g. there's only one definition of any given native method for a given platform, whereas right now we have open and O_CREAT defined twice (in FileSystem and FileBasedLock).

It's pretty hard to get a refactor right when there's only one consumer of the code, and right now that's the case (Mac platform code is the single consumer of the POSIX platform base code). We'll maybe find more cases like this where Linux varies vs. what we've pre-emptively abstracted, but we should handle them as we implement the Linux platform in the tree, and not try to get this PR 100% correct before (imo). More important is that we get the initial refactor down asap so we don't get increasingly large deltas as time presses on.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like a reasonable plan!

@@ -1,42 +1,42 @@
using GVFS.Platform.Mac;
using GVFS.Platform.POSIX;
Copy link
Contributor

Choose a reason for hiding this comment

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

One additional thought here is that we should presumably also rename this file to GVFSHooksPlatform.POSIX.cs and adjust the various *.csproj files to use that instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There'll likely need to be one each for Mac and Linux since GetInstallerExtension will differ for both. It's a bit awkward; any thoughts? Could dump everything except GetInstallerExtension into GVFSHooksPlatform.POSIX, make the class partial, and then have a .Mac and .Linux variant with only GetInstallerExtension?

Copy link
Member

Choose a reason for hiding this comment

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

Could dump everything except GetInstallerExtension into GVFSHooksPlatform.POSIX, make the class partial, and then have a .Mac and .Linux variant with only GetInstallerExtension?

That sounds good to me. I am okay with leaving the current code as-is and making that change in a follow up PR if you prefer.

Copy link
Member

Choose a reason for hiding this comment

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

@kivikakk I just realized nothing is calling GetInstallerExtension anymore. Could you just remove it from this class (and the .Windows.cs version of this class)?

@wilbaker
Copy link
Member

/azp run GitHub VFSForGit Mac Functional Tests

2 similar comments
@kewillford
Copy link
Member

/azp run GitHub VFSForGit Mac Functional Tests

@kewillford
Copy link
Member

/azp run GitHub VFSForGit Mac Functional Tests

@wilbaker
Copy link
Member

@kivikakk @chrisd8088, @kewillford and I have been unable to kick off the Mac functional tests and we suspect it may be due to the merge conflict in GVFS/GVFS.Platform.Mac/MacPlatform.Shared.cs.

Could you resolve this conflict and we'll try kicking off the tests again?

@chrisd8088 chrisd8088 force-pushed the refactor-mac-posix branch 3 times, most recently from 0450a84 to c02a192 Compare March 23, 2019 04:05
For ease of comparsion with the original Mac-only source files,
we retain the line endings on the refactored POSIX common files to
exactly match the original ones.
@chrisd8088
Copy link
Contributor

chrisd8088 commented Mar 23, 2019

OK @wilbaker, I've rebased on the latest master and resolved the conflicts and changes which came with that, and all the CI tests pass except the one which seems "stuck".

@kewillford
Copy link
Member

/azp run GitHub VFSForGit Mac Functional Tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

kivikakk added 4 commits April 2, 2019 14:40
Some constants differ per @chrisd8088's comment here:

microsoft#926 (comment)

When we add the Linux project, we should factor *out* of
POSIXFileBasedLock what's Mac-specific.
@kivikakk
Copy link
Contributor Author

kivikakk commented Apr 2, 2019

All test passing. Let me know if this looks okay; cc @wilbaker @jrbriggs.

@jrbriggs
Copy link
Member

jrbriggs commented Apr 2, 2019

/azp run GitHub VFSForGit Mac Functional Tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@kivikakk
Copy link
Contributor Author

kivikakk commented Apr 2, 2019

Looks like Mac Functional Tests timed out after running for more than 3 hours (but passed as far as it got?).

Copy link
Member

@jrbriggs jrbriggs left a comment

Choose a reason for hiding this comment

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

Approved with suggestions.

@jrbriggs
Copy link
Member

jrbriggs commented Apr 3, 2019

/azp run GitHub VFSForGit Mac Functional Tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

Copy link
Member

@wilbaker wilbaker left a comment

Choose a reason for hiding this comment

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

Approved with suggestions

@kivikakk
Copy link
Contributor Author

kivikakk commented Apr 7, 2019

Suggestions taken up 👍

@kivikakk
Copy link
Contributor Author

kivikakk commented Apr 8, 2019

Curious if the following will work for me:

@kivikakk
Copy link
Contributor Author

kivikakk commented Apr 8, 2019

/azp run GitHub VFSForGit Mac Functional Tests

1 similar comment
@kewillford
Copy link
Member

/azp run GitHub VFSForGit Mac Functional Tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

Copy link
Member

@wilbaker wilbaker left a comment

Choose a reason for hiding this comment

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

Just one more minor file naming comment on the latest changes.

@jrbriggs
Copy link
Member

jrbriggs commented Apr 9, 2019

/azp run GitHub VFSForGit Mac Functional Tests

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@jrbriggs jrbriggs merged commit c9e404d into microsoft:master Apr 9, 2019
@chrisd8088 chrisd8088 deleted the refactor-mac-posix branch April 9, 2019 21:58
@kivikakk
Copy link
Contributor Author

Thanks for your patience with this! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants