public static bool LevelIsHigherThanOrEqualToThreshold(ResultLevel threshold, ResultLevel actualLevel)
 {
     if (levelDictionary.ContainsKey(threshold))
     {
         return levelDictionary[threshold].Contains(actualLevel) || (threshold == actualLevel);
     }
     else
     {
         throw new KeyNotFoundException(threshold.ToString() + " is not a supported Analysis result level");
     }
 }
 public static bool LevelIsHigherThanOrEqualToThreshold(ResultLevel threshold, ResultLevel actualLevel)
 {
     if (levelDictionary.ContainsKey(threshold))
     {
         return(levelDictionary[threshold].Contains(actualLevel) || (threshold == actualLevel));
     }
     else
     {
         throw new KeyNotFoundException(threshold.ToString() + " is not a supported Analysis result level");
     }
 }
Beispiel #3
0
 private LogLevel GetLogLevel(ResultLevel level)
 {
     switch (level)
     {
         case ResultLevel.Success:
             return LogLevel.Verbose;
         case ResultLevel.Info:
             return LogLevel.Info;
         case ResultLevel.Warning:
             return LogLevel.Warning;
         case ResultLevel.Error:
             return LogLevel.Error;
         default:
             throw new NotSupportedException(level.ToString());
     }
 }
Beispiel #4
0
        private LogLevel GetLogLevel(ResultLevel level)
        {
            switch (level)
            {
            case ResultLevel.Success:
                return(LogLevel.Verbose);

            case ResultLevel.Info:
                return(LogLevel.Info);

            case ResultLevel.Warning:
                return(LogLevel.Warning);

            case ResultLevel.Error:
                return(LogLevel.Error);

            default:
                throw new NotSupportedException(level.ToString());
            }
        }
Beispiel #5
0
        private static string GetMessageText(
            Uri uri,
            Region region,
            string ruleId,
            string message,
            ResultLevel resultLevel)
        {
            string path = null;

            if (uri != null)
            {
                // If a path refers to a URI of form file://blah, we will convert to the local path
                if (uri.IsAbsoluteUri && uri.Scheme == Uri.UriSchemeFile)
                {
                    path = uri.LocalPath;
                }
                else
                {
                    path = uri.ToString();
                }
            }

            string issueType = null;

            switch (resultLevel)
            {
                case ResultLevel.Error:
                    issueType = "error";
                    break;

                case ResultLevel.Warning:
                    issueType = "warning";
                    break;

                case ResultLevel.NotApplicable:
                case ResultLevel.Note:
                case ResultLevel.Pass:
                    issueType = "info";
                    break;

                default:
                    throw new InvalidOperationException("Unknown message kind:" + resultLevel.ToString());
            }

            string detailedDiagnosis = NormalizeMessage(message, enquote: false);

            string location = "";

            if (region != null)
            {
                // TODO
                if (region.Offset > 0 ||
                    region.StartColumn == 0)
                {
                    throw new NotImplementedException();
                }

                if (region.StartLine == 0)
                {
                    throw new InvalidOperationException();
                }

                location = region.FormatForVisualStudio();
            }

            string result = (path != null ? (path + location + ": ") : "") +
                   issueType + (!string.IsNullOrEmpty(ruleId) ? " " : "") +
                   (resultLevel != ResultLevel.Note ? ruleId : "") + ": " +
                   detailedDiagnosis;

            return result;
        }
Beispiel #6
0
        private static string GetMessageText(
            Uri uri,
            Region region,
            string ruleId,
            string message,
            ResultLevel resultLevel)
        {
            string path = null;

            if (uri != null)
            {
                // If a path refers to a URI of form file://blah, we will convert to the local path
                if (uri.IsAbsoluteUri && uri.Scheme == Uri.UriSchemeFile)
                {
                    path = uri.LocalPath;
                }
                else
                {
                    path = uri.ToString();
                }
            }

            string issueType = null;

            switch (resultLevel)
            {
            case ResultLevel.Error:
                issueType = "error";
                break;

            case ResultLevel.Warning:
                issueType = "warning";
                break;

            case ResultLevel.Pass:
                issueType = "pass";
                break;

            case ResultLevel.NotApplicable:
            case ResultLevel.Note:
                issueType = "info";
                break;

            default:
                throw new InvalidOperationException("Unknown message kind:" + resultLevel.ToString());
            }

            string detailedDiagnosis = NormalizeMessage(message, enquote: false);

            string location = "";

            if (region != null)
            {
                // TODO
                if (region.Offset > 0 ||
                    region.StartColumn == 0)
                {
                    throw new NotImplementedException();
                }

                if (region.StartLine == 0)
                {
                    throw new InvalidOperationException();
                }

                location = region.FormatForVisualStudio();
            }

            string result = (path != null ? (path + location + ": ") : "") +
                            issueType + (!string.IsNullOrEmpty(ruleId) ? " " : "") +
                            (!string.IsNullOrEmpty(ruleId) ? (ruleId + ": ") : "") +
                            detailedDiagnosis;

            return(result);
        }