Conversation started Dec 19, 2017 at 20:02.
Dec 19, 2017 20:02
Guys, for late bound unit testing, have you considered using a wrapper Assert class (and Fakes), using a predeclared ID. The Assert class might look something like this:
Private LateBoundAssert As Object

Private Sub Class_Initialize()
Set LateBoundAssert = CreateObject("Rubberduck.AssertClass")
End Sub

Public Sub AreEqual(Expected As Variant, Actual As Variant, Message As String)
LateBoundAssert.AreEqual Expected, Actual, Message
End Sub
With the predeclared ID, you could then make use of intellisense, so Assert.AreEqual would work just like the early bound version
@Mat'sMug ^
hmm, our late-bound setup code looks pretty much exactly like that, no?
You currently don't get any intellisense
I guess the predeclared ID would be some attribute decorating the AssertClass interface?
No, it's the VB_PredeclaredID attribute
on a class named Assert in the VBA project.
Dec 19, 2017 20:05
Oh (facepalm)
so you want to wrap the access to Rubberduck's LateBound Assert in a VBA class module to enable IntelliSense?
sounds simple and reasonable
Yeah, I think it would offer the best of both worlds (late and early bound)
I'm just thinking out loud really
it wasn't done because we wanted to interfere as little as possible with the users' code... but I don't think it's going overboard. I like it :)
#FunFact the original VBA implementation did use a predeclared ID Assert class
It would only add two class modules
Dec 19, 2017 20:07
The benefits of Rubberduckin out loud.
and we could even have an option for it
> [x] Create Assert VBA wrapper class
> [ ] Create Fakes VBA wrapper class
sounds plausible.
yeah, that way existing (user) code would still work
that said we're really starting to need per-project settings
What are you using to invoke the methods? Application.Run?
depends on the host application, but yeah
Dec 19, 2017 20:13
Yeah, vbWatchdog doesn't use Application.Run, but I don't think I can expose how I got round that ;)
Have you thought about using class modules for the unit tests instead? I guess you probably have
absolutely
except...
couldn't get .net to create instances
that'd be like the holy grail
Oh, yes you should be able to do that
if we can do that then we can have an actual mocking framework
wait, how?!!?!
grab the ITypeInfo from any IDispatch object implemented by your VBA project, grab the parent ITypeLib from that, and then enumerate all the ITypeInfos in the project. Once you find one, you can call ITypeInfo::CreateInstance
you gotta be kidding
Dec 19, 2017 20:16
No, that should work
@ThunderFrame needs to see this
Confirming - that doesn't require the obsolete tibinfo library, right?
should... can't guarantee it without actually implementing it. But unless VBA screwed up the whole ITypeInfo implementation, it should work
@this no
The IDispatch interface itself exposes members to grab the raw ITypeInfo
From there you get the parent (giving you an ITypeLib). And from there you enumerate the coclasses
Assuming that works, then we would be able to do what we need from a class and implement all tests as a class which also avoid the host-specific implementation of Application.Run
@this it doesn't fix that ;-)
Dec 19, 2017 20:21
The only issue is getting a hold of the initial object from the VBA project.
I like how you make it sound trivial
well, it is
You'd have to have a stub routine that passes an object to your managed side so that you can then grab the initial ITypeInfo
you just need to get the VBA code to pass the instance, right?
yeah
And so you'd still need Application.Run or equivalent to get it started. But it can be any generic VBA created object that you pass
a bit like we grab the VBE instance with parser.Initialize Application.VBE in the (experimental) reflection API
Dec 19, 2017 20:25
There is a cheat for getting the ITypeInfo actually
or equivalent - e.g. get ahold of the VBA runtime's CallByName method, and invoke it
No that needs an object too
something tells me there's black magic going on :)
29 mins ago, by Vogel612
0
Q: Handling lazy-loading webpages using vba

ShahinAfter a long try I've been able to create a script in vba which can successfully handle webpages with lazy-load. It can reach the bottom of a slow loading webpage if the hardcoded number of the loop is set accurately. I tried with few such pages and found it working flawlessly. The one I'm pastin...

Yeah, and I'm not sure if you'll go with it.
Dec 19, 2017 20:28
if it involves injecting precompiled assembler into user code, ...yeah not sure we want to go there ;-)
not yet anyway ;)
no, it's not that bad
If you grab the VBE.ActiveProject.References COM object, and grab the 5th pointer from the object pointer, that's the ITypeInfo
but I didn't tell you that
huh
lol
just curious about how you'd possibly find out these kinds of things
don't ask :)
I didn't!
@Mat'sMug I never thought I'd hear this come from Mug.
Dec 19, 2017 20:31
@IvenBach lol, I know nothing
That's an easy way of getting the ITypeInfo without having to get any live object instance
Nothing is relative...
And that has worked since the first version of VBA6 (and VB6 as well I think)
@WaynePhillipsEA you do know that this is "public record"?
Actually sorry it's obviously not the ITypeInfo( which is instance specific), it's the project ITypeLib
Dec 19, 2017 20:33
yeah was going to say :)
Well I could be anyone pretending to be anyone
;)
I could nuke it from orbit if it's too sensitive
@Mat'sMug Breadcrumb got me there. Not sure what it should correctly display though.
No, it's fine. It's self obtained info, so I'm with it.
If it possibly helps you out, I don't see why I can't share it.
:D
thanks a bunch. FWIW vbWatchDog is quite possibly the only VBIDE add-in we couldn't eat lunch if we tried
Dec 19, 2017 20:37
Some stuff I wouldn't be willing to divulge, but tidbits like above are fine
well I'm honored to hear that :) And FWIW Rubberduck is probably the only addin I would openly recommend to all VBA developers
9
apart from my own of course haha
that's... wow.
You've made great improvements since when I last looked at it
Mug will now print that out and hang it on his wall, next to wedding and children's photos.
so.. wait a minute.. if we can get the ITypeLib for the active VBA project, then we don't need to parse anything to grab module & member attributes, do we?
no mug, no we don't
what type of attributes do you mean?
Dec 19, 2017 20:42
e.g. VB_Description and VB_PredeclaredId/VB_Exposed
which we're already picking up in the type libs we're COM-reflecting
Yeah, they should be accessible
i.e. that code is pretty much already written
this simplifies so many things
without needing to implement a code pane from scratch
ouch you're not planning that are you?
well....
you've got your work cut out!!
Dec 19, 2017 20:44
the idea is to have custom syntax highlighting, code folding, tearable tabs, and put the "intelli" back into "intellisense"
wow. that's going to be quite involved.
@Mat'sMug For those that don't have a description and error out I want to log them. I'm stumbling a little bit. Once you're done.
@WaynePhillipsEA yeah. hopefully we'll be done before Microsoft figures out a way to put the VBIDE out of service
:)
@Mat'sMug you're ambitious, I'll give you that
"Bring the VBE into the 21st Century"
^ mission statement :)
Dec 19, 2017 20:47
Well, yes, a new code pane would certainly help with that
Some would call us duckbrained.
the only problem is that it would have to be design-time only
'cause no way I'm going to get my hands into the debugger
But.... perhaps vbWatchdog could expose some stuff to help you out
you'd give us some compiled blackbox API to play with?
just thinking out loud. obviously, we'd have to be careful with regards to the non OSS nature of vbWatchdog
But if I were to expose a few things, and Rubberduck could optionally hook onto them, perhaps that could work.
@Mat'sMug, yeah, something like that. Much like the VBE itself
Dec 19, 2017 20:51
except with a better API :D
naturally
one problem is that having a .dll like that in RD's repository would make it very easy for anyone to grab and play with
true, but we might be able to come up with some sort of solution.
that does sound wonderful, but maybe we should go one step at a time :)
it's not like we have ~400 feature requests on our hands that also want their share of attention :)
Dec 19, 2017 20:55
nobody will notice if you give them a shiny new code pane and debugger
nobody will care :)
Sep 21 at 16:41, by Mat's Mug
Mar 3 '15 at 19:11, by skiwi
So when will you drop the IDE in which you are building the plugin, and writ eyour own IDE?
Yes, that might be an idea
Aug 21 '16 at 20:44, by ThunderFrame
Aug 14 at 11:58, by RubberDuck
Hey guys. You know how we're always joking about writing our own IDE? I bet (if we could ever find time to write code for fun again) we could fork VS Code. http://opensource.stackexchange.com/a/4292/775
so many instances of "own IDE" in the transcript of this chat..
my favorite:
Apr 17 '15 at 15:41, by RubberDuck
Yeah. Given that, you can't @RichardFoxton. Not unless you want to build your own IDE from scratch. Even the Mug and I aren't that crazy. — RubberDuck 9 secs ago
I'd be up for that. I wrote my own frontend C++ compiler, so I've got experience.
Dec 19, 2017 20:58
using the superb LLVM optimizing backend compiler.
I guess we're now a little off track. sorry about that.
eh, happens all the time, no worries :)
how many core devs on this team?
4-5ish?
a handful... there's @M.Doerner, @Hosch250, myself (haven't committed anything meaningful in a long while though), @this, ...lots of recent newcomers, and even more fly-bys
Dec 19, 2017 21:01
All at varying levels.
I don't think Rubberduck likes parsing my vbMAPI class modules
hmm, parser bugs are down to near-zero by now... what's it complaining about?
It's taking a long time for about 20 classes
just parsing?
I bet SLL mode is failing
(there would be a warning in the logs for it)
It's sitting there eating CPU%
Dec 19, 2017 21:04
that's embarrassing
no parser error reported?
Are there long chains of boolean expressions?
We had one bug report where this was causing an incredibly long parse time.
I wonder how/whether Antlr4.7 is going to improve that
Actually, it might, or rather the necessary grammar changes.
I think it was constantly backtracking because of the large amount of Not operators.
Dec 19, 2017 21:08
[rubberduck-vba/Rubberduck] build for commit 25ba0642 on unknown branch: AppVeyor build failed
BUILD FAILURE!
@Hosch250 was making progress on the Antlr upgrade, I wonder how close to a PR he's at
@Duga why are you trying to copy to the debug folder ffs
I'll be amazed if this eventually completes. I would guess an infinite loop, since CPU is using one core, and RAM use is static.
My yml looks exactly the same as the one on next.
The word Debug does not even appear in it.
@WaynePhillipsEA doesn't MAPI generally have cyclic properties?
@M.Doerner I know - fwiw that comment was directed at appveyor, not you ;-)
Dec 19, 2017 21:11
maybe that's what sending the parser down a rabbit hole
I tested with the code. At about half the number of conditions, it completed in 2 minutes.
@WaynePhillipsEA and I thought @ThunderFrame's code was evil!
@Mat'sMug do you want me to leave it running
@Mat'sMug did I hear Antlr4.7? :D
@Mat'sMug just to clarify - that's MAPI OM, not his classes that exposes it. The MAPI itself is evil, IMHO. :)
Dec 19, 2017 21:13
oh
Btw, each module is parsed on only one thread; the paralellism is in the modules.
I honestly don't think there's much evil code.
so it's the COM Collector that's crawling then
Not by my standards
'Project Name = MyProject
'Module Name = MyModule
Option Explicit

Private MyVar As MyProject
Private MyVar1 As MyModule

Private Type MyProject
  MyModule As String
  MySub As String
End Type

Private Type MyModule
  MyVar As String
  String As MyProject
End Type

Private Type MySub
  MyVar As MyModule
  MyVar1 As MyProject
End Type

Private Type MyVar
  MyProject As MyModule
End Type

Sub MySub()

  Dim MyProject As MyProject
  Dim MyModule As MyProject.MyModule.MyProject
  Dim MySub As MySub
^ resolves fine
Dec 19, 2017 21:15
Yeah, I've got a project with similar stuff to that. Loads of edge cases for my decompiler
@Mat'sMug to be fair, while that's evil, it's not really cyclic. I seem to remember that with MAPI, they have list of properties that can be themselves properties to another properties that is already self-referenced.... At least that's how I remembered it.
but vbMAPI is nothing like that.
it's a type library?
No, it's similar implementation to vbWatchdog. But that resolves fine now in the latest release.
@WaynePhillipsEA what about Max's question? If the library has to make use of expressions that requires lot of left-recursions that can wreck the parser.
or at least make it go really slow
Dec 19, 2017 21:18
Yeah, maybe. I'll leave it running to see if it completes
either it does, or some call stack ends up blowing
If it doesn't complete, I'll try to reduce it down. But that might be a few days before I get to it.
@Mat'sMug so the parser will do recursion, not loops?
Just did a quick test with my personal 'evil' project. only 3 parser errors, which ain't bad really.
@this IDK. pretty sure at least some of the parser logic is recursive though
Dec 19, 2017 21:23
@this as far as I got into antlr, it is recursive almost by definition, isn't it?
@WaynePhillipsEA different errors? or 3 instances of the same grammar bug?
3 different errors
interesting
I can smell the colons from here :)
(right?)
@NelsonVides I'm generally the guy who try to implement recursions as a loop... generally speaking. Sometime you really can't avoid recursions but whenever you are able, it's better to use a loop so that you never have to worry about stack overflow, only the hard drive capacity of your PC. :)
and line continuations?
Dec 19, 2017 21:25
But TBH, I don't think I have the brainpower to improve what ANTLR guys did soo.. there's that.
One looks like a colon bug, yes
@this most likely the problem is with our grammar, not with Antlr itself
@this I'm aware of the issues with recursion and stack overflows. But that's how grammars work for the most part, with heavily nested recursion.
Dim AObject As Object
AObject.Line -(3, 4)
Line is a special method
and the above is valid, at least at compilation level
Rule A have some branching, decides to take Rule B, which has some more branching and it might decide to take Rule A again (and it might then take a different path C the second time it enters A, or the third, or the fourth...
Dec 19, 2017 21:29
@WaynePhillipsEA @ThunderFrame would love that.
@WaynePhillipsEA hmm I clearly recall seeing a parser rule specifically for that weird-syntax special instruction
The idea of recursion is later very well improved by compilers, sometimes. Haskell and family for example, has a very awesome implementation of tail recursion that virtually solves the stack overflow problem, making the stack frame reuse itself every time, therefore, you have a binary loop but your code is organised as recursion, which is very elegant
i.e. it's supposed to be handled
@NelsonVides that's cool. I didn't know that about Haskell.
If True Then:
End Sub
Dec 19, 2017 21:31
@WaynePhillipsEA inside a procedure?
Sorry, yes, I didn't copy in the Sub
Sub Blah()
AObject.Line (1, 2)-(3, 4), , BF
@WaynePhillipsEA That's evil code. I'll slap a colleague who writes that in production. But don't take my words wrong, evil is motivating.
hmm, it is legal
has to be- since that's a single line If statement, followed by an empty line then End Sub. Earlier @M.Doerner pointed out that something like If 1 = 1 Then: Debug.Print "true": Else Debug.Print "false" would be actually a "single-line If statement", in spite of the colons supposedly separating the instruction.
Dec 19, 2017 21:34
Both of these:
AObject.PSet (1, 2)
AObject.PSet (1, 2), 555 ' FLAG 2 means Color has been specified
And this: AObject.Scale
the good news is that they're all quite obscure edge cases :)
AObject.Print AVariant; Spc(5); Tab; Spc(6); AVariant, Spc(0); Tab(55)
Oh yes, absolutely.
@Mat'sMug The post build action is in the project file of Rubberduck.Inspections, and it has been there forever.
@M.Doerner I know.. I don't understand why AppVeyor is trying to copy to the debug folder when it's building a release config
It is literaly written in the project file.
Dec 19, 2017 21:38
> Hello all. I am getting Procedure 'ButtonX_Click' is not used in the Code Inspections window on the latest release. I've only started developing the UI for the app I've been working on for the last few months and it seems all the control events are being flagged this way. I can easily stop inspecting for them but I'll lose visibility on dead code. I *think* I saw a related issue here on github but now I can't find it. Is this a regression or am I doing something wrong?

Access 2016 64 b
from an earlier passing build:
> RubberduckTests -> C:\projects\rubberduck\RubberduckTests\bin\Release\RubberduckTests.dll
copy Rubberduck.Inspections\bin\Release\Rubberduck.Inspections.dll RetailCoder.VBE\bin\Release\Rubberduck.Inspections.dll
1 file(s) copied
Well, that is probably from the action in the yml.
anyway, gtg. 'night all
 
Conversation ended Dec 19, 2017 at 21:41.