private CodeMemberMethod WriteFunctionInfoHelper(CXCursor cursor) { var functionType = cursor.Type; var nativeName = cursor.Spelling.CString; var resultType = cursor.ResultType; CodeMemberMethod method = new CodeMemberMethod(); method.CustomAttributes.Add(this.DllImportAttribute(nativeName, functionType.GetCallingConvention())); // These methods really should not be abstract, but extern, but CodeDOM doesn't support it - // so we'll do post-processing to fix this (sigh). method.Attributes = MemberAttributes.Public | MemberAttributes.Abstract; method.ReturnType = resultType.ToCodeTypeReference(cursor, this.generator); method.Name = nativeName; var functionKind = FunctionType.None; if (nativeName.Contains("_new")) { functionKind = FunctionType.New; } else if (nativeName.Contains("_free")) { functionKind = FunctionType.Free; } else if (nativeName.Contains("pinvoke")) { functionKind = FunctionType.PInvoke; } int numArgTypes = functionType.NumArgTypes; for (uint i = 0; i < numArgTypes; ++i) { var argument = Argument.GenerateArgument(this.generator, functionType, cursor.GetArgument(i), i, functionKind); method.Parameters.Add(argument); } var comment = this.GetComment(cursor); if (comment != null) { method.Comments.Add(comment); } return(method); }