VB -> C#: Converter takes the property name from interface instead of the concrete class.
See original GitHub issueInput code
Here is the code: https://github.com/Yozer/VBConverterBug
Converting project ToConvert results in code that doesn’t compile.
Erroneous output
var test = new Class1() { InterfaceProperty = "xxx" };
Console.WriteLine(test.InterfaceProperty);
Expected output
var test = new Class1() { OtherProperty = "xxx" };
Console.WriteLine(test.OtherProperty);
Details
- Product in use: VS extension
- Version in use: 8.2.4
- Did you see it working in a previous version? No
- Any other relevant information to the issue, or your interest in contributing a fix.
Looks like the converter takes the property name from the interface instead of the concrete class.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
c# - Generic type conversion FROM string
I have a class that I want to use to store "properties" for another class. These properties simply have a name and a...
Read more >Casting a interface to class
An explicit conversion exists (are you missing a cast?) That why I guess it means Casting Interface to Class. but what does it...
Read more >"interface" instances should not be cast to concrete types
Needing to cast from an interface to a concrete type indicates that something is wrong with the abstractions in use, likely that something...
Read more >How to serialize properties of derived classes with System. ...
In this article, you will learn how to serialize properties of derived classes with the System. Text. Json namespace.
Read more >Default interface methods - C# 8.0 draft feature specifications
This feature specification describe the syntax updates necessary to support default interface methods. This includes declaring bodies in ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I don’t think my fix is correct. It works fine for me because all my interfaces and their implementations are in another project that is not being converted. For another case (when we’re converting usages, interfaces & implementations) it incorrectly renames methods.
Looks good from a quick skim. I’ll have to look more closely at the condition you’ve used. I suggested TakeWhile in the hope of covering the situation where A -> B -> C, and only A and C are being converted. But that was just off the top of my head, and may not be optimal for this case or others
If you remove the “Skip” on this test, it should run locally: https://github.com/icsharpcode/CodeConverter/blob/master/Tests/CSharp/MultiFileSolutionAndProjectTests.cs#L22 (Apologies - A build server change broke it a while ago and I haven’t had time to investigate a fix for it yet). There’s a source solution which you could ensure has the vb project referencing the c# project then create a test case in