Skip to content

Godot C# Parser Fails to Parse Namespace Alias Qualifiers #28293

Open
@sethdmoore

Description

@sethdmoore

Godot version:
v3.1.mono.official

OS/device including version:
Windows 10

Issue description:
Cannot compile C# script with namespace alias qualifier.
Using Visual Studio 2019 MSBUILD.

Minimal reproduction project:
Build with following script

using shorthand = System.Collections.Generic;

public class KeyExtension : shorthand::KeyNotFoundException {}

Result

 modules/mono/editor/csharp_project.cpp:183 - Parse error: Unexpected token: :
 Failed to determine namespace and class for script: res://Scripts/Card.cs
 modules/mono/editor/mono_bottom_panel.cpp:168 - Condition ' metadata_err != OK ' is true

Sanity
The above script compiles in Visual Studio Community 2019.
If I change the script from using '::' to a '.', it will compile in Godot.
EG:

using shorthand = System.Collections.Generic;

public class KeyExtension : shorthand.KeyNotFoundException {}

Use Case
We are using protoc (Google's Protobuf) to generate C# files for our Godot project. It generates fine on the Golang backend, but the generated C# code will not compile due to it generating namespace aliases.
EG (partial generated code):

using pb = global::Google.Protobuf;
namespace Card {
  public sealed partial class Card : pb::IMessage<Card> {}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions