Skip to content

GenAPI does not handle types in the global namespace correctly #52303

@reflectronic

Description

@reflectronic

The following project:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
  </PropertyGroup>

  <PropertyGroup>
    <RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10-transport/nuget/v3/index.json</RestoreAdditionalProjectSources>
    <ProduceReferenceAssembly>false</ProduceReferenceAssembly>
    <GenAPIGenerateReferenceAssemblySource>true</GenAPIGenerateReferenceAssemblySource>
    <GenAPITargetPath>..\ref\$(AssemblyName).cs</GenAPITargetPath>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.DotNet.GenAPI.Task" Version="10.0.100-rtm.25479.115" PrivateAssets="all" />
  </ItemGroup>

</Project>

containing the following source file:

public class Class1;

generates the following C# code for the reference assembly:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace <global namespace>
{
    public partial class Class1
    {
    }
}

There should be no namespace declaration generated for types in the global namespace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions