Skip to content

BCL: Encountering System.NullReferenceException when 'enumerationOptions' parameter of Directory.EnumerateFiles method is null #114623

@hrumhurum

Description

@hrumhurum

Description

The following methods throw System.NullReferenceException when their enumerationOptions parameter is null:

  • Directory.EnumerateFiles(String, String, EnumerationOptions)
  • Directory.EnumerateDirectories(String, String, EnumerationOptions)
  • Directory.EnumerateFileSystemEntries(String, String, EnumerationOptions)

Instead, they should throw System.ArgumentNullException when enumerationOptions parameter is null.

Reproduction Steps

Directory.EnumerateFiles(@"C:\", "*", (EnumerationOptions)null);

Expected behavior

  • System.ArgumentNullException: Value cannot be null. (Parameter 'enumerationOptions')

Actual behavior

  • System.NullReferenceException: Object reference not set to an instance of an object.

Regression?

No response

Known Workarounds

No response

Configuration

.NET SDK 9.0.203

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.IOhelp wanted[up-for-grabs] Good issue for external contributors

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions