/// <summary> /// This is specific handling for duplicated Error/Warning ID's. /// </summary> /// <param name="actualerrorwarning"></param> /// <returns></returns> private bool IsDuplicatedErrorMessageIgnorable(ref ErrorWarningCode actualerrorwarning) { if (actualerrorwarning == null) { return(false); } ErrorWarningCode tempewc = null; IDictionaryEnumerator enumerator = expectederrors.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Key.ToString().StartsWith(actualerrorwarning.ID)) { tempewc = (ErrorWarningCode)enumerator.Value; if (tempewc == null) { tempewc = null; continue; } if (String.IsNullOrEmpty(tempewc.Description)) { tempewc = null; continue; } if (actualerrorwarning.Description.Contains(tempewc.Description)) { break; } if (ErrorWarningCode.Compare(tempewc.description, actualerrorwarning.Description)) { currentduplicateerrorwarningid = actualerrorwarning; tempewc = null; enumerator = null; return(true); } tempewc = null; } } // Should never happen! if (tempewc == null) { return(false); } if (actualerrorwarning.Equals(tempewc) == false) { return(false); } currentduplicateerrorwarningid = tempewc; tempewc = null; enumerator = null; return(currentduplicateerrorwarningid.IsIgnoreable); }
/// <summary> /// Method checks if the error/warning exists in the ErrorWarnings list using error id. /// If the error is found verify description depending on IsPartial attribute value. /// Also if error is found check if IsIgnoreable attribute set to true /// </summary> /// <param name="e">BuildEventArgs object from MSBuild</param> /// <param name="errortype">Error or Warning</param> /// <returns></returns> private bool IsErrorMessageIgnorable(BuildEventArgs e, string errortype) { MSBuildEngineCommonHelper.LogDiagnostic = "Executing Find Error message"; if (expectederrors == null && _berrorhandling == true) { // This is when there is no error file specified. return(false); } if (String.IsNullOrEmpty(e.Message)) { return(false); } string errorid = null; BuildWarningEventArgs warningeventargs = null; BuildErrorEventArgs erroreventargs = e as BuildErrorEventArgs; if (erroreventargs == null) { warningeventargs = e as BuildWarningEventArgs; if (warningeventargs == null) { throw new ApplicationException("Type of Build event could not be determined."); } errorid = warningeventargs.Code; } else { errorid = erroreventargs.Code; } ErrorWarningCode actualerrorwarning = new ErrorWarningCode(e); if (_listofhandlederrors == null) { _listofhandlederrors = new List <ErrorWarningCode>(); } _listofhandlederrors.Add(actualerrorwarning); if (!_berrorhandling) { return(false); } if (String.IsNullOrEmpty(errorid)) { errorid = actualerrorwarning.ID; } // Retired. //if (String.IsNullOrEmpty(errorid)) //{ // // Currently in Avalon the implementation is not in line with reporting // // Code ID, Line #, Position and so on. // // Adding work around here. // //MSBuildEngineCommonHelper.Log = "Could not find Error/Warning with ID - " + errorid; // return IsAvalonErrorMessageIgnorable(e, errortype); // //return false; //} if (String.IsNullOrEmpty(errorid)) { if (CheckUnassignedDescriptionExists(e.Message) == false) { //if (listofhandlederrors == null) //{ // listofhandlederrors = new List<string>(); //} //if (listofhandlederrors.Contains(currentduplicateerrorwarningid) == false) //{ // listofhandlederrors.Add(e.Message); //} MSBuildEngineCommonHelper.LogError = "Build error/warning should contain an error ID."; return(false); } else { if (listoferrorwarningswithoutid != null) { for (int i = 0; i < listoferrorwarningswithoutid.Count; i++) { string erroridwithoutdescription = listoferrorwarningswithoutid[i]; if (erroridwithoutdescription.ToLowerInvariant().Contains("_Dup".ToLowerInvariant())) { int index = erroridwithoutdescription.ToLowerInvariant().IndexOf("_Dup".ToLowerInvariant()); erroridwithoutdescription = erroridwithoutdescription.Substring(0, index); } if (listoferrorwarningswithoutid.Contains(erroridwithoutdescription)) { listoferrorwarningswithoutid.RemoveAt(i); if (listoferrorwarningswithoutid.Count > 0 && i > 0) { i--; } _listofhandlederrors.Remove(actualerrorwarning); //break; } } // Todo: } return(true); } } if (IsDuplicated(errorid.ToUpper())) { if (IsDuplicatedErrorMessageIgnorable(ref actualerrorwarning)) { if (_listofhandlederrors != null && _listofhandlederrors.Contains(currentduplicateerrorwarningid)) //if (_listofhandlederrors != null) { //for (int i = 0; i < _listofhandlederrors.Count; i++) //{ // if (_listofhandlederrors[i].Equals(currentduplicateerrorwarningid)) // { _listofhandlederrors.Remove(currentduplicateerrorwarningid); // } //} } currentduplicateerrorwarningid = null; return(true); } else { currentduplicateerrorwarningid = null; return(false); } } if (expectederrors[errorid.ToUpper()] == null) { return(false); } // Get object based on error id. ErrorWarningCode desirederrorwarning = (ErrorWarningCode)expectederrors[errorid.ToUpper()]; if (desirederrorwarning == null) { MSBuildEngineCommonHelper.Log = "Could not find Error/Warning with ID - " + errorid; return(false); } if (actualerrorwarning.Equals(desirederrorwarning) == false) { return(false); } if (_listofhandlederrors != null && _listofhandlederrors.Count > 0 && _listofhandlederrors.Contains(actualerrorwarning)) { _listofhandlederrors.Remove(actualerrorwarning); } actualerrorwarning = null; return(desirederrorwarning.IsIgnoreable); }