-
Notifications
You must be signed in to change notification settings - Fork 193
Fix untestable extension methods #527
Comments
If we are going to do this we should do it now, moving methods around after RC2 should be avoided. |
another alternative might be to add an overload that takes |
Ughm |
Add an overload where? For SendFile? What about the |
@khellang Those are the 2 options. Either promote to interface or use some overload that takes a writable file abstraction. |
For SendFile, we should allow passing |
Moving this to Backlog as we will be in RC2 ask mode very soon. If you feel strongly about this issue, please ping me. |
On the Form file extensions, why not The |
I think |
Only problem with extension methods is that it reintroduces the original problem if you ever use them... Which is what the original problem and why this bug was filed 😄 |
Yes and no. You can still mock the |
Also, if it's changed to a |
If we add |
So no point in adding a convenience method for saving to a path? Like public static void SaveAs(this IFormFile file, string path)
{
using (var fileStream = File.Create(path, DefaultBufferSize))
{
file.Save(fileStream);
}
} |
It just means you can't test it is all. |
It's better in general for devs to call File.Create for themselves. Otherwise you'll end up with some (but not all) of the APIs that take Stream having a string overload for convenience, but you don't know what flags they pass. What file sharing for example? Fail if file exists? Those details may not be consistent if you took a look at how the various convenience methods create files on your behalf... |
Wouldn't that be |
These methods demand that files be on disk. What makes it worse is that these are extension methods so they cannot be stubbed.
Maybe we should make these virtual on
HttpResponse
andIFormFile
(interface method)./cc @Eilon @Tratcher @lodejard
The text was updated successfully, but these errors were encountered: