From afbba8f8809881a0f36d3f6b20c14526c188e2f2 Mon Sep 17 00:00:00 2001 From: Kybxd <627940450@qq.com> Date: Tue, 17 Mar 2026 14:20:32 +0800 Subject: [PATCH 1/5] feat: add CustomItemConf class for C# --- test/csharp-tableau-loader/Program.cs | 1 + .../custom/CustomItemConf.cs | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 test/csharp-tableau-loader/custom/CustomItemConf.cs diff --git a/test/csharp-tableau-loader/Program.cs b/test/csharp-tableau-loader/Program.cs index 6cd17fe..95273a8 100644 --- a/test/csharp-tableau-loader/Program.cs +++ b/test/csharp-tableau-loader/Program.cs @@ -5,6 +5,7 @@ class Program static void Main(string[] _) { Tableau.Registry.Init(); + Tableau.Registry.Register(); var options = new Tableau.HubOptions { diff --git a/test/csharp-tableau-loader/custom/CustomItemConf.cs b/test/csharp-tableau-loader/custom/CustomItemConf.cs new file mode 100644 index 0000000..bd6df31 --- /dev/null +++ b/test/csharp-tableau-loader/custom/CustomItemConf.cs @@ -0,0 +1,34 @@ +using System; + +namespace Custom +{ + public class CustomItemConf : Tableau.Messager, Tableau.IMessagerName + { + private Protoconf.ItemConf.Types.Item? _specialItemConf; + + public string Name() => "CustomItemConf"; + + public override bool Load(string dir, Tableau.Format fmt, in Tableau.Load.MessagerOptions? options = null) => true; + + public override bool ProcessAfterLoadAll(in Tableau.Hub hub) + { + var itemConf = hub.GetItemConf(); + if (itemConf is null) + { + Console.Error.WriteLine("hub get ItemConf failed!"); + return false; + } + var conf = itemConf.Get1(1); + if (conf is null) + { + Console.Error.WriteLine("hub get item 1 failed!"); + return false; + } + _specialItemConf = conf; + Console.WriteLine("custom item conf processed"); + return true; + } + + public string GetSpecialItemName() => _specialItemConf?.Name ?? ""; + } +} \ No newline at end of file From e2bdc780ba519041eed57e9f0f0662b6137c2d81 Mon Sep 17 00:00:00 2001 From: Kybxd <627940450@qq.com> Date: Wed, 25 Mar 2026 15:14:15 +0800 Subject: [PATCH 2/5] chore(testing): update C# testing workflow and string conversions - Update C# testing workflow to use arduino/setup-protoc for Protoc installation - Convert multiple const std::string& to const std::string for better string handling - Remove unused Protobuf log handler related code feat: Add custom Protobuf log handler when ABSL is absent refactor: Switch to version-based Protobuf log handler guards --- .../embed/load.pc.cc | 10 ++-- .../embed/templates/hub.pc.cc.tpl | 13 +++++ .../embed/util.pc.cc | 51 +++++++++++++++---- .../embed/util.pc.h | 22 ++++++++ cmd/protoc-gen-cpp-tableau-loader/messager.go | 2 +- .../src/protoconf/hero_conf.pc.cc | 4 +- .../src/protoconf/hub.pc.cc | 13 +++++ .../src/protoconf/index_conf.pc.cc | 12 ++--- .../src/protoconf/item_conf.pc.cc | 2 +- .../src/protoconf/load.pc.cc | 10 ++-- .../src/protoconf/patch_conf.pc.cc | 6 +-- .../src/protoconf/test_conf.pc.cc | 10 ++-- .../src/protoconf/util.pc.cc | 51 +++++++++++++++---- .../src/protoconf/util.pc.h | 22 ++++++++ 14 files changed, 182 insertions(+), 46 deletions(-) diff --git a/cmd/protoc-gen-cpp-tableau-loader/embed/load.pc.cc b/cmd/protoc-gen-cpp-tableau-loader/embed/load.pc.cc index 88209fe..dc8d06d 100644 --- a/cmd/protoc-gen-cpp-tableau-loader/embed/load.pc.cc +++ b/cmd/protoc-gen-cpp-tableau-loader/embed/load.pc.cc @@ -49,7 +49,7 @@ bool LoadMessager(google::protobuf::Message& msg, const std::filesystem::path& p bool LoadMessagerInDir(google::protobuf::Message& msg, const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr*/) { options = options ? options : std::make_shared(); - const std::string& name = msg.GetDescriptor()->name(); + const std::string name(msg.GetDescriptor()->name()); std::filesystem::path path; if (!options->path.empty()) { // path specified in Paths, then use it instead of dir. @@ -79,7 +79,7 @@ bool LoadMessagerWithPatch(google::protobuf::Message& msg, const std::filesystem // ignore patch files when LoadMode::kModeOnlyMain specified return load_func(msg, path, fmt, nullptr); } - const std::string& name = msg.GetDescriptor()->name(); + const std::string name(msg.GetDescriptor()->name()); std::vector patch_paths; if (!options->patch_paths.empty()) { // patch path specified in PatchPaths, then use it instead of PatchDirs. @@ -155,21 +155,21 @@ bool Unmarshal(const std::string& content, google::protobuf::Message& msg, Forma parse_options.ignore_unknown_fields = options->GetIgnoreUnknownFields(); auto status = google::protobuf::util::JsonStringToMessage(content, &msg, parse_options); if (!status.ok()) { - SetErrMsg("failed to parse " + msg.GetDescriptor()->name() + kJSONExt + ": " + status.ToString()); + SetErrMsg("failed to parse " + std::string(msg.GetDescriptor()->name()) + kJSONExt + ": " + status.ToString()); return false; } return true; } case Format::kText: { if (!google::protobuf::TextFormat::ParseFromString(content, &msg)) { - SetErrMsg("failed to parse " + msg.GetDescriptor()->name() + kTextExt); + SetErrMsg("failed to parse " + std::string(msg.GetDescriptor()->name()) + kTextExt); return false; } return true; } case Format::kBin: { if (!msg.ParseFromString(content)) { - SetErrMsg("failed to parse " + msg.GetDescriptor()->name() + kBinExt); + SetErrMsg("failed to parse " + std::string(msg.GetDescriptor()->name()) + kBinExt); return false; } return true; diff --git a/cmd/protoc-gen-cpp-tableau-loader/embed/templates/hub.pc.cc.tpl b/cmd/protoc-gen-cpp-tableau-loader/embed/templates/hub.pc.cc.tpl index 7424105..5617543 100644 --- a/cmd/protoc-gen-cpp-tableau-loader/embed/templates/hub.pc.cc.tpl +++ b/cmd/protoc-gen-cpp-tableau-loader/embed/templates/hub.pc.cc.tpl @@ -54,7 +54,12 @@ void Hub::InitScheduler() { std::shared_ptr Hub::InternalLoad(const std::filesystem::path& dir, Format fmt /* = Format::kJSON */, std::shared_ptr options /* = nullptr */) const { // intercept protobuf error logs +#if TABLEAU_PB_LOG_LEGACY auto old_handler = google::protobuf::SetLogHandler(util::ProtobufLogHandler); +#else + util::ProtobufAbslLogSink log_sink; + absl::AddLogSink(&log_sink); +#endif auto msger_map = NewMessagerMap(); options = options ? options : std::make_shared(); for (auto iter : *msger_map) { @@ -65,14 +70,22 @@ std::shared_ptr Hub::InternalLoad(const std::filesystem::path& dir, if (!ok) { ATOM_ERROR("load %s failed: %s", name.c_str(), GetErrMsg().c_str()); // restore to old protobuf log handler +#if TABLEAU_PB_LOG_LEGACY google::protobuf::SetLogHandler(old_handler); +#else + absl::RemoveLogSink(&log_sink); +#endif return nullptr; } ATOM_DEBUG("loaded %s", name.c_str()); } // restore to old protobuf log handler +#if TABLEAU_PB_LOG_LEGACY google::protobuf::SetLogHandler(old_handler); +#else + absl::RemoveLogSink(&log_sink); +#endif return msger_map; } diff --git a/cmd/protoc-gen-cpp-tableau-loader/embed/util.pc.cc b/cmd/protoc-gen-cpp-tableau-loader/embed/util.pc.cc index 35b1ff7..f0f1a34 100644 --- a/cmd/protoc-gen-cpp-tableau-loader/embed/util.pc.cc +++ b/cmd/protoc-gen-cpp-tableau-loader/embed/util.pc.cc @@ -83,8 +83,8 @@ bool PatchMessage(google::protobuf::Message& dst, const google::protobuf::Messag // Ensure both messages are of the same type if (dst_descriptor != src_descriptor) { SetErrMsg("dst and src are not messages with the same descriptor"); - ATOM_ERROR("dst %s and src %s are not messages with the same descriptor", dst_descriptor->name().c_str(), - src_descriptor->name().c_str()); + ATOM_ERROR("dst %s and src %s are not messages with the same descriptor", + std::string(dst_descriptor->name()).c_str(), std::string(src_descriptor->name()).c_str()); return false; } @@ -206,18 +206,51 @@ bool PatchMessage(google::protobuf::Message& dst, const google::protobuf::Messag return true; } -// refer: https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/stubs/logging.h +#if TABLEAU_PB_LOG_LEGACY +// refer: https://github.com/protocolbuffers/protobuf/blob/v3.19.3/src/google/protobuf/stubs/logging.h void ProtobufLogHandler(google::protobuf::LogLevel level, const char* filename, int line, const std::string& msg) { - static const std::unordered_map kLevelMap = {{google::protobuf::LOGLEVEL_INFO, log::kInfo}, - {google::protobuf::LOGLEVEL_WARNING, log::kWarn}, - {google::protobuf::LOGLEVEL_ERROR, log::kError}, - {google::protobuf::LOGLEVEL_FATAL, log::kFatal}}; +#define TABLEAU_PB_LOG_INFO google::protobuf::LOGLEVEL_INFO +#define TABLEAU_PB_LOG_WARNING google::protobuf::LOGLEVEL_WARNING +#define TABLEAU_PB_LOG_ERROR google::protobuf::LOGLEVEL_ERROR +#define TABLEAU_PB_LOG_FATAL google::protobuf::LOGLEVEL_FATAL +#define TABLEAU_PB_LOG_LEVEL level +#define TABLEAU_PB_LOG_FILENAME filename +#define TABLEAU_PB_LOG_LINE line +#define TABLEAU_PB_LOG_MESSAGE msg +#else +// refer: https://github.com/abseil/abseil-cpp/blob/20250512.1/absl/log/log_entry.h +void ProtobufAbslLogSink::Send(const absl::LogEntry& entry) { +#define TABLEAU_PB_LOG_INFO absl::LogSeverity::kInfo +#define TABLEAU_PB_LOG_WARNING absl::LogSeverity::kWarning +#define TABLEAU_PB_LOG_ERROR absl::LogSeverity::kError +#define TABLEAU_PB_LOG_FATAL absl::LogSeverity::kFatal +#define TABLEAU_PB_LOG_LEVEL entry.log_severity() +#define TABLEAU_PB_LOG_FILENAME std::string(entry.source_filename()).c_str() +#define TABLEAU_PB_LOG_LINE entry.source_line() +#define TABLEAU_PB_LOG_MESSAGE std::string(entry.text_message()).c_str() +#endif + + static const std::unordered_map kLevelMap = { + {TABLEAU_PB_LOG_INFO, log::kInfo}, + {TABLEAU_PB_LOG_WARNING, log::kWarn}, + {TABLEAU_PB_LOG_ERROR, log::kError}, + {TABLEAU_PB_LOG_FATAL, log::kFatal}}; log::Level lvl = log::kWarn; // default - auto iter = kLevelMap.find(level); + auto iter = kLevelMap.find(TABLEAU_PB_LOG_LEVEL); if (iter != kLevelMap.end()) { lvl = iter->second; } - ATOM_LOGGER_CALL(tableau::log::DefaultLogger(), lvl, "[libprotobuf %s:%d] %s", filename, line, msg.c_str()); + ATOM_LOGGER_CALL(tableau::log::DefaultLogger(), lvl, "[libprotobuf %s:%d] %s", TABLEAU_PB_LOG_FILENAME, + TABLEAU_PB_LOG_LINE, TABLEAU_PB_LOG_MESSAGE); + +#undef TABLEAU_PB_LOG_INFO +#undef TABLEAU_PB_LOG_WARNING +#undef TABLEAU_PB_LOG_ERROR +#undef TABLEAU_PB_LOG_FATAL +#undef TABLEAU_PB_LOG_LEVEL +#undef TABLEAU_PB_LOG_FILENAME +#undef TABLEAU_PB_LOG_LINE +#undef TABLEAU_PB_LOG_MESSAGE } } // namespace util } // namespace tableau \ No newline at end of file diff --git a/cmd/protoc-gen-cpp-tableau-loader/embed/util.pc.h b/cmd/protoc-gen-cpp-tableau-loader/embed/util.pc.h index a69b86a..574848c 100644 --- a/cmd/protoc-gen-cpp-tableau-loader/embed/util.pc.h +++ b/cmd/protoc-gen-cpp-tableau-loader/embed/util.pc.h @@ -1,10 +1,21 @@ #pragma once #include +#include #include #include #include +// Protobuf versions before v4.22.0 (GOOGLE_PROTOBUF_VERSION < 4022000) use the legacy +// logging interface (LogLevel, SetLogHandler). Newer versions removed it in favor of Abseil logging. +#define TABLEAU_PB_LOG_LEGACY (GOOGLE_PROTOBUF_VERSION < 4022000) + +#if !TABLEAU_PB_LOG_LEGACY +#include +#include +#include +#endif + namespace tableau { const std::string& GetErrMsg(); void SetErrMsg(const std::string& msg); @@ -57,7 +68,18 @@ const std::string& Format2Ext(Format fmt); // PatchMessage patches src into dst, which must be a message with the same descriptor. bool PatchMessage(google::protobuf::Message& dst, const google::protobuf::Message& src); +#if TABLEAU_PB_LOG_LEGACY +// ProtobufLogHandler redirects protobuf internal logs to tableau logger. +// Only available for protobuf < v4.22.0, as newer versions removed the old logging interface. void ProtobufLogHandler(google::protobuf::LogLevel level, const char* filename, int line, const std::string& msg); +#else +// ProtobufAbslLogSink redirects protobuf/Abseil logs to tableau logger. +// For protobuf >= v4.22.0, which uses Abseil logging (absl::LogSink). +class ProtobufAbslLogSink : public absl::LogSink { + public: + void Send(const absl::LogEntry& entry) override; +}; +#endif class TimeProfiler { protected: diff --git a/cmd/protoc-gen-cpp-tableau-loader/messager.go b/cmd/protoc-gen-cpp-tableau-loader/messager.go index 94148f3..9bea062 100644 --- a/cmd/protoc-gen-cpp-tableau-loader/messager.go +++ b/cmd/protoc-gen-cpp-tableau-loader/messager.go @@ -160,7 +160,7 @@ func genCppMessage(g *protogen.GeneratedFile, message *protogen.Message) { orderedMapGenerator := orderedmap.NewGenerator(g, message) indexGenerator := indexes.NewGenerator(g, indexDescriptor, message) - g.P("const std::string ", messagerName, "::kProtoName = ", cppFullName, `::GetDescriptor()->name();`) + g.P("const std::string ", messagerName, "::kProtoName = std::string(", cppFullName, `::GetDescriptor()->name());`) g.P() g.P("bool ", messagerName, "::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) {") g.P(helper.Indent(1), "tableau::util::TimeProfiler profiler;") diff --git a/test/cpp-tableau-loader/src/protoconf/hero_conf.pc.cc b/test/cpp-tableau-loader/src/protoconf/hero_conf.pc.cc index c7c4a32..1b7e142 100644 --- a/test/cpp-tableau-loader/src/protoconf/hero_conf.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/hero_conf.pc.cc @@ -10,7 +10,7 @@ #include "util.pc.h" namespace tableau { -const std::string HeroConf::kProtoName = protoconf::HeroConf::GetDescriptor()->name(); +const std::string HeroConf::kProtoName = std::string(protoconf::HeroConf::GetDescriptor()->name()); bool HeroConf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; @@ -69,7 +69,7 @@ const HeroConf::OrderedMap_Hero_AttrMap* HeroConf::GetOrderedMap(const std::stri return &iter->second.first; } -const std::string HeroBaseConf::kProtoName = protoconf::HeroBaseConf::GetDescriptor()->name(); +const std::string HeroBaseConf::kProtoName = std::string(protoconf::HeroBaseConf::GetDescriptor()->name()); bool HeroBaseConf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; diff --git a/test/cpp-tableau-loader/src/protoconf/hub.pc.cc b/test/cpp-tableau-loader/src/protoconf/hub.pc.cc index 8acd9a0..b3f1ac4 100644 --- a/test/cpp-tableau-loader/src/protoconf/hub.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/hub.pc.cc @@ -57,7 +57,12 @@ void Hub::InitScheduler() { std::shared_ptr Hub::InternalLoad(const std::filesystem::path& dir, Format fmt /* = Format::kJSON */, std::shared_ptr options /* = nullptr */) const { // intercept protobuf error logs +#if TABLEAU_PB_LOG_LEGACY auto old_handler = google::protobuf::SetLogHandler(util::ProtobufLogHandler); +#else + util::ProtobufAbslLogSink log_sink; + absl::AddLogSink(&log_sink); +#endif auto msger_map = NewMessagerMap(); options = options ? options : std::make_shared(); for (auto iter : *msger_map) { @@ -68,14 +73,22 @@ std::shared_ptr Hub::InternalLoad(const std::filesystem::path& dir, if (!ok) { ATOM_ERROR("load %s failed: %s", name.c_str(), GetErrMsg().c_str()); // restore to old protobuf log handler +#if TABLEAU_PB_LOG_LEGACY google::protobuf::SetLogHandler(old_handler); +#else + absl::RemoveLogSink(&log_sink); +#endif return nullptr; } ATOM_DEBUG("loaded %s", name.c_str()); } // restore to old protobuf log handler +#if TABLEAU_PB_LOG_LEGACY google::protobuf::SetLogHandler(old_handler); +#else + absl::RemoveLogSink(&log_sink); +#endif return msger_map; } diff --git a/test/cpp-tableau-loader/src/protoconf/index_conf.pc.cc b/test/cpp-tableau-loader/src/protoconf/index_conf.pc.cc index 00b8f0f..ce1bb84 100644 --- a/test/cpp-tableau-loader/src/protoconf/index_conf.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/index_conf.pc.cc @@ -10,7 +10,7 @@ #include "util.pc.h" namespace tableau { -const std::string FruitConf::kProtoName = protoconf::FruitConf::GetDescriptor()->name(); +const std::string FruitConf::kProtoName = std::string(protoconf::FruitConf::GetDescriptor()->name()); bool FruitConf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; @@ -190,7 +190,7 @@ const protoconf::FruitConf::Fruit::Item* FruitConf::FindFirstOrderedFruit(int32_ return conf->front(); } -const std::string Fruit6Conf::kProtoName = protoconf::Fruit6Conf::GetDescriptor()->name(); +const std::string Fruit6Conf::kProtoName = std::string(protoconf::Fruit6Conf::GetDescriptor()->name()); bool Fruit6Conf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; @@ -358,7 +358,7 @@ const protoconf::Fruit6Conf::Fruit::Item* Fruit6Conf::FindFirstOrderedFruit(int3 return conf->front(); } -const std::string Fruit2Conf::kProtoName = protoconf::Fruit2Conf::GetDescriptor()->name(); +const std::string Fruit2Conf::kProtoName = std::string(protoconf::Fruit2Conf::GetDescriptor()->name()); bool Fruit2Conf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; @@ -604,7 +604,7 @@ const protoconf::Fruit2Conf::Fruit::Country::Item* Fruit2Conf::FindFirstItem(int return conf->front(); } -const std::string Fruit3Conf::kProtoName = protoconf::Fruit3Conf::GetDescriptor()->name(); +const std::string Fruit3Conf::kProtoName = std::string(protoconf::Fruit3Conf::GetDescriptor()->name()); bool Fruit3Conf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; @@ -745,7 +745,7 @@ const protoconf::Fruit3Conf::Fruit::Country::Item* Fruit3Conf::FindFirstItem(int return conf->front(); } -const std::string Fruit4Conf::kProtoName = protoconf::Fruit4Conf::GetDescriptor()->name(); +const std::string Fruit4Conf::kProtoName = std::string(protoconf::Fruit4Conf::GetDescriptor()->name()); bool Fruit4Conf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; @@ -1082,7 +1082,7 @@ const protoconf::Fruit4Conf::Fruit::Country::Item* Fruit4Conf::FindFirstItem(int return conf->front(); } -const std::string Fruit5Conf::kProtoName = protoconf::Fruit5Conf::GetDescriptor()->name(); +const std::string Fruit5Conf::kProtoName = std::string(protoconf::Fruit5Conf::GetDescriptor()->name()); bool Fruit5Conf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; diff --git a/test/cpp-tableau-loader/src/protoconf/item_conf.pc.cc b/test/cpp-tableau-loader/src/protoconf/item_conf.pc.cc index 67a9167..d56d96c 100644 --- a/test/cpp-tableau-loader/src/protoconf/item_conf.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/item_conf.pc.cc @@ -10,7 +10,7 @@ #include "util.pc.h" namespace tableau { -const std::string ItemConf::kProtoName = protoconf::ItemConf::GetDescriptor()->name(); +const std::string ItemConf::kProtoName = std::string(protoconf::ItemConf::GetDescriptor()->name()); bool ItemConf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; diff --git a/test/cpp-tableau-loader/src/protoconf/load.pc.cc b/test/cpp-tableau-loader/src/protoconf/load.pc.cc index 960e898..21fb8f7 100644 --- a/test/cpp-tableau-loader/src/protoconf/load.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/load.pc.cc @@ -54,7 +54,7 @@ bool LoadMessager(google::protobuf::Message& msg, const std::filesystem::path& p bool LoadMessagerInDir(google::protobuf::Message& msg, const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr*/) { options = options ? options : std::make_shared(); - const std::string& name = msg.GetDescriptor()->name(); + const std::string name(msg.GetDescriptor()->name()); std::filesystem::path path; if (!options->path.empty()) { // path specified in Paths, then use it instead of dir. @@ -84,7 +84,7 @@ bool LoadMessagerWithPatch(google::protobuf::Message& msg, const std::filesystem // ignore patch files when LoadMode::kModeOnlyMain specified return load_func(msg, path, fmt, nullptr); } - const std::string& name = msg.GetDescriptor()->name(); + const std::string name(msg.GetDescriptor()->name()); std::vector patch_paths; if (!options->patch_paths.empty()) { // patch path specified in PatchPaths, then use it instead of PatchDirs. @@ -160,21 +160,21 @@ bool Unmarshal(const std::string& content, google::protobuf::Message& msg, Forma parse_options.ignore_unknown_fields = options->GetIgnoreUnknownFields(); auto status = google::protobuf::util::JsonStringToMessage(content, &msg, parse_options); if (!status.ok()) { - SetErrMsg("failed to parse " + msg.GetDescriptor()->name() + kJSONExt + ": " + status.ToString()); + SetErrMsg("failed to parse " + std::string(msg.GetDescriptor()->name()) + kJSONExt + ": " + status.ToString()); return false; } return true; } case Format::kText: { if (!google::protobuf::TextFormat::ParseFromString(content, &msg)) { - SetErrMsg("failed to parse " + msg.GetDescriptor()->name() + kTextExt); + SetErrMsg("failed to parse " + std::string(msg.GetDescriptor()->name()) + kTextExt); return false; } return true; } case Format::kBin: { if (!msg.ParseFromString(content)) { - SetErrMsg("failed to parse " + msg.GetDescriptor()->name() + kBinExt); + SetErrMsg("failed to parse " + std::string(msg.GetDescriptor()->name()) + kBinExt); return false; } return true; diff --git a/test/cpp-tableau-loader/src/protoconf/patch_conf.pc.cc b/test/cpp-tableau-loader/src/protoconf/patch_conf.pc.cc index d1e3a0a..8757af8 100644 --- a/test/cpp-tableau-loader/src/protoconf/patch_conf.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/patch_conf.pc.cc @@ -10,7 +10,7 @@ #include "util.pc.h" namespace tableau { -const std::string PatchReplaceConf::kProtoName = protoconf::PatchReplaceConf::GetDescriptor()->name(); +const std::string PatchReplaceConf::kProtoName = std::string(protoconf::PatchReplaceConf::GetDescriptor()->name()); bool PatchReplaceConf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; @@ -20,7 +20,7 @@ bool PatchReplaceConf::Load(const std::filesystem::path& dir, Format fmt, std::s return ok; } -const std::string PatchMergeConf::kProtoName = protoconf::PatchMergeConf::GetDescriptor()->name(); +const std::string PatchMergeConf::kProtoName = std::string(protoconf::PatchMergeConf::GetDescriptor()->name()); bool PatchMergeConf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; @@ -38,7 +38,7 @@ const protoconf::Item* PatchMergeConf::Get(uint32_t id) const { return &iter->second; } -const std::string RecursivePatchConf::kProtoName = protoconf::RecursivePatchConf::GetDescriptor()->name(); +const std::string RecursivePatchConf::kProtoName = std::string(protoconf::RecursivePatchConf::GetDescriptor()->name()); bool RecursivePatchConf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; diff --git a/test/cpp-tableau-loader/src/protoconf/test_conf.pc.cc b/test/cpp-tableau-loader/src/protoconf/test_conf.pc.cc index 41590b4..b60385c 100644 --- a/test/cpp-tableau-loader/src/protoconf/test_conf.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/test_conf.pc.cc @@ -10,7 +10,7 @@ #include "util.pc.h" namespace tableau { -const std::string ActivityConf::kProtoName = protoconf::ActivityConf::GetDescriptor()->name(); +const std::string ActivityConf::kProtoName = std::string(protoconf::ActivityConf::GetDescriptor()->name()); bool ActivityConf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; @@ -396,7 +396,7 @@ const protoconf::Section::SectionItem* ActivityConf::FindFirstAward(uint64_t act return conf->front(); } -const std::string ChapterConf::kProtoName = protoconf::ChapterConf::GetDescriptor()->name(); +const std::string ChapterConf::kProtoName = std::string(protoconf::ChapterConf::GetDescriptor()->name()); bool ChapterConf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; @@ -414,7 +414,7 @@ const protoconf::ChapterConf::Chapter* ChapterConf::Get(uint64_t id) const { return &iter->second; } -const std::string ThemeConf::kProtoName = protoconf::ThemeConf::GetDescriptor()->name(); +const std::string ThemeConf::kProtoName = std::string(protoconf::ThemeConf::GetDescriptor()->name()); bool ThemeConf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; @@ -444,7 +444,7 @@ const std::string* ThemeConf::Get(const std::string& name, const std::string& pa return &iter->second; } -const std::string TaskConf::kProtoName = protoconf::TaskConf::GetDescriptor()->name(); +const std::string TaskConf::kProtoName = std::string(protoconf::TaskConf::GetDescriptor()->name()); bool TaskConf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; @@ -623,7 +623,7 @@ const protoconf::TaskConf::Task* TaskConf::FindFirstActivityExpiry(int64_t expir return conf->front(); } -const std::string StrcaseConf::kProtoName = protoconf::StrcaseConf::GetDescriptor()->name(); +const std::string StrcaseConf::kProtoName = std::string(protoconf::StrcaseConf::GetDescriptor()->name()); bool StrcaseConf::Load(const std::filesystem::path& dir, Format fmt, std::shared_ptr options /* = nullptr */) { tableau::util::TimeProfiler profiler; diff --git a/test/cpp-tableau-loader/src/protoconf/util.pc.cc b/test/cpp-tableau-loader/src/protoconf/util.pc.cc index d51c0c5..3f1e63c 100644 --- a/test/cpp-tableau-loader/src/protoconf/util.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/util.pc.cc @@ -88,8 +88,8 @@ bool PatchMessage(google::protobuf::Message& dst, const google::protobuf::Messag // Ensure both messages are of the same type if (dst_descriptor != src_descriptor) { SetErrMsg("dst and src are not messages with the same descriptor"); - ATOM_ERROR("dst %s and src %s are not messages with the same descriptor", dst_descriptor->name().c_str(), - src_descriptor->name().c_str()); + ATOM_ERROR("dst %s and src %s are not messages with the same descriptor", + std::string(dst_descriptor->name()).c_str(), std::string(src_descriptor->name()).c_str()); return false; } @@ -211,18 +211,51 @@ bool PatchMessage(google::protobuf::Message& dst, const google::protobuf::Messag return true; } -// refer: https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/stubs/logging.h +#if TABLEAU_PB_LOG_LEGACY +// refer: https://github.com/protocolbuffers/protobuf/blob/v3.19.3/src/google/protobuf/stubs/logging.h void ProtobufLogHandler(google::protobuf::LogLevel level, const char* filename, int line, const std::string& msg) { - static const std::unordered_map kLevelMap = {{google::protobuf::LOGLEVEL_INFO, log::kInfo}, - {google::protobuf::LOGLEVEL_WARNING, log::kWarn}, - {google::protobuf::LOGLEVEL_ERROR, log::kError}, - {google::protobuf::LOGLEVEL_FATAL, log::kFatal}}; +#define TABLEAU_PB_LOG_INFO google::protobuf::LOGLEVEL_INFO +#define TABLEAU_PB_LOG_WARNING google::protobuf::LOGLEVEL_WARNING +#define TABLEAU_PB_LOG_ERROR google::protobuf::LOGLEVEL_ERROR +#define TABLEAU_PB_LOG_FATAL google::protobuf::LOGLEVEL_FATAL +#define TABLEAU_PB_LOG_LEVEL level +#define TABLEAU_PB_LOG_FILENAME filename +#define TABLEAU_PB_LOG_LINE line +#define TABLEAU_PB_LOG_MESSAGE msg +#else +// refer: https://github.com/abseil/abseil-cpp/blob/20250512.1/absl/log/log_entry.h +void ProtobufAbslLogSink::Send(const absl::LogEntry& entry) { +#define TABLEAU_PB_LOG_INFO absl::LogSeverity::kInfo +#define TABLEAU_PB_LOG_WARNING absl::LogSeverity::kWarning +#define TABLEAU_PB_LOG_ERROR absl::LogSeverity::kError +#define TABLEAU_PB_LOG_FATAL absl::LogSeverity::kFatal +#define TABLEAU_PB_LOG_LEVEL entry.log_severity() +#define TABLEAU_PB_LOG_FILENAME std::string(entry.source_filename()).c_str() +#define TABLEAU_PB_LOG_LINE entry.source_line() +#define TABLEAU_PB_LOG_MESSAGE std::string(entry.text_message()).c_str() +#endif + + static const std::unordered_map kLevelMap = { + {TABLEAU_PB_LOG_INFO, log::kInfo}, + {TABLEAU_PB_LOG_WARNING, log::kWarn}, + {TABLEAU_PB_LOG_ERROR, log::kError}, + {TABLEAU_PB_LOG_FATAL, log::kFatal}}; log::Level lvl = log::kWarn; // default - auto iter = kLevelMap.find(level); + auto iter = kLevelMap.find(TABLEAU_PB_LOG_LEVEL); if (iter != kLevelMap.end()) { lvl = iter->second; } - ATOM_LOGGER_CALL(tableau::log::DefaultLogger(), lvl, "[libprotobuf %s:%d] %s", filename, line, msg.c_str()); + ATOM_LOGGER_CALL(tableau::log::DefaultLogger(), lvl, "[libprotobuf %s:%d] %s", TABLEAU_PB_LOG_FILENAME, + TABLEAU_PB_LOG_LINE, TABLEAU_PB_LOG_MESSAGE); + +#undef TABLEAU_PB_LOG_INFO +#undef TABLEAU_PB_LOG_WARNING +#undef TABLEAU_PB_LOG_ERROR +#undef TABLEAU_PB_LOG_FATAL +#undef TABLEAU_PB_LOG_LEVEL +#undef TABLEAU_PB_LOG_FILENAME +#undef TABLEAU_PB_LOG_LINE +#undef TABLEAU_PB_LOG_MESSAGE } } // namespace util } // namespace tableau diff --git a/test/cpp-tableau-loader/src/protoconf/util.pc.h b/test/cpp-tableau-loader/src/protoconf/util.pc.h index d25bc85..70ec5eb 100644 --- a/test/cpp-tableau-loader/src/protoconf/util.pc.h +++ b/test/cpp-tableau-loader/src/protoconf/util.pc.h @@ -5,11 +5,22 @@ #pragma once #include +#include #include #include #include +// Protobuf versions before v4.22.0 (GOOGLE_PROTOBUF_VERSION < 4022000) use the legacy +// logging interface (LogLevel, SetLogHandler). Newer versions removed it in favor of Abseil logging. +#define TABLEAU_PB_LOG_LEGACY (GOOGLE_PROTOBUF_VERSION < 4022000) + +#if !TABLEAU_PB_LOG_LEGACY +#include +#include +#include +#endif + namespace tableau { const std::string& GetErrMsg(); void SetErrMsg(const std::string& msg); @@ -62,7 +73,18 @@ const std::string& Format2Ext(Format fmt); // PatchMessage patches src into dst, which must be a message with the same descriptor. bool PatchMessage(google::protobuf::Message& dst, const google::protobuf::Message& src); +#if TABLEAU_PB_LOG_LEGACY +// ProtobufLogHandler redirects protobuf internal logs to tableau logger. +// Only available for protobuf < v4.22.0, as newer versions removed the old logging interface. void ProtobufLogHandler(google::protobuf::LogLevel level, const char* filename, int line, const std::string& msg); +#else +// ProtobufAbslLogSink redirects protobuf/Abseil logs to tableau logger. +// For protobuf >= v4.22.0, which uses Abseil logging (absl::LogSink). +class ProtobufAbslLogSink : public absl::LogSink { + public: + void Send(const absl::LogEntry& entry) override; +}; +#endif class TimeProfiler { protected: From 56b0c50b7a71f6dde3a407817ac66cc011879965 Mon Sep 17 00:00:00 2001 From: Kybxd <627940450@qq.com> Date: Wed, 25 Mar 2026 15:23:38 +0800 Subject: [PATCH 3/5] chore: Fix Clang-GCC toolchain libstdc++ linking refactor: Unify matrix-driven Go setup across CI workflows ci: Unify init script handling across platforms chore: Enforce C++17 and simplify build setup chore: Downgrade Protoc and add CMake policy in CI workflows chore: Downgrade setup-protoc & simplify init scripts chore: Update Protoc version format to include 'v' prefix chore: Align protobuf paths and downgrade setup-protoc chore: Unify protobuf setup across OSes in CI --- .github/workflows/testing-cpp.yml | 16 +++++++++------ .github/workflows/testing-csharp.yml | 27 +++++++++++--------------- .github/workflows/testing-go.yml | 19 ++++++++++++------ init.bat | 15 +++++++------- init.sh | 16 +++++++-------- test/cpp-tableau-loader/CMakeLists.txt | 19 ++++++++++++++++++ 6 files changed, 68 insertions(+), 44 deletions(-) diff --git a/.github/workflows/testing-cpp.yml b/.github/workflows/testing-cpp.yml index b575511..3e88a54 100644 --- a/.github/workflows/testing-cpp.yml +++ b/.github/workflows/testing-cpp.yml @@ -18,25 +18,30 @@ jobs: matrix: include: - os: ubuntu-latest + go-version: 1.21.x + init_script: bash init.sh gen_script: bash gen.sh - cmake_config: cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Debug run_loader: ./bin/loader - os: windows-latest + go-version: 1.21.x + init_script: cmd /c init.bat gen_script: cmd /c gen.bat - cmake_config: cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Debug run_loader: .\bin\loader.exe + name: test (${{ matrix.os }}) runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: - name: Checkout Code uses: actions/checkout@v6 + with: + submodules: recursive - name: Install Go uses: actions/setup-go@v6 with: - go-version: 1.21.x + go-version: ${{ matrix.go-version }} cache: true - name: Install dependencies (Ubuntu) @@ -52,8 +57,7 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 - name: Init submodules and build protobuf - shell: bash - run: bash init.sh + run: ${{ matrix.init_script }} - name: Generate protoconf working-directory: test/cpp-tableau-loader @@ -61,7 +65,7 @@ jobs: - name: CMake Configure working-directory: test/cpp-tableau-loader - run: ${{ matrix.cmake_config }} + run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD=17 - name: CMake Build working-directory: test/cpp-tableau-loader diff --git a/.github/workflows/testing-csharp.yml b/.github/workflows/testing-csharp.yml index b2c5fd5..b631f4c 100644 --- a/.github/workflows/testing-csharp.yml +++ b/.github/workflows/testing-csharp.yml @@ -18,21 +18,26 @@ jobs: matrix: include: - os: ubuntu-latest + go-version: 1.21.x gen_script: bash gen.sh - os: windows-latest + go-version: 1.21.x gen_script: cmd /c gen.bat + name: test (${{ matrix.os }}) runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: - name: Checkout Code uses: actions/checkout@v6 + with: + submodules: recursive - name: Install Go uses: actions/setup-go@v6 with: - go-version: 1.21.x + go-version: ${{ matrix.go-version }} cache: true - name: Install .NET SDK @@ -40,21 +45,11 @@ jobs: with: dotnet-version: "8.0.x" - - name: Install dependencies (Ubuntu) - if: runner.os == 'Linux' - run: sudo apt-get update && sudo apt-get install -y cmake ninja-build - - - name: Install dependencies (Windows) - if: runner.os == 'Windows' - run: choco install cmake ninja -y - - - name: Setup MSVC (Windows) - if: runner.os == 'Windows' - uses: ilammy/msvc-dev-cmd@v1 - - - name: Init submodules and build protobuf - shell: bash - run: bash init.sh + - name: Install Protoc + uses: arduino/setup-protoc@v1 + with: + version: "3.19.3" + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Generate protoconf working-directory: test/csharp-tableau-loader diff --git a/.github/workflows/testing-go.yml b/.github/workflows/testing-go.yml index 99aa4df..8128c05 100644 --- a/.github/workflows/testing-go.yml +++ b/.github/workflows/testing-go.yml @@ -16,10 +16,17 @@ jobs: test: strategy: matrix: - go-version: [1.21.x] - os: [ubuntu-latest, windows-latest] + include: + - os: ubuntu-latest + go-version: 1.21.x + gen_script: bash gen.sh + - os: windows-latest + go-version: 1.21.x + gen_script: cmd /c gen.bat + name: test (${{ matrix.os }}) runs-on: ${{ matrix.os }} + timeout-minutes: 10 steps: - name: Checkout Code @@ -34,17 +41,17 @@ jobs: cache: true - name: Install Protoc - uses: arduino/setup-protoc@v3 + uses: arduino/setup-protoc@v1 with: - version: "23.x" + version: "3.19.3" repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Install protoc-gen-go run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2 - name: Generate protoconf - shell: bash - run: PROTOC=protoc bash test/go-tableau-loader/gen.sh + working-directory: test/go-tableau-loader + run: ${{ matrix.gen_script }} - name: Vet run: go vet ./... diff --git a/init.bat b/init.bat index 2ea0399..a83d505 100644 --- a/init.bat +++ b/init.bat @@ -13,21 +13,22 @@ cd /d "%repoRoot%" git submodule update --init --recursive -REM google protobuf -cd third_party\_submodules\protobuf -git checkout v3.19.3 -git submodule update --init --recursive - REM Build and install the C++ Protocol Buffer runtime and the Protocol Buffer compiler (protoc) REM Refer: https://github.com/protocolbuffers/protobuf/blob/3.19.x/cmake/README.md#cmake-configuration -cd cmake +cd third_party\_submodules\protobuf\cmake REM use Debug version REM - protobuf_MSVC_STATIC_RUNTIME defaults to ON, which uses static CRT (/MTd for Debug). REM Our project's CMakeLists.txt also sets static CRT to match. REM - protobuf_WITH_ZLIB=OFF: disable ZLIB dependency to avoid ZLIB::ZLIB link requirement REM in protobuf's exported CMake targets, which simplifies cross-platform builds. REM - protobuf_BUILD_SHARED_LIBS=OFF: build static libraries explicitly. -cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF +cmake -S . -B build -G Ninja ^ + -DCMAKE_BUILD_TYPE=Debug ^ + -DCMAKE_CXX_STANDARD=17 ^ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ^ + -Dprotobuf_BUILD_TESTS=OFF ^ + -Dprotobuf_WITH_ZLIB=OFF ^ + -Dprotobuf_BUILD_SHARED_LIBS=OFF REM Compile the code cmake --build build --parallel diff --git a/init.sh b/init.sh index 7b4ee9d..84b7a1f 100755 --- a/init.sh +++ b/init.sh @@ -11,23 +11,21 @@ git submodule update --init --recursive # On Ubuntu/Debian, you can install them with: # sudo apt-get install autoconf automake libtool curl make g++ unzip -### reference: https://github.com/protocolbuffers/protobuf/tree/v3.19.3/src - -# google protobuf -cd third_party/_submodules/protobuf -git checkout v3.19.3 -git submodule update --init --recursive - # Build and install the C++ Protocol Buffer runtime and the Protocol Buffer compiler (protoc) # Refer: https://github.com/protocolbuffers/protobuf/blob/3.19.x/cmake/README.md#cmake-configuration -cd cmake +cd third_party/_submodules/protobuf/cmake # use Debug version # - protobuf_MSVC_STATIC_RUNTIME defaults to ON, which uses static CRT (/MTd for Debug). # Our project's CMakeLists.txt also sets static CRT to match. # - protobuf_WITH_ZLIB=OFF: disable ZLIB dependency to avoid ZLIB::ZLIB link requirement # in protobuf's exported CMake targets, which simplifies cross-platform builds. # - protobuf_BUILD_SHARED_LIBS=OFF: build static libraries explicitly. -cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF +cmake -S . -B build -G Ninja \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_CXX_STANDARD=17 \ + -Dprotobuf_BUILD_TESTS=OFF \ + -Dprotobuf_WITH_ZLIB=OFF \ + -Dprotobuf_BUILD_SHARED_LIBS=OFF # Compile the code cmake --build build --parallel diff --git a/test/cpp-tableau-loader/CMakeLists.txt b/test/cpp-tableau-loader/CMakeLists.txt index 0297c3e..11a2823 100644 --- a/test/cpp-tableau-loader/CMakeLists.txt +++ b/test/cpp-tableau-loader/CMakeLists.txt @@ -59,5 +59,24 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) # link libraries target_link_libraries(${PROJECT_NAME} protobuf::libprotobuf) if(NOT MSVC) + # When using clang with a GCC toolchain (e.g. gcc-toolset-13 on RHEL/CentOS), + # clang selects GCC 13's C++ headers but the C compiler (GCC 8) may inject an + # older libstdc++ search path into the link line. This causes undefined references + # to symbols like std::__throw_bad_array_new_length() and std::filesystem::*. + # Detect the GCC library directory used by the CXX compiler and link stdc++/stdc++fs + # from there explicitly. + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + execute_process( + COMMAND ${CMAKE_CXX_COMPILER} -print-libgcc-file-name + OUTPUT_VARIABLE _LIBGCC_FILE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(_LIBGCC_FILE) + get_filename_component(_GCC_LIB_DIR "${_LIBGCC_FILE}" DIRECTORY) + message(STATUS "Detected GCC library directory for clang: ${_GCC_LIB_DIR}") + # Prepend GCC toolchain lib dir so it is searched before the system GCC 8 path. + target_link_options(${PROJECT_NAME} PRIVATE "-L${_GCC_LIB_DIR}") + endif() + endif() target_link_libraries(${PROJECT_NAME} pthread stdc++fs) endif() From 60c4dd1fbba0c4a3bcfd54aeaad025fc726ae6d7 Mon Sep 17 00:00:00 2001 From: Kybxd <627940450@qq.com> Date: Thu, 26 Mar 2026 10:50:20 +0800 Subject: [PATCH 4/5] style: Add clang-format off comments to generated files --- cmd/protoc-gen-cpp-tableau-loader/helper/helper.go | 1 + test/cpp-tableau-loader/src/protoconf/hero_conf.pc.cc | 1 + test/cpp-tableau-loader/src/protoconf/hero_conf.pc.h | 1 + test/cpp-tableau-loader/src/protoconf/hub.pc.cc | 1 + test/cpp-tableau-loader/src/protoconf/hub.pc.h | 1 + test/cpp-tableau-loader/src/protoconf/hub_shard0.pc.cc | 1 + test/cpp-tableau-loader/src/protoconf/hub_shard1.pc.cc | 1 + test/cpp-tableau-loader/src/protoconf/index_conf.pc.cc | 1 + test/cpp-tableau-loader/src/protoconf/index_conf.pc.h | 1 + test/cpp-tableau-loader/src/protoconf/item_conf.pc.cc | 1 + test/cpp-tableau-loader/src/protoconf/item_conf.pc.h | 1 + test/cpp-tableau-loader/src/protoconf/load.pc.cc | 1 + test/cpp-tableau-loader/src/protoconf/load.pc.h | 1 + test/cpp-tableau-loader/src/protoconf/logger.pc.cc | 1 + test/cpp-tableau-loader/src/protoconf/logger.pc.h | 1 + test/cpp-tableau-loader/src/protoconf/patch_conf.pc.cc | 1 + test/cpp-tableau-loader/src/protoconf/patch_conf.pc.h | 1 + test/cpp-tableau-loader/src/protoconf/scheduler.pc.cc | 1 + test/cpp-tableau-loader/src/protoconf/scheduler.pc.h | 1 + test/cpp-tableau-loader/src/protoconf/test_conf.pc.cc | 1 + test/cpp-tableau-loader/src/protoconf/test_conf.pc.h | 1 + test/cpp-tableau-loader/src/protoconf/util.pc.cc | 1 + test/cpp-tableau-loader/src/protoconf/util.pc.h | 1 + 23 files changed, 23 insertions(+) diff --git a/cmd/protoc-gen-cpp-tableau-loader/helper/helper.go b/cmd/protoc-gen-cpp-tableau-loader/helper/helper.go index d309115..2f83204 100644 --- a/cmd/protoc-gen-cpp-tableau-loader/helper/helper.go +++ b/cmd/protoc-gen-cpp-tableau-loader/helper/helper.go @@ -26,6 +26,7 @@ func GenerateCommonHeader(gen *protogen.Plugin, g *protogen.GeneratedFile, versi g.P("// versions:") g.P("// - protoc-gen-cpp-tableau-loader v", version) g.P("// - protoc ", protocVersion(gen)) + g.P("// clang-format off") } func protocVersion(gen *protogen.Plugin) string { diff --git a/test/cpp-tableau-loader/src/protoconf/hero_conf.pc.cc b/test/cpp-tableau-loader/src/protoconf/hero_conf.pc.cc index 1b7e142..3d5235a 100644 --- a/test/cpp-tableau-loader/src/protoconf/hero_conf.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/hero_conf.pc.cc @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off // source: hero_conf.proto #include "hero_conf.pc.h" diff --git a/test/cpp-tableau-loader/src/protoconf/hero_conf.pc.h b/test/cpp-tableau-loader/src/protoconf/hero_conf.pc.h index 50ee08c..0092db8 100644 --- a/test/cpp-tableau-loader/src/protoconf/hero_conf.pc.h +++ b/test/cpp-tableau-loader/src/protoconf/hero_conf.pc.h @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off // source: hero_conf.proto #pragma once diff --git a/test/cpp-tableau-loader/src/protoconf/hub.pc.cc b/test/cpp-tableau-loader/src/protoconf/hub.pc.cc index b3f1ac4..8cd60ff 100644 --- a/test/cpp-tableau-loader/src/protoconf/hub.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/hub.pc.cc @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off #include "hub.pc.h" diff --git a/test/cpp-tableau-loader/src/protoconf/hub.pc.h b/test/cpp-tableau-loader/src/protoconf/hub.pc.h index d5a8d55..3dec021 100644 --- a/test/cpp-tableau-loader/src/protoconf/hub.pc.h +++ b/test/cpp-tableau-loader/src/protoconf/hub.pc.h @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off #pragma once #include diff --git a/test/cpp-tableau-loader/src/protoconf/hub_shard0.pc.cc b/test/cpp-tableau-loader/src/protoconf/hub_shard0.pc.cc index c2efd03..a774e1c 100644 --- a/test/cpp-tableau-loader/src/protoconf/hub_shard0.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/hub_shard0.pc.cc @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off #include "hub.pc.h" diff --git a/test/cpp-tableau-loader/src/protoconf/hub_shard1.pc.cc b/test/cpp-tableau-loader/src/protoconf/hub_shard1.pc.cc index 2b8bb67..aada201 100644 --- a/test/cpp-tableau-loader/src/protoconf/hub_shard1.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/hub_shard1.pc.cc @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off #include "hub.pc.h" diff --git a/test/cpp-tableau-loader/src/protoconf/index_conf.pc.cc b/test/cpp-tableau-loader/src/protoconf/index_conf.pc.cc index ce1bb84..ef84941 100644 --- a/test/cpp-tableau-loader/src/protoconf/index_conf.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/index_conf.pc.cc @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off // source: index_conf.proto #include "index_conf.pc.h" diff --git a/test/cpp-tableau-loader/src/protoconf/index_conf.pc.h b/test/cpp-tableau-loader/src/protoconf/index_conf.pc.h index 09b2253..a9fa3e6 100644 --- a/test/cpp-tableau-loader/src/protoconf/index_conf.pc.h +++ b/test/cpp-tableau-loader/src/protoconf/index_conf.pc.h @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off // source: index_conf.proto #pragma once diff --git a/test/cpp-tableau-loader/src/protoconf/item_conf.pc.cc b/test/cpp-tableau-loader/src/protoconf/item_conf.pc.cc index d56d96c..722a75e 100644 --- a/test/cpp-tableau-loader/src/protoconf/item_conf.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/item_conf.pc.cc @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off // source: item_conf.proto #include "item_conf.pc.h" diff --git a/test/cpp-tableau-loader/src/protoconf/item_conf.pc.h b/test/cpp-tableau-loader/src/protoconf/item_conf.pc.h index 9e736ad..fd757f5 100644 --- a/test/cpp-tableau-loader/src/protoconf/item_conf.pc.h +++ b/test/cpp-tableau-loader/src/protoconf/item_conf.pc.h @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off // source: item_conf.proto #pragma once diff --git a/test/cpp-tableau-loader/src/protoconf/load.pc.cc b/test/cpp-tableau-loader/src/protoconf/load.pc.cc index 21fb8f7..ef25849 100644 --- a/test/cpp-tableau-loader/src/protoconf/load.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/load.pc.cc @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off #include "load.pc.h" diff --git a/test/cpp-tableau-loader/src/protoconf/load.pc.h b/test/cpp-tableau-loader/src/protoconf/load.pc.h index 050c3c0..a8cbef6 100644 --- a/test/cpp-tableau-loader/src/protoconf/load.pc.h +++ b/test/cpp-tableau-loader/src/protoconf/load.pc.h @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off #pragma once #include diff --git a/test/cpp-tableau-loader/src/protoconf/logger.pc.cc b/test/cpp-tableau-loader/src/protoconf/logger.pc.cc index 7e44155..ca604ac 100644 --- a/test/cpp-tableau-loader/src/protoconf/logger.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/logger.pc.cc @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off #include "logger.pc.h" diff --git a/test/cpp-tableau-loader/src/protoconf/logger.pc.h b/test/cpp-tableau-loader/src/protoconf/logger.pc.h index 5f83c57..2925cf9 100644 --- a/test/cpp-tableau-loader/src/protoconf/logger.pc.h +++ b/test/cpp-tableau-loader/src/protoconf/logger.pc.h @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off #pragma once #include diff --git a/test/cpp-tableau-loader/src/protoconf/patch_conf.pc.cc b/test/cpp-tableau-loader/src/protoconf/patch_conf.pc.cc index 8757af8..e943a3d 100644 --- a/test/cpp-tableau-loader/src/protoconf/patch_conf.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/patch_conf.pc.cc @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off // source: patch_conf.proto #include "patch_conf.pc.h" diff --git a/test/cpp-tableau-loader/src/protoconf/patch_conf.pc.h b/test/cpp-tableau-loader/src/protoconf/patch_conf.pc.h index 79c1305..c761d65 100644 --- a/test/cpp-tableau-loader/src/protoconf/patch_conf.pc.h +++ b/test/cpp-tableau-loader/src/protoconf/patch_conf.pc.h @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off // source: patch_conf.proto #pragma once diff --git a/test/cpp-tableau-loader/src/protoconf/scheduler.pc.cc b/test/cpp-tableau-loader/src/protoconf/scheduler.pc.cc index 271b10c..a102e52 100644 --- a/test/cpp-tableau-loader/src/protoconf/scheduler.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/scheduler.pc.cc @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off #include "scheduler.pc.h" diff --git a/test/cpp-tableau-loader/src/protoconf/scheduler.pc.h b/test/cpp-tableau-loader/src/protoconf/scheduler.pc.h index 96cf5c1..7b34521 100644 --- a/test/cpp-tableau-loader/src/protoconf/scheduler.pc.h +++ b/test/cpp-tableau-loader/src/protoconf/scheduler.pc.h @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off #pragma once diff --git a/test/cpp-tableau-loader/src/protoconf/test_conf.pc.cc b/test/cpp-tableau-loader/src/protoconf/test_conf.pc.cc index b60385c..4422fcd 100644 --- a/test/cpp-tableau-loader/src/protoconf/test_conf.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/test_conf.pc.cc @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off // source: test_conf.proto #include "test_conf.pc.h" diff --git a/test/cpp-tableau-loader/src/protoconf/test_conf.pc.h b/test/cpp-tableau-loader/src/protoconf/test_conf.pc.h index c8c91e2..ecf62d9 100644 --- a/test/cpp-tableau-loader/src/protoconf/test_conf.pc.h +++ b/test/cpp-tableau-loader/src/protoconf/test_conf.pc.h @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off // source: test_conf.proto #pragma once diff --git a/test/cpp-tableau-loader/src/protoconf/util.pc.cc b/test/cpp-tableau-loader/src/protoconf/util.pc.cc index 3f1e63c..61e0495 100644 --- a/test/cpp-tableau-loader/src/protoconf/util.pc.cc +++ b/test/cpp-tableau-loader/src/protoconf/util.pc.cc @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off #include "util.pc.h" diff --git a/test/cpp-tableau-loader/src/protoconf/util.pc.h b/test/cpp-tableau-loader/src/protoconf/util.pc.h index 70ec5eb..9216118 100644 --- a/test/cpp-tableau-loader/src/protoconf/util.pc.h +++ b/test/cpp-tableau-loader/src/protoconf/util.pc.h @@ -2,6 +2,7 @@ // versions: // - protoc-gen-cpp-tableau-loader v0.11.0 // - protoc v3.19.3 +// clang-format off #pragma once #include From fdb836e7f256832b4f0a9031f2b4770981e14b73 Mon Sep 17 00:00:00 2001 From: Kybxd <627940450@qq.com> Date: Mon, 30 Mar 2026 22:33:08 +0800 Subject: [PATCH 5/5] feat: Add test case for CustomItemConf --- test/csharp-tableau-loader/Program.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/csharp-tableau-loader/Program.cs b/test/csharp-tableau-loader/Program.cs index 95273a8..63231a2 100644 --- a/test/csharp-tableau-loader/Program.cs +++ b/test/csharp-tableau-loader/Program.cs @@ -127,6 +127,16 @@ static void Main(string[] _) } } + var customItemConf = hub.Get(); + if (customItemConf is null) + { + Console.WriteLine("CustomItemConf is null"); + } + else + { + Console.WriteLine($"specialItemName: {customItemConf.GetSpecialItemName()}"); + } + LoadBin(); }