Esempio n. 1
0
 public override void WriteMessage(Issue issue)
 {
     string format = LineFormat;
     if (IncludeSourceInMessage)
     {
         format = string.Concat("[{5}] ", format);
     }
     _logger.Info(format, issue.Severity, issue.Name, issue.FilePath, issue.Line, issue.Message, issue.Source);
 }
Esempio n. 2
0
        public override void WriteMessage(Issue issue)
        {
            var message = issue.Message;
            if (_includeSourceInMessage)
            {
                message = string.Format("[{0}] {1}", issue.Source, message);
            }

            string category = "information";
            switch (issue.Severity)
            {
                case IssueSeverity.Error:
                    category = "error";
                    break;

                case IssueSeverity.Warning:
                    category = "warning";
                    break;
            }

            string filePath = issue.FilePath.Replace(issue.Project + @"\", string.Empty);

            _logger.Debug("Send compilation message to AppVeyor:");
            _logger.Debug("Message: {0}", message);
            _logger.Debug("Category: {0}", category);
            _logger.Debug("FileName: {0}", filePath);
            _logger.Debug("Line: {0}", issue.Line);
            _logger.Debug("ProjectName: {0}", issue.Project);

            using (var httpClient = _httpClientFactory.Create())
            {
                httpClient.BaseAddress = new Uri(_appVeyorAPIUrl);

                var compilationMessage = new CompilationMessage
                {
                    Message = message,
                    Category = category,
                    FileName = filePath,
                    Line = issue.Line,
                    ProjectName = issue.Project
                };

                if (issue.Offset != null)
                {
                    //_logger.Debug("Column: {0}", issue.Offset.Start);
                    //compilationMessage.Column = issue.Offset.Start;
                }

                var response = httpClient.PostAsJsonAsync("api/build/compilationmessages", compilationMessage).Result;

                if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.NoContent)
                {
                    _logger.Error("An error is occurred during the call to AppVeyor API: {0}", response);
                }
            }
        }
Esempio n. 3
0
 public void WriteMessage(Issue issue)
 {
     throw new NotImplementedException();
 }
Esempio n. 4
0
        public override void WriteMessage(Issue issue)
        {
            var message = issue.Message;
            if (IncludeSourceInMessage)
            {
                message = string.Format("[{0}] {1}", issue.Source, message);
            }

            string category = "information";
            switch (issue.Severity)
            {
                case IssueSeverity.Error:
                    category = "error";
                    break;

                case IssueSeverity.Warning:
                    category = "warning";
                    break;
            }

            string filePath = issue.FilePath.Replace(issue.Project + @"\", string.Empty);
            string details = string.Format("{0} in {1} on line {2}", message, filePath, issue.Line);

            _logger.Debug("Send compilation message to AppVeyor:");
            _logger.Debug("Message: {0}", message);
            _logger.Debug("Category: {0}", category);
            _logger.Debug("FileName: {0}", filePath);
            _logger.Debug("Line: {0}", issue.Line);
            _logger.Debug("ProjectName: {0}", issue.Project);
            _logger.Debug("Details: {0}", details);

            using (var httpClient = _httpClientFactory.Create())
            {
                httpClient.BaseAddress = new Uri(_appVeyorApiUrl);

                var compilationMessage = new CompilationMessage
                {
                    Message = message,
                    Category = category,
                    FileName = filePath,
                    Line = issue.Line,
                    ProjectName = issue.Project,
                    Details = details
                };

                if (issue.Offset != null)
                {
                    _logger.Debug("Column: {0}", issue.Offset.Start);
                    compilationMessage.Column = issue.Offset.Start + 1;
                }

                JsonMediaTypeFormatter jsonFormat = new JsonMediaTypeFormatter();
                jsonFormat.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore;
                jsonFormat.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
                
            var response = httpClient.PostAsync("api/build/compilationmessages", compilationMessage, jsonFormat).Result;

                if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.NoContent)
                {
                    _logger.Error("An error is occurred during the call to AppVeyor API: {0}", response);
                }
            }
        }
Esempio n. 5
0
 public abstract void WriteMessage(Issue issue);