-
Notifications
You must be signed in to change notification settings - Fork 223
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
VB -> C#: Query Expression Syntax not fully implemented #29
Comments
Thanks for raising the issue. I've made a start on very basic query expression syntax which I think I'll try to get released soon. Visual Basic has slightly more features in its query syntax, so it'd take quite a bit more effort to support every possible case. I'll leave this issue open since even if your repro might be fixed, others may come along and upvote further work in this area. |
Hello, How can I help? |
Hi, thanks for getting in touch. I don't think those are related to this issue, but they are all things that can be worked on. If you're up for making changes, I'd suggest working on
Here's an example of a PR that has a similar kind of shape to what you'll need to do: Let me know (on a PR or issue comment) if you need more help - if you can push any code changes you make, and provide examples of what code snippet won't work it'll really help. |
@BaronBodissey I've now merged changes to support IntegerDivideExpression and IsExpression. If you could find which bit of code which threw the exception about |
@GrahamTheCoder I'm currently working on this issue and several others. I intend to commit today for you to check if my coding is okay. |
@GrahamTheCoder Soooorry I'm kinda new in here on github. I didn't understood your comment about |
@BaronBodissey No problem, everyone's new sometime! Yes any extra information about the PlusToken error would be great. |
Any idea when this feature will be implemented? I have a bunch of vb that needs to be converted, and this one keeps biting me. Thanks |
I've been putting it off because I'm not very familiar with vb's query syntax, so the thing I'm worried about is subtly changing the behavior of the code without realizing. It's possible some useful information can be gleaned from either the roslyn API or by following a pattern from the compiler itself. Ideally I'd have some examples of complex queries to test against. If you can provide any examples of queries you're trying to convert it'd help. I'd also be very happy to accept a pr either just containing just test cases, or with some improved implementation if you want to contribute directly. Now that someone is actively interested in the result, I will try to make some improvements in the next 2 weeks. Thanks for posting. |
I can send you a couple of samples that I manually converted. I'm not very familiar with VB's syntax either, that's why I was leaning on you guys :-) |
I put together a simple test case covering some of the broken stuff: [Fact]
public void LinqPartitionDistinct()
{
TestConversionVisualBasicToCSharp(@"Private Shared Function FindPicFilePath() As IEnumerable(Of String)
Dim words = {""an"", ""apple"", ""a"", ""day"", ""keeps"", ""the"", ""doctor"", ""away""}
Return From word In words
Skip 1
Skip While word.Length >= 1
Take While word.Length < 5
Take 2
Distinct
End Function", @"private static IEnumerable<string> FindPicFilePath()
{
var words = new[] {""an"", ""apple"", ""a"", ""day"", ""keeps"", ""the"", ""doctor"", ""away""};
return words
.Skip(1)
.SkipWhile(word => word.Length >= 1)
.TakeWhile(word => word.Length < 5)
.Take(2)
.Distinct();
}");
} When seen like that it looks so simple, but unfortunately I don't think I'll have time to work on this for a few weeks now since I'm away on holiday. |
@camainc Please add any other examples you have in the comments here and I'll turn them into tests |
Sure, next time I hit that I will.
~CRC~
*"You can give without loving, but you cannot love without giving." -- Amy
Carmichael*
[+] You're welcome to add me to your address book
<https://ws.evercontact.com/kwaga-bin/titan/WEB/me.pl/3189554321400600699/i>
…On Tue, May 29, 2018 at 2:17 PM GrahamTheCoder ***@***.***> wrote:
@camainc <https://github.com/camainc> Please add any other examples you
have in the comments here and I'll turn them into tests
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#29 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA5p3oowkVZT8tMI_JemXINJUnxY_Wfaks5t3brUgaJpZM4SP9J2>
.
|
I recently discovered: a Roslyn C# only query syntax to method chain converter. For the C# -> VB direction, it'd be possible to run this as a pre-step, then normal method conversion would work. It's possible something similar already exists for VB. I'm still hoping that the compiler itself may have an implementation we can use contained within it. Here's the example ILSpy output which does end up calling the Skip and Take methods as you would expect. The question is, did all those classes get generated for the closures separately, or intertwined. If it's intertwined we might not be able to easily get the arguments for each function out since even ILSpy doesn't manage to display this perfectly as lambdas return source.Skip(1).SkipWhile((_Closure$__.$I3-0 != null) ? _Closure$__.$I3-0 : (_Closure$__.$I3-0 = ((string word) => word.Length >= 1)))
.TakeWhile((_Closure$__.$I3-1 != null) ? _Closure$__.$I3-1 : (_Closure$__.$I3-1 = ((string word) => word.Length < 5)))
.Take(2)
.Distinct();
[Serializable]
[CompilerGenerated]
internal sealed class _Closure$__
{
public static readonly _Closure$__ $I;
public static Func<string, bool> $I3-0;
public static Func<string, bool> $I3-1;
static _Closure$__()
{
$I = new _Closure$__();
}
internal bool _Lambda$__3-0(string word)
{
return word.Length >= 1;
}
internal bool _Lambda$__3-1(string word)
{
return word.Length < 5;
}
} Needs more investigation. It might be that we can get ILSpy to handle this case and use that directly if Roslyn doesn't have an easier way built-in. |
Now that the basic syntax is covered, I'm going to close this overarching issue and try to deal with individual cases as they come up. |
Tried converting the following...
Large code snippet containing various query syntax
Imports System.Data Imports System.IO Imports FCA Imports FCA.Data Imports Legacy
The text was updated successfully, but these errors were encountered: