diff --git a/codehelp/CodeHelpers/SymbolExtensions.cs b/codehelp/CodeHelpers/SymbolExtensions.cs index 3d59138a..6dbf12e0 100644 --- a/codehelp/CodeHelpers/SymbolExtensions.cs +++ b/codehelp/CodeHelpers/SymbolExtensions.cs @@ -8,33 +8,4 @@ public static bool RequiresUnsafe(this ITypeSymbol symbol) { return symbol.TypeKind == TypeKind.Pointer || symbol.TypeKind == TypeKind.FunctionPointer; } - - public static TypeDeclarationModel GetTypeDeclarationModel(this INamedTypeSymbol symbol) - { - TypeModifiers modifiers = TypeModifiers.None; - if (symbol.IsReadOnly) - { - modifiers |= TypeModifiers.IsReadOnly; - } - if (symbol.IsRefLikeType) - { - modifiers |= TypeModifiers.IsRefLikeType; - } - if (symbol.IsRecord) - { - modifiers |= TypeModifiers.IsRecord; - } - - var className = symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat); - string? nspace = null; - - TypeDeclarationModel? parent = null; - if (symbol.ContainingType is not null) { - parent = symbol.ContainingType.GetTypeDeclarationModel(); - } else { - nspace = symbol.ContainingNamespace is { IsGlobalNamespace: false } ns ? ns.ToDisplayString() : null; - } - - return new(symbol.TypeKind, modifiers, className, nspace, parent); - } } diff --git a/codehelp/CodeHelpers/TypeDeclarationModel.cs b/codehelp/CodeHelpers/TypeDeclarationModel.cs index 9b175a92..e9352ef0 100644 --- a/codehelp/CodeHelpers/TypeDeclarationModel.cs +++ b/codehelp/CodeHelpers/TypeDeclarationModel.cs @@ -50,3 +50,34 @@ public IndentedStringBuilder.IndentedScope WriteClassDeclaration(IndentedStringB return builder.EnterScope(count); } } + +public static class TypeDeclarationExtensions { + public static TypeDeclarationModel GetTypeDeclarationModel(this INamedTypeSymbol symbol) + { + TypeModifiers modifiers = TypeModifiers.None; + if (symbol.IsReadOnly) + { + modifiers |= TypeModifiers.IsReadOnly; + } + if (symbol.IsRefLikeType) + { + modifiers |= TypeModifiers.IsRefLikeType; + } + if (symbol.IsRecord) + { + modifiers |= TypeModifiers.IsRecord; + } + + var className = symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat); + string? nspace = null; + + TypeDeclarationModel? parent = null; + if (symbol.ContainingType is not null) { + parent = symbol.ContainingType.GetTypeDeclarationModel(); + } else { + nspace = symbol.ContainingNamespace is { IsGlobalNamespace: false } ns ? ns.ToDisplayString() : null; + } + + return new(symbol.TypeKind, modifiers, className, nspace, parent); + } +} \ No newline at end of file