Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions exporters/csharp_exporter.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
#include "csharp_exporter.h"

#include "compat/fake_csharp_script.h"
#include "core/error/error_list.h"
#include "core/io/file_access.h"
#include "utility/common.h" // For gdre namespace
#include "utility/common.h"
#include "utility/gdre_settings.h"
#include "utility/godot_mono_decomp_wrapper.h"

void CSharpExporter::_bind_methods() {
}

Error CSharpExporter::export_file(const String &out_path, const String &res_path) {
Error err = OK;
ERR_FAIL_COND_V_MSG(!GDRESettings::get_singleton()->has_loaded_dotnet_assembly(), ERR_CANT_RESOLVE, "No dotnet assembly loaded");
ERR_FAIL_COND_V_MSG(out_path.is_empty(), ERR_INVALID_PARAMETER, "Output path is empty");
ERR_FAIL_COND_V_MSG(res_path.is_empty(), ERR_INVALID_PARAMETER, "Resource path is empty");

Ref<GodotMonoDecompWrapper> decompiler = GDRESettings::get_singleton()->get_dotnet_decompiler();
if (decompiler.is_null()) {
ERR_FAIL_V_MSG(ERR_CANT_RESOLVE, "No dotnet decompiler loaded");
}
ERR_FAIL_COND_V_MSG(decompiler.is_null(), ERR_CANT_RESOLVE, "No dotnet decompiler loaded");

auto source = decompiler->decompile_individual_file(res_path);
if (source.is_empty()) {
ERR_FAIL_V_MSG(ERR_CANT_RESOLVE, "Failed to decompile C# script: " + res_path);
}
ERR_FAIL_COND_V_MSG(source.is_empty(), ERR_CANT_RESOLVE, "Failed to decompile C# script: " + res_path);

err = gdre::ensure_dir(out_path.get_base_dir());
Error err = gdre::ensure_dir(out_path.get_base_dir());
ERR_FAIL_COND_V_MSG(err != OK, err, "Failed to ensure output directory exists: " + out_path.get_base_dir());

Ref<FileAccess> f = FileAccess::open(out_path, FileAccess::WRITE);
Expand All @@ -33,8 +30,11 @@ Error CSharpExporter::export_file(const String &out_path, const String &res_path
}

Ref<ExportReport> CSharpExporter::export_resource(const String &output_dir, Ref<ImportInfo> import_infos) {
// This should not be used by the import exporter during full project recovery
ERR_FAIL_V_MSG(Ref<ExportReport>(), "Not implemented");
Ref<ExportReport> report;
report.instantiate();
report->set_error(ERR_UNAVAILABLE);
report->set_message("CSharpExporter::export_resource is not implemented");
return report;
}

void CSharpExporter::get_handled_types(List<String> *out) const {
Expand All @@ -58,6 +58,6 @@ String CSharpExporter::get_default_export_extension(const String &res_path) cons

Vector<String> CSharpExporter::get_export_extensions(const String &res_path) const {
Vector<String> extensions;
extensions.push_back("cs");
extensions.push_back(get_default_export_extension(res_path));
return extensions;
}
Loading