コード例 #1
0
        public void LogIssue(
            AzureDevOpsIssueType type,
            string message,
            string sourcePath   = null,
            string lineNumber   = null,
            string columnNumber = null,
            string code         = null)
        {
            var properties = $"type={GetText(type)};";

            if (!string.IsNullOrEmpty(sourcePath))
            {
                properties += $"sourcepath={sourcePath};";
            }

            if (!string.IsNullOrEmpty(lineNumber))
            {
                properties += $"linenumber={lineNumber};";
            }

            if (!string.IsNullOrEmpty(columnNumber))
            {
                properties += $"columnnumber={columnNumber};";
            }

            if (!string.IsNullOrEmpty(code))
            {
                properties += $"code={code};";
            }

            _messageSink($"##vso[task.logissue {properties}]{message}");
        }
コード例 #2
0
        private string GetText(AzureDevOpsIssueType type)
        {
            switch (type)
            {
            case AzureDevOpsIssueType.Warning:
                return("warning");

            case AzureDevOpsIssueType.Error:
                return("error");

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, message: null);
            }
        }