Skip to content

fix: TypeExtensions.GetMetadataName produces 'null.TypeName' for root namespace types #4866

@thomhurst

Description

@thomhurst

Description

File: TUnit.Analyzers/Extensions/TypeExtensions.cs (Line 11)

public static string GetMetadataName(this Type type)
{
    return $"{type.Namespace}.{type.Name}";  // Namespace can be null
}

For root namespace types, type.Namespace is null, resulting in "null.TypeName".

Suggested Fix

return string.IsNullOrEmpty(type.Namespace) ? type.Name : $"{type.Namespace}.{type.Name}";

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions