Skip to content

Commit cc5a14a

Browse files
v3.0.0 (#3)
* Upgrade to .NET 9 and update dependencies - Updated target framework in `LFPublish.csproj` and `ListFunctions-Next.csproj` to `net9.0`. - Upgraded `System.Management.Automation` package from `7.4.0` to `7.5.2` in both projects. - Changed `ImplicitUsings` from `disable` to `enable` in `ListFunctions-Next.csproj`. - Added `AllowUnsafeBlocks` property to `ListFunctions.Engine.csproj`. - Introduced new `PackageReference` for `System.Management.Automation` specific to `net9.0` in `ListFunctions.Engine.csproj`. - Updated `LangVersion` for `ListFunctions.Engine.csproj` to `latest` for `net6.0` and `net8.0`, and set to `preview` for `net9.0`. - Improved null handling and type safety in `HashCodeBlock.cs`. - Modified `PSThisVariable` to use `HashSet<string>` instead of `IReadOnlySet<string>` for better performance. - Cleaned up using directives across various files to enhance code readability and maintainability. * Add new references and implement read-only collections Updated `ListFunctions-NETFramework.csproj` to remove `MG.Collections` and add references for `Microsoft.Bcl.Memory`, `System.Buffers`, `System.Memory`, `System.Numerics.Vectors`, `System.Runtime.CompilerServices.Unsafe`, `System.ValueTuple`, and `ZLinq`. Added `app.config` and `packages.config` with necessary binding redirects and package dependencies. Introduced `ReadOnlySet.cs` to define the `IReadOnlySet` interface and its implementation, providing a read-only collection that supports set operations. Added `SingleValueReadOnlySet.cs` for creating read-only sets containing a single value. Significant changes in `Empty.cs` include the removal of generic parameters and the introduction of `EmptyHolder`, along with modifications to use `Array.Empty` for improved functionality. Updated `EnumerableExtensions.cs` to replace the original `TryGetCount` method with a new implementation using pattern matching for better handling of collection types. Enhanced `ScriptBlockFilter.cs` to improve instance creation and utilize the new `SingleValueReadOnlySet` and `ReadOnlySet` for managing collections of `PSVariable`. * Add StructLayout and Enumerator for SingleValueReadOnlySet - Introduced a new `using` directive for `System.Runtime.InteropServices`. - Added a `StructLayout` attribute to `SingleValueReadOnlySet<T>` for sequential memory layout. - Removed the `_isNotEmpty` field; modified `IsEmpty` to check if `_value` is null. - Updated the `Contains` method to return false if the set is empty or the item is null. - Modified `IsProperSubsetOf`, `IsSubsetOf`, `IsSupersetOf`, and `SetEquals` methods to use `AsValueEnumerable()` for improved performance. - Changed `GetEnumerator` to return a custom `Enumerator` struct instead of yielding the value directly. - Defined a new `Enumerator` struct implementing `IEnumerator<T>` for iterating over the single value in the set. * Enhance null handling and type safety across modules - Improved null handling and type safety in various methods. - Updated collection checks in `PSVariableCollectionExtensions.cs` for explicit `PSObject` type handling. - Simplified statement count check in `ScriptBlockExtensions.cs`. - Modified `Compare` method in `ComparingBlock.cs` to accept nullable types. - Changed string comparison logic in `DictionaryCtor.cs` to use `StringComparer.CurrentCulture`. - Added nullability annotations in several methods in `EqualityBlock.cs`. - Implemented error handling for method resolution failures in `EqualityBlock.cs`. - Added similar error handling for method retrieval in `ReflectionResolver.cs`. - Updated iteration in `ScriptBlockFilter.cs` to use `AsValueEnumerable()` for improved performance. * Add performance improvements and new features - Changed `EnumerateVariables` in `AssertAllObjectsCmdlet.cs` to return a `PSVariable[]` for better performance. - Updated `_condition` in `AssertAnyObjectCmdlet.cs` to be non-nullable and added nullability attributes to `InputObject`. - Modified `ProcessWhenNoCondition` to handle nullable arrays and ensure only non-null objects are processed. - Removed a parameter from the `$CopyToOutput` array in `Debug.ps1`. - Disabled implicit usings and nullable reference types in `ListFunctions-Next.csproj`. - Replaced `using System;` with `using ListFunctions.Extensions;` in `ValidateScriptVariableAttribute.cs` and enhanced `EnumerateAllVariablesInBlock` return type. - Added `SetExtensions` class in `SetExtensions.cs` with `UnionWithRef` method for improved performance. - Updated serialization constructor in `HashCodeScriptException.cs` for .NET 8 compatibility. - Improved `ToDictionary` method in `ScriptBlockInvocationException.cs` for clarity and performance. - Changed iteration in `ScriptBlockFilter.cs` to use `AsValueEnumerable()` for better performance. * Remove ZLinq references and add EnumerableExtensions - Removed `ZLinq` library reference from `ListFunctions-NETFramework.csproj` and its entry in `packages.config`. - Eliminated `using ZLinq.Linq;` from `ValidateScriptVariableAttribute.cs` and modified `EnumerateAllVariablesInBlock` to conditionally use `ZLinq` types. - Added new file `EnumerableExtensions.cs` with an `AsValueEnumerable` extension method for `IEnumerable<T>`. - Updated `PSVariableCollectionExtensions.cs` to access the last element of a collection using `collection.Count - 1`. - Included a conditional `using ZLinq.Linq;` directive in `SetExtensions.cs` based on the target framework. - Moved `ZLinq` package reference to a conditional item group in `ListFunctions.Engine.csproj`. - Enhanced methods in `Guard.cs` with `MethodImpl` attributes for aggressive inlining and conditional exception throwing based on the target framework. * Update string comparison and streamline imports - Changed string comparison in `ArgumentToTypeNameTransformAttribute.cs` from `InvariantCultureIgnoreCase` to `OrdinalIgnoreCase` for module name checks, affecting cultural behavior. - Removed `ListFunctions.Extensions` import in `ValidateScriptVariableAttribute.cs` and consolidated `System` imports to include additional namespaces: `System.Collections.Generic`, `System.Linq`, `System.Management.Automation`, `System.Management.Automation.Language`, and `ZLinq`. * Add support for unsafe code and enhance list handling - Updated project files to allow unsafe code blocks. - Introduced `_genericType` in `NewListCmdlet.cs` for better generic type management. - Changed `InputObject` from an array to `IList?` for flexible input handling. - Modified `BeginProcessing` to initialize lists based on generic type and capacity. - Added methods to set object type and handle null elements. - Updated `ProcessRecord` to use `Count` for null/empty list checks. - Refactored item addition logic into `AddItemsToList` and `AddTypedItemsToList`. - Added `AsValueEnumerable` method in `EnumerableExtensions.cs` for casting `IEnumerable` to `IEnumerable<object>`. * Enhance InputObject handling and enable nullable types - Changed `InputObject` type from `IList?` to `object?[]?` for improved flexibility. - Updated `ProcessRecord` method to check `InputObject.Length` instead of `Count`. - Modified `AddItemsToList` to accept `object?[]` parameter for item addition. - Updated `AddTypedItemsToList` to use the new `object?[]` parameter for type conversion. - Added `#nullable enable` directive in `ArgumentToTypeNameTransformAttribute.cs` for enhanced type safety. - Changed namespace in `SetExtensions.cs` from `ListFunctions.Extensions` to `ZLinq`. * Add dictionary conversion features and nullable types Enhanced `ConvertToDictionaryCmdlet.cs` with new properties for key and value selectors, improved error handling, and a method to determine input object types, supporting both property-based and script-based extraction. Updated `NewDictionaryCmdlet.cs` to include nullable reference types for `KeyType` and `ValueType`, allowing better handling of undefined types. The `Capacity` property now includes an alias for "Size" to improve usability. * Enhance ConvertToDictionaryCmdlet and add extensions - Made `ValueSelector` nullable for better optional handling. - Introduced `ScriptBlockExtensions.cs` with `ReplaceWithArgsZero()` method to enhance script block flexibility. - Updated `_dictionary` instantiation to use an array for constructor parameters. - Modified `ValueSelector` invocation to use null-conditional operator for safer code. - Changed implicit conversion in `DoubleBool` from logical AND (`&&`) to bitwise AND (`&`). - Improved error handling in `SortingCollectorCtor` with null check on generic method invocation. - Added `#nullable enable` directive to several files to support nullable reference types. * Enhance ValuePropertyName type and refactor ReplaceWithArgsZero - Changed `ValuePropertyName` from `string` to `object?` for increased flexibility. - Updated logic to check if `ValuePropertyName` is a string before string operations. - Modified handling of `ValueSelector` to accommodate the new `ValuePropertyName` type. - Refactored `ReplaceWithArgsZero` in `ScriptBlockExtensions.cs` to use a new `ReplaceString` method for improved string replacement logic. - Simplified string replacement logic and ensured compatibility across different frameworks. * Add nullable types and improve documentation - Introduced nullable reference types in `AssertAnyObjectCmdlet.cs` for properties. - Enhanced XML documentation in `ArgumentToTypeNameTransformAttribute.cs` and `ListTransformAttribute.cs`. - Clarified validation logic and variable handling in `ValidateScriptVariableAttribute.cs`. - Improved structure and added enumerators in `PipelineItem.cs`. - Updated exception handling in `Guard.cs` for better efficiency based on .NET version. * Add ListPool and refactor ListFunctions classes - Introduced a new `ListPool` class for efficient list management with methods for renting and returning lists. - Updated `FindIndexCmdletBase.cs` to use nullable reference types, changing `IList InputObject` to `object?[]? InputObject`. - Simplified `ComparingBase` and derived classes by removing generic type parameters. - Enhanced `ScriptBlockFilter` to handle collections more generically, improving type safety. - Refactored variable handling in `PSComparingVariable` and `PSThisVariable` for better performance using `MemoryMarshal` and `Unsafe`. - Removed conditional compilation directives for .NET version checks, streamlining the codebase. * Refactor FindIndexCmdlet and enhance object pooling - Added nullable reference types with `#nullable enable`. - Updated `InputObject` to use an array of objects. - Commented out several methods related to index finding. - Introduced a generic `ListPool` class for efficient list management. - Added `IPoolable` and `IResettable` interfaces for object pooling. - Updated `PSThisVariable` to implement `IResettable`. - Overall improvements for type safety, performance, and list handling in cmdlets. * Enhance nullability support and pooling mechanisms - Updated `InputObject` in `FindIndexCmdletBase.cs` to support nullable arrays and explicitly rent lists as `ListPool<object?>`. - Added a new virtual method `Stop(List<object?> list)` in `FindIndexCmdletBase.cs` for future implementation. - Modified `ListPool<T>` in `ListPool.cs` to allow nullable reference types. - Enhanced `ObjPool` in `ObjPool.cs` with generic constraints and methods for renting and returning items. - Implemented `IPoolable` interface in `PSComparingVariable` and added lifecycle management methods. * Bump version to 3.0.0 and refactor codebase Updated project version to 3.0.0 across multiple files. Removed several external library references in favor of modern alternatives. Added new source file inclusion from `ListFunctions-Next`. Updated `AssemblyInfo.cs` and `packages.config` for compatibility. Introduced nullable reference types in `AssertAllObjectsCmdlet.cs`. Refactored `AssertAnyObjectCmdlet.cs` to improve class hierarchy. Significant redesign of `ScriptBlockFilter` with backward compatibility. Modified `PSThisVariable` to implement `IPoolable` for better memory management. Updated `Debug.ps1` to ensure module imports are forced. * Refactor case sensitivity handling in EqualityConstructingCmdlet - Introduced nullable reference types with `#nullable enable`. - Updated `CaseSensitive` property to use `IsParameterValueCaseSensitive`. - Modified `GetCustomEqualityComparer` to return appropriate `StringComparer`. - Renamed `RetrieveCaseSensitiveSetting` to `IsParameterValueCaseSensitive` and changed its implementation to use `LanguagePrimitives.IsTrue`. * Refactor cmdlets for improved structure and error handling - Refactored `AssertAllObjectsCmdlet` and `AssertAnyObjectCmdlet` to inherit from `AssertObjectCmdlet`, enhancing their processing logic and allowing nullable collections. - Updated `AssertObjectCmdlet` with a new `HasCondition` property and improved error handling in processing methods. - Enhanced `ConvertToDictionaryCmdlet`, `EqualityConstructingCmdlet`, and collection cmdlets (`NewDictionaryCmdlet`, `NewHashSetCmdlet`, `NewListCmdlet`, `NewSortedSetCmdlet`) for better type handling and error reporting. - Refactored `FindIndexCmdlet` and `FindLastIndexCmdlet` to inherit from `ListFunctionCmdletBase`, improving input handling. - Improved error handling and processing flow in `ListFunctionCmdletBase` with a new `_wantsToStop` flag. - Updated project file for assembly visibility changes and modified `ListPool` and `ObjPool` for better framework compatibility. * Remove commented-out EndProcessing method This commit removes the unused and commented-out `EndProcessing` method in the `AssertAnyObjectCmdlet.cs` file. The method previously contained logic for condition checking and outputting based on `_hasNonNull` and `_stop`. The existing `End` method, which writes the script result, remains unchanged. * Remove ScriptBlockFilterOld and related classes This commit removes the entire `ScriptBlockFilterOld.cs` file, including the `ScriptBlockFilterOld` abstract class and its derived class `ScriptBlockFilterOld<T>`. All associated methods, properties, namespaces, and using directives have also been deleted. * Update handling of Debug.ps1 in project files Refactor `ListFunctions-NETFramework.csproj` and `ListFunctions-Next.csproj` to conditionally manage the inclusion of `Debug.ps1`. In non-Release configurations, it will be copied to the output directory, while in Release configurations, it will not be copied to either the output or publish directories. Previous entries for `Debug.ps1` have been removed to implement this logic. * Update ListFunctions module to version 3.0.0 - Updated version number in `ListFunctions.psd1` from `2.0.0` to `3.0.0`. - Changed copyright year in `ListFunctions.psd1` from `2024` to `2025`. - Modified minimum PowerShell version requirement in `ListFunctions.psd1` from `5.1` to `5.0`. - Adjusted assembly loading in `ListFunctions.psm1`, commenting out certain modules. - Inverted logic in `ProcessCore` method of `AssertObjectCmdlet.cs`. - Added `ZLinq.dll` and deleted `MG.Collections.Resources.dll` and `MG.Collections.dll`. * Update ListFunctions module for PowerShell 5.1 support - Updated PowerShell version requirement to 5.1. - Added `New-SortedSet` to exported cmdlets. - Modified file list to include `Core\ZLinq.dll` and retain `Desk\ListFunctions.NETFramework.dll`, removing `Core\MG.Collections.dll` and `Core\MG.Collections.Resources.dll`. - Expanded tags in `PrivateData` to include 'Convert' and 'ConvertTo'. - Updated release notes to reflect performance improvements and ZLinq library utilization for PowerShell 7. --------- Co-authored-by: Mike Garvey <mgarvey@dgrsystems.com>
1 parent f71f66f commit cc5a14a

File tree

78 files changed

+1816
-888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1816
-888
lines changed
4.5 KB
Binary file not shown.
3.5 KB
Binary file not shown.
-6 KB
Binary file not shown.
-37.5 KB
Binary file not shown.

ListFunctions/Core/ZLinq.dll

252 KB
Binary file not shown.
4 KB
Binary file not shown.
3 KB
Binary file not shown.
-5.5 KB
Binary file not shown.
-40 KB
Binary file not shown.

ListFunctions/ListFunctions.psd1

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'ListFunctions.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '2.0.0'
15+
ModuleVersion = '3.0.0'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = @('Desk', 'Core')
@@ -27,7 +27,7 @@
2727
CompanyName = 'Yevrag35, LLC.'
2828

2929
# Copyright statement for this module
30-
Copyright = 'Copyright (c) 2020-2024 Yevrag35, LLC.'
30+
Copyright = 'Copyright (c) 2020-2025 Yevrag35, LLC.'
3131

3232
# Description of the functionality provided by this module
3333
Description = 'A simple module that provides functions to manipulate, search, and create Arrays, Collections, Lists, and Sets.'
@@ -75,7 +75,7 @@
7575
CmdletsToExport = @(
7676
'Assert-AllObject', 'Assert-AnyObject', 'Find-IndexOf',
7777
'Find-LastIndexOf', 'New-Dictionary', 'New-HashSet', 'New-List',
78-
'New-SortedSet'
78+
'New-SortedSet', 'ConvertTo-Dictionary'
7979
)
8080

8181
# Variables to export from this module
@@ -99,12 +99,9 @@
9999
'ListFunctions.psm1',
100100
'Core\ListFunctions.Engine.dll',
101101
'Core\ListFunctions.Next.dll',
102-
'Core\MG.Collections.dll',
103-
'Core\MG.Collections.Resources.dll',
102+
'Core\ZLinq.dll',
104103
'Desk\ListFunctions.Engine.dll',
105-
'Desk\ListFunctions.NETFramework.dll',
106-
'Desk\MG.Collections.dll',
107-
'Desk\MG.Collections.Resources.dll'
104+
'Desk\ListFunctions.NETFramework.dll'
108105
)
109106

110107
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
@@ -115,7 +112,7 @@
115112
# Tags applied to this module. These help with module discovery in online galleries.
116113
Tags = @('All', 'Any', 'Array', 'Assert', 'bool', 'Collection', 'compare', 'Condition',
117114
'count', 'Enumerable', 'equality', 'Find', 'HashSet', 'index', 'Last', 'Linq',
118-
'List', 'Modify', 'Predicate', 'Remove', 'set', 'sort', 'Test', 'Where')
115+
'List', 'Modify', 'Predicate', 'Remove', 'set', 'sort', 'Test', 'Where', 'Convert', 'ConvertTo')
119116

120117
# A URL to the license for this module.
121118
LicenseUri = 'https://raw.githubusercontent.com/Yevrag35/PowerShell-ListFunctions/master/LICENSE'
@@ -129,7 +126,7 @@
129126
# Prerelease = 'beta'
130127

131128
# ReleaseNotes of this module
132-
ReleaseNotes = 'Overhaul of all cmdlets and moved to binary module for performance improvements.'
129+
ReleaseNotes = 'Refactoring work to improve performance and reduce overhead. Utilizes ZLinq library for PowerShell 7 version for further gains.'
133130

134131
} # End of PSData hashtable
135132

0 commit comments

Comments
 (0)