Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion missing members of lambda parameter in fault tolerance case #34312

Merged
merged 17 commits into from
Mar 29, 2019

Conversation

ivanbasov
Copy link
Contributor

Fix #8237

@ivanbasov ivanbasov added the IDE-IntelliSense Completion, Signature Help, Quick Info label Mar 21, 2019
@ivanbasov ivanbasov added this to the 16.1.P1 milestone Mar 21, 2019
@ivanbasov ivanbasov requested review from CyrusNajmabadi and a team March 21, 2019 00:04
@ivanbasov ivanbasov changed the title Theninclude Completion missing members of lambda parameter in fault tolerance case Mar 21, 2019
IParameterSymbol parameter,
int position,
Func<TArgumentListSyntax, SeparatedSyntaxList<TArgumentSyntax>> getArguments,
CancellationToken cancellationToken)
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whooboy. this is complex.

  1. Consider doc'ing this.
  2. should we pull these type parameters up to the class? Does either language ever call this same method with a different instantiation? #Resolved

where TLambdaExpressionSyntax : SyntaxNode

{
if (!(parameter.ContainingSymbol is IMethodSymbol containingMethod &&
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole method needs comments helping explain what is going on. i.e.: // this code is to help give intellisense in the following case: .... And then explain what we're looking for and what this is working around. #Resolved

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm going to hold off until then, aas that will really help me understand what's going on here and why it's appropriate. Ping me whne you think it's good to look again! #Resolved

return default;
}

var lambdaSyntax = containingMethod.DeclaringSyntaxReferences.Single().GetSyntax(cancellationToken) as TLambdaExpressionSyntax;
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single is very dangerous. We should verify we only have one ref before doing this. you never know if a future compiler change might break this. #Resolved

@ivanbasov
Copy link
Contributor Author

ivanbasov commented Mar 26, 2019

@CyrusNajmabadi , @dpoeschl , could you please review? #Resolved

@@ -32,6 +32,7 @@
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="$(MicrosoftVisualStudioShell150Version)" />
<PackageReference Include="Microsoft.VisualStudio.ComponentModelHost" Version="$(MicrosoftVisualStudioComponentModelHostVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
<PackageReference Include="StreamJsonRpc" Version="$(StreamJsonRpcVersion)" />
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from another PR. Thank you!


In reply to: 268920484 [](ancestors = 268920484)

protected abstract bool TryGetOrdinalInArgumentList(SyntaxNode argumentOpt, out int ordinalInInvocation);

// This code is to help give intellisense in the following case:
// query.Include(a => a.SomeProerty).ThenInclude(a => a.
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proerty #Resolved

// Cannot proceed without DeclaringSyntaxReferences.
// We expect that there is a single DeclaringSyntaxReferences in the scenario.
// If anything changes on the compiler side, the approach should be revised.
if (containingMethod.DeclaringSyntaxReferences.IsDefaultOrEmpty || containingMethod.DeclaringSyntaxReferences.Length > 1)
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeclaringSyntaxReferences is never Default. So you could just simple this to .DeclaringSyntaxReferences.Length != 1 #Resolved

continue;
}

type = type.GetAllTypeArguments()[ordinalInLambda];
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allTypeArguments[ordinalInLambda] #Resolved

Return New VisualBasicRecommendationServiceRunner(context, filterOutOfScopeLocals, cancellationToken)
End Function

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove. #Resolved

@@ -17,6 +17,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
End Sub

Public Overrides Function GetSymbols() As ImmutableArray(Of ISymbol)

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove... #Resolved

@@ -53,6 +54,29 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
Return ImmutableArray(Of ISymbol).Empty
End Function

Protected Overrides Function IsInvocationExpression(syntaxNode As SyntaxNode) As Boolean

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove #Resolved

End Function

Protected Overrides Function IsLambdaExpression(syntaxNode As SyntaxNode) As Boolean

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove #Resolved

Copy link
Contributor Author

@ivanbasov ivanbasov Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of those empty lines. I just found them in the original code. Was it an obsolete code style? #Resolved

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... that's super bizarre... i'm not sure how that happened. def can remove :) (and can get rid of all my comments). #Resolved

Copy link
Contributor Author

@ivanbasov ivanbasov Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Thanks! Will remove all the empty lines #Resolved

End Function

Protected Overrides Function TryGetOrdinalInArgumentList(argumentOpt As SyntaxNode, ByRef ordinalInInvocation As Integer) As Boolean

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove #Resolved


ordinalInInvocation = -1
Return False
End Function
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, fwiw, i think you could use ISyntaxFacts and not need the top two methods. You could also move this method into the base type. #Resolved

@@ -85,6 +109,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
End Function

Private Function GetUnqualifiedSymbolsForLabelContext() As ImmutableArray(Of ISymbol)

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove. this style is not used at all in the IDE. #Resolved

@@ -491,6 +523,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Recommendations
End Function

Private Function IsOrContainsValidAccessibleClass(namespaceOrTypeSymbol As INamespaceOrTypeSymbol, within As ISymbol) As Boolean

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please undo all of this :) it's just not the IDE style (i also don't understand why we'd want it). #Resolved

return default(IIncludableQueryable<TEntity, TProperty>);
}
}
}]]>
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you extract this into a constant and just include that in all these tests. it really bloats to have to have it in each test. #Resolved

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it also makes it harder to tell how each test differs. #Resolved


Friend Class Registration
Public Property Activities As ICollection(Of Activity)
End Class
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same point here. #Resolved

{
var builder = ArrayBuilder<ITypeSymbol>.GetInstance();
var expressionSymbol = _context.SemanticModel.Compilation.GetTypeByMetadataName(typeof(Expression<>).FullName);
var funcSymbol = _context.SemanticModel.Compilation.GetTypeByMetadataName(typeof(Func<>).FullName);
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to be resilient to these not being around.

it's rare, but it can definitely happen during solution load (when we don't have all references properly attached). Either we can bail here if they're null, or we can check them in the loop accordingly. #Resolved

cancellationToken As CancellationToken) As AbstractRecommendationServiceRunner(Of VisualBasicSyntaxContext)
context As VisualBasicSyntaxContext,
filterOutOfScopeLocals As Boolean,
cancellationToken As CancellationToken) As AbstractRecommendationServiceRunner(Of VisualBasicSyntaxContext)
Return New VisualBasicRecommendationServiceRunner(context, filterOutOfScopeLocals, cancellationToken)
End Function
End Class
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can just revert this file. #Resolved

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. would like test cleanup, and we need some null checks. I don't need to review again. Tnx!

@ivanbasov
Copy link
Contributor Author

@dpoeschl please review

@ivanbasov
Copy link
Contributor Author

@genlu could you please review?

@ivanbasov ivanbasov modified the milestones: 16.1.P1, 16.1.P2 Mar 27, 2019
Copy link
Member

@genlu genlu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@ivanbasov ivanbasov merged commit f38ba3a into dotnet:master Mar 29, 2019
@ivanbasov ivanbasov deleted the theninclude branch March 29, 2019 19:02
@gafter
Copy link
Member

gafter commented Mar 29, 2019

Nice work @ivanbasov !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IDE-IntelliSense Completion, Signature Help, Quick Info
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants