Skip to content

DataDictionary.Empty is not protected by potential bugs. #280

Open
@frabe1579

Description

I've found a potential source of bugs:
the class Foundatio.Utility.DataDictionary exposes a static readonly field Empty to represent empty dictionaries, but it's instance is not readonly, so values can be added to Empty causing potential bugs.
The current declaration is:

public static readonly DataDictionary Empty = new();

A new safe declaration shoud be

public static DataDictionary Empty => new();

This at least returns always empty dictionaries, but creates a new instance at every call.
Another approach should be to re-implement DataDictionary with explicit implementation of IDictionary and IReadOnlyDictionary, or something else.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions