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
Expose file attributes of OneDrive placeholders #8745
Conversation
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.
Nice work!
src/System.Management.Automation/namespaces/FileSystemProvider.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.
I'm not sure that we can add tests.
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
Co-Authored-By: sba923 <github.nospam4sba@xoxy.net>
Co-Authored-By: sba923 <github.nospam4sba@xoxy.net>
Strange: I've updated the code, and CodeFactor (still) reports issues that refer to the previous version of the code... What am I missing? |
Hmm... Looks like it's complaining mainly about the constants not being marked as internal/private/public. I think Ilya recommended they should all be You can probably ignore the complaints about names with underscores, though; I think that's a common style in this repo and they'll probably adjust the style rules for it sooner or later. 😄 |
I was actually fighting... my git ignorance. Now that my changes have been pushed again, CodeFactor has run again and reports only 8 issues. Checking them out. |
My understanding of what I see is that CodeFactor issues are blocking, so I will have to get rid of those underscores! |
@sba923 most of the time, yeah, but this isn't the first time I've seen it come up with issues that the PS team and maintainers don't necessarily agree with. If you're more or less done (check that failing test on the Windows CI and see if you can figure that one out and resolve if it's something your changes might have affected), just remove the WIP flag and ping the codeowners for further review. If those issues are a problem they'll let you know. 🙂 |
This is getting tough. I've tried commenting out the core of the change... and Windows CI doesn't fail anymore. This means the "placeholder mode" has an impact on the behavior of I'm going back to my C# test tool for the placeholder issue and see what I can understand from there. |
I think I'm gonna need some help...
Everything's expected (my machine has developer mode enabled). The behavior of the How could I debug that failing test in CI? |
??? reverted to the initial code, Windows CI now succeeds... |
@sba923 |
I've changed the code to get rid of the last two issues with underscores, but I could revert to the names from the SDK #define's to make the code more understandable. What do you think? |
@sba923 Yes, our guidelines say:
|
OK, will change that back (which will bring two CodeFactor issues back). BTW you asked me earlier to change |
@sba923 My understanding is that C++ CHAR is C# char and has 2 byte length so we can not use sbyte. I am ok with using char - we can always use cast to int to check result code. |
IIRC CHAR is a typedef for C/C++ char which is a signed 8-bit type, so not the same as C# char which is a UTF-16 2-byte character. TBC once I'm in front of my PC 😜 |
I expected that there is auto marshalling for char but it is not blittable. So you are right and it should be sbyte. |
Everything's green, except for CodeFactor. What's still blocking the PR from merging? |
OK, fine. |
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
I've come up with the following crude test script to be used for non-CI / interactive testing:
Would there be a way to add this to the codebase? |
Code changes made.
|
I can not open https://blogs.msdn.microsoft.com/kebab/2013/06/09/an-introduction-to-error-handling-in-powershell/ - seems the site temporary broken in the time. |
How's that related to the failing test? |
1 similar comment
How's that related to the failing test? |
The link is from the fail test. Please ignore this - we'll restart the test later. |
Oops... Hadn't checked what those links were... |
Codacy has been pending for 7 hours... anything wrong there? What about my test script question? |
Looking at a few other PRs, it seems Codacy reviews might have been disabled for the time being. Not sure about any kind of interactive test scripts, though. It might be worth looking into whether you can manually create a filesystem object with the placeholder attributes set, and then testing that the cmdlets properly retrieve that data back. |
Codacy doesn't look disabled to me, it says "Pending — Hang in there, Codacy is reviewing your Pull request." I will look into the testing approach you're suggesting. The code I shared earlier assumes the test file is created under the OneDrive sync folder, which causes the OneDrive plumbing to set some of the attributes that get maskes by the "placeholder compatibility" mechanism. I could indeed try to create a file "anywhere" with those bits set, and see what PSCore and WinPS return for that same file. |
Yeah, I'm sure if you push another commit it probably will go away. It's just an issue of Github only updating those when a commit is made, or the tool itself updates the status (which it won't if it's been disabled). |
Restarted 'PowerShell-CI-static-analysis' as the error is unrelated and was fixed by another PR. |
@sba923 Thank you for your contribution! |
You're very welcome! We haven't addressed the question of potentially keeping my (interactive) test script somewhere in the source tree.... |
@adityapatwardhan Could you please help with the test? Make sense to add it? |
Note that I haven't been able to find a way to create test files with the appropriate attributes, outside of the OneDrive client's sync folder, from the test script (yet). Without this, it's not possible to run the test in an automated way. FWIW, here's the current version of the script:
|
PR Summary
Fix #8315.
PowerShell Core must "expose" the OneDrive placeholders so as to make all their attributes visible
This is done by changing the "placeholder compatibility mode" to PHCM_EXPOSE_PLACEHOLDERS
PR Context
Without this change, PowerShell Core isn't backwards-compatible with Windows PowerShell: the attributes returned for OneDrive placeholders are not the same as in PS5.1
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.[feature]
to your commit messages if the change is significant or affects feature tests