/// <summary> /// Defines method using pre-built method model. /// </summary> /// <param name="methods">Methods group that owns new method.</param> /// <param name="model">Method model.</param> /// <param name="async">If <c>true</c>, append <see cref="ASYNC_SUFFIX"/> to method name.</param> /// <param name="withAwait">If <c>true</c>, method contains <c>await</c> operations and should be marked with <c>async</c> modifier.</param> /// <returns>Method builder instance.</returns> private MethodBuilder DefineMethod(MethodGroup methods, MethodModel model, bool async = false, bool withAwait = false) { var builder = methods.New(AST.Name(async ? model.Name + ASYNC_SUFFIX : model.Name)); if (withAwait) { builder.SetModifiers(model.Modifiers | Modifiers.Async); } else { builder.SetModifiers(model.Modifiers); } if (model.Summary != null) { builder.XmlComment().Summary(model.Summary); } if (model.CustomAttributes != null) { foreach (var attr in model.CustomAttributes) { builder.AddAttribute(attr); } } return(builder); }