Open daveoftheparty opened 2 years ago
InterfaceStore has a lot of duplicate method calls against the SemanticModel, such as below:
InterfaceStore
.Select(prop => new { Namespace = node.Model.GetDeclaredSymbol(prop.Parent)?.ContainingSymbol?.ToString(), InterfaceName = node.Model.GetDeclaredSymbol(prop.Parent).Name, TypeArguments = GetInterfaceTypeArguments(node.Model.GetDeclaredSymbol(prop.Parent).Name, node.Model, prop.Parent), SourceFile = string.IsNullOrWhiteSpace(prop?.Parent.SyntaxTree.FilePath) ? uriAsFile : prop.Parent.SyntaxTree.FilePath, PropertyName = prop.Identifier.Text })
This happened through evolution of the code, maybe red-green then -oops-forgot-to-refactor
There may be a performance improvement here by converting the code to something like:
.Select(prop => { var parentSymbol = node.Model.GetDeclaredSymbol(prop.Parent); return new { Namespace = parentSymbol?.ContainingSymbol?.ToString(), InterfaceName = parentSymbol.Name, TypeArguments = GetInterfaceTypeArguments(parentSymbol.Name, node.Model, prop.Parent), SourceFile = string.IsNullOrWhiteSpace(prop?.Parent.SyntaxTree.FilePath) ? uriAsFile : prop.Parent.SyntaxTree.FilePath, PropertyName = prop.Identifier.Text }; })
InterfaceStore
has a lot of duplicate method calls against the SemanticModel, such as below:This happened through evolution of the code, maybe red-green then -oops-forgot-to-refactor
There may be a performance improvement here by converting the code to something like: