-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
NikolayPianikov
authored and
NikolayPianikov
committed
Feb 1, 2022
1 parent
a17712d
commit af1c101
Showing
7 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
namespace TeamCity.MSBuild.Logger | ||
{ | ||
using JetBrains.TeamCity.ServiceMessages; | ||
using JetBrains.TeamCity.ServiceMessages.Write.Special; | ||
using Microsoft.Build.Framework; | ||
|
||
internal class BuildErrorMessageUpdater: IServiceMessageUpdater | ||
{ | ||
private readonly IEventContext _eventContext; | ||
|
||
public BuildErrorMessageUpdater(IEventContext eventContext) => | ||
_eventContext = eventContext; | ||
|
||
public IServiceMessage UpdateServiceMessage(IServiceMessage message) | ||
{ | ||
if (_eventContext.TryGetEvent(out var buildEventManager) | ||
&& buildEventManager is BuildErrorEventArgs error) | ||
{ | ||
var newMessage = new PatchedServiceMessage(message); | ||
if (!string.IsNullOrWhiteSpace(error.Code)) | ||
{ | ||
newMessage.Add("code", error.Code); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(error.File)) | ||
{ | ||
newMessage.Add("file", error.File); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(error.Subcategory)) | ||
{ | ||
newMessage.Add("subcategory", error.Subcategory); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(error.ProjectFile)) | ||
{ | ||
newMessage.Add("projectFile", error.ProjectFile); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(error.SenderName)) | ||
{ | ||
newMessage.Add("senderName", error.SenderName); | ||
} | ||
|
||
newMessage.Add("columnNumber", error.ColumnNumber.ToString()); | ||
newMessage.Add("endColumnNumber", error.EndColumnNumber.ToString()); | ||
newMessage.Add("lineNumber", error.LineNumber.ToString()); | ||
newMessage.Add("endLineNumber", error.EndLineNumber.ToString()); | ||
return newMessage; | ||
} | ||
|
||
return message; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
namespace TeamCity.MSBuild.Logger | ||
{ | ||
using JetBrains.TeamCity.ServiceMessages; | ||
using JetBrains.TeamCity.ServiceMessages.Write.Special; | ||
using Microsoft.Build.Framework; | ||
|
||
internal class BuildMessageMessageUpdater: IServiceMessageUpdater | ||
{ | ||
private readonly IEventContext _eventContext; | ||
|
||
public BuildMessageMessageUpdater(IEventContext eventContext) => | ||
_eventContext = eventContext; | ||
|
||
public IServiceMessage UpdateServiceMessage(IServiceMessage message) | ||
{ | ||
if (_eventContext.TryGetEvent(out var buildEventManager) | ||
&& buildEventManager is BuildMessageEventArgs msg) | ||
{ | ||
var newMessage = new PatchedServiceMessage(message); | ||
if (!string.IsNullOrWhiteSpace(msg.Code)) | ||
{ | ||
newMessage.Add("code", msg.Code); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(msg.File)) | ||
{ | ||
newMessage.Add("file", msg.File); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(msg.Subcategory)) | ||
{ | ||
newMessage.Add("subcategory", msg.Subcategory); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(msg.ProjectFile)) | ||
{ | ||
newMessage.Add("projectFile", msg.ProjectFile); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(msg.SenderName)) | ||
{ | ||
newMessage.Add("senderName", msg.SenderName); | ||
} | ||
|
||
newMessage.Add("columnNumber", msg.ColumnNumber.ToString()); | ||
newMessage.Add("endColumnNumber", msg.EndColumnNumber.ToString()); | ||
newMessage.Add("lineNumber", msg.LineNumber.ToString()); | ||
newMessage.Add("endLineNumber", msg.EndLineNumber.ToString()); | ||
newMessage.Add("importance", msg.Importance.ToString()); | ||
|
||
return newMessage; | ||
} | ||
|
||
return message; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
namespace TeamCity.MSBuild.Logger | ||
{ | ||
using JetBrains.TeamCity.ServiceMessages; | ||
using JetBrains.TeamCity.ServiceMessages.Write.Special; | ||
using Microsoft.Build.Framework; | ||
|
||
internal class BuildWarningMessageUpdater: IServiceMessageUpdater | ||
{ | ||
private readonly IEventContext _eventContext; | ||
|
||
public BuildWarningMessageUpdater(IEventContext eventContext) => | ||
_eventContext = eventContext; | ||
|
||
public IServiceMessage UpdateServiceMessage(IServiceMessage message) | ||
{ | ||
if (_eventContext.TryGetEvent(out var buildEventManager) | ||
&& buildEventManager is BuildWarningEventArgs warning) | ||
{ | ||
var newMessage = new PatchedServiceMessage(message); | ||
if (!string.IsNullOrWhiteSpace(warning.Code)) | ||
{ | ||
newMessage.Add("code", warning.Code); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(warning.File)) | ||
{ | ||
newMessage.Add("file", warning.File); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(warning.Subcategory)) | ||
{ | ||
newMessage.Add("subcategory", warning.Subcategory); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(warning.ProjectFile)) | ||
{ | ||
newMessage.Add("projectFile", warning.ProjectFile); | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(warning.SenderName)) | ||
{ | ||
newMessage.Add("senderName", warning.SenderName); | ||
} | ||
|
||
newMessage.Add("columnNumber", warning.ColumnNumber.ToString()); | ||
newMessage.Add("endColumnNumber", warning.EndColumnNumber.ToString()); | ||
newMessage.Add("lineNumber", warning.LineNumber.ToString()); | ||
newMessage.Add("endLineNumber", warning.EndLineNumber.ToString()); | ||
return newMessage; | ||
} | ||
|
||
return message; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace TeamCity.MSBuild.Logger | ||
{ | ||
using System; | ||
using System.Linq; | ||
using JetBrains.Annotations; | ||
using JetBrains.TeamCity.ServiceMessages; | ||
using JetBrains.TeamCity.ServiceMessages.Write; | ||
|
||
internal class PatchedServiceMessage : ServiceMessage | ||
{ | ||
public PatchedServiceMessage([NotNull] IServiceMessage message) | ||
: base(message.Name) | ||
{ | ||
if (message == null) throw new ArgumentNullException(nameof(message)); | ||
AddRange(message.Keys.ToDictionary(x => x, message.GetValue)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters