Skip to content

Commit

Permalink
Initial version of NaturalStringExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
augustoproiete committed Jan 12, 2021
1 parent 90b8bc8 commit 48af434
Show file tree
Hide file tree
Showing 22 changed files with 893 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "0.38.5",
"commands": [
"dotnet-cake"
]
},
"minver-cli": {
"version": "2.4.0",
"commands": [
"minver"
]
}
}
}
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
end_of_line = unset
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[*.{xml,config,nuspec,csproj,props,targets,ps1}]
indent_size = 2

[*.{sh}]
end_of_line = lf

[*.{dotsettings}]
end_of_line = lf
13 changes: 13 additions & 0 deletions .github/workflows/dependabot-cake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
on:
schedule:
# every Sunday at 6am
- cron: '0 6 * * SUN'

workflow_dispatch:

jobs:
dependabot-cake:
runs-on: ubuntu-latest
steps:
- name: check/update cake dependencies
uses: augustoproiete-actions/nils-org--dependabot-cake-action@v1
65 changes: 65 additions & 0 deletions NaturalStringExtensions.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A40E4FCE-76C0-4203-A359-CE412A28ACD6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{A21F092D-AF88-49C9-BA29-9D3658106302}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{4F24789D-F35D-4C2A-B744-70F2BA1B1299}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{9EE2DA52-0EC6-4B67-BCAD-0A57AF0F95EC}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
build.cake = build.cake
build.cmd = build.cmd
build.ps1 = build.ps1
build.sh = build.sh
cake.config = cake.config
CHANGES.md = CHANGES.md
CODEOWNERS = CODEOWNERS
global.json = global.json
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleConsole", "sample\SampleConsole\SampleConsole.csproj", "{6D96EF45-C13A-4784-8BB6-48214B6FBE4B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NaturalStringExtensions", "src\NaturalStringExtensions\NaturalStringExtensions.csproj", "{1D3AF11E-9062-4146-96E0-87EFEB6E75C8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NaturalStringExtensions.Tests", "test\NaturalStringExtensions.Tests\NaturalStringExtensions.Tests.csproj", "{66B3A125-9518-41F3-A28B-F9AE45A49A3C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6D96EF45-C13A-4784-8BB6-48214B6FBE4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D96EF45-C13A-4784-8BB6-48214B6FBE4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D96EF45-C13A-4784-8BB6-48214B6FBE4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D96EF45-C13A-4784-8BB6-48214B6FBE4B}.Release|Any CPU.Build.0 = Release|Any CPU
{1D3AF11E-9062-4146-96E0-87EFEB6E75C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D3AF11E-9062-4146-96E0-87EFEB6E75C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D3AF11E-9062-4146-96E0-87EFEB6E75C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D3AF11E-9062-4146-96E0-87EFEB6E75C8}.Release|Any CPU.Build.0 = Release|Any CPU
{66B3A125-9518-41F3-A28B-F9AE45A49A3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66B3A125-9518-41F3-A28B-F9AE45A49A3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66B3A125-9518-41F3-A28B-F9AE45A49A3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66B3A125-9518-41F3-A28B-F9AE45A49A3C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6D96EF45-C13A-4784-8BB6-48214B6FBE4B} = {4F24789D-F35D-4C2A-B744-70F2BA1B1299}
{1D3AF11E-9062-4146-96E0-87EFEB6E75C8} = {A40E4FCE-76C0-4203-A359-CE412A28ACD6}
{66B3A125-9518-41F3-A28B-F9AE45A49A3C} = {A21F092D-AF88-49C9-BA29-9D3658106302}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5C1C3FD9-FF97-46E3-926B-6A3ACC0650D9}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions NaturalStringExtensions.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<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">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArgumentsStyleLiteral/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeObjectCreationWhenTypeEvident/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeTrailingCommaInMultilineLists/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CommentTypo/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String></wpf:ResourceDictionary>
Binary file added asset/natural-string-extensions-nuget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added asset/natural-string-extensions.snk
Binary file not shown.
121 changes: 121 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#addin "nuget:?package=Cake.MinVer&version=0.2.0"

var target = Argument<string>("target", "pack");
var buildVersion = MinVer(s => s.WithTagPrefix("v").WithDefaultPreReleasePhase("preview"));

Task("clean")
.Does(() =>
{
CleanDirectory("./build/artifacts");
CleanDirectories("./src/**/bin");
CleanDirectories("./src/**/obj");
CleanDirectories("./test/**/bin");
CleanDirectories("./test/**/obj");
});

Task("restore")
.IsDependentOn("clean")
.Does(() =>
{
DotNetCoreRestore("./NaturalStringExtensions.sln", new DotNetCoreRestoreSettings
{
LockedMode = true,
});
});

Task("build")
.IsDependentOn("restore")
.Does(() =>
{
DotNetCoreBuild("./NaturalStringExtensions.sln", new DotNetCoreBuildSettings
{
Configuration = "Debug",
NoRestore = true,
NoIncremental = false,
ArgumentCustomization = args =>
args.AppendQuoted($"-p:Version={buildVersion.Version}")
.AppendQuoted($"-p:AssemblyVersion={buildVersion.FileVersion}")
.AppendQuoted($"-p:FileVersion={buildVersion.FileVersion}")
.AppendQuoted($"-p:ContinuousIntegrationBuild=true")
});
DotNetCoreBuild("./NaturalStringExtensions.sln", new DotNetCoreBuildSettings
{
Configuration = "Release",
NoRestore = true,
NoIncremental = false,
ArgumentCustomization = args =>
args.AppendQuoted($"-p:Version={buildVersion.Version}")
.AppendQuoted($"-p:AssemblyVersion={buildVersion.FileVersion}")
.AppendQuoted($"-p:FileVersion={buildVersion.FileVersion}")
.AppendQuoted($"-p:ContinuousIntegrationBuild=true")
});
});

Task("test")
.IsDependentOn("build")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
{
Configuration = "Release",
NoRestore = true,
NoBuild = true,
};
var projectFiles = GetFiles("./test/**/*.csproj");
foreach (var file in projectFiles)
{
DotNetCoreTest(file.FullPath, settings);
}
});

Task("pack")
.IsDependentOn("test")
.Does(() =>
{
var releaseNotes = $"https://github.com/augustoproiete/NaturalStringExtensions/releases/tag/v{buildVersion.Version}";
DotNetCorePack("./src/NaturalStringExtensions/NaturalStringExtensions.csproj", new DotNetCorePackSettings
{
Configuration = "Release",
NoRestore = true,
NoBuild = true,
OutputDirectory = "./build/artifacts",
ArgumentCustomization = args =>
args.AppendQuoted($"-p:Version={buildVersion.Version}")
.AppendQuoted($"-p:PackageReleaseNotes={releaseNotes}")
});
});

Task("publish")
.IsDependentOn("pack")
.Does(context =>
{
var url = context.EnvironmentVariable("NUGET_URL");
if (string.IsNullOrWhiteSpace(url))
{
context.Information("No NuGet URL specified. Skipping publishing of NuGet packages");
return;
}
var apiKey = context.EnvironmentVariable("NUGET_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey))
{
context.Information("No NuGet API key specified. Skipping publishing of NuGet packages");
return;
}
var nugetPushSettings = new DotNetCoreNuGetPushSettings
{
Source = url,
ApiKey = apiKey,
};
foreach (var nugetPackageFile in GetFiles("./build/artifacts/*.nupkg"))
{
DotNetCoreNuGetPush(nugetPackageFile.FullPath, nugetPushSettings);
}
});

RunTarget(target);
11 changes: 11 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@echo on
@cd %~dp0

set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
set DOTNET_CLI_TELEMETRY_OPTOUT=1
set DOTNET_NOLOGO=1

dotnet tool restore
@if %ERRORLEVEL% neq 0 goto :eof

dotnet cake %*
13 changes: 13 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$ErrorActionPreference = 'Stop'

Set-Location -LiteralPath $PSScriptRoot

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
$env:DOTNET_NOLOGO = '1'

dotnet tool restore
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

dotnet cake @args
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
12 changes: 12 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euox pipefail

cd "$(dirname "${BASH_SOURCE[0]}")"

export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_NOLOGO=1

dotnet tool restore

dotnet cake "$@"
12 changes: 12 additions & 0 deletions cake.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Nuget]
Source=https://api.nuget.org/v3/index.json
UseInProcessClient=true
LoadDependencies=false

[Paths]
Tools=./.cake
Addins=./.cake/addins
Modules=./.cake/modules

[Settings]
SkipVerification=false
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"allowPrerelease": false,
"version": "5.0.100",
"rollForward": "latestFeature"
}
}
7 changes: 7 additions & 0 deletions sample/SampleConsole/LibraryVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SampleConsole
{
internal class LibraryVersion
{
public string? VersionNumber { get; set; }
}
}
44 changes: 44 additions & 0 deletions sample/SampleConsole/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace SampleConsole
{
class Program
{
static void Main(string[] args)
{
var unsortedVersions = new List<LibraryVersion>
{
new LibraryVersion { VersionNumber = "10.1.0" },
new LibraryVersion { VersionNumber = "20.2.3" },
new LibraryVersion { VersionNumber = "2.1.0" },
new LibraryVersion { VersionNumber = "1.1.0" },
new LibraryVersion { VersionNumber = "10.0.0" },
new LibraryVersion { VersionNumber = "2.0.0" },
new LibraryVersion { VersionNumber = "10.2.0" },
new LibraryVersion { VersionNumber = "1.0.0" },
new LibraryVersion { VersionNumber = "20.2.0" },
new LibraryVersion { VersionNumber = "20.1.0" },
};

var versionsAlphabetical = unsortedVersions.OrderBy(v => v.VersionNumber);
Console.WriteLine("Alphabetical:");

foreach (var version in versionsAlphabetical)
{
Console.WriteLine($"- {version.VersionNumber}");
}

Console.WriteLine();

var versionsNatural = unsortedVersions.OrderByNatural(v => v.VersionNumber);
Console.WriteLine("Natural:");

foreach (var version in versionsNatural)
{
Console.WriteLine($"- {version.VersionNumber}");
}
}
}
}
14 changes: 14 additions & 0 deletions sample/SampleConsole/SampleConsole.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net5.0;netcoreapp3.1;net461</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NaturalStringExtensions\NaturalStringExtensions.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 48af434

Please sign in to comment.