Breaking change: Remove deprecated GetPrototype MessageFactory.GetPrototype(),

MessageFactory.CreatePrototype(), MessageFactory.GetMessages(),
SymbolDatabase.GetPrototype(), SymbolDatabase.CreatePrototype(), SymbolDatabase.GetMessages()

Replacement APIs are: message_factory.GetMessages(), message_factory.GetMessageClass(), message_factory.GetMessageClassesForFiles()

PiperOrigin-RevId: 693421414
pull/19102/head
Jie Luo 4 months ago committed by Copybara-Service
parent 08d5ef9485
commit c261b49a95
  1. 17
      csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs
  2. 63
      python/google/protobuf/message_factory.py
  3. 22
      python/google/protobuf/symbol_database.py

@ -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";
}

@ -142,69 +142,6 @@ class MessageFactory(object):
"""Initializes a new factory."""
self.pool = pool or descriptor_pool.DescriptorPool()
def GetPrototype(self, descriptor):
"""Obtains a proto2 message class based on the passed in descriptor.
Passing a descriptor with a fully qualified name matching a previous
invocation will cause the same class to be returned.
Args:
descriptor: The descriptor to build from.
Returns:
A class describing the passed in descriptor.
"""
warnings.warn(
'MessageFactory class is deprecated. Please use '
'GetMessageClass() instead of MessageFactory.GetPrototype. '
'MessageFactory class will be removed after 2024.',
stacklevel=2,
)
return GetMessageClass(descriptor)
def CreatePrototype(self, descriptor):
"""Builds a proto2 message class based on the passed in descriptor.
Don't call this function directly, it always creates a new class. Call
GetMessageClass() instead.
Args:
descriptor: The descriptor to build from.
Returns:
A class describing the passed in descriptor.
"""
warnings.warn(
'Directly call CreatePrototype is wrong. Please use '
'GetMessageClass() method instead. Directly use '
'CreatePrototype will raise error after July 2023.',
stacklevel=2,
)
return _InternalCreateMessageClass(descriptor)
def GetMessages(self, files):
"""Gets all the messages from a specified file.
This will find and resolve dependencies, failing if the descriptor
pool cannot satisfy them.
Args:
files: The file names to extract messages from.
Returns:
A dictionary mapping proto names to the message classes. This will include
any dependent messages as well as any messages defined in the same file as
a specified message.
"""
warnings.warn(
'MessageFactory class is deprecated. Please use '
'GetMessageClassesForFiles() instead of '
'MessageFactory.GetMessages(). MessageFactory class '
'will be removed after 2024.',
stacklevel=2,
)
return GetMessageClassesForFiles(files, self.pool)
def GetMessages(file_protos, pool=None):
"""Builds a dictionary of all the messages available in a set of files.

@ -51,28 +51,6 @@ class SymbolDatabase():
"""Initializes a new SymbolDatabase."""
self.pool = pool or descriptor_pool.DescriptorPool()
def GetPrototype(self, descriptor):
warnings.warn(
'SymbolDatabase.GetPrototype() is deprecated. Please '
'use message_factory.GetMessageClass() instead. '
'SymbolDatabase.GetPrototype() will be removed in Jan 2025.'
)
return message_factory.GetMessageClass(descriptor)
def CreatePrototype(self, descriptor):
warnings.warn('Directly call CreatePrototype() is wrong. Please use '
'message_factory.GetMessageClass() instead. '
'SymbolDatabase.CreatePrototype() will be removed in '
'Jan 2025.')
return message_factory._InternalCreateMessageClass(descriptor)
def GetMessages(self, files):
warnings.warn('SymbolDatabase.GetMessages() is deprecated. Please use '
'message_factory.GetMessageClassedForFiles() instead. '
'SymbolDatabase.GetMessages() will be removed in '
'Jan 2025.')
return message_factory.GetMessageClassedForFiles(files, self.pool)
def RegisterMessage(self, message):
"""Registers the given message type in the local database.

Loading…
Cancel
Save