Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-469381: ReSharper 'Extract Method' shows an incorrect async preview of extracted method

$
0
0
Reporter Martin (IAmMartin) Martin (IAmMartin)
Created Apr 23, 2018 4:28:38 PM
Updated Apr 23, 2018 4:28:47 PM
Subsystem No Subsystem
Assignee Unassigned
Priority Normal
State Submitted
Type Unspecified
Fix version No Fix versions
Affected versions 2018.1
Fixed In Version ReSharper Undefined
VsVersion All Versions
2018.1

namespace ReSharperBugs.v2018_1
{
[TestClass]
public sealed class ExtractMethodTests
{
[TestMethod]
public async Task Test()
{
// Extract this part of the method to a new method. START -->
IClient client = new Client();
Field[] fields = await client.GetAllFields(CancellationToken.None);
Dictionary<string, string> types = new Dictionary<string, string>();
foreach (Field field in fields)
{
types.Add(field.Id, "");
}
// <-- END

types.Count.ShouldBe(0);
}
}

public interface IClient
{
Task<Field[]> GetAllFields(CancellationToken ct);
}

internal class Client : IClient
{
public Task<Field[]> GetAllFields(CancellationToken ct)
{
throw new NotImplementedException();
}
}

public class Field
{
public string Id { get; set; }
}
}

Preview shows (incorrect Task)
private static async Task Dictionary()
{
IClient client = new Client();
Field[] fields = await client.GetAllFields(CancellationToken.None);
Dictionary<string, string> types = new Dictionary<string, string>();
foreach (Field field in fields)
{
types.Add(field.Id, "");
}
return types;
}

Actual (correct Task<Dictionary<string, string>>)
private static async Task<Dictionary<string, string>> Dictionary()
{
IClient client = new Client();
Field[] fields = await client.GetAllFields(CancellationToken.None);
Dictionary<string, string> types = new Dictionary<string, string>();
foreach (Field field in fields)
{
types.Add(field.Id, "");
}
return types;
}



Viewing all articles
Browse latest Browse all 106942

Trending Articles