Skip to content

System.DirectoryServices nullability follow-up #49128

@krwq

Description

@krwq

While adding nullable annotations to System.DirectoryServices I've found few inconsistencies which need a bit more investigation or some more background in the area.

  • Consider making PropertyManager.GetPropertyValue return non-nullable. Currently it's marked as returning nullable because there is currently nothing guarding against publicly available DirectoryEntry.Properties[anyName].Add(null) which means it technically can return null. I'm not sure we can ever get null from the network.
  • DirectorySearcher.Filter is currently marked as nullable but there are couple of clues it actually should be marked as: [AllowNull] public string Filter ... - the reason it's marked as nullable is because:
    • public DirectorySearcher(DirectoryEntry? searchRoot, string? filter, string[]? propertiesToLoad, SearchScope scope) is assigning filter directly and does not do any validation
      • Most likely constructor should be assigning to the property rather than field - in my opinion it's not intentional but I'm not 100% sure on that and we try to avoid making any product changes during nullable annotations
    • in Utils.cs: internal static Hashtable GetValuesWithRangeRetrieval(DirectoryEntry searchRootEntry, string? filter, ArrayList propertiesWithRangeRetrieval, ArrayList propertiesWithoutRangeRetrieval, SearchScope searchScope) is being called with explicit null from DirectoryServer.cs GetParitions() (call goes through internal static Hashtable GetValuesWithRangeRetrieval(DirectoryEntry searchRootEntry, string? filter, ArrayList propertiesToLoad, SearchScope searchScope))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions