paul1956 / CSharpToVB

New version of CSharpToVB converter
MIT License
25 stars 9 forks source link

Missing AddressOf #77

Closed VBAndCs closed 3 years ago

VBAndCs commented 3 years ago

In this sample

    public sealed class Timer
    {
        private static void ThreadTimerCallback(object tag)
        {
            if (Timer._tick != null)
            {
                Timer._tick();
            }
        }

        static Timer()
        {
            _interval = 100000000;
            _threadTimer = new System.Threading.Timer(ThreadTimerCallback);
        }
}

The last stement is cinverted to: _threadTimer = New Threading.Timer(ThreadTimerCallback)

When there is no () in C#, add AddressOf in VB.

VBAndCs commented 3 years ago

Also, there is still an error converting ref and out args that are infered from the params. I advice to convert this project and see the errors. SmallBasicLibrary.zip

VBAndCs commented 3 years ago

Another error you will see in the project conversion:

DoubleAnimation doubleAnimation = new DoubleAnimation(num, end, new Duration(TimeSpan.FromMilliseconds(timespan)));

Will be:

Dim doubleAnimation1 As New DoubleAnimation(num, [end], New Duration(TimeSpan1.FromMilliseconds(timespan)))

TimeSpan is changed to TimeSpan1. Please check first that this is not a shared method invocation. In fact, the one that should be changed is thetimespan var sent as an argument.

VBAndCs commented 3 years ago

And this one:

_applicationThread = new Thread((ThreadStart)delegate
{
    Application application = new Application();
    autoEvent.Set();
   _application = application;
   application.Run();
});

The converter added AddressOf b4 the lambda sub!

            _applicationThread = New Thread(
                CType(AddressOf Sub()
                        Dim application1 As New Application
                        autoEvent.[Set]()
                       _application = application1
                       application1.Run()
          End Sub, ThreadStart))

And there is no need to the cast in VB.

paul1956 commented 3 years ago

@VBAndCs doing this as 1 issue is very difficult to track and address. I need 1 issue per error AND a before C# and after VB to make any progress.

paul1956 commented 3 years ago

@VBAndCs AddressOf is Fixed in converter 5.0.1.20. The last issue directly above is also fixed. The others need to be in separate issue to allow tracking. Look at Tests.Issues. This is what I need to be able to fix issue. Just providing snippets doesn't always show the issue.