Skip to content
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

Resources not converted VB -> C# #540

Closed
marcal opened this issue Mar 10, 2020 · 7 comments · Fixed by #545
Closed

Resources not converted VB -> C# #540

marcal opened this issue Mar 10, 2020 · 7 comments · Fixed by #545
Labels
output logic error A bug where the converted output behaves differently to the input code VB -> C# Specific to VB -> C# conversion

Comments

@marcal
Copy link

marcal commented Mar 10, 2020

Hello,
I have decided to make a test to convert a a small project from vb.net to c#. as I had problems I have
)tried to do a conversion of a smaller project.

I have made a simple form with one toolstrip button whose picture is in the project resource. The picture resource doesn't exist in the converted project. The picture is there but the project says that there is no [resources]. Here is a small project to reproduce the error.
WindowsApp1.zip

  • In another project I sometimes have two constructors for a Form but I can't find a reason (I will try to make a project to reproduce later)
  • I also have a problem when there is a file
    Resources.nl-BE.Designer.vb in my project : the file has a size of 0 and is not converted but c# want this file (so it must be created manually)

Thank you
Marc

@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Mar 10, 2020

Thanks for posting. Part of the issue sounds like #423. I'll have more of a look this weekend, but just in case it helps in the meantime, saving the resource file in visual studio (ensuring code generation is enabled) should regenerate the designer file I think.

The constructor issue (now tracked as #541) sounds related to something I've been changing recently but not released yet. Might be worth trying the latest ci build (vsix file within drop.zip)
https://icsharpcode.visualstudio.com/icsharpcode-pipelines/_build/latest?definitionId=2&branchName=master&status=succeeded
Now released as 8.0.0, could you try the updated version?

I'll update the relevant other tickets with any details, and just track the first issue you mentioned "the project says that there is no [resources]". If the resource is looked up by namespace, it could be caused by the namespace being generated differently in VB and C# depending on the rootnamespace of the project, but I'll try the (much appreciated) example this weekend and let you know.

@GrahamTheCoder GrahamTheCoder added the VB -> C# Specific to VB -> C# conversion label Mar 11, 2020
@marcal
Copy link
Author

marcal commented Mar 13, 2020

Thank you. I will try as this week end
MArc

@GrahamTheCoder GrahamTheCoder added the output logic error A bug where the converted output behaves differently to the input code label Mar 14, 2020
@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Mar 14, 2020

For the default resource, you can workaround by changing a line in the designer.cs file:
new System.Resources.ResourceManager("WindowsApp1.Resources", typeof(Resources).Assembly)
to
new System.Resources.ResourceManager("WindowsApp1.My_Project.Resources", typeof(Resources).Assembly)

Regenerating the designer file also fixes this (i.e. Open the resx file, next to code generation select public, select internal again, then press ctrl+s). Unfortunately it then changes the namespace - so I'll also change CustomToolNamespace in the csproj as part of this issue.

Hopefully I'll have time tomorrow to find the best fix for this (and for #423)

@marcal
Copy link
Author

marcal commented Mar 14, 2020

Hello,

I have made a test project (removed everything from an project to have the error with the resource file.

  • The work around with public doesn't work and there is no resourcemanager... to edit (first part)...

  • I also have the error
    Operator '==' cannot be applied to operands of type 'T' and 'default' Backup

  • Also, there is no reference to Microsoft.VisualBasic so there are a lot of errors
    (The converted designer has
    [Microsoft.VisualBasic.CompilerServices.DesignerGenerated()]
    that seems to be useless

Backup.zip

@GrahamTheCoder
Copy link
Member

I've made sure the Microsoft.VisualBasic reference gets added in more cases in #545
I'll keep the attribute just for consistency with the input, but you're right it won't do anything.

@GrahamTheCoder GrahamTheCoder added this to the 8.1.0 milestone Mar 16, 2020
@Saibamen
Copy link
Contributor

Should be fixed in release 8.0.2: https://github.com/icsharpcode/CodeConverter/releases/tag/8.0.2
Please retest

@marcal
Copy link
Author

marcal commented Mar 20, 2020

Hello,

It is working. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
output logic error A bug where the converted output behaves differently to the input code VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants