Skip to content

Commit

Permalink
Code formating
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed Sep 13, 2024
1 parent 0652eb5 commit 591f862
Show file tree
Hide file tree
Showing 276 changed files with 706 additions and 465 deletions.
16 changes: 8 additions & 8 deletions Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
packageId,
Path.Combine(outputDir, "CSharpInteractive", $"{packageId}.{packageVersion.ToString()}.nupkg"),
true),

new PackageInfo(
toolPackageId,
Path.Combine(outputDir, "CSharpInteractive.Tool", $"{toolPackageId}.{packageVersion.ToString()}.nupkg"),
true),

new PackageInfo(
templatesPackageId,
Path.Combine(templateOutputDir, $"{templatesPackageId}.{packageVersion.ToString()}.nupkg"),
Expand All @@ -74,7 +74,7 @@
{
Directory.Delete(nuGetPackagePath, true);
}

var packageOutput = Path.GetDirectoryName(package.Package);
if (Directory.Exists(packageOutput))
{
Expand Down Expand Up @@ -153,7 +153,7 @@
var dotCoverReportXml = Path.Combine(reportDir, "dotCover.xml");
new DotNetCustom("dotCover", "report", $"--source={dotCoverSnapshot}", $"--output={dotCoverReportXml}", "--reportType=TeamCityXml").WithShortName("Generating the code coverage reports")
.Run().EnsureSuccess();

if (TryGetCoverage(dotCoverReportXml, out coveragePercentage))
{
switch (coveragePercentage)
Expand All @@ -176,7 +176,7 @@
var uninstallTool = new DotNetCustom("tool", "uninstall", toolPackageId, "-g")
.WithShortName("Uninstalling tool");

if (uninstallTool.Run(_ => { } ).ExitCode != 0)
if (uninstallTool.Run(_ => { }).ExitCode != 0)
{
Warning($"{uninstallTool} failed.");
}
Expand Down Expand Up @@ -271,20 +271,20 @@ async Task CheckCompatibilityAsync(
.WithWorkingDirectory(buildProjectDir)
.WithShortName($"Creating a new {sampleProjectName}")
.RunAsync().EnsureSuccess();

await new DotNetBuild()
.WithProject(buildProjectDir)
.WithSources(nuGetSource, Path.Combine(output, "CSharpInteractive"))
.WithShortName($"Building the {sampleProjectName}")
.BuildAsync().EnsureSuccess();

await new DotNetRun()
.WithProject(buildProjectDir)
.WithNoBuild(true)
.WithWorkingDirectory(sampleProjectDir)
.WithShortName($"Running a build for the {sampleProjectName}")
.RunAsync().EnsureSuccess();

await new DotNetCustom("csi", Path.Combine(buildProjectDir, "Program.csx"))
.WithWorkingDirectory(sampleProjectDir)
.WithShortName($"Running a build as a C# script for the {sampleProjectName}")
Expand Down
10 changes: 5 additions & 5 deletions Build/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

internal static class Tools
{
public static bool CI =>
public static bool CI =>
Environment.GetEnvironmentVariable("TEAMCITY_VERSION") is not null
|| Environment.GetEnvironmentVariable("CI") == "true";

public static NuGetVersion GetNextNuGetVersion(NuGetRestoreSettings settings, NuGetVersion defaultVersion)
{
var floatRange = defaultVersion.Release != string.Empty
Expand All @@ -33,7 +33,7 @@ private static string GetNextRelease(SemanticVersion curVersion, string release)
return release;
}

return int.TryParse(string.Concat(curVersion.Release.Where(char.IsNumber)), out var num)
return int.TryParse(string.Concat(curVersion.Release.Where(char.IsNumber)), out var num)
? $"{string.Concat(curVersion.Release.Where(i => !char.IsNumber(i)))}{num + 1}"
: release;
}
Expand All @@ -58,7 +58,7 @@ public static string GetProperty(string name, string defaultProp, bool showWarni

return defaultProp;
}

public static bool TryGetCoverage(string dotCoverReportXml, out int coveragePercentage)
{
var dotCoverReportDoc = new XmlDocument();
Expand All @@ -79,7 +79,7 @@ public static bool HasLinuxDocker()
hasLinuxDocker = true;
}
});

return hasLinuxDocker;
}
}
21 changes: 11 additions & 10 deletions CSharpInteractive.HostApi/BuildMessage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ReSharper disable InconsistentNaming
// ReSharper disable NotAccessedPositionalProperty.Global
// ReSharper disable InconsistentNaming

namespace HostApi;

using JetBrains.TeamCity.ServiceMessages;
Expand Down Expand Up @@ -45,18 +46,18 @@ public record BuildMessage(
/// <summary>
/// Contains the result of test execution when <see cref="State"/> is set to <see cref="BuildMessageState.TestResult"/>.
/// </summary>
public TestResult? TestResult =>
public TestResult? TestResult =>
ServiceMessage != null && TryGetTestState(ServiceMessage.Name, out var testState)
? CreateResult(CreateKey(ServiceMessage), ServiceMessage, testState)
: default(TestResult?);

/// <inheritdoc />
public override string ToString() => Text;

internal static TestResult CreateResult(TestKey key, IServiceMessage message, TestState state)
{
var testSource = message.GetValue("testSource") ?? string.Empty;
var displayName = message.GetValue("displayName") ?? string.Empty;
var displayName = message.GetValue("displayName") ?? string.Empty;
var resultDisplayName = message.GetValue("resultDisplayName") ?? string.Empty;
var codeFilePath = message.GetValue("codeFilePath") ?? string.Empty;
var fullyQualifiedName = message.GetValue("fullyQualifiedName") ?? string.Empty;
Expand All @@ -69,7 +70,7 @@ internal static TestResult CreateResult(TestKey key, IServiceMessage message, Te
.WithResultDisplayName(resultDisplayName)
.WithCodeFilePath(codeFilePath)
.WithFullyQualifiedName(fullyQualifiedName);

if (Guid.TryParse(message.GetValue("id"), out var id))
{
result = result.WithId(id);
Expand All @@ -84,30 +85,30 @@ internal static TestResult CreateResult(TestKey key, IServiceMessage message, Te
{
result = result.WithLineNumber(lineNumber);
}

return result;
}

internal static TestKey CreateKey(IServiceMessage message)
{
var flowId = message.GetValue("flowId") ?? string.Empty;
var suiteName = message.GetValue("suiteName") ?? string.Empty;
var suiteName = message.GetValue("suiteName") ?? string.Empty;
var name = message.GetValue("name") ?? string.Empty;
return new TestKey(flowId, suiteName, name);
}

private static bool TryGetTestState(string? name, out TestState state)
{
switch(name?.ToLowerInvariant())
switch (name?.ToLowerInvariant())
{
case "testfinished":
state = TestState.Finished;
return true;

case "testignored":
state = TestState.Ignored;
return true;

case "testfailed":
state = TestState.Failed;
return true;
Expand All @@ -116,7 +117,7 @@ private static bool TryGetTestState(string? name, out TestState state)
state = default;
return false;
}

// ReSharper disable once NotAccessedPositionalProperty.Local
internal readonly record struct TestKey(string FlowId, string SuiteName, string TestName);
}
7 changes: 4 additions & 3 deletions CSharpInteractive.HostApi/BuildMessageState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global

namespace HostApi;

/// <summary>
Expand All @@ -21,17 +22,17 @@ public enum BuildMessageState
/// Build warning.
/// </summary>
Warning,

/// <summary>
/// The message that the string was sent to stdErr.
/// </summary>
StdError,

/// <summary>
/// Build error.
/// </summary>
Failure,

/// <summary>
/// Build problem.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions CSharpInteractive.HostApi/BuildStatistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override string ToString()
{
sb.Append(" and ");
}

sb.Append(Tests);
sb.Append(" finished ");
sb.Append(GetName("test", Tests));
Expand All @@ -76,7 +76,7 @@ private static void AddValue(StringBuilder sb, string name, int value, int initi
{
sb.Append(", ");
}

sb.Append(value);
sb.Append(' ');
sb.Append(name);
Expand Down
10 changes: 5 additions & 5 deletions CSharpInteractive.HostApi/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ public enum Color
/// Standard text output color.
/// </summary>
Default,

/// <summary>
/// The color of the header output.
/// </summary>
Header,

/// <summary>
/// Color of trace messages.
/// </summary>
Trace,

/// <summary>
/// Color of the success messages.
/// </summary>
Expand All @@ -35,12 +35,12 @@ public enum Color
/// Color of messages containing warnings.
/// </summary>
Warning,

/// <summary>
/// Color of messages containing errors.
/// </summary>
Error,

/// <summary>
/// Colour for details.
/// </summary>
Expand Down
5 changes: 3 additions & 2 deletions CSharpInteractive.HostApi/CommandLine.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ReSharper disable UnusedMember.Global
// ReSharper disable MemberCanBeProtected.Global
// ReSharper disable ReturnTypeCanBeEnumerable.Global

namespace HostApi;

using System.Diagnostics;
Expand Down Expand Up @@ -50,7 +51,7 @@ internal CommandLine(IStartInfo startInfo)
{ }

/// <inheritdoc/>
public string ShortName =>
public string ShortName =>
!string.IsNullOrWhiteSpace(_shortName)
? _shortName
: Path.GetFileNameWithoutExtension(ExecutablePath);
Expand Down Expand Up @@ -82,7 +83,7 @@ public override string ToString()
return sb.ToString();
}

private static string Escape(string text) =>
private static string Escape(string text) =>
!text.TrimStart().StartsWith("\"") && text.Contains(' ')
? $"\"{text}\""
: text;
Expand Down
4 changes: 2 additions & 2 deletions CSharpInteractive.HostApi/CommandLineTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static class CommandLineTools
/// <returns>Created command line.</returns>
public static CommandLine AsCommandLine(this string executable, params string[] args) =>
new(executable, args);

/// <summary>
/// Customizes a command line by overriding its parameters as command line arguments and others.
/// <example>
Expand All @@ -41,7 +41,7 @@ public static CommandLine AsCommandLine(this string executable, params string[]
/// <param name="baseCommandLine">The base command for customization.</param>
/// <param name="customizer">Customization function.</param>
/// <returns>Customized command line.</returns>
public static ICommandLine Customize(this ICommandLine baseCommandLine, Func<CommandLine, ICommandLine> customizer) =>
public static ICommandLine Customize(this ICommandLine baseCommandLine, Func<CommandLine, ICommandLine> customizer) =>
new CustomCommandLine(baseCommandLine, customizer);

private class CustomCommandLine(ICommandLine baseCommandLine, Func<CommandLine, ICommandLine> customizer) : ICommandLine
Expand Down
Loading

0 comments on commit 591f862

Please sign in to comment.