Skip to content

Commit db1fa67

Browse files
C#
1 parent 6f1801d commit db1fa67

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

src/Features/CSharp/Portable/ExtractMethod/CSharpMethodExtractor.CSharpCodeGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,9 @@ protected override ExpressionSyntax CreateCallSignature()
604604
}
605605

606606
var invocation = (ExpressionSyntax)InvocationExpression(methodExpression, ArgumentList([.. arguments]));
607-
if (this.SelectionResult.CreateAsyncMethod())
607+
if (this.SelectionResult.ContainsAwaitExpression())
608608
{
609-
if (this.SelectionResult.ShouldCallConfigureAwaitFalse())
609+
if (this.SelectionResult.ContainsConfigureAwaitFalse())
610610
{
611611
if (this.GetFinalReturnType()
612612
.GetMembers(nameof(Task.ConfigureAwait))

src/Features/Core/Portable/ExtractMethod/MethodExtractor.Analyzer.cs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ private OperationStatus GetOperationStatus(
217217
? OperationStatus.UnsafeAddressTaken
218218
: OperationStatus.SucceededStatus;
219219

220-
var asyncRefOutParameterStatus = CheckAsyncMethodRefOutParameters(variables);
221-
222220
var variableMapStatus = failedVariables.Count == 0
223221
? OperationStatus.SucceededStatus
224222
: new OperationStatus(succeeded: true,
@@ -230,25 +228,11 @@ private OperationStatus GetOperationStatus(
230228
? OperationStatus.LocalFunctionCallWithoutDeclaration
231229
: OperationStatus.SucceededStatus;
232230

233-
return readonlyFieldStatus.With(anonymousTypeStatus)
234-
.With(unsafeAddressStatus)
235-
.With(asyncRefOutParameterStatus)
236-
.With(variableMapStatus)
237-
.With(localFunctionStatus);
238-
}
239-
240-
private OperationStatus CheckAsyncMethodRefOutParameters(IList<VariableInfo> parameters)
241-
{
242-
if (SelectionResult.CreateAsyncMethod())
243-
{
244-
var names = parameters.Where(v => v is { UseAsReturnValue: false, ParameterModifier: ParameterBehavior.Out or ParameterBehavior.Ref })
245-
.Select(p => p.Name ?? string.Empty);
246-
247-
if (names.Any())
248-
return new OperationStatus(succeeded: true, string.Format(FeaturesResources.Asynchronous_method_cannot_have_ref_out_parameters_colon_bracket_0_bracket, string.Join(", ", names)));
249-
}
250-
251-
return OperationStatus.SucceededStatus;
231+
return readonlyFieldStatus
232+
.With(anonymousTypeStatus)
233+
.With(unsafeAddressStatus)
234+
.With(variableMapStatus)
235+
.With(localFunctionStatus);
252236
}
253237

254238
private MultiDictionary<ISymbol, SyntaxToken> GetSymbolMap()
@@ -286,7 +270,7 @@ private ImmutableArray<VariableInfo> MarkVariableInfosToUseAsReturnValueIfPossib
286270
// return values of the method since we can't actually have out/ref with an async method.
287271
var outRefCount = numberOfOutParameters + numberOfRefParameters;
288272
if (outRefCount > 0 &&
289-
this.SelectionResult.CreateAsyncMethod() &&
273+
this.SelectionResult.ContainsAwaitExpression() &&
290274
this.SyntaxFacts.SupportsTupleDeconstruction(this.SemanticDocument.Document.Project.ParseOptions!))
291275
{
292276
var result = new FixedSizeArrayBuilder<VariableInfo>(variableInfo.Length);

src/Features/Core/Portable/ExtractMethod/MethodExtractor.CodeGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected abstract partial class CodeGenerator<TNodeUnderContainer, TCodeGenerat
5656

5757
protected readonly bool LocalFunction;
5858

59-
private ITypeSymbol? _finalReturnType;
59+
private ITypeSymbol _finalReturnType;
6060

6161
protected CodeGenerator(
6262
SelectionResult selectionResult,

0 commit comments

Comments
 (0)