The managed Engine class can provide overloads; that's C# 2.0-safe.
On 07-Feb-14 11:31, Hoover, Jacob wrote:
My other message got killed as it was too large. Yes, the interface
needs the = NULL in order for it to work. However, having the
interface define the default works and as you are pointing out the
interface default is used when invoking the member through the
interface even if your actual implementation has a different default.
I believe the compatibility goal here is for existing 3.x BA's to be
able to be recompiled while still calling interface->Detect() with no
parameters.
My final concerns are with the managed side. Should it be defined on
the interface with a default value there? If we do, would it be
abandoning C# 3.0 and older as it didn't have "optional" arguments?
*From:*Bryan Wolf [mailto:brw...@jackhenry.com]
*Sent:* Friday, February 07, 2014 9:00 AM
*To:* WiX toolset developer mailing list
*Subject:* Re: [WiX-devs] Self update bundles, the detect issue.
SAL Annotations are definitely not used to generate code; I
double-checked by creating a function and passed nullptr to it and it
happily (!) crashed. Also no warnings were thrown nor compiler errors
emitted unless Code Analysis was turned on -- and then, only a warning.
For what it's worth, default parameters are not part of a method or
function's type. Default parameters are instructions for the call site
and not the method/function. From an academic point of view, this has
specific implications in the case of an ABC because overriding only
works on types and, as mentioned, a default parameter is not part of
that. This is particularly relevant for pure virtual functions because
it means overriding does not carry with it the default parameters. See
section 8.3.6.10 of C++11 standard.
From a practical point of view, the impact is that all future
overrides have to carry the correct default parameter value and, in
some cases, can even fail to provide one and the compiler of that
class will be ok with that. The default parameter of the implementing
class is chosen over all other possibilities. The short of it is that
there's no way to validate/verify that a correct default parameter is
chosen nor verify which specific default parameter is chosen in client
code. It won't cause any issues for now and is probably fine but, if,
say, a 3rd party were to implement the interface then they will
definitely have some weirdness. Long-term, I think the technical term
for this is "brittle" -- especially when someone implements the
interface in such a way that they get a "wrong number of arguments"
error on an interface they believe they've implemented correctly as
most people aren't familiar with this portion of C++.
There's a CERT advisory against this specific practice discussed here:
https://www.securecoding.cert.org/confluence/display/cplusplus/OOP04-CPP.+Prefer+not+to+give+virtual+functions+default+argument+initializers
Just some thoughts I figured I would throw out for this :-) Hopefully
in the not-too-distant future I'll be able to contribute to WiX, but
for now all I can do is lurk on mailing lists.
(had to trim the history to try to get under 40KiB)
*From:*Rob Mensching [mailto:r...@robmensching.com]
*Sent:* Thursday, February 6, 2014 4:30 PM
*To:* WiX toolset developer mailing list
*Subject:* Re: [WiX-devs] Self update bundles, the detect issue.
My understanding is that the SAL annotation is just for static
analysis. The default argument ("= NULL") is the important part. I
just wasn't sure it'd work in the interface but knowing that it does,
I guess I'm not completely surprised.
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
WiX-devs mailing list
WiX-devs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-devs
--
sig://boB
http://joyofsetup.com/
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
WiX-devs mailing list
WiX-devs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-devs