Skip to content

Use NRT#53287

Merged
CyrusNajmabadi merged 52 commits intodotnet:mainfrom
CyrusNajmabadi:useNRT
May 10, 2021
Merged

Use NRT#53287
CyrusNajmabadi merged 52 commits intodotnet:mainfrom
CyrusNajmabadi:useNRT

Conversation

@CyrusNajmabadi
Copy link
Contributor

No description provided.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 9, 2021 00:27
@ghost ghost added the Area-IDE label May 9, 2021
@CyrusNajmabadi CyrusNajmabadi merged commit 47fb229 into dotnet:main May 10, 2021
@CyrusNajmabadi CyrusNajmabadi deleted the useNRT branch May 10, 2021 01:23
@ghost ghost added this to the Next milestone May 10, 2021
Comment on lines +23 to +24
[NotNull]
public INamedTypeSymbol? ContainingType { get; private set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

😕 Why?

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 type is factory constructed. If you get an instance of it, the factory will have checked that this was not null.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just public INamedTypeSymbol ContainingType { get; }?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i got warnings then that the constructor doesn't set it. Do we have a preferred idiom hre? It's a transitional value. but i would prefer it represent the value for the final consumer that passes this around and operates on it.

Comment on lines +23 to +24
[NotNull]
public INamedTypeSymbol? ContainingType { get; private set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

😕

public bool IsIndexerMemberCRef(SyntaxNode node)
=> node.Kind() == SyntaxKind.IndexerMemberCref;
public bool IsIndexerMemberCRef(SyntaxNode? node)
=> node.IsKind(SyntaxKind.IndexerMemberCref);
Copy link
Contributor

@sharwell sharwell May 10, 2021

Choose a reason for hiding this comment

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

💭 It's interesting that this doesn't required the parameter attributes to match. If this isn't just a compiler oversight, perhaps we should add a code style analyzer for it?

if (index < 0)
{
return (null, null);
return default;
Copy link
Contributor

Choose a reason for hiding this comment

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

The original form had a bunch of benefits here. If the original had used default I don't think this return would have even been flagged by NRT.

}

private static (string pre, string post) GetPreAndPostTextParts(string text)
private static (string? pre, string? post) GetPreAndPostTextParts(string text)
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Based on use sites, (string pre, string post)? would be a less intrusive change here.

Comment on lines +140 to +141
if (parameter == null)
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

❔ Is this fixing a bug, or was it not reachable?


if (!syntaxFacts.IsSimpleArgument(current.Parent) ||
!syntaxFacts.IsElementAccessExpression(current.Parent.Parent.Parent))
!syntaxFacts.IsElementAccessExpression(current.Parent?.Parent?.Parent))
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 This only needed ?. for the last access:

current.Parent.Parent?.Parent


var collectionType = semanticModel.GetTypeInfo(collectionExpression, cancellationToken);
if (collectionType.Type == null && collectionType.Type.TypeKind == TypeKind.Error)
if (collectionType.Type == null || collectionType.Type.TypeKind == TypeKind.Error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test for this?

var conversion = compilation.ClassifyCommonConversion(argumentTypeInfo.Type, parameterType);
if (conversion.IsImplicit)
return true;
if (argumentTypeInfo.Type != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

❔ Is this not an intended precondition of the method? If it is, we could just add the following at the start of the (private) method:

Contract.ThrowIfNull(argumentTypeInfo.Type);

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at call sites, it looks more complicated (i.e. null is allowed for this property if the conditions above produce an early return). We could still add a Contract.ThrowIfNull, but it would need to be at this location in the method.

if (string.Equals(missingAssemblyIdentity.Name, candidateProject.AssemblyName, StringComparison.OrdinalIgnoreCase))
var candidateProject = project.Solution.GetRequiredProject(candidateProjectId);
if (candidateProject.SupportsCompilation &&
string.Equals(missingAssemblyIdentity.Name, candidateProject.AssemblyName, StringComparison.OrdinalIgnoreCase))
Copy link
Contributor

Choose a reason for hiding this comment

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

@jasonmalinowski to verify if we need to add any new checks for target projects that do not support compilation

var formatMethodsAcceptingParamsArray = formatMethods
.Where(x => x.Parameters.Length > 1 && x.Parameters[1].Type.Kind == SymbolKind.ArrayType);
if (formatMethodsAcceptingParamsArray.Contains(invocationSymbol))
if (expression != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test for this gap?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants