public static void LogTargetParseError(IAnalysisContext context, Region region, string message) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // {0}({1}): error {2}: {3} context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR1000_ParseError, NotificationLevel.Error, null, false, context.TargetUri.LocalPath, region.FormatForVisualStudio(), ERR1000_ParseError, message)); context.RuntimeErrors |= RuntimeConditions.TargetParseError; }
private static string GetMessageText( Uri uri, Region region, string ruleId, string message, ResultKind kind, FailureLevel level) { string path = null; ValidateKindAndLevel(kind, level); 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 (level) { case FailureLevel.Note: issueType = "info"; break; case FailureLevel.Error: issueType = "error"; break; case FailureLevel.Warning: issueType = "warning"; break; case FailureLevel.None: issueType = kind.ToString().ToLowerInvariant(); break; default: throw new InvalidOperationException("Unknown message kind:" + level.ToString()); } string detailedDiagnosis = NormalizeMessage(message, enquote: false); string location = ""; if (region != null) { // TODO if (region.CharOffset > 0 || region.ByteOffset > 0 || region.StartColumn == 0) { return(string.Empty); } 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); }
private static string GetMessageText( string toolName, Uri uri, Region region, string ruleId, string message, ResultKind kind, FailureLevel level) { string path = null; ValidateKindAndLevel(kind, level); path = ConstructPathFromUri(uri); string issueType = null; switch (level) { case FailureLevel.Note: issueType = "note"; break; case FailureLevel.Error: issueType = "error"; break; case FailureLevel.Warning: issueType = "warning"; break; case FailureLevel.None: issueType = kind.ToString().ToLowerInvariant(); // Shorten to 'info' for compat reasons with previous behaviors. if (issueType == "informational") { issueType = "info"; } ; break; default: throw new InvalidOperationException("Unknown message level:" + level.ToString()); } string detailedDiagnosis = NormalizeMessage(message, enquote: false); string location = ""; if (region != null) { // TODO if (region.CharOffset > 0 || region.ByteOffset > 0 || region.StartColumn == 0) { return(string.Empty); } if (region.StartLine == 0) { throw new InvalidOperationException(); } location = region.FormatForVisualStudio(); } string messageText = (path != null ? (path + location) : toolName) + ": " + issueType + (!string.IsNullOrEmpty(ruleId) ? " " : "") + (!string.IsNullOrEmpty(ruleId) ? (ruleId + ": ") : "") + detailedDiagnosis; return(messageText); }
public static void LogTargetParseError(IAnalysisContext context, Region region, string message) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // {0}({1}): error {2}: {3} context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR1000_ParseError, NotificationLevel.Error, null, false, context.TargetUri.LocalPath, region.FormatForVisualStudio(), ERR1000_ParseError, message)); context.RuntimeErrors |= RuntimeConditions.TargetParseError; }
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; }
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); }