Closed viclin-msft closed 3 years ago
My current workaround:
private IEnumerable<SyntaxElement> GetEnumerableElements(SyntaxList list)
{
foreach (var element in list)
{
yield return element.GetChild(0); // element is SeparatedElement; the first child is the actual item in list
}
}
SyntaxList elements = ...
GetEnumerableElements(elements).Select(x => x.ToString());
Adding @Matt Warrenmailto:mattwar@microsoft.com
// Sent from phone
From: Victor Lin notifications@github.com
Sent: Wednesday, December 30, 2020 10:22:05 PM
To: microsoft/Kusto-Query-Language Kusto-Query-Language@noreply.github.com
Cc: Subscribed subscribed@noreply.github.com
Subject: Re: [microsoft/Kusto-Query-Language] Make SyntaxList implement IEnumerable
My current workaround:
private IEnumerable
SyntaxList elements = ... GetEnumerableElements(elements).Select(x => x.ToString());
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FKusto-Query-Language%2Fissues%2F41%23issuecomment-752746543&data=04%7C01%7CAlexander.Sloutsky%40microsoft.com%7C4689bd1900aa403cdabf08d8ad00931f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637449565279496978%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=X66v1ol9aW8mdza9TSDtPU%2FUtj7pQJNAD5obib4hyBE%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAEH2NB2AND6CTKURYDXIJ6DSXODW3ANCNFSM4VOVUMQQ&data=04%7C01%7CAlexander.Sloutsky%40microsoft.com%7C4689bd1900aa403cdabf08d8ad00931f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637449565279496978%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=5VtL1s7qWEYYMoPYyrF9cukxFGaAiQZXuIyx4ykPpyQ%3D&reserved=0.
The type SyntaxList
is an abstract base for SyntaxList<T>
. SyntaxList<T>
already does implement IEnumerable<T>
via IReadOnlyList<T>
. However, if both the base type and subtype implement different IEnumerable<T>
it confuses LINQ and blocks uses of extension methods on any SyntaxList<T>
subtype.
SyntaxList
does implement the enumerable pattern, though. That lets you use foreach, but not other LINQ methods.
Currently,
SyntaxList
does not support LINQ queries, e.g.This can be supported by having the class implement
IEnumerable<SyntaxElement>
.It is comparable to Microsoft.CodeAnalysis.SyntaxList.