Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] [Mono] Add support for file-scoped namespace declaration. #56427

Merged
merged 1 commit into from
Jan 3, 2022

Conversation

zaevi
Copy link
Contributor

@zaevi zaevi commented Jan 2, 2022

Support for parsing C# scripts with file-scoped namespace declaration:

using Godot;

namespace MyGame;

public class Main : Node2D
{
    // ...
}

@zaevi zaevi requested a review from a team as a code owner January 2, 2022 11:08
@Chaosus Chaosus added this to the 3.5 milestone Jan 2, 2022
@Zireael07
Copy link
Contributor

Shouldn't this have a master version, too?

@zaevi
Copy link
Contributor Author

zaevi commented Jan 2, 2022

Shouldn't this have a master version, too?

Actually, it's a FIX to customized C# parser for 3.x. Master doesn't need this :P

Copy link
Member

@raulsntos raulsntos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is C# 10 syntax and the .csproj that we create by default targets net472 (which defaults to C# 7.3) so it wouldn't really be valid but I think it's fine for this parser to consider it valid since it's only used to retrieve the script metadata.

In master this parser no longer exists as it was replaced with source generators (#46713).

@zaevi
Copy link
Contributor Author

zaevi commented Jan 2, 2022

Yes, so I usually switch my csproj target to netstandard2.1 with <LangVersion>preview</LangVersion>.

For preview, some syntactic sugars for C# 8+ are valid, like file-scoped namespace, global using and pattern-matching enhancements😄.

@akien-mga akien-mga merged commit ccbfe85 into godotengine:3.x Jan 3, 2022
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants