godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Add dotnet/project/solution_name project setting. #6985

Open Yharooer opened 1 year ago

Yharooer commented 1 year ago

Describe the project you are working on

A 2D game written in C# with Godot .NET. The core game mechanics are written in a C# library which can be used elsewhere (eg in machine learning for training models of NPCs). I have one C# project called GameName.Core with the core mechanics. I have another C# project called GameName.Godot with the Godot implementation.

Describe the problem or limitation you are having in your project

I have the following file hierarchy:

GameName
 - GameName.sln
 - src
   - Core
     - GameName.Core.csproj
   - Godot
     - GameName.Godot.csproj
     - project.godot

The naming of the C# project with the Godot code is GameName.Godot. However the solution name is GameName. Godot uses the dotnet/project/assembly_name project setting for the name of the .csproj and the .sln files, however if a solution is split into multiple projects, then the solution name and project name may not be identical.

If the solution name is not properly configured then we cannot open .cs files or debugger errors in Visual Studio from Godot.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The feature would include an additional project setting dotnet/project/solution_name. If this is not specified, then the editor would use the assembly_name project setting for the name of the .sln file. If this is specified, then the editor would use the solution_name project setting for the name of the .sln file.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The project.godot file may contain:

[dotnet]

project/assembly_name="GameName.Godot"
project/solution_name="GameName"
project/solution_directory="../../"

This would open the correct .sln file in the file hierarchy described above. However without this implementation we are required to rename the GameName.Godot C# project or the name of the solution.

This can be implemented with only a few lines of change. See: https://github.com/Yharooer/godot/commit/bf4a7ee1656006f3c75a6413921f37d0a556348c

If this enhancement will not be used often, can it be worked around with a few lines of script?

This cannot be worked around without changing the name of the solution.

Is there a reason why this should be core and not an add-on in the asset library?

This improves the Godot .NET experience out of the box and is a change in the way Godot .NET launches Visual Studio. This cannot be provided with an add-on.

raulsntos commented 1 year ago

This sounds reasonable to me. Since you have already implemented the proposal, feel free to open a PR. If you do open a PR make sure not to use the master branch in your fork, also you may want to read CONTRIBUTING.md.