- Notifications
You must be signed in to change notification settings - Fork 10
VS-140: Fixed Error Reported by VS-140 Jira Ticket #66
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
Conversation
| } | ||
| } | ||
| | ||
| return builderDefinitionNodes.ToArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just return IEnumerable<Node> or IList<>, to skip this temporary allocations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| { | ||
| case NodeType.Builders: | ||
| { | ||
| nodesToRewrite = GetBuildersDefinitionNodes(semanticModel, expressionNode).ToArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So ToArray was moved to a different place. The goal was to avoid unnecessary copying of List to Array, in such transient processing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| continue; | ||
| } | ||
| | ||
| .FirstOrDefault(n => semanticModel.GetTypeInfo(n).Type.IsSupportedIMongoCollection()) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collectionNode == null logic is gone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| static DriverVersionHelper() | ||
| { | ||
| var driverVersion = Environment.GetEnvironmentVariable("DRIVER_VERSION"); | ||
| DriverVersions = new[] { NuGetVersion.Parse(driverVersion) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No-commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| } | ||
| rewriteContext.ConstantsMapper.FinalizeLiteralsRegistration(); | ||
| | ||
| //Get Node Remappings for Root Nodes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a comment in the case where it mostly repeats the method name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| // Skip MongoDB.Driver.Builders<T> nodes | ||
| if (node is MemberAccessExpressionSyntax memberAccessExpressionSyntax && | ||
| semanticModel.GetSymbolInfo(memberAccessExpressionSyntax).Symbol is IPropertySymbol propertyTypeSymbol && | ||
| propertyTypeSymbol.IsDefinedInMongoDriver() && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| // limitations under the License. | ||
| | ||
| // | ||
| using System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need these usings, and '//' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tests/MongoDB.Analyzer.Tests.Common.TestCases/Builders/BuildersDefinitions.cs Show resolved Hide resolved
| public FilterDefinitionBuilder<User> GetFilterDefinitionBuilder() => Builders<User>.Filter; | ||
| public static FilterDefinitionBuilder<User> GetFilterDefinitionBuilderStatic() => Builders<User>.Filter; | ||
| | ||
| public BuildersDefinitions GetClass() => new BuildersDefinitions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=> new(); (and next line)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| var typeArguments = rootTypeArguments.Select(rootTypeArgument => SyntaxFactory.ParseTypeName(typesProcessor | ||
| .GetTypeSymbolToGeneratedTypeMapping(rootTypeArgument))).ToArray(); | ||
| | ||
| var buildersGenericType = SyntaxFactory.GenericName("Builders").WithTypeArgumentList( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a const in MqlGeneratorSyntaxElements.Builders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| var rootTypeArguments = rootType.TypeArguments.ToArray(); | ||
| | ||
| var typeArguments = rootTypeArguments.Select(rootTypeArgument => SyntaxFactory.ParseTypeName(typesProcessor | ||
| .GetTypeSymbolToGeneratedTypeMapping(rootTypeArgument))).ToArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to convert to arrays at all (here and above).
Also we need to check whether type was processed by typesProcessor, and return early if it was not, like it's done in HandleRemappedType.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| if (symbolInfo.Symbol == null) | ||
| { | ||
| return default; | ||
| nodesRemapping.Clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a fan of indicating an error by clearing accumulated results. Let's have this method return a boolean indicating it's success.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| | ||
| [BuildersMQL("{ \"Name\" : \"User Name1\" }")] | ||
| [BuildersMQL("{ \"Name\" : \"User Name2\" }")] | ||
| public void MethodTest() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for 'Test' suffix. Let's try come up with a better convention here. Something like
Variable_definition_projection,
Variable_definition_indexkeys,
Method_definition
Static_method_definition
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| expressionDescendants = expressionNode.DescendantNodes(n => n != rootNode).OfType<IdentifierNameSyntax>(); | ||
| rootNodeRemapped = SyntaxFactory.IdentifierName(MqlGeneratorSyntaxElements.Linq.QueryableName); | ||
| expressionDescendants = expressionNode.DescendantNodes(n => !rootNodes.Contains(n)).OfType<IdentifierNameSyntax>(); | ||
| processGenerics = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node need for setting processGenerics here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
No description provided.