Skip to main content


Showing posts from 2017

Visual Studio 2015 Code Analyzer and configuration with StyleCop

What is Diagnostic/Code Analyzer? To put it simply it is something similar to Resharper or Telerik JustCode. It analyzes codes while writing on code editor and suggest for improvements of codes through Squiggles, light icon and based on various severity.
How it works?
I had mentioned that it is similar to Resharper and Telerik JustCode but internal infrastructure is completely different.
It is dependent on new compiler Roslyn. Roslyn has a clever compile technique, unlike older version which makes it faster and flexible for dynamic compilation without the need of the entire code base. The structure is basically divided into two categories Syntax Tree, and Semantic Model. The syntax tree is related to syntaxes only it does not require any reference check. It can be related to DOM elements structure in case of HTML.  Syntax Tree consists of very fine details as simple as WhiteSpace under the code. The Semantic Model is kind of references of Syntax Tree in which it tries to resolve any depen…

Handling JSON DateTime format on Asp.Net Core

This is a very simple trick to handle JSON date format on AspNet Core by global settings. This can be applicable for the older version as well.

In a newer version by default, .Net depends upon Newtonsoft to process any JSON data. Newtonsoft depends upon Newtonsoft.Json.Converters.IsoDateTimeConverter class for processing date which in turns adds timezone for JSON data format.

There is a global setting available for same that can be adjusted according to requirement. So, for example, we want to set default formatting to US format, we just need this code.

services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.DateTimeZoneHandling = "MM/dd/yyyy HH:mm:ss"; });