Skip to content

Commit

Permalink
Merge pull request #27 from pfpack/release/v2.0.0-rc.2.0.0
Browse files Browse the repository at this point in the history
release/v2.0.0-rc.2.0.0
  • Loading branch information
pmosk authored Nov 15, 2021
2 parents 6a48b03 + 402ece7 commit ac54189
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/primitives-linq/Primitives.Linq/Primitives.Linq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Description>PrimeFuncPack Primitives.Linq is a core library for .NET consisting of useful extensions making work with Linq easier.</Description>
<RootNamespace>System</RootNamespace>
<AssemblyName>PrimeFuncPack.Primitives.Linq</AssemblyName>
<Version>2.0.0-rc.1.0.1</Version>
<Version>2.0.0-rc.1.0.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Description>PrimeFuncPack Primitives.Pipeline is a core library for .NET consisting of useful extensions making work with functional pipelines easier.</Description>
<RootNamespace>System</RootNamespace>
<AssemblyName>PrimeFuncPack.Primitives.Pipeline</AssemblyName>
<Version>2.0.0-rc.1.0.1</Version>
<Version>2.0.0-rc.1.0.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Description>PrimeFuncPack Primitives.Predicates is a core library for .NET consisting of useful extensions and predicates making work with the nullable feature easier.</Description>
<RootNamespace>System</RootNamespace>
<AssemblyName>PrimeFuncPack.Primitives.Predicates</AssemblyName>
<Version>2.0.0-rc.1.0.1</Version>
<Version>2.0.0-rc.1.0.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace PrimeFuncPack.Primitives.Tests;

partial class StringExtensionsTests
{
[Test]
public void ToStringOrEmpty_ExpectIsObsoleteWithError()
{
const string expectedObsoleteMessage = "This method is obsolete. Consider to call obj?.ToString().OrEmpty() instead.";

IReadOnlyCollection<MethodInfo> methods = typeof(StringExtensions)
.GetMethods(BindingFlags.Public | BindingFlags.Static)
.Where(method => method.Name == nameof(StringExtensions.ToStringOrEmpty))
.ToArray();

Assert.AreEqual(2, methods.Count);

Assert.IsTrue(
methods.All(
method => method.CustomAttributes.Any(
attr
=>
attr.AttributeType == typeof(ObsoleteAttribute) &&
attr.ConstructorArguments.Count == 2 &&
attr.ConstructorArguments[0].ArgumentType == typeof(string) &&
attr.ConstructorArguments[0].Value is expectedObsoleteMessage &&
attr.ConstructorArguments[1].ArgumentType == typeof(bool) &&
attr.ConstructorArguments[1].Value is true)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace PrimeFuncPack.Primitives.Tests;

partial class StringExtensionsTests
{
[Obsolete]
[Test]
public void ToStringOrEmpty_Ref_SourceIsNull_ExpectEmpty()
{
Expand All @@ -15,6 +16,7 @@ public void ToStringOrEmpty_Ref_SourceIsNull_ExpectEmpty()
Assert.IsEmpty(actual);
}

[Obsolete]
[Test]
public void ToStringOrEmpty_Ref_SourceToStringIsNull_ExpectEmpty()
{
Expand All @@ -24,6 +26,7 @@ public void ToStringOrEmpty_Ref_SourceToStringIsNull_ExpectEmpty()
Assert.IsEmpty(actual);
}

[Obsolete]
[Test]
[TestCase(EmptyString)]
[TestCase(WhiteSpaceString)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace PrimeFuncPack.Primitives.Tests;

partial class StringExtensionsTests
{
[Obsolete]
[Test]
public void ToStringOrEmpty_StructNullable_SourceIsNull_ExpectEmpty()
{
Expand All @@ -15,6 +16,7 @@ public void ToStringOrEmpty_StructNullable_SourceIsNull_ExpectEmpty()
Assert.IsEmpty(actual);
}

[Obsolete]
[Test]
public void ToStringOrEmpty_StructNullable_SourceToStringIsNull_ExpectEmpty()
{
Expand All @@ -24,6 +26,7 @@ public void ToStringOrEmpty_StructNullable_SourceToStringIsNull_ExpectEmpty()
Assert.IsEmpty(actual);
}

[Obsolete]
[Test]
[TestCase(EmptyString)]
[TestCase(WhiteSpaceString)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace PrimeFuncPack.Primitives.Tests;

partial class StringsTests
{
[Test]
public void ToStringOrEmpty_ExpectIsObsoleteWithError()
{
const string expectedObsoleteMessage = "This method is obsolete. Consider to call obj?.ToString().OrEmpty() instead.";

IReadOnlyCollection<MethodInfo> methods = typeof(Strings)
.GetMethods(BindingFlags.Public | BindingFlags.Static)
.Where(method => method.Name == nameof(Strings.ToStringOrEmpty))
.ToArray();

Assert.AreEqual(2, methods.Count);

Assert.IsTrue(
methods.All(
method => method.CustomAttributes.Any(
attr
=>
attr.AttributeType == typeof(ObsoleteAttribute) &&
attr.ConstructorArguments.Count == 2 &&
attr.ConstructorArguments[0].ArgumentType == typeof(string) &&
attr.ConstructorArguments[0].Value is expectedObsoleteMessage &&
attr.ConstructorArguments[1].ArgumentType == typeof(bool) &&
attr.ConstructorArguments[1].Value is true)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace PrimeFuncPack.Primitives.Tests;

partial class StringsTests
{
[Obsolete]
[Test]
public void ToStringOrEmpty_Ref_SourceIsNull_ExpectEmpty()
{
Expand All @@ -15,6 +16,7 @@ public void ToStringOrEmpty_Ref_SourceIsNull_ExpectEmpty()
Assert.IsEmpty(actual);
}

[Obsolete]
[Test]
public void ToStringOrEmpty_Ref_SourceToStringIsNull_ExpectEmpty()
{
Expand All @@ -24,6 +26,7 @@ public void ToStringOrEmpty_Ref_SourceToStringIsNull_ExpectEmpty()
Assert.IsEmpty(actual);
}

[Obsolete]
[Test]
[TestCase(EmptyString)]
[TestCase(WhiteSpaceString)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace PrimeFuncPack.Primitives.Tests;

partial class StringsTests
{
[Obsolete]
[Test]
public void ToStringOrEmpty_StructNullable_SourceIsNull_ExpectEmpty()
{
Expand All @@ -15,6 +16,7 @@ public void ToStringOrEmpty_StructNullable_SourceIsNull_ExpectEmpty()
Assert.IsEmpty(actual);
}

[Obsolete]
[Test]
public void ToStringOrEmpty_StructNullable_SourceToStringIsNull_ExpectEmpty()
{
Expand All @@ -24,6 +26,7 @@ public void ToStringOrEmpty_StructNullable_SourceToStringIsNull_ExpectEmpty()
Assert.IsEmpty(actual);
}

[Obsolete]
[Test]
[TestCase(EmptyString)]
[TestCase(WhiteSpaceString)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace System;

internal static class InternalObsoleteErrors
{
public const bool ToStringOrEmpty = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace System;

internal static class InternalObsoleteMessages
{
public const string ToStringOrEmpty = "This method is obsolete. Consider to call obj?.ToString().OrEmpty() instead.";
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Description>PrimeFuncPack Primitives.Strings is a core library for .NET consisting of useful extensions making work with strings easier.</Description>
<RootNamespace>System</RootNamespace>
<AssemblyName>PrimeFuncPack.Primitives.Strings</AssemblyName>
<Version>2.0.0-rc.1.0.1</Version>
<Version>2.0.0-rc.2.0.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/primitives-strings/Primitives.Strings/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ public static string OrEmpty(this string? value)
=>
Strings.OrNullIfWhiteSpace(value);

// TODO: Consider to delete the method in v3.0
[Obsolete(InternalObsoleteMessages.ToStringOrEmpty, error: InternalObsoleteErrors.ToStringOrEmpty)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string ToStringOrEmpty<T>(this T? value)
=>
Strings.ToStringOrEmpty(value);

// TODO: Consider to delete the method in v3.0
[Obsolete(InternalObsoleteMessages.ToStringOrEmpty, error: InternalObsoleteErrors.ToStringOrEmpty)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string ToStringOrEmpty<T>(this T? value) where T : struct
=>
Expand Down
4 changes: 4 additions & 0 deletions src/primitives-strings/Primitives.Strings/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ public static string OrEmpty(string? value)
? null
: value;

// TODO: Consider to delete the method in v3.0
[Obsolete(InternalObsoleteMessages.ToStringOrEmpty, error: InternalObsoleteErrors.ToStringOrEmpty)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string ToStringOrEmpty<T>(T? value)
=>
value?.ToString() ?? Empty;

// TODO: Consider to delete the method in v3.0
[Obsolete(InternalObsoleteMessages.ToStringOrEmpty, error: InternalObsoleteErrors.ToStringOrEmpty)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string ToStringOrEmpty<T>(T? value) where T : struct
=>
Expand Down
10 changes: 5 additions & 5 deletions src/primitives/Primitives/Primitives.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Description>PrimeFuncPack Primitives is a core library for .NET consisting of useful extensions and predicates making work with functional pipelines, Linq, strings, the nullable feature, etc. easier.</Description>
<RootNamespace>System</RootNamespace>
<AssemblyName>PrimeFuncPack.Primitives</AssemblyName>
<Version>2.0.0-rc.1.0.1</Version>
<Version>2.0.0-rc.2.0.0</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -32,10 +32,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PrimeFuncPack.Primitives.Linq" Version="2.0.0-rc.1.0.1" />
<PackageReference Include="PrimeFuncPack.Primitives.Pipeline" Version="2.0.0-rc.1.0.1" />
<PackageReference Include="PrimeFuncPack.Primitives.Predicates" Version="2.0.0-rc.1.0.1" />
<PackageReference Include="PrimeFuncPack.Primitives.Strings" Version="2.0.0-rc.1.0.1" />
<PackageReference Include="PrimeFuncPack.Primitives.Linq" Version="2.0.0-rc.1.0.2" />
<PackageReference Include="PrimeFuncPack.Primitives.Pipeline" Version="2.0.0-rc.1.0.2" />
<PackageReference Include="PrimeFuncPack.Primitives.Predicates" Version="2.0.0-rc.1.0.2" />
<PackageReference Include="PrimeFuncPack.Primitives.Strings" Version="2.0.0-rc.2.0.0" />
</ItemGroup>

</Project>

0 comments on commit ac54189

Please sign in to comment.