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

VS-153: Enable TypesProcessor to Process Dictionaries #77

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Ravi-Raghavan
Copy link
Collaborator

Enable TypesProcessor to Process Dictionaries

@Ravi-Raghavan Ravi-Raghavan requested a review from BorisDog July 12, 2024 15:55
SyntaxFactory.Identifier("List"),
SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList(new[] { underlyingTypeSyntax })));
var underlyingTypeSyntaxes = namedTypeSymbol.TypeArguments.Select(typeArgument => CreateTypeSyntaxForSymbol(typeArgument));
var collectionIdentifier = namedTypeSymbol.TypeArguments.Length switch
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need a better collection identification here.
What if it's MyCustomList<A,B> : IList<A> (probably good idea to add tests).

Let's determine the collection type by the actual type: Dictionary, IDictionary => Dictionary, List ... => List

public class CustomEnumerableHolder
{
public CustomIEnumerable<int> Enumerable1 { get; set; }
public CustomIEnumerable<EnumerableHolder> Enumerable2 { get; set; }
}

public class CustomIDictionary<TKey, TValue> : IDictionary<TKey, TValue>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add also ISet, Queue, Stack, just to be on the safe side.

@@ -253,4 +253,18 @@ private static (NodeType NodeType, INamedTypeSymbol NamedSymbol, SyntaxNode Expr

return (nodeType, namedType, expressionNode);
}

private static bool ProcessTypeArguments(IEnumerable<ITypeSymbol> typeArguments, TypesProcessor typesProcessor)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could simplify with
namedType.TypeArguments.All(t => typesProcessor.ProcessTypeSymbol(t) != null)
Maybe no need for the helper method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

public void CustomDictionaries()
{
_ = GetMongoQueryable<CustomDictionariesHolder>().Where(t =>
t.IntDictionary["key"] == 1 &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

Indentation everywhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@Ravi-Raghavan Ravi-Raghavan requested a review from BorisDog August 6, 2024 15:33
@BorisDog BorisDog removed their request for review August 15, 2024 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants