Skip to content

Invoking Rubberduck methods from VBA or other COM-Aware programs #6269

Open
@DecimalTurn

Description

@DecimalTurn

For VBA-Build, I was curious to see if it was possible to install Rubberduck inside a GitHub Action worker and run the tests inside a VBA project. The installation part worked, but as discussed in #5995, there is no way to access Rubberduck's method from the CLI at the moment.

However, looking in the code, there is currently this comment in TypeLibsAPI.cs:

{
/// <summary>
/// FOR DEBUGGING/DEVELOPMENT PURPOSES, ALLOW ACCESS TO SOME VBETypeLibsAPI FEATURES FROM VBA
/// </summary>
/// <remarks>
/// VBA Usage example:
/// With Application.VBE.Addins("Rubberduck.Extension").Object
/// .ExecuteCode("ProjectName", "ModuleName", "ProcedureName")
/// End With
/// </remarks>
[
ComVisible(true),
Guid(RubberduckGuid.DebugAddinObjectInterfaceGuid),
InterfaceType(ComInterfaceType.InterfaceIsDual),
EditorBrowsable(EditorBrowsableState.Always)
]
public interface IVBETypeLibsAPI_Object
{
[DispId(1)]
bool CompileProject(string projectName);
[DispId(2)]

And this suggests to me that if the TypeLibsAPI was available in the release build or an alternative build, it would be possible to acess certain Rubberduck methods via VBA/COM directly. Then, it would be possible to write some kind of wrapper around the RunAllTestsCommand to return the outcome of the tests as a text file that could be used by the CLI.

eg.:

    Dim Output As String
    With Application.VBE.AddIns("Rubberduck.Extension").Object
        Output = .RunAllTests()
    End With
    ' Then write output to text file...

Does that sounds like a reasonable idea? I could try to work on this.

Side note Also, while playing around with a debug build, I tried :
    Dim Output As String
    With Application.VBE.AddIns("Rubberduck.Extension").Object
        Output = .DocumentAll()
    End With
    Debug.Print Output

But I'm getting the error below while calling Output = .DocumentAll()

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests, or enhancements to existing features. Ideas. Anything within the project's scope.typeinfo-processingIssue is easier to resolve with knowledge of the COM collector/ITypeLib internal API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions