Skip to content

Commit 0e695c4

Browse files
update Subgroup fetching for methods
1 parent ed3b656 commit 0e695c4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Code/Helpers/Extensions/ObjectExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ public static string FriendlyTypeName(this object obj)
1818
{
1919
return obj.GetType().FriendlyTypeName();
2020
}
21+
22+
public static T WithCurrent<T>(this T obj, Func<T, T> func) => func(obj);
2123
}

Code/MethodSystem/BaseMethods/Method.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using SER.Code.ArgumentSystem.BaseArguments;
44
using SER.Code.Helpers;
55
using SER.Code.Helpers.Exceptions;
6+
using SER.Code.Helpers.Extensions;
67
using SER.Code.ScriptSystem;
78

89
namespace SER.Code.MethodSystem.BaseMethods;
@@ -19,7 +20,12 @@ public abstract class Method
1920
protected Method()
2021
{
2122
var type = GetType();
22-
Subgroup = type.Namespace?.Split('.').LastOrDefault()?.Replace("Methods", "") ?? "Unknown";
23+
24+
Subgroup = type.Namespace?
25+
.Split('.')
26+
.LastOrDefault()?
27+
.WithCurrent(name => name.Substring(0, name.Length - "Methods".Length))
28+
?? "Unknown";
2329

2430
var name = type.Name;
2531
if (!name.EndsWith("Method"))
@@ -33,7 +39,7 @@ protected Method()
3339

3440
public readonly string Name;
3541

36-
public abstract string? Description { get; }
42+
public abstract string Description { get; }
3743

3844
public abstract Argument[] ExpectedArguments { get; }
3945

0 commit comments

Comments
 (0)