-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from pfpack/release/v2.0.0-rc.2.0.0
release/v2.0.0-rc.2.0.0
- Loading branch information
Showing
15 changed files
with
111 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...tives-strings/Primitives.Strings.Tests/StringExtensions.Tests/ToStringOrEmpty_Obsolete.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/ToStringOrEmpty_Obsolete.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/primitives-strings/Primitives.Strings/InternalObsolete/InternalObsoleteErrors.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
6 changes: 6 additions & 0 deletions
6
src/primitives-strings/Primitives.Strings/InternalObsolete/InternalObsoleteMessages.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters