dotnet / dotnet/dotnet-api-docs
MessageProperties.Item[string] can throw, but documentation claims null is returned
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
In the documentation for `MessageProperties.Item[string]`, it is claimed that:
> The property with the specified name, or null if the property does not exist.
This is incorrect. The code will throw an exception if the property does not exist. This is not mentioned in the documentation.
Rendered documentation:
https://learn.microsoft.com/en-us/dotnet/api/system.servicemodel.channels.messageproperties.item?view=dotnet-plat-ext-6.0&viewFallbackFrom=net-6.0#system-servicemodel-channels-messageproperties-item(system-string)
Documentation source:
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.ServiceModel.Channels/MessageProperties.xml
dotnet/wcf source code:
https://github.com/dotnet/wcf/blob/4e2a97e639417fd14158c9e7f0bb36de342a667d/src/System.Private.ServiceModel/src/System/ServiceModel/Channels/MessageProperties.cs#L73
4.8 reference source has the same behaviour:
https://referencesource.microsoft.com/#System.ServiceModel/System/ServiceModel/Channels/MessageProperties.cs,67
Contributor guide
Assessment
This issue has not been assessed yet.