Code/Editors/Attributes/NamespaceGroupAttribute.cs
using System;
using System.Linq;

namespace ExtendedBox.Editors.Attributes;

[AttributeUsage(AttributeTargets.All)]
public sealed class NamespaceGroupAttribute : GroupAttribute
{
    public NamespaceGroupAttribute(Type type, int depth = -1, int skipLast = 0) : base(GetGroup(type, depth, skipLast))
    {
    }

    private static string GetGroup(Type type, int depth, int skipLast)
    {
        if(depth == 0)
            return string.Empty;

        var fullName = type.FullName;
        if(fullName is null)
            return string.Empty;

        if(depth < 0)
            depth = int.MaxValue - 1;

        var splitted = fullName.Split('.').SkipLast(skipLast + 1).TakeLast(depth);
        if(!splitted.Any())
            return string.Empty;

        return string.Join('/', splitted);
    }
}