Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ public Task NoParameters_AppendsTokenAndAddsUsing() =>
RequireCancellationTokenParameterCodeFixProvider
>.VerifyCodeFixAsync(
"""
using System.Threading;
using System.Threading.Tasks;

public sealed class Sample
{
public Task {|NE0010:Run|}() => HelperAsync();

private static Task HelperAsync(CancellationToken token = default) => Task.CompletedTask;
private static Task HelperAsync(System.Threading.CancellationToken token = default) => Task.CompletedTask;
}
""",
"""
Expand All @@ -36,7 +35,7 @@ public sealed class Sample
{
public Task Run(CancellationToken cancellationToken = default) => HelperAsync(token: cancellationToken);

private static Task HelperAsync(CancellationToken token = default) => Task.CompletedTask;
private static Task HelperAsync(System.Threading.CancellationToken token = default) => Task.CompletedTask;
}
"""
);
Expand Down Expand Up @@ -136,14 +135,13 @@ public Task FileScopedNamespace_UsingInsertedAtNamespaceLevel() =>
"""
namespace Sample;

using System.Threading;
using System.Threading.Tasks;

public sealed class Sample
{
public Task {|NE0010:Run|}() => HelperAsync();

private static Task HelperAsync(CancellationToken token = default) => Task.CompletedTask;
private static Task HelperAsync(System.Threading.CancellationToken token = default) => Task.CompletedTask;
}
""",
"""
Expand All @@ -156,7 +154,7 @@ public sealed class Sample
{
public Task Run(CancellationToken cancellationToken = default) => HelperAsync(token: cancellationToken);

private static Task HelperAsync(CancellationToken token = default) => Task.CompletedTask;
private static Task HelperAsync(System.Threading.CancellationToken token = default) => Task.CompletedTask;
}
"""
);
Expand Down Expand Up @@ -452,14 +450,13 @@ public Task BlockScopedNamespaceWithExistingUsings_UsingInsertedAtNamespaceLevel
"""
namespace Sample
{
using System.Threading;
using System.Threading.Tasks;

public sealed class Sample
{
public Task {|NE0010:Run|}() => HelperAsync();

private static Task HelperAsync(CancellationToken token = default) => Task.CompletedTask;
private static Task HelperAsync(System.Threading.CancellationToken token = default) => Task.CompletedTask;
}
}
""",
Expand All @@ -473,7 +470,7 @@ public sealed class Sample
{
public Task Run(CancellationToken cancellationToken = default) => HelperAsync(token: cancellationToken);

private static Task HelperAsync(CancellationToken token = default) => Task.CompletedTask;
private static Task HelperAsync(System.Threading.CancellationToken token = default) => Task.CompletedTask;
}
}
"""
Expand Down Expand Up @@ -547,6 +544,53 @@ private static System.Threading.Tasks.Task HelperAsync(
"""
);

[Test]
public Task BlockScopedNamespaceNewUsingSortsAfterAllExisting_AppendedWithIndentation() =>
CSharpCodeFixVerifier<
RequireCancellationTokenParameterAnalyzer,
RequireCancellationTokenParameterCodeFixProvider
>.VerifyCodeFixAsync(
"""
namespace Sample
{
using System.Collections.Generic;

public sealed class Sample
{
public System.Threading.Tasks.Task {|NE0010:Run|}()
{
_ = new List<int>();
return HelperAsync();
}

private static System.Threading.Tasks.Task HelperAsync(
System.Threading.CancellationToken token = default
) => System.Threading.Tasks.Task.CompletedTask;
}
}
""",
"""
namespace Sample
{
using System.Collections.Generic;
using System.Threading;

public sealed class Sample
{
public System.Threading.Tasks.Task Run(CancellationToken cancellationToken = default)
{
_ = new List<int>();
return HelperAsync(token: cancellationToken);
}

private static System.Threading.Tasks.Task HelperAsync(
System.Threading.CancellationToken token = default
) => System.Threading.Tasks.Task.CompletedTask;
}
}
"""
);

// ---- Call-site propagation edge cases --------------------------------------------------------------

[Test]
Expand Down
Loading