paul1956 / CSharpToVB

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

Please don't change public API names #80

Closed VBAndCs closed 2 years ago

VBAndCs commented 2 years ago

In this class I has a Value property:

public class Placeholder<T>
{
    T value;

    public T Value
    {
        get => value;
        set
        {
            Found = true;
            this.value = value;
        }
    }

    public bool Found = false;

    public override string ToString()
    {
        if (Found)
            return value?.ToString();

        return "Not Found";
    }
}

The converter changed it's name to Value1:

' To configure or remove Option's included in result, go to Options/Advanced Options...
Option Compare Text
Option Explicit On
Option Infer Off
Option Strict On

Public Class Placeholder(Of T)
    Private value As T
    Public Property Value1 As T
        Get
            Return value
        End Get

        Set(Value As T)
            Found = True
            Me.value = value
        End Set
    End Property
    Public Found As Boolean = False
    Public Overrides Function ToString() As String
        If Found Then
            Return value?.ToString()
        End If

        Return "Not Found"
    End Function
End Class

I know you are trying to avoid confection with the value filed, but you can safely change the private field name. Changing the public property name Value to Value1 causes many errors, some of them can happen in reflection in frameworks that use naming convention. So, whenever the case conflict happens, change the private name not the public name. Thanks.

paul1956 commented 2 years ago

Converter 5.0.2.5 fixes part of this. I no longer rename Value to Value1 but value is not renamed either. I do add Me. to value

VBAndCs commented 2 years ago

I no longer rename Value to Value1 but value is not renamed either

VB can't accept value and Value as two differenr names. I recommend to rename value to _value, but be aware not to change Value param in the set blocks in properties.

paul1956 commented 2 years ago

@VBAndCs I think I have a complete fix in 5.0.2.6. posted tomorrow. If not please provide complete source of C# and VB where conversion does not work.