public static bool TryReadXml(string filename, out CCCheckOutput data) { #region CodeContracts Contract.Requires(!string.IsNullOrEmpty(filename)); Contract.Ensures(!Contract.Result <bool>() || Contract.ValueAtReturn(out data) != null); #endregion CodeContracts Contract.Assert(File.Exists(filename)); data = null; try { var text = File.ReadAllText(filename); var serializer = new XmlSerializer(typeof(CCCheckOutput)); using (var reader = new StringReader(text)) { data = (CCCheckOutput)serializer.Deserialize(reader); } } catch (Exception e) { Console.WriteLine("Something went wrong in opening the input file"); Console.WriteLine("This is the exception {0}", e.ToString()); return(false); } return(true); }
public static bool TryReadXml(string filename, out CCCheckOutput data) { #region CodeContracts Contract.Requires(!string.IsNullOrEmpty(filename)); Contract.Ensures(!Contract.Result<bool>() || Contract.ValueAtReturn(out data) != null); #endregion CodeContracts Contract.Assert(File.Exists(filename)); data = null; try { var text = File.ReadAllText(filename); var serializer = new XmlSerializer(typeof(CCCheckOutput)); using(var reader = new StringReader(text)) { data = (CCCheckOutput)serializer.Deserialize(reader); } } catch(Exception e) { Console.WriteLine("Something went wrong in opening the input file"); Console.WriteLine("This is the exception {0}", e.ToString()); return false; } return true; }
public static IEnumerable <BaseAnnotation> GetAnnotationDictionary(CCCheckOutput xml) { #region CodeContracts Contract.Requires(xml != null); Contract.Ensures(Contract.Result <IEnumerable <BaseAnnotation> >() != null); Contract.Ensures(Contract.ForAll(Contract.Result <IEnumerable <BaseAnnotation> >(), annotation => annotation != null)); #endregion CodeContracts Output.WriteLine("Processing the suggestions"); var annotations = ProcessSuggestions(xml); DebugParsing(annotations); return(annotations); }
public static IEnumerable<BaseAnnotation> GetAnnotationDictionary(CCCheckOutput xml) { #region CodeContracts Contract.Requires(xml != null); Contract.Ensures(Contract.Result <IEnumerable<BaseAnnotation>>() != null); Contract.Ensures(Contract.ForAll(Contract.Result <IEnumerable<BaseAnnotation>>(), annotation => annotation != null)); #endregion CodeContracts Output.WriteLine("Processing the suggestions"); var annotations = ProcessSuggestions(xml); DebugParsing(annotations); return annotations; }
private static IEnumerable<BaseAnnotation> ProcessSuggestions(CCCheckOutput xml) { var annotations = new List<BaseAnnotation>(); foreach (var assembly in xml.Items.OfType<CCCheckOutputAssembly>()) { if (assembly.Method != null) { foreach (var methodgroup in assembly.Method.GroupBy(x => x.Name)) { var first = methodgroup.Last(); Contract.Assume(first != null); ProcessMethod(first, annotations); } } } return annotations.AsReadOnly(); }
private static IEnumerable <BaseAnnotation> ProcessSuggestions(CCCheckOutput xml) { var annotations = new List <BaseAnnotation>(); foreach (var assembly in xml.Items.OfType <CCCheckOutputAssembly>()) { if (assembly.Method != null) { foreach (var methodgroup in assembly.Method.GroupBy(x => x.Name)) { var first = methodgroup.Last(); Contract.Assume(first != null); ProcessMethod(first, annotations); } } } return(annotations.AsReadOnly()); }