Closed ghost closed 5 years ago
@SteveLaycock is it possible to share the interface definition for the Kvp
? Knowing how the dispatch IDs are arranged may help clarify the issue.
No problem. I've attached the source code file. Please be aware that I am not a professional programmer have only previously coded in VBA (apart from some 6502 assembly and a small amount of ANSI C back in the 1980's doing image processing stuff for my PhD). This was my first foray into c# and it did take a few months googling and trial and error to get to the current state. I'm currently working up courage to put it up on code review for comment.
The VBA test suite for the Kvp object is also attached
@SteveLaycock Two questions:
p
is declared. That might also help.So far, I have not been able to reproduce this issue ar any discrepancy between the selection and expression.
Final stupid question, just in case: you have not defined a public function Split
in your project or a private one in the module, right?
Your stupid question is entirely correct in its surmise. I am stupid, I will go and stand in the corner with my pointy hat on for the rest of the evening. The code in question should of course read VBA.Split... Which of course raises the follow on inspection thought that VBA has missed this duplication of names so maybe its a job for rubberduck?
BUT what would be causing a similar error in the following case
'@TestMethod("HelperForStrings")
Private Sub T2A_Stringify_object()
Dim myString As String
Dim myTest As String
Dim myValue As Collection
On Error GoTo TestFail
'Arrange:
myString = "{Can't stringify Type: Collection}"
Set myValue = New Collection
myValue.Add "Hurrah"
myTest = HelperForStrings.Stringify(Array(myValue), vbNullString)
'Assert:
Assert.AreEqual myString, myTest
'TestExit:
Exit Sub
TestFail:
Assert.Fail "Test raised an error: #" & Err.Number & " - " & Err.Description
End Sub
which gives the inspection report
Error: In a context that requires a value type, the expression 'myValue' of object type 'VBE7.DLL;VBA.Collection' is used that does not have a suitable default member. - (Utuls) Utils.TestStrings, line 261
FWIW we do have shadowed inspection. I think that should have been caught.
OK, this is a legitimate bug. The resolver does not correctly handle param arrays, atm.
I have to correct myself, the problem is not strictly with param arrays but with the type names provided for arrays by the part of RD that loads libraries. It adds parentheses to the type name ,if the type is an array. This interferes with the check for the parameter type Variant
for param arrays.
Rubberduck version information
Version 2.4.1.4940 OS: Microsoft Windows NT 10.0.18362.0, x64 Host Product: Microsoft Office x64 Host Version: 16.0.12026.20108 Host Executable: WINWORD.EXE
Description
I'm getting the following inspection result, but the variable highlighted when I double click the inpsection report is not that referred to by the inspection report
Error: In a context that requires a value type, the expression 'Split(p.Value, mySeparator)' of object type 'VBAExtensions.tlb;VBAExtensions.Kvp' is used that does not have a suitable default member. - (Utuls) Utils.OStrActor
The object Kvp is provided by a C# library, the result of my first foray into c# programming.
I've refreshed the project several times to make sure that I'm not looking at out of date information.
The variable p.value is a string.