1
Vote

Codebuilder does not work correctly

description

Hi,
 
Trying to use the codebuilder, i had found the following:
public CodeBuilder Append(char value, int repeatCount)
{
 return Append(value, repeatCount);
}
 
That's wrong because the function will call itself leading to a stack overflow. The same applies to all the "Append" functions from Append(char value, int repeatCount) to AppendFormat(string format, object arg0, object arg1, object arg2).
 
I think that part of the code should have to look like:
public CodeBuilder Append(char value, int repeatCount)
{
 
    AppendIndent();
    builder.Append(value, repeatCount);
    return this;
}
 
public CodeBuilder Append(string value, int startIndex, int count)
{
    AppendIndent();
    builder.Append(value, startIndex, count);
  return this;
}
 
public CodeBuilder Append(char[] value, int startIndex, int charCount)
{
    AppendIndent();
    builder.Append(value, startIndex, charCount);
  return this;
}
 
public CodeBuilder AppendFormat(string format, object arg0)
{
    AppendIndent();
    builder.AppendFormat(format, arg0);
  return this;
}
 
public CodeBuilder AppendFormat(string format, object[] args)
{
    AppendIndent();
    builder.AppendFormat(format, args);
    return this;
}
 
public CodeBuilder AppendFormat(IFormatProvider provider, string format, object[] args)
{
    AppendIndent();
    builder.AppendFormat(provider, format, args);
    return this;
}
 
public CodeBuilder AppendFormat(string format, object arg0, object arg1)
{
    AppendIndent();
    builder.AppendFormat(format, arg0, arg1);
    return this;
}
 
public CodeBuilder AppendFormat(string format, object arg0, object arg1, object arg2)
{
    AppendIndent();
    builder.AppendFormat(format, arg0, arg1, arg2);
    return this;
}

comments