rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 299 forks source link

Supporting Autodesk Inventor #5997

Open inventordev opened 2 years ago

inventordev commented 2 years ago

Hello,

I'm trying to support Autodesk Inventor.

Some of declaration throw the exceptions and they cause "Resolver Error". I determined the declarations that causing the error and wrote the code to discard them.

// TypeAnnotationPass.cs
        public void Execute(IReadOnlyCollection<QualifiedModuleName> modules)
        {
            var toDetermineAsTypeDeclaration = _declarationFinder
                                                .FindDeclarationsWithNonBaseAsType()
                                                .Where(decl => decl.AsTypeDeclaration == null 
                                                        || modules.Contains(decl.QualifiedName.QualifiedModuleName));
            foreach (var declaration in toDetermineAsTypeDeclaration)
            {
+               if (declaration.CustomFolder == "Inventor" && 
+                   declaration.AsTypeName == "Circle")
+               {
+                   continue;
+               }
                AnnotateType(declaration);
            }
        }

How can I properly address this issue?

Thanks,

inventordev commented 2 years ago

I found the interesting thread. https://stackoverflow.com/questions/22986017/undocumented-vba-special-keywords-circle-and-scale

Here is a test code and the errors happen with a vanilla Excel VBA.

Sub test()
    Dim Circle As Object ' Error
    Dim Scale as Object ' Error
    Dim Line As Object ' OK
    Dim Point As Object ' OK
End Sub

"Circle" seems to be a special keyword and Rubberduck may be confused because Inventor has a class named "Circle".

MDoerner commented 2 years ago

I think you are right with your analysis. To deal with this, one probably has to amend the parser and the resolver in analogy with how we did it to enable the Object.Print statement from VB6.

ls-2037 commented 2 years ago

Hi @inventordev , I have applied this patch to the lastest Rubberduck source code, but Rubberduck still crashes on load with Inventor 2020. Which version of Inventor are you using?

inventordev commented 2 years ago

Hi, I'm using Inventor 2022. I'll try with 2020 later.

inventordev commented 2 years ago

Inventor 2020 cause an error when booting VBE as you said...

inventordev commented 2 years ago

NLog.LogManager.Configuration was null if Inventor 2020 was used and this caused the error. I don't know why it was null or who should have initialized this object.

ls-2037 commented 1 year ago

Hi @inventordev , I have been using this patch with Inventor 2022 and it does allow Rubberduck to work. However, I often get an "Unexpected Error" from Rubberduck during refresh when I have Inventor files open. Have you had any similar issues?