Sunday, January 4, 2015

Assembly Neutral Interface in ASP.NET 5(vNext)


Recently Microsoft has open sourced it’s entire ASP.NET next version stack on GitHub and I have been closely watching this for a quite a some time to understand how they have created architecture of it and how they organize everything in such a large stack.

I have seen  [AssemblyNeutral] attribute in few of interfaces and I was curious why it was required. So I dig into it and learned about it.

Why we need Assembly Neutral Interfaces?

In earlier version of ASP.NET and Microsoft.NET Interfaces are bind to a assembly where it is declared. Let’s say I have written a interface under DotNetJalps namespace for my framework.
namespace DotNetJalps
{
    public interface ILogger
    {
        DoAmazingStuff();
    }
}
Now after some time this framework is super popular and everybody loves abstraction I have created and now they wants same abstraction so there are two ways we can do this.

  1. Convenience me to write this abstraction.
  2. Write implementation themself and maintain that.
Share:

C# 6.0–New feature series

This post will be aggregator post for all C# 6.0 feature series. Here you can find all of my blog posts about what’s new in C# 6.0.

Till now, I have written following blog posts.

C# 6.0–nameof Operator
C# 6.0–Auto implemented property initializer
C# 6.0–Static class using statement
C# 6.0–String Interpolation
C# 6.0- Null Conditional Operator
C# 6.0–Exception Filters
C# 6.0–String Interpolation
C# 6.0–Expression Bodied Members
C# 6.0–Dictionary Initializers
Recent updates to C# 6.0 syntax with new version of Visual Studio 2015 CTP

Hope you like it. Stay tuned for lot more about new Microsoft.NET technologies!!
Share:
Saturday, January 3, 2015

C# 6.0–String Interpolation

This blog post is part of C# 6.0 Features Series.
As we all know, C# 6.0 provides lots of small enhancements to the language and string interpolation is one of them. In this blog post we are going to learn how this small new feature can help us for string concatenation.

So let’s take small example, Where I have created a new example of string concatenation. Following is a code for that.
using System;
namespace StringInterpolation
{
    class Program
    {
        static void Main(string[] args)
        {
            string name = "Jalpesh Vadgama";

            //Old way of string concentaionation 
            Console.WriteLine("My name is" + name);
            Console.WriteLine("My name is {0}", name);

            //New way of doing this
            Console.WriteLine("My name is {name}");
        }
    }
}
Share:
Friday, January 2, 2015

Happy New year 2015

New year passed so fast and that I have not feel as its a big time. On this occasion I would like to thank you all my readers for reading my blog and encourage me via putting lots of comments. I promise I will keep writing this blog whenever I get a chance.

Wishing every one a happy new year!!
Share:
Thursday, January 1, 2015

C# 6.0–Exception Filters

This blog post is part of C# 6.0 Features Series.
C# 6.0 contains lots of small features and one of them is Exception filters. It is already there with VB.NET earlier but now it is available in C# also. In exception filters now if exception is combined with Exception statement and If condition of if satisfy then it will execute that block.

Let’s take a simple example to understand it better. Following is a code for a simple console application. Before exception filters we were able to write a code like following.
using System;

namespace ExceptionFilters
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                throw new Exception("Jalpesh");
            }

            catch (Exception ex)
            {
                if(ex.Message =="Jalpesh")
                    Console.WriteLine("Exception with Message Jalpesh is executed");
                else
                    Console.WriteLine("Exception with Message DotNetJalps executed");
            }
        }
    }
}
In above example, I have thrown a exception in try block and in catch block I have written if-else block to check message and based on that it will print some method.

Share:
Tuesday, December 30, 2014

C# 6.0–Null conditional operator

This blog post is part of C# 6.0 Features Series.
As we know there are lots of small features added in C# 6.0 and Null conditional operator is one of them. You can check null with specific conditions with Null conditional operator and this will definitely increase productivity of developers and there will be less lines of code.

Let’s create example. Following are two classes I have created for this example. Address class will contains two properties like Street and City.
namespace NullConditionalOperator
{
    public class Address
    {
        public string Street { get; set; }
        public string City { get; set; }
    }
}
And Same way Person class contains four properties Id,FirstName,Lastname and Address which is of type Address class which we have created.

Share:
Sunday, December 28, 2014

C# 6.0–Static class using statement

This blog post is part of C# 6.0 Features Series.
C# 6.0 version introduced lot of small features and one of that features is  using feature. Now with C# 6.0 you can use using statement which was not possible in earlier versions of  C#. Following is a example of using statement in C#.
using static System.Console;

namespace StaticClassUsing
{
    class Program
    {
        static void Main(string[] args)
        {
            WriteLine("With using statement");
        }
    }
}
And below is output when you run your application.

Share:

C# 6.0–Auto implemented property initializer

This blog post is part of C# 6.0 Features Series.
As we all know C# 6.0 is there in preview mode and Microsoft has added few small features to C# 6.0 which helps  lot while you develop application. In today’s blog post we are going to learn one more small feature called “Auto implemented property initializers”.

Developers working on C# used a automatic properties a lot and there has been lot of demands from developers that automatic properties should a have initializers and Microsoft has listened to that feedback and with C# 6.0 it has been introduced. So now we don’t have to use constructors to initialize automatic properties and there will be less and much cleaner code for Automatic property initializations.

Share:
Saturday, December 27, 2014

Continuous Integration with visualstudio.com,Unit Test(Test Driven Development) and TFS


Before some time I have written a blog post about Continuous integration with visualstudio.com and TFS and It goes quite a good number visits and lots of people are asking for unit test integration with continuous integration too. Today one of colleague also asked for the same. I thought it will be good idea to write a Blog post about it.

In this blog post we are going to create a new MVC application with a Test Project so that we can run tests and configure unit test with continuous integration. So Let’s first create a new application in visual studio.com.

New-Project-unit-test-continious-integration

Share:
Friday, December 26, 2014

Colorized tooltip in visual studio 2015

Visual studio 2015 provides lots of new features and Colorized tooltip is one of the features that I really like. As we all know that Visual studio supports automatic collapse of various language constructs like classes, methods.  When you mouse hover it automatically show hidden code presented in that portion.

In earlier version of Visual Studio that tooltip was shown with hidden code but it was in plain text. Now this tooltip is colorized with syntax highlighting so your hidden code is more readable.It’s look like below.

colorized-tooltip-visualstudio2015

Hope you like it. Stay tuned for more. I’m going to post lot more blog post about new Visual Studio 2015 features.
Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews