dotnet / dotnet/dotnet-api-docs

MessageProperties.Item[string] can throw, but documentation claims null is returned

Open
#8,601 1 comment 0 reactions 0 assignees View on GitHub
area-System.ServiceModel Pri3 untriaged
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

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.