We all know that Microsoft always delivers awesome features in all the releases and they are already planning for the features of C# 8.0

As per a video on Channel 9, Mads Torgersen has explained about the possible features of C# 8.0

There are possibly 4 features till now which are as below:

Nullable reference types

Async Streams(Foreach Async)

Default Interface Implementations

Extension Everything

In this post, I will explain about the Async Streams.

For normal Async methods we write it as below:

async Task(int) Test()
{
return x;
}

and we call it by:

await Test();

What it does is, it waits until the things returned from Test method and after that only, it goes to the next step.

But it works with only one resource.

Now imagine we want to work with some live stream where we get data in the continuous live stream. For example, some IoT where data comes every moment. But we want to process them in our own time like one at a time.

Here comes the Async version of IEnumerable:

IAsyncEnumerable<T>

So basically, it is just like an enumerable except that when you move next in an enumerable way, that is Async.

It is kind of a way of Lay loading enumerability in Async way.

When defining an async iterator, you would use this function signature:

async IAsyncEnumerable<string> MethodName()
{
yield return "Test";
}

And can be used as:

foreach await (string s in asyncStream)

Above is nothing but the combination of Async and Enumerable, you wait inside it and you return inside it.

Though it looks like IObersable but it is different. The benefit of using this instead of IObservable<T> from Reactive Extensions is that the consumer controls the flow rate. This is referred to as a “pull model” and IObservable<T> is a “push model”.

In Foreach Async, consumers tell when it is ready and then it processes the next one.

Here we have logger provider along with the levels so it allows us to configure logging levels per logging provider.

Previously, the entry inappsettings.jsonwould only be applicable to the console logger but now the entry in theappsettings.jsonhas logger provider names in it like Debug, EventLog, TraceSource etc.

Do not forget to make these changes as it is required and it may throw the exception if you have missed this. I saw some StackOverflow questions mainly on this where people forgot to add related details in appsettings.json file.

Once it is done, in Main class, we can configure the logging details as shown below:

In my last post, I have explained about the setup required for .Net Core 2.0 which you can find here.

Along with Core 2.0, there are some newly added default templates has been added by Microsoft team.

The major attraction is the SPA templates that are shipped with Core 2.0.

SPA templates like Angular, React.js, React.js and Redux etc can be seen in default template page:

These three templates create actually the same sample application but the difference is in JavaScript libraries. Notice that these new templates are available only when ASP.NET Core 2 is selected from framework dropdown on top of the dialog.

The best part is, JavaScript Services functionality is used by these SPA templates to embed Node.js within .Net Core on the server. Thus it compiles the Javascript applications server-side as part of .Net build.

The advantage of having SPA templates in the default template section is, most of the required scripts, dlls and other required components are already added in the application so you can start building your application without worrying about the dependencies.

Microsoft has announced Core 2.0 and it has some awesome features which I will explain in future blog posts.

For now, let us see how to converts your Core 1.0 application into Core 2.0

First of all, we will change the .Net core version in global.json file as shown below:

{
"sdk": {
"version": "2.0.0-preview3-006912"
}
}

After that we need to change the target library to Core 2.0 as shown below:

Also, change and update below line in .csproj file:

<TargetFramework>netcoreapp2.0</TargetFramework>

Once it is done, we need to add below package in the .csproj file:

<ItemGroup>

<PackageReferenceInclude=“Microsoft.AspNetCore.All”Version=“2.0.0” />

</ItemGroup>

This new metapackage contains references to all of the AspNetCore packages and maintains a complete line-up of compatible packages. You can still include explicit references to specific Microsoft.AspNetCore.* package versions if you need one that is outside of the lineup

Now we need to change PackageTargetFallback in same .csproj file as below:

MasterCard is going to conduct one of the biggest hackathons of India on November. Name of the hackathon is Amplitude 2017.

The theme of this Hackathon is #CashLessBanoIndia. Name of the theme is self-explanatory, the main focus of this hackathon is to come up with the ideas which will encourage people to use digital payments instead of Cash.

There are mainly 4 themes for this hackathon which includes creating meta data driven rules platform, how to accelerate the adoption of digital payments in India, To develop alternate payment solution for merchants and increase the security of P2P and P2M transactions.

MasterCard has some awesome products which can be used for this hackathon. By the way, developers can use any API or products they want for the hackathon.