Given following two type-definitions:
Visual Basic'File: IInterface.vb
Public Interface IInterface
Property Prop As String
End Interface
'File: Class1.vb
Public Class Class1
Implements IInterface
Public Property Prop As String Implements IInterface.Prop
End Class
When moving IInterface to Namespace "Test", the code for "Class1" looks like that:
Visual BasicImports ClassLibrary1.Test
Public Class Class1
Implements IInterface
Public Property Prop As String Implements Test.IInterface
End Class
The implements-statement for the property "Prop" has also been changed - and to a complete sensless statement -, what is wrong.
It seems to me, that the implementation is only half done. I would like to have this as the result:
Visual BasicPublic Class Class1
Implements Test.IInterface
Public Property Prop As String Implements Test.IInterface.Prop
End Class
The Namespace "ClassLibrary1.Test" should not be imported, so conflicts with members of other imported namespaces are avoided:
Visual Basic' File: IInterface1.vb
Namespace Test1
Public Interface IInterface
Property Prop As String
End Interface
End Namespace
' File: IInterface2.vb
Namespace Test2
Public Interface IInterface
Property Prop As String
End Interface
End Namespace
'File: Class1.vb
Public Class Class1
Implements Test1.IInterface, Test2.IInterface
Public Property Prop1 As String Implements Test1.IInterface.Prop
Public Property Prop2 As String Implements Test2.IInterface.Prop
End Class
Hi Robert,
Thank you for the code snippet. I have reproduced the issue with the Implements clause and we are working on it.
Hi Alex,
thank you for hotfix. Testing it results in following code after refactoring:
Imports ClassLibrary1.Test Public Class Class1 Implements IInterface1 Public Property Prop As String Implements Test.IInterface1.Prop End Class
This code is a little bit confusing and leads to missunderstandings. Please decide for only one way, not two ways at the same time:
* When you realy want an Imports-Statement, then remove the Namespace-Name in the Implements-Statement ("Name can be simplified").
* And when you want to go the way I suggest, then remove the Imports-Statement and add the Namespace-Name to the Implements-Statement. This result would be fine:
Public Class Class1 Implements Test.IInterface1 Public Property Prop As String Implements Test.IInterface1.Prop End Class
Hi Robert,
Thank you for your feedback! Please give us some time to research the situation and make necessary corrections.
Robert,
We have made necessary corrections and now there isn't a redundant 'Test' qualifier in the Impelements section. However, it's not possible to 'simplify' the Imports name because it makes code uncompilable:
https://www.screencast.com/t/Nsrt60Fx
Alex,
I think you missed my intent, and there is a confusion between the Imports- and the Implements-Statements and the Base-Namespace.
My opinion is to remove the Imports(!)-Statement at all, and to include the namespace (without the Base-Namespace "ClassLibrary33") to the Imports(!)-Statements.
In VB.net it is not neccessary to include the Base-Namespace (eg. "ClassLibrary33"). So my example, mentioned in a previous comment, functions well!
Please have a look at the attached Project.
Hi Robert,
The use of Imports or fully-qualified types is a matter of code styling. I suggest you set the 'Namespace references declaration style' option (CodeRush\Options\Editor\Visual Basic\Programming Style) to 'Use fully qualified type names':
https://www.screencast.com/t/JUISH3QlQ1
Hi Alex,
YESSS! That's what I wanted!
I didn't realized, that this option exists.
Thank you!
You are welcome, Robert!