Skip to content

Commit

Permalink
Don't sort fields & properties + comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dpoeschl committed May 29, 2020
1 parent 1c98fa4 commit 535d786
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -934,13 +934,17 @@ private async Task<SyntaxNode> GenerateInferredCallsiteExpressionAsync(
semanticModel, position, document.Project.Solution.Workspace, cancellationToken: cancellationToken).ConfigureAwait(false);

var sourceSymbols = recommendations.Where(r => r.IsNonImplicitAndFromSource());

// For locals, prefer the one with the closest declaration. Because we used the Recommender,
// we do not have to worry about filtering out inaccessible locals.
// TODO: Support range variables here as well: https://github.com/dotnet/roslyn/issues/44689
var orderedLocalAndParameterSymbols = sourceSymbols
.Where(s => s.IsKind(SymbolKind.Local) || s.IsKind(SymbolKind.Parameter))
.OrderByDescending(s => s.Locations.First().SourceSpan.Start);

// No particular ordering preference for properties/fields.
var orderedPropertiesAndFields = sourceSymbols
.Where(s => s.IsKind(SymbolKind.Property) || s.IsKind(SymbolKind.Field))
.OrderByDescending(s => s.Locations.First().SourceSpan.Start);
.Where(s => s.IsKind(SymbolKind.Property) || s.IsKind(SymbolKind.Field));

var fullyOrderedSymbols = orderedLocalAndParameterSymbols.Concat(orderedPropertiesAndFields);

Expand Down

0 comments on commit 535d786

Please sign in to comment.