dotnet / dotnet/dotnet-api-docs

Assigning things into Data throws if the key or value isn't Serializable. this should be documented.

Open
#10,002 1 comment 0 reactions 0 assignees View on GitHub
area-System.Runtime Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

The sourcecode of ListDictionaryInternal is explicit:
```cs
if (key == null)
{
throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key"));
}
if (!key.GetType().IsSerializable)
{
throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), "key");
}
if (value != null && !value.GetType().IsSerializable)
{
throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), "value");
}
```

i think this should at least be mentioned in the documentation, e.g. somewhere here:
https://learn.microsoft.com/en-us/dotnet/api/system.exception.data?view=netframework-4.8#system-exception-data

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.