Skip to content

Commit bce17ad

Browse files
committed
Refactor cmdlets and remove unused methods
This commit simplifies several cmdlet classes by removing unused methods, including `BeginProcessing`, `ProcessRecord`, and `EndProcessing` from `AssertAllObjectsCmdlet.cs` and `AssertAnyObjectCmdlet.cs`. The `FindIndexCmdlet.cs` file has been streamlined by removing the `End` method and related indexing methods. Additionally, the non-generic `TryGetCount` method in `EnumerableExtensions.cs` has been removed to focus on generics. Unused code has been cleaned up in `ScriptBlockInvocationException.cs`, and abstract methods in `PSComparingVariable.cs` have been eliminated. Finally, the `PSThisVariable<T>` class has been removed, indicating a potential refactor in variable management.
1 parent d49d2b9 commit bce17ad

File tree

7 files changed

+0
-136
lines changed

7 files changed

+0
-136
lines changed

src/engine/ListFunctions-Next/Cmdlets/Assertions/AssertAllObjectsCmdlet.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,5 @@ protected override void End(bool scriptResult)
4848
{
4949
this.WriteObject(!scriptResult);
5050
}
51-
52-
//protected override void BeginProcessing()
53-
//{
54-
// _equality = new ScriptBlockFilter(this.Condition, new PSVariable(ERROR_ACTION_PREFERENCE, this.ScriptBlockErrorAction));
55-
//}
56-
//protected override void ProcessRecord()
57-
//{
58-
// if (!_stop)
59-
// {
60-
// _stop = !_equality.All(this.InputObject);
61-
// }
62-
//}
63-
//protected override void EndProcessing()
64-
//{
65-
// this.WriteObject(_stop);
66-
//}
6751
}
6852
}

src/engine/ListFunctions-Next/Cmdlets/Assertions/AssertAnyObjectCmdlet.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,6 @@ protected override bool ProcessWhenNoCondition()
5252
}
5353

5454
return false;
55-
//if (!_hasNonNull)
56-
//{
57-
// ProcessWhenNoCondition(this.InputObject, ref _hasNonNull);
58-
//}
59-
//if (!this.HasCondition)
60-
//{
61-
62-
63-
// return;
64-
//}
65-
//else if (!_stop)
66-
//{
67-
// _stop = _equality.Any(this.InputObject);
68-
//}
6955
}
7056
protected override void End(bool scriptResult)
7157
{

src/engine/ListFunctions-Next/Cmdlets/Finds/FindIndexCmdlet.cs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -81,50 +81,6 @@ protected override void Cleanup()
8181
_list = null!;
8282
}
8383
}
84-
85-
//protected override void End(List<object?> list, PSVariable scriptErrorAction)
86-
//{
87-
88-
//}
89-
90-
//static readonly Lazy<Dictionary<Type, MethodInfo>> _indexMethods =
91-
// new Lazy<Dictionary<Type, MethodInfo>>(BuildMethodCache);
92-
93-
//protected override MethodInfo GetFindIndexMethod(Type listType, Type genericType)
94-
//{
95-
// var list = new List<object>();
96-
97-
// if (_indexMethods.IsValueCreated
98-
// &&
99-
// _indexMethods.Value.TryGetValue(genericType, out MethodInfo? info))
100-
// {
101-
// return info;
102-
// }
103-
104-
// info = GetIndexMethodDefinition(listType, genericType);
105-
106-
// Debug.Assert(!(info is null));
107-
// _indexMethods.Value.TryAdd(genericType, info);
108-
109-
// return info;
110-
//}
111-
112-
//private static MethodInfo GetIndexMethodDefinition(Type listType, Type genericType)
113-
//{
114-
// Type genPred = PredicateType.MakeGenericType(genericType);
115-
116-
// return listType.GetMethod(
117-
// name: nameof(List<object>.FindIndex),
118-
// bindingAttr: BindingFlags.Instance | BindingFlags.Public,
119-
// binder: null,
120-
// types: new Type[] { genPred },
121-
// modifiers: null)!;
122-
//}
123-
124-
//private static Dictionary<Type, MethodInfo> BuildMethodCache()
125-
//{
126-
// return new Dictionary<Type, MethodInfo>(3);
127-
//}
12884
}
12985
}
13086

src/engine/ListFunctions.Engine/Internal/EnumerableExtensions.cs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,6 @@ namespace ListFunctions.Internal
1010
{
1111
internal static class EnumerableExtensions
1212
{
13-
const string COUNT = "Count";
14-
15-
//internal static bool TryGetCount(this IEnumerable nonGenCollection, out int count)
16-
//{
17-
// if (nonGenCollection is ICollection icol)
18-
// {
19-
// count = icol.Count;
20-
// return true;
21-
// }
22-
// else if (nonGenCollection is Array arr)
23-
// {
24-
// count = arr.Length;
25-
// return true;
26-
// }
27-
28-
// Type type = nonGenCollection.GetType();
29-
// PropertyInfo? countProp;
30-
// try
31-
// {
32-
// countProp = type.GetProperty(COUNT, BindingFlags.Public | BindingFlags.Instance, null, typeof(int), Array.Empty<Type>(), Array.Empty<ParameterModifier>());
33-
34-
// if (countProp is null)
35-
// {
36-
// count = 0;
37-
// return false;
38-
// }
39-
40-
// if (countProp.GetValue(nonGenCollection) is int number)
41-
// {
42-
// count = number;
43-
// return true;
44-
// }
45-
// }
46-
// catch (Exception e)
47-
// {
48-
// Debug.Fail(e.Message);
49-
// }
50-
51-
// count = 0;
52-
// return false;
53-
//}
54-
5513
#if NET5_0_OR_GREATER
5614
[MethodImpl(MethodImplOptions.AggressiveInlining)]
5715
internal static bool TryGetCount<T>(this IEnumerable<T> enumerable, out int count)

src/engine/ListFunctions.Engine/Modern/Exceptions/ScriptBlockInvocationException.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ private static void AddToDict(ref Dictionary<string, object?> dict, PSVariable?
151151
if (variables is null || variables.Count <= 0)
152152
{
153153
return Empty.Dictionary<string, object?>();
154-
//return Empty<string, object?>.Dictionary;
155154
}
156155

157156
var dict = new Dictionary<string, object?>(variables.Count, StringComparer.InvariantCultureIgnoreCase);

src/engine/ListFunctions.Engine/Modern/Variables/PSComparingVariable.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ private protected PSComparingVariable()
2222
{
2323
}
2424

25-
//public abstract void Initialize();
26-
//public abstract bool TryReset();
27-
2825
internal static PSComparingVariable<T> Left<T>()
2926
{
3027
return new PSComparingVariable<T>(_left);

src/engine/ListFunctions.Engine/Modern/Variables/PSThisVariable.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,4 @@ public bool TryReset()
6767
return true;
6868
}
6969
}
70-
71-
//internal sealed class PSThisVariable<T> : PSThisVariable
72-
//{
73-
// internal T? Value => (T?)base.ObjValue;
74-
75-
// internal PSThisVariable()
76-
// : base()
77-
// {
78-
// }
79-
80-
// internal void AddToVarList(T value, List<PSVariable> variables)
81-
// {
82-
// this.SetValue(value);
83-
// this.InsertIntoList(variables);
84-
// }
85-
//}
8670
}

0 commit comments

Comments
 (0)