FileMultipartSection.FileStream and MultipartSection.Body Nullability Differences
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
## Background and Motivation
Not sure if this is really an API proposal, but it was the only issue template that made sense to me.
I noticed [FileMultipartSection.FileStream](https://github.com/dotnet/aspnetcore/blob/main/src/Http/WebUtilities/src/FileMultipartSection.cs#L55) is marked as a Nullable Stream, but [MultipartSection.Body](https://github.com/dotnet/aspnetcore/blob/main/src/Http/WebUtilities/src/MultipartSection.cs#L52) Stream is not Nullable. It looks like `FileMultipartSection.FileStream` is only set from the `MultipartSection.Body` so I would assume that both would have the same Nullable reference type. My only thought is that `MultipartSection.Body` has a public setter so it "could" be set to null, but if so then `FileMultipartSection.FileStream` should be null too. I could be overlooking something.
## Proposed API
Both to have the same Nullability if that assumption is correct
## Usage Examples
Either changing the MultipartSection Body property to
``` C#
public Stream? Body { get; set; } = default;
```
or changing the FileMultipartSection.FileStream to
``` C#
public Stream FileStream => Section.Body;
```
## Alternative Designs
Leave it as is. I could be looking at this wrong so I apolgize.
## Risks
Could add warnings / errors to existing code that uses the Nullable feature if the change was to `Stream` and not `Stream?`
Contributor guide
Assessment
This issue has not been assessed yet.