paul1956 / CSharpToVB

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

Set Option Infer to ON and on Sub Main remove Private access modifier #50

Closed elGuille-info closed 3 years ago

elGuille-info commented 4 years ago

In a small file for console application I found this: Set Option Infer to On because in for loops the variable isn't assigned a type For i = 1 To args.Length -1 And in C# the "infer" is default when using var.

I know you can set in the CSharpToVB application, but... it should be as default ON (like Option Strict is).

The Sub Main method was set as Private Sub Main and as a console application (even on WinForms) should be the entry point.

On the Editor will be a good idea to use another font type for view the code (Cosnsolas, etc.) or at least an option to set the font.

These are my 2 cents :-) Thanks!

Guillermo (#evolveVB #evolucionarVB)

paul1956 commented 3 years ago

@elGuille-info Thanks for the feedback

You can set the Option defaults any way you want under Options/Advanced Options.. and the app will remember. You can also select what you want included in each file. So I am not going to change this. If I ever have an installer it could set the defaults or I could force user to it on First Run.

I agree about Consolas and will change in next update and allow user to set Font for the session. I will save it when VS supports settings fully in a future update,

Not sure how to fix Sub Main I do special case it as below. If you can recommend a solution open a separate issue and I will look at it

If Me.IsModule AndAlso
  methodNameToken.ValueText = "Main" AndAlso
  node.Modifiers.Count = 1 AndAlso
  node.Modifiers(0).IsKind(CS.SyntaxKind.StaticKeyword) Then
  modifiers = PublicModifier.ToList
Else
    modifiers = ConvertModifiers(node.Modifiers, Me.IsModule, If(containingType?.IsInterfaceType() = True, TokenContext.Local, TokenContext.Member)).ToList
End If
elGuille-info commented 3 years ago

You can set the Option defaults any way you want under Options/Advanced Options.. and the app will remember. You can also select what you want included in each file. So I am not going to change this. If I ever have an installer it could set the defaults or I could force user to it on First Run.

Yes, I know, but if you are converting from C# to VB, and the user doesn't set OPTION INFER to ON then can get erros because C# always use the equivalent Option Infer On. Or at least set Option Infer On and Option Strict On by default.

Guillermo

paul1956 commented 3 years ago

@elGuille-info I changed default but it will not change any existing installations (its the way setting works). Option Strict on is already the default.