How many times in your code do you need to parse strings to primitive values? I would guess pretty often. How often do you use
TryParse method, to avoid unnecessary exception handling? The same guess – probably pretty often. How many times did you wish that
TryParse didn’t use
out method parameter? Yes, the same answer again. But how many times did you think how to improve that scenario? Probably never. I think you should have done that! There is quite a lot of room for improvement here. Simple tricks that may make your parsing logic much simpler, cleaner and more verbatim.
Continue reading Better TryParse method, when you don’t like out parameters and/or need default value
In my previous post I wrote about solution-wide Rename Code Fix using Roslyn, which is supposed to analyze method declarations and suggest a fix when method marked with
async modifier does not have a name that ends with Async. The code I suggested works just fine, however there were some comments about improvements that can be made to make it work better. In this post I’m trying to address one of the suggestions, what results in seconds version of
Continue reading Improve Code Fix performance using correct CodeAction.Create overload
Last time when I posted about Diagnostic with Code Fix using Microsoft .NET Compiler Platform, aka “Roslyn” the fix was completely local. This time, inspired by a tweet by Luke Sigler (@Schandlich) I decided to go for solution-wide rename.
Continue reading Solution-wide Rename from Code Fix Provider – Fix async method naming
I think everyone already knows that during //Build conference Anders Hejlsberg announced that Roslyn API (renamed to .NET Compiler Platform) is now an open source project (he actually clicked Public button live, on stage). It’s really a great news. But even though a lot of people think that main purpose of that move is to allow everyone to make his own version of C#, I don’t think that’s true. I think the main purpose of Roslyn project is still the same – to provide modern and open compiler infrastructure which will make extension development much easier, because extension code now knows exactly the same stuff compiler does. Because of that I decided to give it a try and write simple Diagnostic with Code Fix.
Continue reading My first “Diagnostic with Code Fix” using Roslyn API
The release of new version of ASP.NET Identity – ASP.NET Identity 2.0.0 comes with new sample project, which shows how all the new features like email confirmation, password recovery and two-factor authentication can be used while creating web applications. However, the new sample follows an approach which sometime is not acceptable: it uses an email address as user name. In my case, I need these data to be separated, and that’s why I decided to modify sample project to allow that.
Continue reading ASP.NET Identity 2.0.0 – UserName and Email separation
I just watched The Future of C# talk by Mads Torgersen recorded at NDC London conference over a month ago. Among all the stuff Mads talked about one really drawn my attention: methods/properties with multiple results. Unfortunately, instead of providing some new, crazy idea how to make it possible in C# he focused on making current usage easier. I think language designers could go much further and create real multiple results experience!
Continue reading The Future of C# and multiple results. Why don’t we use anonymous types?
I’ve spent last two days working on my first open source .NET library named CloneExtensions. It gives you a smart way to clone your object instances without implementing any interface writing any additional
Clone method at all. It uses Expression Tree to compile that
Clone method for you right before you’re trying to use
GetClone for given type
T for the first time.
Continue reading Introducing CloneExtensions .NET cloning library