public static string GetText(this CodeClass2 cls, vsCMPart part = vsCMPart.vsCMPartWholeWithAttributes) { try { var startPoint = cls.GetStartPoint(part); if (startPoint == null) { return(""); } var endPoint = cls.GetEndPoint(part); return(endPoint == null ? "" : startPoint.CreateEditPoint().GetText(endPoint)); } catch (NotImplementedException e) { //catch random errors when trying to get start / end point Console.WriteLine(e.ToString()); return(""); } }