Skip to content

Commit f4b4a07

Browse files
author
David McCarter
committed
Refactor and update various files
* Updated the "Last Modified On" date in multiple files to "07-31-2024". * Removed redundant discard operators `_` in `CachedEnumerable.cs` and `TaskExtensions.cs`. * Removed `DisposeCollection` and `ProcessCollectionToDispose` methods in `ObjectExtensions.cs`. * Modified `GetCountry` in `Countries.cs` and `Equals` in `PrefixAndLength.cs` to use `string.Equals` with `StringComparison.Ordinal`. * Re-added `CountryConverters.cs` with original content.
1 parent 1cfb116 commit f4b4a07

File tree

9 files changed

+14
-49
lines changed

9 files changed

+14
-49
lines changed

source/dotNetTips.Spargine.8.Core/CachedEnumerable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 12-28-2020
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 07-19-2024
7+
// Last Modified On : 07-31-2024
88
// ***********************************************************************
99
// <copyright file="CachedEnumerable.cs" company="McCarter Consulting">
1010
// Copyright (c) David McCarter - dotNetTips.com. All rights reserved.
@@ -100,7 +100,7 @@ public sealed class CachedEnumerable<T>(IEnumerable<T> enumerable) : IEnumerable
100100
/// </summary>
101101
/// <exception cref="InvalidOperationException">Thrown if the enumerable is null.</exception>
102102
[MethodImpl(MethodImplOptions.AggressiveInlining)]
103-
private void CheckEnumerable() => _ = this._enumerable.CheckIsNotNull(true);
103+
private void CheckEnumerable() => this._enumerable.CheckIsNotNull(true);
104104

105105
/// <summary>
106106
/// Releases unmanaged and - optionally - managed resources.

source/dotNetTips.Spargine.8.Core/Collections/CollectionRandomizer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 11-06-2023
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 07-12-2024
7+
// Last Modified On : 07-15-2024
88
// ***********************************************************************
99
// <copyright file="CollectionRandomizer.cs" company="McCarter Consulting">
1010
// McCarter Consulting (David McCarter)

source/dotNetTips.Spargine.8.Core/Security/SHA256PasswordHasher.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 10-12-2021
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 07-15-2024
7+
// Last Modified On : 07-31-2024
88
// ***********************************************************************
99
// <copyright file="SHA256PasswordHasher.cs" company="McCarter Consulting">
1010
// McCarter Consulting (David McCarter)
@@ -54,7 +54,6 @@ private static byte[] GenerateSalt(int byteLength)
5454
/// The resulting hash can be used for securely storing passwords.</remarks>
5555
private static byte[] HashPasswordWithSalt(string password, byte[] salt)
5656
{
57-
using var hashAlgorithm = SHA256.Create();
5857
var passwordBytes = Encoding.UTF8.GetBytes(password);
5958

6059
// Combine salt and password bytes

source/dotNetTips.Spargine.8.Extensions/ObjectExtensions.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 09-15-2017
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 07-18-2024
7+
// Last Modified On : 07-31-2024
88
// ***********************************************************************
99
// <copyright file="ObjectExtensions.cs" company="McCarter Consulting">
1010
// David McCarter - dotNetTips.com
@@ -52,30 +52,6 @@ public static class ObjectExtensions
5252
private static readonly ObjectPool<StringBuilder> _stringBuilderPool =
5353
new DefaultObjectPoolProvider().CreateStringBuilderPool();
5454

55-
/// <summary>
56-
/// Tries to dispose items in the <see cref="IEnumerable" />.
57-
/// </summary>
58-
/// <param name="items">The items.</param>
59-
private static void DisposeCollection(this IEnumerable items) => ProcessCollectionToDispose(items);
60-
61-
/// <summary>
62-
/// Processes the <see cref="IEnumerable" /> to dispose.
63-
/// </summary>
64-
/// <param name="items">The items.</param>
65-
private static void ProcessCollectionToDispose(IEnumerable items)
66-
{
67-
if (items.HasItems())
68-
{
69-
foreach (var item in items)
70-
{
71-
if (item is IDisposable disposeItem)
72-
{
73-
disposeItem.TryDispose();
74-
}
75-
}
76-
}
77-
}
78-
7955
/// <summary>
8056
/// Converts the specified object to the specified type <typeparamref name="T" />.
8157
/// </summary>

source/dotNetTips.Spargine.8.Extensions/TaskExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 11-25-2019
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 07-16-2024
7+
// Last Modified On : 07-31-2024
88
// ***********************************************************************
99
// <copyright file="TaskExtensions.cs" company="McCarter Consulting">
1010
// McCarter Consulting (David McCarter)
@@ -34,7 +34,7 @@ public static class TaskExtensions
3434
/// PerformLongRunningWorkAsync().FireAndForget();
3535
/// </example>
3636
[Information("Original code from: https://weblog.west-wind.com/posts/2021/Jul/07/Thoughts-on-AsyncAwait-Conversion-in-a-Desktop-App", "David McCarter", "7/13/2021", UnitTestStatus = UnitTestStatus.Completed, Status = Status.Available, Documentation = "https://bit.ly/SpargineSep2022")]
37-
public static void FireAndForget([NotNull] this Task task) => _ = task.ArgumentNotNull().ContinueWith(tsk => tsk.Exception, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.Default);
37+
public static void FireAndForget([NotNull] this Task task) => task.ArgumentNotNull().ContinueWith(tsk => tsk.Exception, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.Default);
3838

3939
/// <summary>
4040
/// Fires the task and forgets it. Validates that <paramref name="task" /> is not null and handles exceptions using the provided action.
@@ -46,6 +46,6 @@ public static class TaskExtensions
4646
/// SomeType.FireAsync("Test Message").FireAndForget(exAction);
4747
/// </example>
4848
[Information("Original code from: https://weblog.west-wind.com/posts/2021/Jul/07/Thoughts-on-AsyncAwait-Conversion-in-a-Desktop-App", "David McCarter", "7/13/2021", UnitTestStatus = UnitTestStatus.Completed, Status = Status.Available, Documentation = "https://bit.ly/SpargineSep2022")]
49-
public static void FireAndForget([NotNull] this Task task, [NotNull] Action<Exception> action) => _ = task.ArgumentNotNull().ContinueWith((tsk) => action?.Invoke(tsk.Exception), CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.Default);
49+
public static void FireAndForget([NotNull] this Task task, [NotNull] Action<Exception> action) => task.ArgumentNotNull().ContinueWith((tsk) => action?.Invoke(tsk.Exception), CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.Default);
5050

5151
}

source/dotNetTips.Spargine.8.Extensions/TypeOfType.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 01-12-2023
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 07-16-2024
7+
// Last Modified On : 07-31-2024
88
// ***********************************************************************
99
// <copyright file="TypeOfType.cs" company="McCarter Consulting">
1010
// McCarter Consulting (David McCarter)
@@ -13,16 +13,6 @@
1313
// ***********************************************************************
1414

1515
//`![Spargine 8 - #RockYourCode](6219C891F6330C65927FA249E739AC1F.png;https://bit.ly/Spargine )
16-
17-
18-
19-
20-
21-
22-
23-
24-
25-
2616
namespace DotNetTips.Spargine.Extensions;
2717

2818
/// <summary>

source/dotNetTips.Spargine.8.Tester/Data/Countries.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 03-12-2023
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 07-17-2024
7+
// Last Modified On : 07-31-2024
88
// ***********************************************************************
99
// <copyright file="Countries.cs" company="McCarter Consulting">
1010
// McCarter Consulting (David McCarter)
@@ -112,7 +112,7 @@ public static Country GetCountry([NotNull] CountryName countryName)
112112
{
113113
countryName = countryName.ArgumentNotNull();
114114

115-
return GetCountries().FirstOrDefault(p => p.Name == countryName.GetDescription());
115+
return GetCountries().FirstOrDefault(p => string.Equals(p.Name, countryName.GetDescription(), StringComparison.Ordinal));
116116
}
117117

118118
/// <summary>

source/dotNetTips.Spargine.8.Tester/Data/ContryConverters.cs renamed to source/dotNetTips.Spargine.8.Tester/Data/CountryConverters.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Last Modified By : David McCarter
77
// Last Modified On : 07-16-2024
88
// ***********************************************************************
9-
// <copyright file="ContryConverters.cs" company="McCarter Consulting">
9+
// <copyright file="CountryConverters.cs" company="McCarter Consulting">
1010
// McCarter Consulting (David McCarter)
1111
// </copyright>
1212
// <summary>Converters tailored for Country.</summary>

source/dotNetTips.Spargine.8.Tester/PrefixAndLength.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 03-13-2023
55
//
66
// Last Modified By : David McCarter
7-
// Last Modified On : 07-22-2024
7+
// Last Modified On : 07-31-2024
88
// ***********************************************************************
99
// <copyright file="PrefixAndLength.cs" company="McCarter Consulting">
1010
// McCarter Consulting (David McCarter)
@@ -58,7 +58,7 @@ internal struct PrefixAndLength(string prefix, int length) : IEquatable<PrefixAn
5858
/// </summary>
5959
/// <param name="other">An object to compare with this object.</param>
6060
/// <returns>true if the current object is equal to the other parameter; otherwise, false.</returns>
61-
public readonly bool Equals(PrefixAndLength other) => this.Prefix == other.Prefix && this.Length == other.Length;
61+
public readonly bool Equals(PrefixAndLength other) => string.Equals(this.Prefix, other.Prefix, StringComparison.Ordinal) && this.Length == other.Length;
6262

6363
/// <summary>
6464
/// Returns a hash code for this instance.

0 commit comments

Comments
 (0)