Wednesday, 29 December 2021

Visual Studio 2022 New Features and Upgradation

 In this article, I will explain what are the new features of VS 2022 and how to upgrade Visual studio from 2019 to VS2022

 

Visual Studio 2022, the latest iteration of Microsoft’s integrated development environment (IDE), was released in November 2021. Compared to Visual Studio 2019, the two are very similar—at first glance, at least. For example, the menus received only slight tweaks.  UI is same as VS 2019 only some color code has changes

For example, Visual Studio 2022 is the first Visual Studio that is 64-bit—but they certainly haven’t rushed the move from 32-bit (Windows XP had a 64-bit version available back in 2005!).

 

Download visual Studi0: https://visualstudio.microsoft.com/vs/  




Upgrading to Visual Studio 2022

I moved over from Visual Studio 2019 to Visual Studio 2022. Solutions and Projects just open; there isn’t the upgrade path of previous versions.  

Microsoft is giving Git much higher priority than its own TFS version control. Incidentally, TFS changed its name to Azure DevOps Server in 2020 (read more about that), though TFS is still easier to pronounce. Team Explorer, 

 

C# 10.0

There’s nothing major in C# 10 beyond a collection of small improvements. A lot of it is code simplification, with global and implicit usings and removing the need for namespaces to nest code when the file only has one namespace. 


Improvements in .NET 6

There are significant speed improvements, particularly in file I/O but also throughout (more details of changes in this Microsoft blog entry).  

One of the more significant changes is improvement in JSON handling. Microsoft started this in .NET 5, and .NET 6 continues it with new features, including serialization and deserialization to and from streams. If you use Newtonsoft for JS



NET Productivity tooling

 

Number of productivity tools are added in VS2022 to improve developer experience, and reduce the errors. Code refactoring now provides the option for updating the existing function for any addition of new parameter or overloading the same function by adding new parameter to it.  Track value source option will provide developer the complete analysis of value the variable is holding. This will definitely ease out debugging experience in visual studio.


Windows is refreshing (windows 11) and definitely, this might have motivated VS team to change the icons to look more brighter and refresh. The icons in VS2022 are refreshed and it brings more clarity of its usage, for light and dark modes. Along with icons the default editor font has been changed to Cascadia code for better code readability.

 

64-Bit Application

For the first time, Visual Studio 2022 offers a 64-bit application, and no longer has a 4 GB limitation of memory for the primary devenv.exe process. If you want to use a 32-bit application, you can run and debug the application.

Open, edit, run, and debug the largest and most complex solutions without running out of memory.

Unrestricted access to all PC memory results in better performance and fewer out-of-memory errors. Microsoft says it makes every part of the workflow faster and more efficient – from loading solutions to debugging F5.

. Better Usability

The new user interface is refreshed and modernized, and utilizes lighter icons for the light and dark versions of the interface. Users now have hundreds of options to customize with changes - reducing complexity and decreasing the cognitive load. Look for these additions as well:

  • Updated icons for better clarity, consistency, readability, and contrast
  • Cascadia Code increases readability with a new fixed-width font and improved themes
  • Integration with Accessibility Insights detects accessibility issues before the software reaches end-users
  • Customizatize the VS experience with IDE settings and the ability to synchronize settings between devices

 

 

Enhanced Debugging

Visual Studio 2022 is a friend to the developer, with the new debugging tool that diagnose issues quickly. You can use async visualizations, automatic analyzers, time travel debugging, and more.

This November, Visual Studio 2022 will be compatible with GrapeCity's .NET products, including Spread.NET v15, ComponentOne, GrapeCity Documents, and ActiveReports.NET.

 

Conclusion

The latest Visual Studio hasn’t really altered that much, other than the move to 64-bit, but given all of the small enhancements in C# and other languages, .NET 6 and so on, it’s definitely worth the upgrade. If you are using .NET 5, the Hot Reload feature is probably enough justification by itself to upgrade. 


Happy programming!!

Don’t forget to leave your feedback and comments below!

Regards

Sujeet Bhujbal

--------------------------------------------------------------------------------

 Blog: www.sujeetbhujbal.com

Personal Website :-http://sujeetbhujbal.wordpress.com/ 

CodeProject:-http://www.codeproject.com/Members/Sujit-Bhujbal 

CsharpCorner:-http://www.c-sharpcorner.com/Authors/sujit9923/sujit-bhujbal.aspx

Linkedin :-http://in.linkedin.com/in/sujitbhujbal 

Twitter :-http://twitter.com/SujeetBhujbal 

------------------------------------------------------------------------------

Tuesday, 6 July 2021

How to benchmark C# code using BenchmarkDotNet

In this article, I will explain How to benchmark C# code using BenchmarkDotNet

 

 BenchmarkDotNet is a lightweight, open-source, powerful .NET library that can transform your methods into benchmarks, track those methods, and then provide insights into the performance data captured.

 It is easy to write BenchmarkDotNet benchmarks and the results of the benchmarking process are user friendly as well.

 

Why benchmark code?

A benchmark is a measurement or a set of measurements related to the performance of a piece of code in an application. 

Benchmarking code is essential to understanding the performance metrics of the methods in your application. It is always a good approach to have the metrics at hand when you’re optimizing code. It is very important for us to know if the changes made in the code have improved or worsened the performance. 

Benchmarking also helps you to narrow in on the portions of the code in the application that needs refactoring.



Create a console application project in Visual Studio

First off, let’s create a .NET Core console application project in Visual Studio. Assuming Visual Studio 2019 is installed in your system, follow the steps outlined below to create a new .NET Core console application project in Visual Studio.

  1. Launch the Visual Studio IDE.
  2. Click on “Create a new project.”
  3. In the “Create new project” window, select “Console App (.NET Core)” from the list of templates displayed.
  4. Click Next.
  5. In the “Configure your new project” window shown next, specify the name and location for the new project.
  6. Click Create.




Install the BenchmarkDotNet NuGet package

To work with BenchmarkDotNet you must install the BenchmarkDotNet package. You can do this either via the NuGet Package Manager inside the Visual Studio 2019 IDE, or by executing the following command at the NuGet Package Manager Console:

Install-Package BenchmarkDotNet


Steps for benchmarking code using BenchmarkDotNet

To run BenchmarkDotNet in your .NET Framework or .NET Core application you must follow these steps:

  1. Add the necessary NuGet package
  2. Add Benchmark attributes to your methods
  3. Create a BenchmarkRunner instance
  4. Run the application in Release mode

Create a benchmarking class in .NET Core







Run the benchmark in your .NET Core application

If you run the application in debug mode, here’s the error message you’ll see:

Hence you should run your project in the release mode only. To run benchmarking, specify the following command at the Visual Studio command prompt.

dotnet run -p BenchmarkDotNetDemo.csproj -c Release

Analyze the benchmarking results

Once the execution of the benchmarking process is complete, a summary of the results will be displayed at the console window. The summary section contains information related to the environment in which the benchmarks were executed, such as the BenchmarkDotNet version, operating system, computer hardware, .NET version, compiler information, and information related to the performance of the application.

A few files will also be created in the BenchmarkDotNet.Artifacts folder under the application’s root folder. Here is a summary of the results. 



BenchmarkDotNet is a nice tool that provides a simple way to make an informed decision about the performance metrics of your application. In BenchmarkDotNet, invocation of a method that has the Benchmark attribute set is known as an operation. An iteration is a name given to a collection of several operations.



Happy programming!!

Don’t forget to leave your feedback and comments below!

Regards

Sujeet Bhujbal

--------------------------------------------------------------------------------

 Blog: www.sujeetbhujbal.com

Personal Website :-http://sujeetbhujbal.wordpress.com/ 

CodeProject:-http://www.codeproject.com/Members/Sujit-Bhujbal 

CsharpCorner:-http://www.c-sharpcorner.com/Authors/sujit9923/sujit-bhujbal.aspx

Linkedin :-http://in.linkedin.com/in/sujitbhujbal 

Twitter :-http://twitter.com/SujeetBhujbal 

------------------------------------------------------------------------------

 




Tuesday, 29 June 2021

.Net Framework Vs .Net Core

 Hello Friends,  


In this article, I will explain the difference between  .Net Framework Vs .Net Core


.Net Framework and .Net Core both are two different implementations of the .Net Runtime. The first one is older and .Net Core is newer than .Net Framework. Today, we will understand the difference between and .Net Framework and .Net Core and how these both are different from the .Net Standard, and why we should use .Net Standard.

1. What is .Net Framework?

.Net Framework is a framework for building and managing Windows and Web-based applications. This is an old framework created by Microsoft and provides end to end solution to create Windows applications generally known as Win Forms and Web Application like Asp.Net or Asp.Net MVC applications.

What we can do with .Net Framework.

  1. Create a Windows Application.
  2. Create Web Forms using Asp.Net, Rest API using Web API and enterprise application using Asp.Net MVC
  3. Can use multiple languages, that’s why it is language independent.
  4. Create an app with good performance.

2. What is .Net Core?

.Net Core is a cross-platform and open-source framework for building an application that can run on any platform. It is also created by Microsoft. It is not a new version of .Net Framework, whereas it is a totally new framework that is written from scratch to develop an application that can run on any platform like Mac, Linux, or Windows.  Earlier .Net Framework was Language-Independent but .Net Core is language-independent as well as platforms independent.

What we can do with .Net Core.

  1. Create cross platforms applications.
  2. Can use Microservices
  3. Deploy an application to Dockers container.
  4. Create a highly scalable and performable system.
  5. Create Asp.Net Core, Razor page, UMP, Mobile native app, and Blazor application.


Happy programming!!
Don’t forget to leave your feedback and comments below!
Regards
Sujeet Bhujbal
--------------------------------------------------------------------------------
------------------------------------------------------------------------------

Friday, 30 April 2021

How to Use Cookies in Asp.Net Core

 Hello Friends,  


In this article, I will explain how to Use Cookies in  ASP.NET CORE .




1. Let me show you how to Implement the Cookie in an ASP.NET Core application.

Configuration

As for configuring the behavior of cookies globally, you can do it in the Startup.
public void ConfigureServices(IServiceCollection services)
{
    services.Configure<CookiePolicyOptions>(options =>
    {
        options.CheckConsentNeeded = context => true;
        options.MinimumSameSitePolicy = SameSiteMode.None;
        options.HttpOnly = HttpOnlyPolicy.Always;
        options.Secure = CookieSecurePolicy.Always;
        // you can add more options here and they will be applied to all cookies (middleware and manually created cookies)
    });

    ...
}

2. CookieOptions

There are different cookie options available. It extends the cookie behavior in the browser.
 
Options
Domain - The domain you want to associate with a cookie
Path - Cookie Path
Expires - The expiration date and time of the cookie
HttpOnly - Gets or sets a value that indicates whether a cookie is accessible by client-side script or not.
Secure - Transmit the cookie using Secure Sockets Layer (SSL) that is, over HTTPS only.  



Happy programming!!
Don’t forget to leave your feedback and comments below!
Regards
Sujeet Bhujbal
--------------------------------------------------------------------------------
------------------------------------------------------------------------------


Wednesday, 17 March 2021

Angular 11 New Features

Hello Friends,  

 

In this article, I will explain Angular Version 11 new features.  Version 11 of Angular has been released on Nov 12, In Angular Version 11 having below listed features.






New features and changes in Angular 11

Component test harnesses

Component test harnesses is a new feature that was added to Angular with the release of Angular Version 9. It was used to test Angular material components and it also provides a robust and legible API surface to help developers while testing material components.

 

TypeScript 4.0 support

The new Angular 11 upgraded the supports for TypeScript from version 3.9. Now, Angular also supports TypeScript 4.0. The goal with this update is to improve the build speed. So, the new Angular ensures an improvement in the build system speed from the older versions and also updates the speed of ngcc.

webpack 5 support

webpack is a tool that lets developers compile larger JavaScript modules. It is also known as a module bundler. It compiles a large number of files and generates a single file that can run an app. The new webpack 5 was released last month, but is not fully stable for use. The new Angular 11 supports the latest release of webpack. The reason it supports the new webpack is because Angular wants to achieve

 

 

Automatic Inlining of Fonts

 

One of the new features introduces automatic font inlining in Angular 11, which means during compile time Angular CLI will download and inline fonts that are being used and linked in the application. 

 

The inlining font is the default behavior in apps built with angular 11, so if you want to take and benefit from this advantage we need to do update our angular application to the angular 11 version.

 

Component Test Harnesses

 

In Angular 9 there was this component test harness that provided a readable and robust API based for testing Angular material components with the supported API at test. With this new version 11, we now have harnesses for all components, so even more test suites can now be built by developers.

 

Improved Reporting and Logging

 

The next one Angular 11 has a lot of improvements in the new CLI output to make logs and reports easier to read. You can see the logs and generated files. Please refer to the below images.

 

Updated Language Service Preview

 

Angular 11 makes development with Angular more productive. The Angular team has introduced the Angular Language Service, which provides helpful tools.

 

The previous Angular 10 versions of the language service are based on View Engine. From now on, we have a sneak peek of the Ivy-based language service. The updated language service provides a more powerful and accurate experience for developers in the Angular 11 version.

 

For example, now the language service will be able to correctly infer generic types in templates the same way the TypeScript compiler does.

 

Updated Hot Module Replacement (HMR) Support

 

In version 11 they’ve updated the CLI to allow enabling HMR when starting an application with ng serve. To run the following command:

 

ng serve --hmr

 

 Faster Builds

 

The Angular 11 supported typescript version 4.0. Angular is one of the fastest frameworks. Angular 11 allows for faster development and building the application.

 

In Angular 11 when we install dependencies, the ngcc update process is now 2–4x faster and compilation is also faster in the updated version.

 

Experimental webpack 5 Support

 

Now webpack version 5 will let you make faster builds with continuousdisk caching and smaller bundles.

 

If we need to enable webpack our project, please add the following code to the package.json file:

 

1.    "resolutions": {  

2.      "webpack": "5.4.0"  

3.   }  

 

 

Currently, we need to test this, as npm does not yet support the resolutions property.

 

 

 

How to update to Angular version 11

 

If we need to update Angular 10 or the old version needs to be updated to the latest version, Angular 11, please execute the below line in the command section:

 

ng update @angular/cli @angular/core

 

Happy programming!!
Don’t forget to leave your feedback and comments below!
Regards
Sujeet Bhujbal
--------------------------------------------------------------------------------
------------------------------------------------------------------------------