Serving Industries Worldwide

Innovative Ways - Satisfied Clientele

What’s new in .NET productivity?


Listening is fun too.

Straighten your back and cherish with coffee - PLAY !

 
 

dot-NET-productivity

The .NET Productivity team additionally called Roslyn is always thinking of new ways to make .NET developers more productive.In this blog we will be going to show you the improvements or updates in .NET productivity.

Table of Content

Tooling Improvements

The tooling improvement is when you write a date and time, which type of date and time you want on your code like full date, only time, etc. You can place your caret inside the DateTime and TimeSpan string literal and Press (CTRL + Space). After, you can see completion options and an explanation as to what each character.

new1

Figure: Date Time Productivity
 

You can add file header which allows you to easily add file headers to existing files, projects, and solutions using EditorConfig. First of all,you’ll need to add the file_header_template rule to your .editorconfig file. After, you can set the value to equal the header text you’d like applied. In the next, you can add the place your caret on the first line of any C# or Visual Basic files.

new2

Figure: File_header_template rule in .editorconfig file
 

You can Press (CTRL + .) to trigger the Quick Actions and Refactoring’s menu and select Add file header.

new3

Figure: Add file header
 

You can change the method signature dialog now allows you to add a parameter. You can add place your caret within the method’s signature. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu and select Change Signature. Then, the dialog box opens where you can now select the Add to a add parameter.

new4

Figure: Change Signature Dialog Box
 

If you select Add, the new Add Parameter dialog opens. The dialog box allows you to add a type name and a parameter name. After, you can choose to make the parameter required or optional with a default value.

Then, you can add the value of the client-side and select a named argument for that value or you can introduce a TODO variable. You can TODO variable puts a TODO in your code so you can visit each error and go through each call site independently and decide what you pass. If you pass optional parameters so you have the option to omit the call site completely.

new5

Figure: Add Parameter Dialog Box Window
 

Code Fixes and Refactorings

If you know sometimes while the coding time you do code and some mistakes in your code the Visual Studio provides code fixes and refactorings are the code suggestions the compiler provides through the light bulb and screwdriver icons.

   

You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu. After, you can see the following list of the code fixes and refactorings that are new in Visual Studio 2019.

You can see the add explicit cast code fix which allows you to add an explicit cast when an expression cannot be implicit cast. You can place your caret on the error, you can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu and select Add explicit cast.

new6

Figure: Typecastingdata type
 

In the simplify conditional expression, you can refactoring simplifies conditional expression to be more legible and concise. You can place your caret on the conditional expression. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu and select Simplify conditional expression.

new7

Figure: Simplify conditional expression
 

You can do refactoring at your fingertips to convert between regular string and verbatim string literals. You can place your caret on either a regular string or the verbatim string literals. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu. Then, select from one of the following.

You can select convert to verbatim string

new8

Figure: Convert to verbatim string
 

It allows you to pin properties within the debugger programmatically in your code in the add debugger display attribute. You can place your caret on the class name. You can Press (CTRL + .) to trigger the Quick Actions and Refactoringsmenu and select the Add DebuggerDisplay attribute. It will add the debugger to the top of your class and generate an auto method that returns ToString(), It can be edit to return the property value you want to be pinned in the debugger.

new9

Figure: Add Debugger Display while selecting the class
 

It generates a boilerplate code with comparison operators for types that implement IComparable. In the generate comparison operators, you can place your caret either inside the class or on IComparable. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu and select Generate comparison operators.

new10

Figure: Generate comparison operators
 

It automatically adds the IEquatable as well as the equals and not equals operators for structs in the generate IEquatable operators. You can place your caret within the struct. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu and select Generate Equals(object).

new11

Figure: Generate comparison operators
 

Looking for Dedicated ASP.Net Web Developer ?

Your Search ends here.

 

It allows you to easily create a constructor with properties in type in the generate properties when generating a constructor. You can place your caret on the instance. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu and select Generate constructor in (with properties).

It is now an easy fix for accidental assignments and comparisons. You can place your caret on the warning You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu. Then, select from one of the following options.

In accidental assignments, you can select Assign to ‘.value’.

new12

Figure: Accidental assignments
 

In accidental comparison, you can select Compare to ‘.value’.

new13

Figure: Accidental Comparison
 

You too easily identify code and fix a suppression operator that does no effect. In this example, in this case, someone wanted to express that something isn’t ‘string’ and typed ‘the ‘is not string’.! operator is legal but is interpreted as asserting the expression on the left is not ‘null’. It was still confusing, so we can now offer a warning and code. You can place your caret on the suppression operator. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu. After, from the given two operators you can choose one of them.

You can remove the operator completely, Select Remove operator (preserves semantics).

new14

Figure: Remove operator (preserves semantics)
 

You can negate the expression, select Negate expression (change semantics).

new15

Figure:Negate Expression
 

Conclusion

If you practice on code, sometime you will find mistake in the code so the Visual Studio provides productivity that to detect which types of mistake are there in the code like explicit, add method if not defined in the code, etc. If you get an error,Visual Studio shows the message of an error on the red line so you will know which type of error so you can easily solve your error.

dot-NET-productivity

The .NET Productivity team additionally called Roslyn is always thinking of new ways to make .NET developers more productive.In this blog we will be going to show you the improvements or updates in .NET productivity.

Table of Content

Tooling Improvements

The tooling improvement is when you write a date and time, which type of date and time you want on your code like full date, only time, etc. You can place your caret inside the DateTime and TimeSpan string literal and Press (CTRL + Space). After, you can see completion options and an explanation as to what each character.

new1

Figure: Date Time Productivity
 

You can add file header which allows you to easily add file headers to existing files, projects, and solutions using EditorConfig. First of all,you’ll need to add the file_header_template rule to your .editorconfig file. After, you can set the value to equal the header text you’d like applied. In the next, you can add the place your caret on the first line of any C# or Visual Basic files.

new2

Figure: File_header_template rule in .editorconfig file
 

You can Press (CTRL + .) to trigger the Quick Actions and Refactoring’s menu and select Add file header.

new3

Figure: Add file header
 

You can change the method signature dialog now allows you to add a parameter. You can add place your caret within the method’s signature. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu and select Change Signature. Then, the dialog box opens where you can now select the Add to a add parameter.

new4

Figure: Change Signature Dialog Box
 

If you select Add, the new Add Parameter dialog opens. The dialog box allows you to add a type name and a parameter name. After, you can choose to make the parameter required or optional with a default value.

Then, you can add the value of the client-side and select a named argument for that value or you can introduce a TODO variable. You can TODO variable puts a TODO in your code so you can visit each error and go through each call site independently and decide what you pass. If you pass optional parameters so you have the option to omit the call site completely.

new5

Figure: Add Parameter Dialog Box Window
 

Code Fixes and Refactorings

If you know sometimes while the coding time you do code and some mistakes in your code the Visual Studio provides code fixes and refactorings are the code suggestions the compiler provides through the light bulb and screwdriver icons.

   

You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu. After, you can see the following list of the code fixes and refactorings that are new in Visual Studio 2019.

You can see the add explicit cast code fix which allows you to add an explicit cast when an expression cannot be implicit cast. You can place your caret on the error, you can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu and select Add explicit cast.

new6

Figure: Typecastingdata type
 

In the simplify conditional expression, you can refactoring simplifies conditional expression to be more legible and concise. You can place your caret on the conditional expression. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu and select Simplify conditional expression.

new7

Figure: Simplify conditional expression
 

You can do refactoring at your fingertips to convert between regular string and verbatim string literals. You can place your caret on either a regular string or the verbatim string literals. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu. Then, select from one of the following.

You can select convert to verbatim string

new8

Figure: Convert to verbatim string
 

It allows you to pin properties within the debugger programmatically in your code in the add debugger display attribute. You can place your caret on the class name. You can Press (CTRL + .) to trigger the Quick Actions and Refactoringsmenu and select the Add DebuggerDisplay attribute. It will add the debugger to the top of your class and generate an auto method that returns ToString(), It can be edit to return the property value you want to be pinned in the debugger.

new9

Figure: Add Debugger Display while selecting the class
 

It generates a boilerplate code with comparison operators for types that implement IComparable. In the generate comparison operators, you can place your caret either inside the class or on IComparable. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu and select Generate comparison operators.

new10

Figure: Generate comparison operators
 

It automatically adds the IEquatable as well as the equals and not equals operators for structs in the generate IEquatable operators. You can place your caret within the struct. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu and select Generate Equals(object).

new11

Figure: Generate comparison operators
 

Looking for Dedicated ASP.Net Web Developer ?

Your Search ends here.

 

It allows you to easily create a constructor with properties in type in the generate properties when generating a constructor. You can place your caret on the instance. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu and select Generate constructor in (with properties).

It is now an easy fix for accidental assignments and comparisons. You can place your caret on the warning You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu. Then, select from one of the following options.

In accidental assignments, you can select Assign to ‘.value’.

new12

Figure: Accidental assignments
 

In accidental comparison, you can select Compare to ‘.value’.

new13

Figure: Accidental Comparison
 

You too easily identify code and fix a suppression operator that does no effect. In this example, in this case, someone wanted to express that something isn’t ‘string’ and typed ‘the ‘is not string’.! operator is legal but is interpreted as asserting the expression on the left is not ‘null’. It was still confusing, so we can now offer a warning and code. You can place your caret on the suppression operator. You can Press (CTRL + .) to trigger the Quick Actions and Refactorings menu. After, from the given two operators you can choose one of them.

You can remove the operator completely, Select Remove operator (preserves semantics).

new14

Figure: Remove operator (preserves semantics)
 

You can negate the expression, select Negate expression (change semantics).

new15

Figure:Negate Expression
 

Conclusion

If you practice on code, sometime you will find mistake in the code so the Visual Studio provides productivity that to detect which types of mistake are there in the code like explicit, add method if not defined in the code, etc. If you get an error,Visual Studio shows the message of an error on the red line so you will know which type of error so you can easily solve your error.