-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Behavior changed about filesystemInfo.Attributes
in .NET Core preview2/3 causes 2 tests to fail in Get-ChildItem.Tests.ps1
#4145
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
Comments
What I'm seeing on both platforms is that the exception is no longer thrown, but After the item is written to the pipeline, when it is displayed, the I think it might be worth keeping the provider code as is (I don't think the |
It seems we should refresh to get -1 https://github.com/dotnet/corefx/blob/801dde95a5eac06140d0ac633ac3f9bfdd25aca5/src/System.IO.FileSystem/src/System/IO/FileSystemInfo.Unix.cs#L264 |
I had fetched the latest source (commit ece27ff), done a new |
I meant that we should call Refresh() or Exists() to get fresh FileAttributes. |
@iSazonov You were exactly right. I hadn't realized there was a Assuming we want to continue with the current behavior, i.e. writing an error message and continuing the enumeration, I'm preparing a PR to do that. |
That means calling |
Yes, it is expensive. I think we should avoid this. Now we haven't exception so maybe silently ignore this? |
If we don't refresh and check for -1, we should end up displaying the file as if it had not (yet) been deleted. Whether that's the right thing may depend on how the cmdlet is being used. |
The file system is constantly changing, so perhaps this is the expected behavior. We can also skip new files or changing their size if it happens later we read first the list. |
I quite agree. So long as our users understand that the file system is this dynamic, then this should be the expected behavior. So my take is that we leave the cmdlet code as is, with no additional call to |
I quite agree that we should keep the
|
If we remove the test hooks, the tests themselves don't make much sense. That being said, I'm in favor of removing the test hooks and the tests. |
I agree to remove the test hooks and tests:
|
@daxian-dbw is there anything more to do with this one? |
Nothing needs to be done. This issue was not closed when merging #4200 |
In
2.0.0-preview1
.NET Core,filesystemInfo.Attributes
raises anFileNotFoundException
exception when the file is deleted or renamed during the enumration.In
2.0.0-preview2/3
.NET Core,filesystemInfo.Attributes
returns -1 without raising any exception.This behavior change was by design -- to align with the current behavior on Full .NET. For detailed information, please see https://github.com/dotnet/corefx/issues/20456.
This behavior change causes the following tests to fail in test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 (they will be marked as pending for now):
These 2 tests were added in PR #3806, which assumes that the
FileNotFoundException
will be thrown in case the file is deleted or renamed during enumeration. Since the behavior has changed in .NET Core, the fix needs to be revisited./cc @jeffbi
The text was updated successfully, but these errors were encountered: