Skip to content

Commit db26562

Browse files
author
Oren (electricessence)
committed
Updates for snugpk
1 parent 510eeb2 commit db26562

6 files changed

Lines changed: 49 additions & 57 deletions

File tree

LISCENSE.md renamed to LICENSE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT)
22

3-
## Copyright (c) 2017 Oren J. Ferrari
3+
## Copyright (c) 2020 electricessence (Oren F.)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
21+
THE SOFTWARE.

Open.Text.csproj

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,40 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
5-
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
6-
<Authors>electricessence</Authors>
7-
<Company />
8-
<Product />
5+
<LangVersion>latest</LangVersion>
6+
<Nullable>enable</Nullable>
7+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
8+
<Authors>electricessence</Authors>
99
<Description>A set of useful classes for working with strings and formatting values.
1010

11-
Part of the "Open" set of libraries.</Description>
11+
Part of the "Open" set of libraries.
12+
</Description>
1213
<PackageLicenseUrl></PackageLicenseUrl>
13-
<PackageProjectUrl>https://github.com/electricessence/Open.Text</PackageProjectUrl>
14-
<Copyright>https://github.com/electricessence/Open.Text/blob/master/LISCENSE.md</Copyright>
15-
<RepositoryType>git</RepositoryType>
16-
<RepositoryUrl>https://github.com/electricessence/Open.Text</RepositoryUrl>
17-
<PackageTags>dotnet, dotnetcore, string, text, format, stringbuilder, extensions</PackageTags>
18-
<Version>2.1.0</Version>
14+
<PackageProjectUrl>https://github.com/Open-NET-Libraries/Open.Text</PackageProjectUrl>
15+
<Copyright>https://github.com/Open-NET-Libraries/Open.Text/blob/master/LICENSE.md</Copyright>
16+
<RepositoryUrl>https://github.com/Open-NET-Libraries/Open.Text</RepositoryUrl>
17+
<RepositoryType>git</RepositoryType>
18+
<PackageTags>dotnet, dotnetcore, string, text, format, stringbuilder, extensions</PackageTags>
19+
<Version>2.2.0</Version>
1920
<PackageReleaseNotes></PackageReleaseNotes>
20-
<PackageLicenseExpression>MIT</PackageLicenseExpression>
21-
</PropertyGroup>
22-
23-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
24-
<LangVersion>latest</LangVersion>
25-
</PropertyGroup>
26-
27-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
28-
<LangVersion>latest</LangVersion>
21+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
22+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
23+
<IncludeSymbols>true</IncludeSymbols>
24+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
25+
<PackageIcon>logo.png</PackageIcon>
2926
</PropertyGroup>
3027

28+
<ItemGroup>
29+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
30+
</ItemGroup>
31+
3132
<ItemGroup>
3233
<None Remove=".git" />
3334
<None Remove=".gitignore" />
34-
<None Remove="LISCENSE.md" />
35-
<None Remove="README.md" />
35+
<None Include="logo.png">
36+
<Pack>True</Pack>
37+
<PackagePath></PackagePath>
38+
</None>
3639
</ItemGroup>
3740

3841
<ItemGroup>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
A set of useful classes for working with strings and formatting values.
44

5-
[![NuGet](http://img.shields.io/nuget/v/Open.Text.svg)](https://www.nuget.org/packages/Open.Text/)
5+
[![NuGet](https://img.shields.io/nuget/v/Open.Text.svg)](https://www.nuget.org/packages/Open.Text/)

StringBuilderExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static StringBuilder ToStringBuilder<T>(this IEnumerable<T> source)
2727
return sb;
2828
}
2929

30-
public static StringBuilder ToStringBuilder<T>(this in ReadOnlySpan<T> source, in string separator)
30+
public static StringBuilder ToStringBuilder<T>(this in ReadOnlySpan<T> source, string separator)
3131
{
3232
var len = source.Length;
3333
if (len < 2 || string.IsNullOrEmpty(separator))
@@ -63,7 +63,7 @@ public static StringBuilder ToStringBuilder<T>(this in ReadOnlySpan<T> source, i
6363
return sb;
6464
}
6565

66-
public static StringBuilder ToStringBuilder<T>(this IEnumerable<T> source, in string separator)
66+
public static StringBuilder ToStringBuilder<T>(this IEnumerable<T> source, string separator)
6767
{
6868
var sb = new StringBuilder();
6969
var first = true;
@@ -93,7 +93,7 @@ public static StringBuilder ToStringBuilder<T>(this IEnumerable<T> source, in ch
9393
/// <summary>
9494
/// Shortcut for adding an array of values to a StringBuilder.
9595
/// </summary>
96-
public static StringBuilder AppendAll<T>(this StringBuilder target, IEnumerable<T> values, string separator = null)
96+
public static StringBuilder AppendAll<T>(this StringBuilder target, IEnumerable<T> values, string? separator = null)
9797
{
9898
if (target is null)
9999
throw new NullReferenceException();
@@ -109,7 +109,7 @@ public static StringBuilder AppendAll<T>(this StringBuilder target, IEnumerable<
109109
else
110110
{
111111
foreach (var value in values)
112-
target.AppendWithSeparator(separator, value);
112+
target.AppendWithSeparator(separator!, value);
113113
}
114114
}
115115
return target;

Text.cs

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ IEnumerable<string> SplitAsEnumerableCore()
151151
/// <param name="search">The search string to look for. If the search is null or empty this method returns null.</param>
152152
/// <param name="comparisonType">The comparison type to use when searching.</param>
153153
/// <returns>The source of the string before the search string. Returns null if search string is not found.</returns>
154-
public static string BeforeFirst(this string source, string search, StringComparison comparisonType = StringComparison.Ordinal)
154+
public static string? BeforeFirst(this string source, string search, StringComparison comparisonType = StringComparison.Ordinal)
155155
{
156156
if (source is null)
157157
throw new NullReferenceException();
@@ -171,7 +171,7 @@ public static string BeforeFirst(this string source, string search, StringCompar
171171
/// <param name="search">The search string to look for. If the search is null or empty this method returns null.</param>
172172
/// <param name="comparisonType">The comparison type to use when searching.</param>
173173
/// <returns>The source of the string after the search string. Returns null if search string is not found.</returns>
174-
public static string AfterFirst(this string source, string search, StringComparison comparisonType = StringComparison.Ordinal)
174+
public static string? AfterFirst(this string source, string search, StringComparison comparisonType = StringComparison.Ordinal)
175175
{
176176
if (source is null)
177177
throw new NullReferenceException();
@@ -191,7 +191,7 @@ public static string AfterFirst(this string source, string search, StringCompari
191191
/// <param name="search">The search string to look for. If the search is null or empty this method returns null.</param>
192192
/// <param name="comparisonType">The comparison type to use when searching.</param>
193193
/// <returns>The source of the string before the search string. Returns null if search string is not found.</returns>
194-
public static string BeforeLast(this string source, string search, StringComparison comparisonType = StringComparison.Ordinal)
194+
public static string? BeforeLast(this string source, string search, StringComparison comparisonType = StringComparison.Ordinal)
195195
{
196196
if (source is null)
197197
throw new NullReferenceException();
@@ -211,7 +211,7 @@ public static string BeforeLast(this string source, string search, StringCompari
211211
/// <param name="search">The search string to look for. If the search is null or empty this method returns null.</param>
212212
/// <param name="comparisonType">The comparison type to use when searching.</param>
213213
/// <returns>The source of the string after the search string. Returns null if search string is not found.</returns>
214-
public static string AfterLast(this string source, string search, StringComparison comparisonType = StringComparison.Ordinal)
214+
public static string? AfterLast(this string source, string search, StringComparison comparisonType = StringComparison.Ordinal)
215215
{
216216
if (source is null)
217217
throw new NullReferenceException();
@@ -400,7 +400,7 @@ public static bool IsNullOrWhiteSpace(this string source)
400400
/// </summary>
401401
/// <param name="value">The value to be trimmed.</param>
402402
/// <param name="trim">True will trim whitespace from valid response.</param>
403-
public static string ToNullIfWhiteSpace(this string value, bool trim = false)
403+
public static string? ToNullIfWhiteSpace(this string value, bool trim = false)
404404
=> string.IsNullOrWhiteSpace(value) ? null
405405
: (trim ? value.Trim() : value);
406406

@@ -410,7 +410,7 @@ public static string ToNullIfWhiteSpace(this string value, bool trim = false)
410410
/// </summary>
411411
/// <param name="value">The value to be formatted.</param>
412412
/// <param name="format">The format string.</param>
413-
public static string ToFormat(this string value, string format = null)
413+
public static string ToFormat(this string value, string? format = null)
414414
=> string.IsNullOrWhiteSpace(value) ? string.Empty
415415
: (format is null ? value : string.Format(format, value));
416416

@@ -420,7 +420,7 @@ public static string ToFormat(this string value, string format = null)
420420
/// </summary>
421421
/// <param name="value">The value to be formatted.</param>
422422
/// <param name="format">The format string.</param>
423-
public static string ToFormat(this int? value, string format = null)
423+
public static string ToFormat(this int? value, string? format = null)
424424
{
425425
if (format is null) format = "{0}";
426426
return value is null ? string.Empty : string.Format(format, value.Value);
@@ -431,7 +431,7 @@ public static string ToFormat(this int? value, string format = null)
431431
/// </summary>
432432
/// <param name="value">The value to be formatted.</param>
433433
/// <param name="format">The format string.</param>
434-
public static string ToFormat(this short? value, string format = null)
434+
public static string ToFormat(this short? value, string? format = null)
435435
{
436436
if (format is null) format = "{0}";
437437
return value is null ? string.Empty : string.Format(format, value.Value);
@@ -449,7 +449,7 @@ public static bool IsAlphaNumeric(this string source, bool trim = false)
449449
}
450450

451451
#region Regex helper methods.
452-
public static string GetValue(this GroupCollection groups, string groupName, bool throwIfInvalid = false)
452+
public static string? GetValue(this GroupCollection groups, string groupName, bool throwIfInvalid = false)
453453
{
454454
if (groups is null)
455455
throw new NullReferenceException();
@@ -640,14 +640,12 @@ public static string TrimEnd(this string source, string pattern)
640640
/// <summary>
641641
/// Shortcut for WriteLineNoTabs on a TextWriter. Mimimcs similar classes.
642642
/// </summary>
643-
public static void WriteLineNoTabs(this TextWriter writer, string s = null)
643+
public static void WriteLineNoTabs(this TextWriter writer, string? s = null)
644644
{
645-
if (writer is null)
646-
throw new NullReferenceException();
645+
if (writer is null) throw new NullReferenceException();
647646
Contract.EndContractBlock();
648647

649-
if (s != null)
650-
writer.Write(s);
648+
if (s != null) writer.Write(s);
651649
writer.Write(NEWLINE);
652650
}
653651

@@ -659,21 +657,12 @@ public static void WriteLineNoTabs(this TextWriter writer, string s = null)
659657
/// <param name="values">The values to inject.</param>
660658
/// <returns>The resultant string.</returns>
661659
public static string Supplant<T>(this string format, T[] values)
662-
{
663-
if (values is null)
664-
return format;
665-
666-
switch (values.Length)
660+
=> values is null ? format : values.Length switch
667661
{
668-
case 0:
669-
return format;
670-
case 1:
671-
return string.Format(format, values[0]);
672-
default:
673-
return string.Format(format,
674-
values as object[] ?? values.Cast<object>().ToArray());
675-
}
676-
}
662+
0 => format,
663+
1 => string.Format(format, values[0]),
664+
_ => string.Format(format, values as object[] ?? values.Cast<object>().ToArray()),
665+
};
677666

678667
}
679668
}

logo.png

54.6 KB
Loading

0 commit comments

Comments
 (0)