Skip to content

Commit

Permalink
Add enumerable string extensions for fluent style
Browse files Browse the repository at this point in the history
  • Loading branch information
gitfool authored and devlead committed Oct 25, 2020
1 parent f3662b4 commit f3c6053
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See the LICENSE file in the project root for more information.

using Cake.Common.Tests.Fixtures.Tools.DotNetCore.Test;
using Cake.Core.IO;
using Cake.Core;
using Cake.Testing;
using Xunit;

Expand Down Expand Up @@ -108,7 +108,7 @@ public void Should_Add_RunSettings_Arguments()
{
// Given
var fixture = new DotNetCoreTesterFixture();
fixture.Arguments = ProcessArgumentBuilder.FromStrings(new[] { "MSTest.DeploymentEnabled=false", "MSTest.MapInconclusiveToFailed=true" });
fixture.Arguments = new[] { "MSTest.DeploymentEnabled=false", "MSTest.MapInconclusiveToFailed=true" }.ToProcessArguments();

// When
var result = fixture.Run();
Expand Down
36 changes: 36 additions & 0 deletions src/Cake.Core/Extensions/EnumerableStringExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using Cake.Core.IO;

// ReSharper disable once CheckNamespace
namespace Cake.Core
{
/// <summary>
/// Contains extension methods for <see cref="T:IEnumerable{String}"/>.
/// </summary>
public static class EnumerableStringExtensions
{
/// <summary>
/// Performs a conversion from <see cref="IEnumerable{String}"/> to <see cref="ProcessArgumentBuilder"/>.
/// </summary>
/// <param name="values">The text values to convert.</param>
/// <returns>A <see cref="ProcessArgumentBuilder"/>.</returns>
public static ProcessArgumentBuilder ToProcessArguments(this IEnumerable<string> values)
{
return ProcessArgumentBuilder.FromStrings(values);
}

/// <summary>
/// Performs a conversion from <see cref="IEnumerable{String}"/> to <see cref="ProcessArgumentBuilder"/>.
/// </summary>
/// <param name="values">The text values to convert.</param>
/// <returns>A <see cref="ProcessArgumentBuilder"/>.</returns>
public static ProcessArgumentBuilder ToProcessArgumentsQuoted(this IEnumerable<string> values)
{
return ProcessArgumentBuilder.FromStringsQuoted(values);
}
}
}

0 comments on commit f3c6053

Please sign in to comment.