question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider adopting IFileProvider abstraction for all file system interactions

See original GitHub issue

Is your feature request related to a problem? Please describe. In various places, system.io namespace is used to check check for folders / files and read files into memory. These means there is no level of indirection for file access.

Describe the solution you’d like I would like to provide an IFileProvider to be used for all file system access (Microsoft.Extensions.FileProviders). The benefit of this, to me, is that there are many different implementations of IFileProvider that could be swapped out as needed. For example, for testing, I could use an InMemory IFileProvider (stage in memory streams for plugins and config files). At application run time, I could use the PhysicalFileProvider from IHostingEnvironment or perhaps provide an AzureBlobStorageFileProvider or 7ZipArchiveFileProvider (there are some IFileProviders that allow you to effectively mount zip archives as a file system which could be useful if you want to download plugins as zip files, and want to keep them compressed).

Describe alternatives you’ve considered Sticking with system.io.

Additional context Add any other context or screenshots about the feature request here.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dazinatorcommented, Feb 8, 2019

ah ok.

Perhaps a better way forward for me then, is first shadow-copy the plugins from the IFileProvider to some temp physical directory first on startup, and then use dotnetcoreplugins to load them from there as normal. I can then IFileProvider.Watch for changes to plugins in the source at runtime and when they change, Unload the ALC, shadow copy again the new versions, and reload them with dotnetcoreplugins again. Should allow me to host plugins anywhere IFileProvider supports. Should also allow me to update the plugins at the source because they won’t be locked by any process due to the addition of the shadow copy before load. I’ll close this

0reactions
natemcmastercommented, Feb 8, 2019

Yeah, that sounds like a better approach.

Read more comments on GitHub >

github_iconTop Results From Across the Web

File Providers in ASP.NET Core
ASP.NET Core abstracts file system access through the use of File Providers. File Providers are used throughout the ASP.NET Core framework.
Read more >
How to use File Providers in ASP.Net Core
File Provider abstractions​​ The file providers implement the IFileProvider interface. There are three implementations of IFileProvider: Physical ...
Read more >
File Providers In ASP.NET Core
In other words, we can say that "File Provider is an abstraction over file system". The file providers use IFileProvider interface and it ......
Read more >
IFileProvider use case and abstraction issues #825
Questioning whether the IFileProvider abstraction needs improving (or its implementations) - due to following issues. I am finding usage of the ...
Read more >
Unit Testing with File System Abstraction | by Paul Gerard
This allows us to abstract the file system and provides us with an interface and class that can be injected into the code,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found