Code
(please note that there's the <<:caret:>>
marker)
C#namespace SUT {
using System.Threading.Tasks;
using System.Collections.Generic;
class C {
int Number { get; set; }
static async Task<int> GetNumber(int number) => await Task.Delay(0).ContinueWith((_) => number);
static async Task DoSomething(IEnumerable<int> ints) {
List<C> list = new();
<<:caret:>>foreach (var x in ints) {
var c = new C() {
Number = await GetNumber(x)
};
list.Add(c);
}
}
}
}
Actual result
Refactoring is available and its application leads to the CS4034 compiler-time error:
C#namespace SUT {
using System.Threading.Tasks;
using System.Collections.Generic;
class C {
int Number { get; set; }
static async Task<int> GetNumber(int number) => await Task.Delay(0).ContinueWith((_) => number);
static async Task DoSomething(IEnumerable<int> ints) {
List<C> list = new();
list.AddRange(ints.Select(x => new C()
{
Number = await GetNumber(x) // CS4034
}));
}
}
}
Expected result
Refactoring is not available.