PCLStorage icon indicating copy to clipboard operation
PCLStorage copied to clipboard

Looking for synchronous API

Open pmorris-dev opened this issue 10 years ago • 6 comments

Now that Universal Windows has support for returning to the System.IO.File, etc. API's with their synchronous method calls, we would like to see support in PCLStorage for synchronous calls. We think it preferable to retain the use of synchronous file IO patterns in Android and iOS code and update asynchronous Windows IO patterns to match that (rather than introduce the complexity of asynchronous file IO patterns into Android and iOS code). What is your opinion? Are there plans to support this in PCLStorage?

pmorris-dev avatar Jan 05 '16 18:01 pmorris-dev

I think that now that System.IO file APIs are available everywhere, there's not much of a need for PCL Storage. Is there a reason not to just use those APIs directly?

dsplaisted avatar Jan 05 '16 19:01 dsplaisted

Thanks for the quick response. So System.IO.File is available on all the platforms but I can’t access System.IO.File calls from within a portable lib so as I understand it I need some abstraction down there (like System.IO.Stream). Am I missing something?

On Jan 5, 2016, at 2:07 PM, Daniel Plaisted [email protected] wrote:

I think that now that System.IO file APIs are available everywhere, there's not much of a need for PCL Storage. Is there a reason not to just use those APIs directly?

— Reply to this email directly or view it on GitHub https://github.com/dsplaisted/PCLStorage/issues/30#issuecomment-169099655.

pmorris-dev avatar Jan 05 '16 19:01 pmorris-dev

Yes, a lot of the new ".NET Core" APIs are not currently available in PCLs targeting Xamarin. They should be eventually. So for now you would probably want to create your own abstraction if you want to use the APIs from a PCL.

dsplaisted avatar Jan 05 '16 19:01 dsplaisted

Would you consider it admissible to add synchronous implementations to the PCLStorage API?

pmorris-dev avatar Jan 06 '16 19:01 pmorris-dev

I would prefer not to add synchronous APIs to the PCLStorage package itself. They will be obsolete once the System.IO APIs are available in PCLs.

If you want a package with synchronous APIs in the meantime, I'd welcome a PR to create a separate package for that.

dsplaisted avatar Jan 07 '16 17:01 dsplaisted

Ok then. We may just write a thin abstraction around the File and Directory API's to tide us over. Thanks for your input.

pmorris-dev avatar Jan 08 '16 21:01 pmorris-dev