question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Behavior changed about `filesystemInfo.Attributes` in .NET Core preview2/3 causes 2 tests to fail in `Get-ChildItem.Tests.ps1`

See original GitHub issue

In 2.0.0-preview1 .NET Core, filesystemInfo.Attributes raises an FileNotFoundException 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):

  • “Should continue enumerating a directory when a contained item is deleted”
  • “Should continue enumerating a directory when a contained item is renamed”

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
jeffbicommented, Jul 6, 2017

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 Refresh(), and modify the tests to verify that the cmdlet does not show an error but instead retrieves the file information it can.

0reactions
daxian-dbwcommented, Aug 1, 2017

Nothing needs to be done. This issue was not closed when merging #4200

Read more comments on GitHub >

github_iconTop Results From Across the Web

Recent change to Attribute.GetCustomAttributes is ...
I know it's possible that this was an intentional breaking change and perhaps the correct resolution is to change things in ASP.NET Core....
Read more >
c# - Problems with DeploymentItem attribute
The test methods have a DeploymentItem attribute, specifying a text file which is parsed by the business logic method that is being tested...
Read more >
FileSystemInfo.Attributes Property (System.IO)
The caller attempts to set an invalid file attribute. -or- .NET Framework only: The user attempts to set an attribute value but doesn't...
Read more >
Be careful with .NET Core Folder Structure - Simple Talk
I'm working on some personal .NET Core projects and I faced some strange errors. Ok, I'm too fresh on .NET Core and I...
Read more >
PowerShell script to change OneDrive file attributes
This causes OneDrive to slow down or just get stuck syncing. I found a way to perform a mass change of the file/folder...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found