paul1956 / CSharpToVB

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

Wrong type for out param #41

Closed VBAndCs closed 4 years ago

VBAndCs commented 4 years ago

C#

        protected static PropertyHelper[] GetVisibleProperties(
            Type type,
            Func<PropertyInfo, PropertyHelper> createPropertyHelper,
            ConcurrentDictionary<Type, PropertyHelper[]> allPropertiesCache,
            ConcurrentDictionary<Type, PropertyHelper[]> visiblePropertiesCache)
        {
            if (visiblePropertiesCache.TryGetValue(type, out var result))
            {
                return result;
            }
        }

VB:

Option Compare Text
Option Explicit On
Option Infer Off
Option Strict On
Protected Shared Function GetVisibleProperties( _
_type As Type,
createPropertyHelper As Func(Of PropertyInfo, PropertyHelper),
allPropertiesCache As ConcurrentDictionary(Of Type, PropertyHelper()),
visiblePropertiesCache As ConcurrentDictionary(Of Type, PropertyHelper())) As PropertyHelper()
    Dim result As Type = Nothing

    If visiblePropertiesCache.TryGetValue(_type, result) Then
        Return result
    End If
End Function

This declaration: 'Dim result As Type = Nothing' is wrong, since Type is the first param type, and you need the second param type. Try it with know methods to reproduce it.

And by the way, I hope you format the separated lines as in the function param list , by adding some taps to start of each line.

paul1956 commented 4 years ago

I don't do the formatting, I copy it from C# and then call Normalize. The problem is after an _ the formatting code does not work correctly and there is a open issue against Roslyn. I will see if there are any manual improvements I can do.

paul1956 commented 4 years ago

fixed in 4.2.11.0 converter 3.3.0.0