Skip to content
This repository was archived by the owner on Apr 6, 2024. It is now read-only.

Commit b29203a

Browse files
committed
(GH-135) Add IDE integration with Visual Studio using TeamCity addin
1 parent c45ecf4 commit b29203a

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

src/Cake.Issues.Reporting.Generic.Tests/IdeIntegrationSettingsTests.cs

+16-1
Original file line numberDiff line numberDiff line change
@@ -535,5 +535,20 @@ public void Should_Replace_EndColumn_Token()
535535
result.ShouldBe("FooendColumnBar");
536536
}
537537
}
538+
539+
public sealed class TheForVisualStudioUsingTeamCityAddinMethod
540+
{
541+
[Fact]
542+
public void Should_Return_Settings()
543+
{
544+
// Given
545+
546+
// When
547+
var settings = IdeIntegrationSettings.ForVisualStudioUsingTeamCityAddin();
548+
549+
// Then
550+
settings.ShouldNotBeNull();
551+
}
552+
}
538553
}
539-
}
554+
}

src/Cake.Issues.Reporting.Generic/GenericIssueReportFormatAliases.cs

+15
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@
1515
[SuppressMessage("ReSharper", "UnusedType.Global", Justification = "Class will be loaded by Cake")]
1616
public static class GenericIssueReportFormatAliases
1717
{
18+
/// <summary>
19+
/// Gets an instance of the IDE integration settings for opening files in Visual Studio using the TeamCity addin.
20+
/// </summary>
21+
/// <param name="context">The context.</param>
22+
/// <returns>IDE integration settings.</returns>
23+
[CakeMethodAlias]
24+
[CakeAliasCategory(ReportingAliasConstants.ReportingFormatCakeAliasCategory)]
25+
public static IdeIntegrationSettings GenericIssueReportIdeIntegrationSettingsForVisualStudioUsingTeamCityAddin(
26+
this ICakeContext context)
27+
{
28+
context.NotNull(nameof(context));
29+
30+
return IdeIntegrationSettings.ForVisualStudioUsingTeamCityAddin();
31+
}
32+
1833
/// <summary>
1934
/// Gets an instance of a the generic report format using an embedded template.
2035
/// </summary>

src/Cake.Issues.Reporting.Generic/IdeIntegrationSettings.cs

+20
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ public class IdeIntegrationSettings
2222
/// </summary>
2323
public string MenuEntryText { get; set; } = "Open in IDE";
2424

25+
/// <summary>
26+
/// Returns settings for integrating with Visual Studio using the TeamCity addin.
27+
/// </summary>
28+
/// <returns>Settings for integrating with Visual Studio using the TeamCity addin.</returns>
29+
public static IdeIntegrationSettings ForVisualStudioUsingTeamCityAddin()
30+
{
31+
return new IdeIntegrationSettings()
32+
{
33+
MenuEntryText = "Open in Visual Studio",
34+
JavaScript =
35+
@"function sendHttpGetRequest(filePath, lineNumber) {
36+
var url = 'http://127.0.0.1:63330/file?file=' + filePath + '&line=' + lineNumber;
37+
var xmlHttp = new XMLHttpRequest();
38+
xmlHttp.open('GET', url, false);
39+
xmlHttp.send(null);
40+
}",
41+
OpenInIdeCall = "sendHttpGetRequest({FilePath}, {Line});"
42+
};
43+
}
44+
2545
/// <summary>
2646
/// Returns the JavaScript which should be called to open the file affected by an issue in an IDE
2747
/// with all patterns of <see cref="OpenInIdeCall"/> replaced.

0 commit comments

Comments
 (0)