This project is read-only.

Syntax Generation Ignores Numeric Values in Attributes


It appears that Sandcastle's syntax generators ignore numeric values in attributes. Either I've missed this being reported already or it's surprising that nobody has yet :)
For example, the following C# code has an attribute that is initialized with two numeric literals of type System.Int32:
[MyAttribute(First = 876, Second = 987)]
void Foo();
The syntax that is generated looks something like the following:
[MyAttribute(First = , Second = )]
private void Foo();
Notice that the numeric literals have been omitted.
The root of the problem appears to be in the following code, found at line 581 of CSharpDeclarationSyntax.cs (and similar for the other languages), in the SyntaxComponents.dll assembly:
case "value":
string text = value.Value;
string typeId = type.GetAttribute("api", String.Empty);
switch (typeId) {
case "T:System.String":
case "T:System.Boolean":
  bool bool_value = Convert.ToBoolean(text);
  if (bool_value) {
  } else {
case "T:System.Char":
I don’t see any reason for the omission of a case statement for “T:System.Int32” and other numeric types that can be specified as literal values for attributes; e.g., Int64, Float, Double, Decimal.
Original bug report:


ringler wrote Mar 2, 2011 at 11:22 AM

My strong support for this bug! I just spend an hour trying to find out why the int attribute arguments don't get printed.

wrote Sep 30, 2011 at 6:03 AM

ryanwool wrote Sep 30, 2011 at 6:04 AM

Is this bug got fixed?
Or is there any work around?

charlass wrote Dec 6, 2011 at 2:55 PM

+1 for fixing this bug!

We have a large set of entity / dto classes, all properties are annotated with EntLib validation attributes.
It would be extremely helpful to print these attributes in the documentation.
Currently we only have the choice between "I'm not telling you" or "Ok, so I will duplicate the info", both choices stink for obvious reasons...

wrote Dec 6, 2011 at 2:55 PM

wrote Dec 6, 2011 at 3:02 PM

wrote Dec 6, 2011 at 3:05 PM

wrote Jan 28, 2012 at 2:21 PM

wrote Feb 22, 2013 at 1:39 AM