title: EnvDTE in c#: how do i add parameters to a generated c++ function?
body: <p>I am trying to generate a function with parameters. adding the function header and body works fine, but when I try to add parameters I get an exception that I haven't been able to solve.</p>
  
  <pre><code>func.AddParameter("num", "int");
  </code></pre>
  
  <p>I get the exception:</p>
  
  <blockquote>
    <p>Failed to return new Code Element. Possibly syntax error. New Element Name: num</p>
  </blockquote>
  
  <p>this is how I generated the function head and body:</p>
  
  <pre><code>VCCodeFunction func = (VCCodeFunction)(((VCFileCodeModel)(file.FileCodeModel)).AddFunction("testfunc", vsCMFunction.vsCMFunctionFunction, "testClass2"));
  func.BodyText = "for(int i=0; i &lt; 5; ++i){}\n return 1;";
  </code></pre>
  
  <p>this generates:</p>
  
  <pre><code>testClass2 testfunc()
  {
      for (int i = 0; i &lt; 5; i++) {}
      return 1;
  }
  </code></pre>
  
  <p>as a temporary solution I get around the issue by manually adding the parameters one character left from where the body starts (or within the parenthesis)</p>
  
  <pre><code>var tp = func.GetStartPoint(vsCMPart.vsCMPartBodyWithDelimiter);
  var ep = tp.CreateEditPoint();
  ep.CharLeft();
  ep.Insert("int num");
  </code></pre>
  
  <p>but I feel this is bad practice.
  what am I doing wrong?</p>