Skip to content

Commit fcb78fd

Browse files
committed
Added string Extensions for RemoveLeadingSlash and RemoveTrailingSlash
1 parent d06c221 commit fcb78fd

4 files changed

Lines changed: 207 additions & 1 deletion

File tree

.nuke/build.schema.json

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"$ref": "#/definitions/build",
4+
"title": "Build Schema",
5+
"definitions": {
6+
"build": {
7+
"type": "object",
8+
"properties": {
9+
"BuildNo": {
10+
"type": "integer",
11+
"description": "The Buildnumber provided by the CI"
12+
},
13+
"Configuration": {
14+
"type": "string",
15+
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
16+
"enum": [
17+
"Debug",
18+
"Release"
19+
]
20+
},
21+
"Continue": {
22+
"type": "boolean",
23+
"description": "Indicates to continue a previously failed build attempt"
24+
},
25+
"Help": {
26+
"type": "boolean",
27+
"description": "Shows the help text for this build assembly"
28+
},
29+
"Host": {
30+
"type": "string",
31+
"description": "Host for execution. Default is 'automatic'",
32+
"enum": [
33+
"AppVeyor",
34+
"AzurePipelines",
35+
"Bamboo",
36+
"Bitbucket",
37+
"Bitrise",
38+
"GitHubActions",
39+
"GitLab",
40+
"Jenkins",
41+
"Rider",
42+
"SpaceAutomation",
43+
"TeamCity",
44+
"Terminal",
45+
"TravisCI",
46+
"VisualStudio",
47+
"VSCode"
48+
]
49+
},
50+
"IsRc": {
51+
"type": "boolean",
52+
"description": "Is RC Version"
53+
},
54+
"NoLogo": {
55+
"type": "boolean",
56+
"description": "Disables displaying the NUKE logo"
57+
},
58+
"Partition": {
59+
"type": "string",
60+
"description": "Partition to use on CI"
61+
},
62+
"Plan": {
63+
"type": "boolean",
64+
"description": "Shows the execution plan (HTML)"
65+
},
66+
"Profile": {
67+
"type": "array",
68+
"description": "Defines the profiles to load",
69+
"items": {
70+
"type": "string"
71+
}
72+
},
73+
"Root": {
74+
"type": "string",
75+
"description": "Root directory during build execution"
76+
},
77+
"Skip": {
78+
"type": "array",
79+
"description": "List of targets to be skipped. Empty list skips all dependencies",
80+
"items": {
81+
"type": "string",
82+
"enum": [
83+
"Clean",
84+
"Compile",
85+
"Deploy",
86+
"Release",
87+
"Restore",
88+
"Test"
89+
]
90+
}
91+
},
92+
"Solution": {
93+
"type": "string",
94+
"description": "Path to a solution file that is automatically loaded"
95+
},
96+
"Target": {
97+
"type": "array",
98+
"description": "List of targets to be invoked. Default is '{default_target}'",
99+
"items": {
100+
"type": "string",
101+
"enum": [
102+
"Clean",
103+
"Compile",
104+
"Deploy",
105+
"Release",
106+
"Restore",
107+
"Test"
108+
]
109+
}
110+
},
111+
"Verbosity": {
112+
"type": "string",
113+
"description": "Logging verbosity during build execution. Default is 'Normal'",
114+
"enum": [
115+
"Minimal",
116+
"Normal",
117+
"Quiet",
118+
"Verbose"
119+
]
120+
},
121+
"Version": {
122+
"type": "string",
123+
"description": "Version to be injected in the Build"
124+
}
125+
}
126+
}
127+
}
128+
}

build/_build.csproj.DotSettings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=HeapView_002EDelegateAllocation/@EntryIndexedValue">DO_NOT_SHOW</s:String>
33
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=VariableHidesOuterVariable/@EntryIndexedValue">DO_NOT_SHOW</s:String>
44
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ClassNeverInstantiated_002EGlobal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
@@ -21,6 +21,7 @@
2121
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
2222
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
2323
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
24+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
2425
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
2526
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
2627
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Abstract.FileSystem
6+
{
7+
/// <summary>
8+
///
9+
/// </summary>
10+
public static class StringExtensions
11+
{
12+
/// <summary>
13+
/// Remove a leading slash
14+
/// </summary>
15+
/// <param name="value"></param>
16+
/// <returns></returns>
17+
public static string RemoveLeadingSlash(this string value)
18+
{
19+
if (value.StartsWith("/") || value.StartsWith("\\"))
20+
{
21+
return value.Substring(1);
22+
}
23+
24+
return value;
25+
}
26+
27+
/// <summary>
28+
/// Remove a trailing slash
29+
/// </summary>
30+
/// <param name="value"></param>
31+
/// <returns></returns>
32+
public static string RemoveTrailingSlash(this string value)
33+
{
34+
if (value.EndsWith("/") || value.EndsWith("\\"))
35+
{
36+
return value.Substring(0, value.Length - 1);
37+
}
38+
39+
return value;
40+
}
41+
}
42+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Abstract.FileSystem.Test
8+
{
9+
public class StringExtensionsTests
10+
{
11+
[Test]
12+
public void StringExtensions_RemoveLeadingSlash_Slash()
13+
{
14+
"/test/leading/".RemoveLeadingSlash().Should().Be("test/leading/");
15+
}
16+
17+
[Test]
18+
public void StringExtensions_RemoveLeadingSlash_Backslash()
19+
{
20+
"\\test\\leading\\".RemoveLeadingSlash().Should().Be("test\\leading\\");
21+
}
22+
23+
[Test]
24+
public void StringExtensions_RemoveTrailingSlash_Slash()
25+
{
26+
"/test/leading/".RemoveTrailingSlash().Should().Be("/test/leading");
27+
}
28+
29+
[Test]
30+
public void StringExtensions_RemoveTrailingSlash_Backslash()
31+
{
32+
"\\test\\leading\\".RemoveTrailingSlash().Should().Be("\\test\\leading");
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)