You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The aim of dotnet/roslyn#40364 is simplification, while the aim of this alternative is performance.
↓ denotes where the suggestion span would be and _ denotes the spans that would be faded as unnecessary.
classC{// Changed to an instance method because of https://github.com/dotnet/roslyn/pull/58288boolIsEven(intx)=>x%2==0;voidExample1(){// 💡 Avoid allocation by replacing method group with lambda// ↓↓↓↓↓↓_=new[]{1,2,3}.Where(IsEven);// 🛠 Fix result:_=new[]{1,2,3}.Where(n =>IsEven(n));}voidExample2(){varneverReassigned=newFunc<int,bool>(IsEven);// 💡 Avoid allocation by replacing lambda with delegate// _____↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓____=new[]{1,2,3}.Where(n =>neverReassigned(n));// 💡 Avoid allocation by replacing lambda with delegate// _____↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓___________=new[]{1,2,3}.Where(n =>neverReassigned.Invoke(n));// 💡 Avoid allocation by replacing Invoke method group with delegate// ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓________=new[]{1,2,3}.Where(neverReassigned.Invoke);// 🛠 Fix result:_=new[]{1,2,3}.Where(neverReassigned);}voidExample3(){varreassigned=newFunc<int,bool>(IsEven);// No diagnostic_=new[]{1,2,3}.Where(n =>reassigned.Invoke(n));// 💡 Avoid allocation by replacing Invoke method group with delegate// ↓↓↓↓↓↓↓↓↓↓________=new[]{1,2,3}.Where(reassigned.Invoke);reassigned= n =>!IsEven(n);// 🛠 Fix result:_=new[]{1,2,3}.Where(reassigned);}}
The text was updated successfully, but these errors were encountered:
The aim of dotnet/roslyn#40364 is simplification, while the aim of this alternative is performance.
↓
denotes where the suggestion span would be and_
denotes the spans that would be faded as unnecessary.The text was updated successfully, but these errors were encountered: