Skip to content

NativeAOT returns null Type.Namespace for a nested generic type whose FullName includes a namespace #135106

Closed

Description

@ReubenBond

Description

A nested generic type has a correct namespace-qualified FullName but a null Namespace under NativeAOT. The same executable under CoreCLR returns the namespace for both the constructed type and its generic definition.

This was found while validating generated Orleans serialization-contract registrations. A standalone reproduction without Orleans or other package dependencies reproduces it. Orleans' type-name formatter uses Type.Namespace, so a format/parse round-trip then loses the namespace. No formatter workaround was added.

Reproduction

A net10.0 console project with project-local <PublishAot>true</PublishAot>:

namespace NamespaceRepro;

internal static class Program
{
    private static void Main()
    {
        var type = typeof(Container.Hidden<int>);
        Console.WriteLine($"Dynamic code: {System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported}");
        Console.WriteLine($"FullName: {type.FullName}");
        Console.WriteLine($"Namespace: {type.Namespace ?? "<null>"}");
        Console.WriteLine($"Definition namespace: {type.GetGenericTypeDefinition().Namespace ?? "<null>"}");
        Console.WriteLine($"Outer namespace: {typeof(Program).Namespace ?? "<null>"}");
    }

    internal static class Container
    {
        internal sealed class Hidden<T>;
    }
}

Publish and execute for win-x64. For comparison, run the same project with dotnet run -c Release -p:PublishAot=false.

Actual output

Native:

Dynamic code: False
FullName: NamespaceRepro.Program+Container+Hidden`1[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Namespace: <null>
Definition namespace: <null>
Outer namespace: NamespaceRepro

CoreCLR:

Dynamic code: True
FullName: NamespaceRepro.Program+Container+Hidden`1[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
Namespace: NamespaceRepro
Definition namespace: NamespaceRepro
Outer namespace: NamespaceRepro

Environment

Windows x64, .NET SDK 10.0.401, runtime and Microsoft.DotNet.ILCompiler 10.0.12. Native publishing used Visual Studio 2022 environmental tools with IlcUseEnvironmentalTools=true. The standalone reproduction publishes normally without trim/AOT warning suppressions.

Expected behavior

The constructed nested type and its definition return NamespaceRepro, matching CoreCLR and their namespace-qualified FullName values. Related Orleans investigation: dotnet/orleans#11374.

Activity

  1. dotnet-policy-service commented on Oct 2, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
    See info in area-owners.md if you want to be subscribed.

  2. added a commit that references this issue on Oct 5, 2026
    c31313e
  3. locked and limited conversation to collaborators on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

  • Status
    No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions