ExcelArgumentAttribute / ExcelFunctionAttribute inheritance broken

Jan 6, 2012 at 1:42 PM

Inheriting from ExcelArgumentAttribute or ExcelFunctionAttribute was possible in version 0.25, but is broken in 0.29.

It looks like this doesn't work because attribute.GetType().FullName is used to discover attributes without looking at the base types.

The fix is quite simple, just make a 'MatchesAttributeType' method that looks at base types as well.

Coordinator
Jan 8, 2012 at 11:26 AM

Hi,

I agree it won't be hard to add.

How do you use the derived attribute types? Would it not make more sense for you to use your own attribute types, instead of extending the Excel-DNA attributes by inheritance?

I'm just trying to ensure this is a change that makes sense to me - I'm surprised that you used it that way.

-Govert

Jan 8, 2012 at 11:48 AM
The ExcelArgumentAttribute/ExcelFunctionAttribute attributes are provided and consumed by ExcelDNA, so the information conveyed can't really be provided on my own custom attribute type.

To give an example of where this is useful, there are several common types of arguments that are used through our system, and subclassing ExcelArgumentAttribute to provide those common names and also behaviours (like optional) is very helpful. For example, we have an attribute MarketArgumentAttribute which provides a name and a description for market properties. We use this style for 8 different argument types that have common characteristics across different excel functions.

The obvious alternative is to seal the attributes, but I think the above usage scenario is useful and it would be a shame to let this remain being a breaking change.
It also means we would have to go through and change all our code using a style (most likely assigning name/optional etc to the properties manually) which is tedious and error prone.
Not to mention the bugs we may introduce weining off the ability to subclass the attributes!


From: [email removed]
To: [email removed]
Date: Sun, 8 Jan 2012 04:26:53 -0800
Subject: Re: ExcelArgumentAttribute / ExcelFunctionAttribute inheritance broken [exceldna:285228]

From: govert
Hi,
I agree it won't be hard to add.
How do you use the derived attribute types? Would it not make more sense for you to use your own attribute types, instead of extending the Excel-DNA attributes by inheritance?
I'm just trying to ensure this is a change that makes sense to me - I'm surprised that you used it that way.
-Govert
Read the full discussion online.
To add a post to this discussion, reply to this email (exceldna@discussions.codeplex.com)
To start a new discussion for this project, email exceldna@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Coordinator
Jan 8, 2012 at 9:35 PM

OK, I have implemented this in the latest check-in  - Change Set 71779 under the Source Code tab.

Could you please check that the new version works for you, and that this issue is resolved?

-Govert

Jan 9, 2012 at 11:11 AM

Thanks so much!

Is this todo required in XlMethodInfo.cs anymore?

//·TODO:·Add·checks·for·attribType.BaseType·?·(http://exceldna.codeplex.com/discussions/285228)

This one in XlParameterInfo.cs also needs to be changed I think:

········////·HACK:·Some·problem·with·library·references·-·

72

········////·For·now·relax·the·assembly·reference·and·use·late-bound

73

················Type·attribType·=·attrib.GetType();

74

················if·(attribType.FullName·==·"ExcelDna.Integration.ExcelArgumentAttribute")

75

················{

From: govert [email removed]
Sent: Sunday, January 08, 2012 10:36 PM
To: cvolzke@live.com.au
Subject: Re: ExcelArgumentAttribute / ExcelFunctionAttribute inheritance broken [exceldna:285228]

From: govert

OK, I have implemented this in the latest check-in - Change Set 71779 under the Source Code tab.

Could you please check that the new version works for you, and that this issue is resolved?

-Govert

Coordinator
Jan 9, 2012 at 11:17 AM

Ah - sorry! I missed the ExcelArgumentAttribute. I'll try tomorrow.

-Govert

Coordinator
Jan 9, 2012 at 6:07 PM

OK - the attributes derived from ExcelArgumentAttribute should be sorted out with Change Set 71800.

-Govert