Rubberduck icon indicating copy to clipboard operation
Rubberduck copied to clipboard

Failing test: Identify_NamedParameter_Parameter_FromExcel

Open pflugs30 opened this issue 1 year ago • 21 comments

While working on #6063, I encountered a single failing test: image

 Identify_NamedParameter_Parameter_FromExcel
   Source: SelectedDeclarationProviderTests.cs line 515
   Duration: 1.7 sec

  Message: 
  Expected: <Rubberduck.Parsing.Symbols.ParameterDeclaration>
  But was:  <Rubberduck.Parsing.Symbols.ParameterDeclaration>


  Stack Trace: 
SelectedDeclarationProviderTests.Identify_NamedParameter_Parameter_FromExcel() line 532

When I debug through the test, I see the following: image

So, the expected Scope and ParentScope are EXCEL.EXE;Excel._Worksheet.Paste" and the actual Scope and ParentScope are EXCEL.EXE;Excel.Worksheet.Paste". I haven't explored these tests too much. Is there any chance this issue is related to 64-bit vs 32-bit? Could it be related to particular versions of Excel installed on the development machine?

Originally posted by @pflugs30 in https://github.com/rubberduck-vba/Rubberduck/issues/6063#issuecomment-1368085235

pflugs30 avatar Dec 30 '22 20:12 pflugs30

Nah, that was me messing up my local build - fixing the test should be as simple as changing its expectations to match the actual.

retailcoder avatar Dec 30 '22 20:12 retailcoder

@retailcoder but this is passing on both VS 2019, VS 2022 and on AV's VS 2022?

I think there's something about the Excel library. I don't think it's a 32/64 bit thing but rather the Excel library, need to double check what it's using.

bclothier avatar Dec 30 '22 20:12 bclothier

@pflugs30 , could you grab the XML files from this path:

.\RubberduckTests\bin\Testfiles\Resolver and zip it up and post it here? I want to do a diff on those files.

bclothier avatar Dec 30 '22 21:12 bclothier

FYI I sent you an invite to the RD org; if you accept the invite you'll be an "official" contributor and will be able to label issues and get access to the RD3 private repository: feel free to look around, but note that I have a ton of local changes yet to be pushed there.

retailcoder avatar Dec 30 '22 22:12 retailcoder

@pflugs30 , could you grab the XML files from this path:

.\RubberduckTests\bin\Testfiles\Resolver and zip it up and post it here? I want to do a diff on those files.

Sorry for the delay... I'm having trouble getting the files uploaded to Github for some weird reason. If they won't go up soon, then I'll try another method.

pflugs30 avatar Dec 30 '22 22:12 pflugs30

FYI I sent you an invite to the RD org; if you accept the invite you'll be an "official" contributor and will be able to label issues and get access to the RD3 private repository: feel free to look around, but note that I have a ton of local changes yet to be pushed there.

Thank you very much! I'm happy to be a part of the team. I'm looking forward to contributing, particularly with unit testing. I think you may have known that already... 😏

pflugs30 avatar Dec 30 '22 22:12 pflugs30

@pflugs30 , could you grab the XML files from this path:

.\RubberduckTests\bin\Testfiles\Resolver and zip it up and post it here? I want to do a diff on those files.

Here's a link to the files. I'm not sure why Github isn't working... https://file.io/HcdmSmVHc6ct

pflugs30 avatar Dec 30 '22 22:12 pflugs30

Here are the files! They finally uploaded... Resolver.zip

pflugs30 avatar Dec 30 '22 23:12 pflugs30

Unfortunately they seem to be 100% identical. Will have to look somewhere else.

bclothier avatar Dec 30 '22 23:12 bclothier

@bclothier I'm running the tests again on a fresh VM with a clean VS2022 install and NO installation of MS Office of any kind. With only 4 GB RAM, the tests may take a while, so I'll send an update in a bit. The good news is the builds went super smooth! :-)

pflugs30 avatar Dec 30 '22 23:12 pflugs30

Yup, same failure on the VM.

pflugs30 avatar Dec 31 '22 00:12 pflugs30

Would any system or VS diagnostic information be helpful?

pflugs30 avatar Dec 31 '22 00:12 pflugs30

I think I'd be more interested in knowing how it arrived to the Worksheet instead of the _Worksheet.

If I go up through the ParentDeclaration, it describes the _Worksheet as a ClassModule; there is no mention of the Worksheet anywhere in the chain.

This is what I see when describing both (ran from immediate window while in break mode in file RubberduckTests\Symbols\SelectedDeclarationProviderTests.cs at line 839:

?state.DeclarationFinder.DeclarationsWithType(DeclarationType.ClassModule).Where(x=>x.ComponentName == "Worksheet").First()
(ClassModule) Public "Worksheet" As "Worksheet" | {L1C1}
    Accessibility: Public
    Annotations: Count = 0
    AsTypeContext: null
    AsTypeDeclaration: (ClassModule) Public "Worksheet" As "Worksheet" | {L1C1}
    AsTypeIsBaseType: false
    AsTypeName: "Worksheet"
    AsTypeNameWithoutArrayDesignator: "Worksheet"
    Attributes: Count = 1
    AttributesPassContext: null
    ComponentName: "Worksheet"
    Context: null
    CustomFolder: "Excel"
    DeclarationType: ClassModule
    DefaultMember: null
    DescriptionString: ""
    FullAsTypeName: "EXCEL.EXE;Excel.Worksheet"
    HasDefaultInstanceVariable: The function evaluation requires all threads to run.
    HasPredeclaredId: The function evaluation requires all threads to run.
    HasTypeHint: false
    IdentifierName: "Worksheet"
    ImplementedInterfaces: {System.Linq.Enumerable.WhereEnumerableIterator<Rubberduck.Parsing.Symbols.ClassModuleDeclaration>}
    IsArray: false
    IsControl: false
    IsEnumeratorMember: false
    IsExposed: true
    IsExtensible: The function evaluation requires all threads to run.
    IsGlobalClassModule: false
    IsInterface: false
    IsObject: true
    IsObjectArray: false
    IsObjectOrObjectArray: true
    IsSelfAssigned: false
    IsTypeSpecified: false
    IsUndeclared: false
    IsUserDefined: false
    IsUserInterface: false
    IsWithEvents: true
    Members: Count = 162
    ParentDeclaration: (Project) Implicit "Excel" As "Excel" | {L1C1}
    ParentScope: "VBE"
    ParentScopeDeclaration: (Project) Implicit "Excel" As "Excel" | {L1C1}
    ProjectDisplayName: 'state.DeclarationFinder.DeclarationsWithType(DeclarationType.ClassModule).Where(x=>x.ComponentName == "Worksheet").First().ProjectDisplayName' threw an exception of type 'System.NullReferenceException'
    ProjectId: "External2003575673"
    ProjectName: "Excel"
    QualifiedModuleName: {EXCEL.EXE;Excel.Worksheet}
    QualifiedName: {EXCEL.EXE;Excel.Worksheet.Worksheet}
    QualifiedSelection: {EXCEL.EXE;Excel.Worksheet L1C1}
    References: Count = 1
    Scope: "EXCEL.EXE;Excel.Worksheet"
    Selection: {L1C1}
    Subtypes: Count = 0
    SupertypeNames: Count = 2
    Supertypes: Count = 2
    TypeHint: null
    _annotations: Count = 0
    _asTypeDeclaration: (ClassModule) Public "Worksheet" As "Worksheet" | {L1C1}
    _hasPredeclaredId: ThreadSafetyMode=ExecutionAndPublication, IsValueCreated=false, IsValueFaulted=false, Value=false
    _isExposed: ThreadSafetyMode=ExecutionAndPublication, IsValueCreated=true, IsValueFaulted=false, Value=true
    _isExtensible: ThreadSafetyMode=ExecutionAndPublication, IsValueCreated=false, IsValueFaulted=false, Value=false
    _isGlobal: false
    _isGlobalSyncObject: {object}
    _members: Count = 162
    _neverArray: {Rubberduck.Parsing.Symbols.DeclarationType[18]}
    _references: Count = 1
    _subtypes: Count = 0
    _supertypeNames: Count = 2
    _supertypes: Count = 2
?state.DeclarationFinder.DeclarationsWithType(DeclarationType.ClassModule).Where(x=>x.ComponentName == "_Worksheet").First()
(ClassModule) Public "_Worksheet" As "_Worksheet" | {L1C1}
    Accessibility: Public
    Annotations: Count = 0
    AsTypeContext: null
    AsTypeDeclaration: (ClassModule) Public "_Worksheet" As "_Worksheet" | {L1C1}
    AsTypeIsBaseType: false
    AsTypeName: "_Worksheet"
    AsTypeNameWithoutArrayDesignator: "_Worksheet"
    Attributes: Count = 0
    AttributesPassContext: null
    ComponentName: "_Worksheet"
    Context: null
    CustomFolder: "Excel"
    DeclarationType: ClassModule
    DefaultMember: null
    DescriptionString: ""
    FullAsTypeName: "EXCEL.EXE;Excel._Worksheet"
    HasDefaultInstanceVariable: The function evaluation requires all threads to run.
    HasPredeclaredId: The function evaluation requires all threads to run.
    HasTypeHint: false
    IdentifierName: "_Worksheet"
    ImplementedInterfaces: {System.Linq.Enumerable.WhereEnumerableIterator<Rubberduck.Parsing.Symbols.ClassModuleDeclaration>}
    IsArray: false
    IsControl: false
    IsEnumeratorMember: false
    IsExposed: The function evaluation requires all threads to run.
    IsExtensible: The function evaluation requires all threads to run.
    IsGlobalClassModule: false
    IsInterface: true
    IsObject: true
    IsObjectArray: false
    IsObjectOrObjectArray: true
    IsSelfAssigned: false
    IsTypeSpecified: false
    IsUndeclared: false
    IsUserDefined: false
    IsUserInterface: false
    IsWithEvents: false
    Members: Count = 145
    ParentDeclaration: (Project) Implicit "Excel" As "Excel" | {L1C1}
    ParentScope: "VBE"
    ParentScopeDeclaration: (Project) Implicit "Excel" As "Excel" | {L1C1}
    ProjectDisplayName: 'state.DeclarationFinder.DeclarationsWithType(DeclarationType.ClassModule).Where(x=>x.ComponentName == "_Worksheet").First().ProjectDisplayName' threw an exception of type 'System.NullReferenceException'
    ProjectId: "External2003575673"
    ProjectName: "Excel"
    QualifiedModuleName: {EXCEL.EXE;Excel._Worksheet}
    QualifiedName: {EXCEL.EXE;Excel._Worksheet._Worksheet}
    QualifiedSelection: {EXCEL.EXE;Excel._Worksheet L1C1}
    References: Count = 0
    Scope: "EXCEL.EXE;Excel._Worksheet"
    Selection: {L1C1}
    Subtypes: Count = 1
    SupertypeNames: Count = 0
    Supertypes: Count = 0
    TypeHint: null
    _annotations: Count = 0
    _asTypeDeclaration: (ClassModule) Public "_Worksheet" As "_Worksheet" | {L1C1}
    _hasPredeclaredId: ThreadSafetyMode=ExecutionAndPublication, IsValueCreated=false, IsValueFaulted=false, Value=false
    _isExposed: ThreadSafetyMode=ExecutionAndPublication, IsValueCreated=false, IsValueFaulted=false, Value=false
    _isExtensible: ThreadSafetyMode=ExecutionAndPublication, IsValueCreated=false, IsValueFaulted=false, Value=false
    _isGlobal: false
    _isGlobalSyncObject: {object}
    _members: Count = 145
    _neverArray: {Rubberduck.Parsing.Symbols.DeclarationType[18]}
    _references: Count = 0
    _subtypes: Count = 1
    _supertypeNames: Count = 0
    _supertypes: Count = 0

bclothier avatar Dec 31 '22 01:12 bclothier

Here's what I get:

?state.DeclarationFinder.DeclarationsWithType(DeclarationType.ClassModule).Where(x=>x.ComponentName == "Worksheet").First()
(ClassModule) Public "Worksheet" As "Worksheet" | {L1C1}
    Accessibility: Public
    Annotations: Count = 0
    AsTypeContext: null
    AsTypeDeclaration: (ClassModule) Public "Worksheet" As "Worksheet" | {L1C1}
    AsTypeIsBaseType: false
    AsTypeName: "Worksheet"
    AsTypeNameWithoutArrayDesignator: "Worksheet"
    Attributes: Count = 1
    AttributesPassContext: null
    ComponentName: "Worksheet"
    Context: null
    CustomFolder: "Excel"
    DeclarationType: ClassModule
    DefaultMember: null
    DescriptionString: ""
    FullAsTypeName: "EXCEL.EXE;Excel.Worksheet"
    HasDefaultInstanceVariable: The function evaluation requires all threads to run.
    HasPredeclaredId: The function evaluation requires all threads to run.
    HasTypeHint: false
    IdentifierName: "Worksheet"
    ImplementedInterfaces: {System.Linq.Enumerable.WhereEnumerableIterator<Rubberduck.Parsing.Symbols.ClassModuleDeclaration>}
    IsArray: false
    IsControl: false
    IsEnumeratorMember: false
    IsExposed: true
    IsExtensible: The function evaluation requires all threads to run.
    IsGlobalClassModule: false
    IsInterface: false
    IsObject: true
    IsObjectArray: false
    IsObjectOrObjectArray: true
    IsSelfAssigned: false
    IsTypeSpecified: false
    IsUndeclared: false
    IsUserDefined: false
    IsUserInterface: false
    IsWithEvents: true
    Members: Count = 162
    ParentDeclaration: (Project) Implicit "Excel" As "Excel" | {L1C1}
    ParentScope: "VBE"
    ParentScopeDeclaration: (Project) Implicit "Excel" As "Excel" | {L1C1}
    ProjectDisplayName: 'state.DeclarationFinder.DeclarationsWithType(DeclarationType.ClassModule).Where(x=>x.ComponentName == "Worksheet").First().ProjectDisplayName' threw an exception of type 'System.NullReferenceException'
    ProjectId: "External2003575673"
    ProjectName: "Excel"
    QualifiedModuleName: {EXCEL.EXE;Excel.Worksheet}
    QualifiedName: {EXCEL.EXE;Excel.Worksheet.Worksheet}
    QualifiedSelection: {EXCEL.EXE;Excel.Worksheet L1C1}
    References: Count = 1
    Scope: "EXCEL.EXE;Excel.Worksheet"
    Selection: {L1C1}
    Subtypes: Count = 0
    SupertypeNames: Count = 2
    Supertypes: Count = 2
    TypeHint: null
    _annotations: Count = 0
    _asTypeDeclaration: (ClassModule) Public "Worksheet" As "Worksheet" | {L1C1}
    _hasPredeclaredId: ThreadSafetyMode=ExecutionAndPublication, IsValueCreated=false, IsValueFaulted=false, Value=false
    _isExposed: ThreadSafetyMode=ExecutionAndPublication, IsValueCreated=true, IsValueFaulted=false, Value=true
    _isExtensible: ThreadSafetyMode=ExecutionAndPublication, IsValueCreated=false, IsValueFaulted=false, Value=false
    _isGlobal: false
    _isGlobalSyncObject: {object}
    _members: Count = 162
    _neverArray: {Rubberduck.Parsing.Symbols.DeclarationType[18]}
    _references: Count = 1
    _subtypes: Count = 0
    _supertypeNames: Count = 2
    _supertypes: Count = 2
?state.DeclarationFinder.DeclarationsWithType(DeclarationType.ClassModule).Where(x=>x.ComponentName == "_Worksheet").First()
(ClassModule) Public "_Worksheet" As "_Worksheet" | {L1C1}
    Accessibility: Public
    Annotations: Count = 0
    AsTypeContext: null
    AsTypeDeclaration: (ClassModule) Public "_Worksheet" As "_Worksheet" | {L1C1}
    AsTypeIsBaseType: false
    AsTypeName: "_Worksheet"
    AsTypeNameWithoutArrayDesignator: "_Worksheet"
    Attributes: Count = 0
    AttributesPassContext: null
    ComponentName: "_Worksheet"
    Context: null
    CustomFolder: "Excel"
    DeclarationType: ClassModule
    DefaultMember: null
    DescriptionString: ""
    FullAsTypeName: "EXCEL.EXE;Excel._Worksheet"
    HasDefaultInstanceVariable: The function evaluation requires all threads to run.
    HasPredeclaredId: The function evaluation requires all threads to run.
    HasTypeHint: false
    IdentifierName: "_Worksheet"
    ImplementedInterfaces: {System.Linq.Enumerable.WhereEnumerableIterator<Rubberduck.Parsing.Symbols.ClassModuleDeclaration>}
    IsArray: false
    IsControl: false
    IsEnumeratorMember: false
    IsExposed: The function evaluation requires all threads to run.
    IsExtensible: The function evaluation requires all threads to run.
    IsGlobalClassModule: false
    IsInterface: true
    IsObject: true
    IsObjectArray: false
    IsObjectOrObjectArray: true
    IsSelfAssigned: false
    IsTypeSpecified: false
    IsUndeclared: false
    IsUserDefined: false
    IsUserInterface: false
    IsWithEvents: false
    Members: Count = 145
    ParentDeclaration: (Project) Implicit "Excel" As "Excel" | {L1C1}
    ParentScope: "VBE"
    ParentScopeDeclaration: (Project) Implicit "Excel" As "Excel" | {L1C1}
    ProjectDisplayName: 'state.DeclarationFinder.DeclarationsWithType(DeclarationType.ClassModule).Where(x=>x.ComponentName == "_Worksheet").First().ProjectDisplayName' threw an exception of type 'System.NullReferenceException'
    ProjectId: "External2003575673"
    ProjectName: "Excel"
    QualifiedModuleName: {EXCEL.EXE;Excel._Worksheet}
    QualifiedName: {EXCEL.EXE;Excel._Worksheet._Worksheet}
    QualifiedSelection: {EXCEL.EXE;Excel._Worksheet L1C1}
    References: Count = 0
    Scope: "EXCEL.EXE;Excel._Worksheet"
    Selection: {L1C1}
    Subtypes: Count = 1
    SupertypeNames: Count = 0
    Supertypes: Count = 0
    TypeHint: null
    _annotations: Count = 0
    _asTypeDeclaration: (ClassModule) Public "_Worksheet" As "_Worksheet" | {L1C1}
    _hasPredeclaredId: ThreadSafetyMode=ExecutionAndPublication, IsValueCreated=false, IsValueFaulted=false, Value=false
    _isExposed: ThreadSafetyMode=ExecutionAndPublication, IsValueCreated=false, IsValueFaulted=false, Value=false
    _isExtensible: ThreadSafetyMode=ExecutionAndPublication, IsValueCreated=false, IsValueFaulted=false, Value=false
    _isGlobal: false
    _isGlobalSyncObject: {object}
    _members: Count = 145
    _neverArray: {Rubberduck.Parsing.Symbols.DeclarationType[18]}
    _references: Count = 0
    _subtypes: Count = 1
    _supertypeNames: Count = 0
    _supertypes: Count = 0

pflugs30 avatar Dec 31 '22 02:12 pflugs30

They appear to be identical. But it does establish that in both cases, there's both a _Worksheet and Worksheet declarations. That seem to suggest that the resolver isn't consistently selecting the same one under all conditions. Thoughts, @retailcoder or @MDoerner ?

bclothier avatar Dec 31 '22 02:12 bclothier

Looking at the history here: https://github.com/rubberduck-vba/Rubberduck/commit/862ed33a6e7c0307e98a81f0956206164bc9a27b

It looks like the qualified member calls in are resolving to the underscored/hidden interface/class, and unqualified ones resolve to the non-underscored type - it was probably breaking some inspection, and treating them like one and the same basically fixed the symptoms. I'd pragmatically just make the test pass by tweaking its expectations, and then there's perhaps an underlying resolver issue with inconsistent resolution of qualified member calls vs unqualified ones, but we are working around it.

retailcoder avatar Dec 31 '22 03:12 retailcoder

Well, it sounds like getting the test to pass on my machine may cause it to break in AppVeyor, right, @bclothier?

pflugs30 avatar Dec 31 '22 03:12 pflugs30

Hm, perhaps the best thing to do would be to mark it as ignored... could be just a matter of ordering of the declarations, assuming a .FirstOrDefault somewhere in the resolution.

retailcoder avatar Dec 31 '22 03:12 retailcoder

It does sound like a replay of what I went through in my own local back when I tried to build it in VS2022.

retailcoder avatar Dec 31 '22 03:12 retailcoder

Well, it sounds like getting the test to pass on my machine may cause it to break in AppVeyor, right, @bclothier?

Yes, it did break AV originally and it fails on both VMs with 2019 and 2022, respectively.

I'm in favor of marking it ignored until we can establish what's really going with this. It has the markings of a heisenbug which will take a while to figure out....

bclothier avatar Dec 31 '22 03:12 bclothier

Works for me! I'd prefer to get working on the mocking initiative, anyway... ;-)

pflugs30 avatar Dec 31 '22 03:12 pflugs30