Roslyn open source
IDE Features (CTL+.)
. lightball to remove unused namespace
.. fix the scope , remove all unused cross the project / solutions
. refactor
rename, introduce local variable, show conflict
add this automaticaly if their is conflict that could be resolved by IDE
. Array vs ImmutableArray
var c=new ImmutableArray(); call c.length will trigger null exception.
//you can build code analyzer
//tell the ide you shoudl you ImmutableArray<int>.empty
language new features
instead of big change, little things added.
1.using static System.Console. //simar typescript import {WriteLine} from systemcnosole
then you can call WriteLine methods.
2.Immutable, auto property.
public class Point
{
public int x {get;}
public int y {get;}=default10;
}
3 lambda for methods
public void string ToString()=>String.format("tostring {0}", x);
4 $String,
public void String toString()=>$({X}{Y})
5. nameof(variable)
Log.d(nameof(variable))
6.?.
if p!=null && p.name=="xxx"
will be if p?.name=="xx"
if json!=null && json['x']!=null && json['x']=="mon"
will be
if(json?['x']?=="mon")
7.initlize elements
public JObject tojson()=>return new jsonobject(){['x']=x, ['Y']=y }
8. awit in catch block
try
{
var result=await repo.DosomethingAsync();
}
catch(Excepton ex)
{
await repo.LogException(ex) //doable now
}
9.catch(Exception ex) when (ex.Occurences>3)
Debugging features
1. you can edit code, even add new class , and do initialization code when debugging the app
run linq query
also in watch window
people.find(p=>p.age>20)
C# extensions toolkit in the extnsion gallery
2. C# interactive window
#r "System"
#r "System.Core"
using System.Diagnostics;
using System.linq;
var memoryPigs =from p in Process.getProcesses() where p.workset64 >64*1024*1024 select new
{p.ProcessName, p.WorkingSet}
foreach(var r in memopigs)
{
Console.writeline(r)7y
}
No comments:
Post a Comment