diff --git a/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs b/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs deleted file mode 100644 index 208ce1fcb631..000000000000 --- a/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs +++ /dev/null @@ -1,17 +0,0 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd -#endregion - -namespace Google.Protobuf.Reflection; - -internal sealed partial class FeatureSetDescriptor -{ - // Canonical serialized form of the edition defaults, generated by embed_edition_defaults. - private const string DefaultsBase64 = - "ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH"; -} diff --git a/hpb/extension.h b/hpb/extension.h index 6dea740af9b3..2cacc765426c 100644 --- a/hpb/extension.h +++ b/hpb/extension.h @@ -141,10 +141,23 @@ class ExtensionRegistry { } } + static const ExtensionRegistry& generated_registry() { + static const ExtensionRegistry* r = NewGeneratedRegistry(); + return *r; + } + private: friend upb_ExtensionRegistry* ::hpb::internal::GetUpbExtensions( const ExtensionRegistry& extension_registry); upb_ExtensionRegistry* registry_; + + // TODO: b/379100963 - Introduce ShutdownHpbLibrary + static const ExtensionRegistry* NewGeneratedRegistry() { + static upb::Arena* global_arena = new upb::Arena(); + ExtensionRegistry* registry = new ExtensionRegistry(*global_arena); + upb_ExtensionRegistry_AddAllLinkedExtensions(registry->registry_); + return registry; + } }; template (bytes.value(), extensions).value(); + ::hpb::Parse(bytes.value(), + hpb::ExtensionRegistry::generated_registry()) + .value(); EXPECT_EQ("Test123", parsed_model.str1()); EXPECT_EQ(true, hpb::GetExtension(&parsed_model, theme).ok()); EXPECT_EQ( @@ -1287,9 +1285,10 @@ TEST(CppGeneratedCode, HasExtensionAndRegistry) { std::string data = std::string(::hpb::Serialize(&source, arena).value()); // Test with ExtensionRegistry - hpb::ExtensionRegistry extensions(arena); - extensions.AddExtension(theme); - TestModel parsed_model = ::hpb::Parse(data, extensions).value(); + TestModel parsed_model = + ::hpb::Parse(data, + hpb::ExtensionRegistry::generated_registry()) + .value(); EXPECT_TRUE(::hpb::HasExtension(&parsed_model, theme)); }