private static ExtractMethodResult TryWithoutMakingValueTypesRef( Document document, NormalizedSnapshotSpanCollection spans, ExtractMethodResult result, CancellationToken cancellationToken) { OptionSet options = document.Project.Solution.Options; if (options.GetOption(ExtractMethodOptions.DontPutOutOrRefOnStruct, document.Project.Language) || !result.Reasons.IsSingle()) { return(null); } var reason = result.Reasons.FirstOrDefault(); var length = FeaturesResources.Asynchronous_method_cannot_have_ref_out_parameters_colon_bracket_0_bracket.IndexOf(':'); if (reason != null && length > 0 && reason.IndexOf(FeaturesResources.Asynchronous_method_cannot_have_ref_out_parameters_colon_bracket_0_bracket.Substring(0, length), 0, length, StringComparison.Ordinal) >= 0) { options = options.WithChangedOption(ExtractMethodOptions.DontPutOutOrRefOnStruct, document.Project.Language, true); var newResult = ExtractMethodService.ExtractMethodAsync( document, spans.Single().Span.ToTextSpan(), options, cancellationToken).WaitAndGetResult(cancellationToken); // retry succeeded, return new result if (newResult.Succeeded || newResult.SucceededWithSuggestion) { return(newResult); } } return(null); }
private static ExtractMethodResult TryWithoutMakingValueTypesRef( Document document, NormalizedSnapshotSpanCollection spans, ExtractMethodResult result, ExtractMethodOptions options, CancellationToken cancellationToken) { if (options.DontPutOutOrRefOnStruct || !result.Reasons.IsSingle()) { return(null); } var reason = result.Reasons.FirstOrDefault(); var length = FeaturesResources.Asynchronous_method_cannot_have_ref_out_parameters_colon_bracket_0_bracket.IndexOf(':'); if (reason != null && length > 0 && reason.IndexOf(FeaturesResources.Asynchronous_method_cannot_have_ref_out_parameters_colon_bracket_0_bracket.Substring(0, length), 0, length, StringComparison.Ordinal) >= 0) { var newResult = ExtractMethodService.ExtractMethodAsync( document, spans.Single().Span.ToTextSpan(), localFunction: false, options with { DontPutOutOrRefOnStruct = true },