dotnet / dotnet/aspnetcore

Make BrowserFile testable

Open
#42,690 6 comments 3 reactions 0 assignees View on GitHub
area-blazor enhancement feature-blazor-jsinterop
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

In its current state `BrowserFile` is an `internal sealed class` which makes it impossible to unit-test from the outside world.

Especially if you have functions like [`BrowserFileExtensions.RequestImageFileAsync`](https://github.com/dotnet/aspnetcore/blob/main/src/Components/Web/src/Forms/InputFile/BrowserFileExtensions.cs#L29) which takes an `IBrowserFile` but throws exceptions when invoked with everything besides the concrete **internal** `BrowserFile` type.

### Describe the solution you'd like

The easiest and least invasive solution would be to make the `BrowserFile` type `public` and not `sealed`.

### Additional context

_No response_

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.