| 240 | const Vector<String> reserved_assembly_names = { "GodotSharp", "GodotSharpEditor", "Godot.SourceGenerators" }; |
| 241 | |
| 242 | String get_csharp_project_name() { |
| 243 | String name = GLOBAL_GET("dotnet/project/assembly_name"); |
| 244 | if (name.is_empty()) { |
| 245 | name = GLOBAL_GET("application/config/name"); |
| 246 | Vector<String> invalid_chars = Vector<String>({ // |
| 247 | // Windows reserved filename chars. |
| 248 | ":", "*", "?", "\"", "<", ">", "|", |
| 249 | // Directory separators. |
| 250 | "/", "\\", |
| 251 | // Other chars that have been found to break assembly loading. |
| 252 | ";", "'", "=", "," }); |
| 253 | name = name.strip_edges(); |
| 254 | for (int i = 0; i < invalid_chars.size(); i++) { |
| 255 | name = name.replace(invalid_chars[i], "-"); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | if (name.is_empty()) { |
| 260 | name = "UnnamedProject"; |
| 261 | } |
| 262 | |
| 263 | // Avoid reserved names that conflict with Godot assemblies. |
| 264 | if (reserved_assembly_names.has(name)) { |
| 265 | name += "_"; |
| 266 | } |
| 267 | |
| 268 | return name; |
| 269 | } |
| 270 | |
| 271 | } // namespace Path |
no test coverage detected