Tweetsharp is a .NET library to connect with Twitter. Complete, easy to use, but with a little problem: it's platform-depending. That means you can't use it on PCL projects. For me, it was a big problem: Ocell depends heavily on Tweetsharp. I wanted to refactor the code, moving the ViewModels to a PCL project (it's easier for testing, it would simplify the creation of a Windows Store app too) but I couldn't do that with Tweetsharp being platform-dependent. So, open-source to the rescue, I forked it and migrated it.

I made some hard decisions. As the original project is no longer being maintained, I decided to break compatibility to make the migration easier. The first (and most important) thing is that Tweetsharp no longer depends on Hammock. Instead, it now uses HttpClient. Why? Because it's being actively maintained by Microsoft, it's on NuGet, it's used widely, it's portable and it uses async/await methods.

Obviously, using async/await means I can create Async methods for the API calls. Tweetsharp has support for a lot of patterns to call a method (Begin/End, blocking calls, callbacks...), but given that all these patterns can be done with async/await and Tasks, I deleted them. The only pattern supported in my fork of Tweetsharp is async/await, both to simplify things and to avoid some problems with the PCL migration. This breaks compatibility with every project out there using Tweetsharp, I know, but I think it's better to keep things simple. Also, if you want to keep these calls, it shouldn't be that hard to add them to the code using the TwitterService.tt template that Daniel Crenna originally created.

As Hammock is removed, the OAuth support it provides is also gone. I replaced it with AsyncOAuth, a library for making OAuth signed requests, integrated with HttpClient. The only setup it needs is configuring the HMAC-SHA1 signing function (the instructions are in their readme). Also, the version in Nuget has a problem with special characters (&, = especially) in URLs. I fixed it and sent a pull request, but I don't know when will the author update the package. In the meantime, either don't try to send requests with special characters in URLs (it gives an IndexOutOfRangeException out of nowhere, and believe me it was really hard to debug it), or download my fork, compile it and replace the DLL in your project.

Edit: forget about that "special character problem", Yoshifumi Kawai is awesome; merged my pull request and updated the Nuget package in just a few hours :)

I also removed the OAuth functions in Tweetsharp (GetAuthorizationUri and similar), but just because I didn't wanted to deal with that. I think AsyncOAuth gives you some of those functions, but I didn't check it out.

TODO

Support for uploading images is not done yet. It shouldn't be difficult, though. Streaming support needs to be done.

Organization and compatibility with Daniel Crenna's original repo

Currently, the organization in my repo is a little bit of a mess. The branch with the PCL project is pcl-refactor, not master. Why? Because master contains modifications only suitable for Ocell. I know, it's strange, and it's a mess.

The branch pcl-refactor doesn't have strange things, and it should merge cleanly with Daniel Crenna's master branch. But I'm not making a pull request yet, even more when work in this migration is not yet finished.

Just one final thing: I don't want to steal the ownership/merits of the Tweetsharp project. All credits go to Daniel Crenna, the original developer of the project. I just tweaked some things (and broke a lot of them in the way too).