/// <summary> /// Adds a link to the bug. Will not add if already there. /// </summary> /// <param name="target"></param> /// <param name="comment"></param> /// <returns></returns> bool IBug.AddLink(Uri target, string comment) { var link = new Microsoft.TeamFoundation.WorkItemTracking.Client.Hyperlink(target.ToString()); link.Comment = comment == null ? "Review page" : comment; if (_workItem.Links.Contains(link)) return false; // BUG in TFS: LinkCollection.Contains returns false even when the link exists, and then // on Add it throws a ValidationException. So keep checking but also put in a try/catch. try { _workItem.Links.Add(link); } catch (ValidationException) { return false; } var invalidFields = _workItem.Validate(); if (invalidFields != null && invalidFields.Count != 0) { Console.WriteLine("Bug validation failed for bug ID {0}:", ((IBug)this).Id); foreach (var obj in invalidFields) { var field = (Field)obj; Console.WriteLine("Invalid field: {0}", field.Name); } } Debug.Assert(_workItem.IsValid()); _workItem.Save(); return true; }
internal Hyperlink(Tfs.Hyperlink hyperLink) : base(hyperLink.Location, hyperLink.Comment) { }
internal HyperlinkProxy(Tfs.Hyperlink hyperLink) : base(hyperLink) { _hyperLink = hyperLink; }