aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs')
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs22
1 files changed, 17 insertions, 5 deletions
diff --git a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs
index ae819801..30718709 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/DescriptorPool.cs
@@ -50,14 +50,15 @@ namespace Google.ProtocolBuffers.Descriptors
private readonly IDictionary<DescriptorIntPair, EnumValueDescriptor> enumValuesByNumber =
new Dictionary<DescriptorIntPair, EnumValueDescriptor>();
- private readonly DescriptorPool[] dependencies;
+ private readonly HashSet<FileDescriptor> dependencies;
internal DescriptorPool(FileDescriptor[] dependencyFiles)
{
- dependencies = new DescriptorPool[dependencyFiles.Length];
+ dependencies = new HashSet<FileDescriptor>();
for (int i = 0; i < dependencyFiles.Length; i++)
{
- dependencies[i] = dependencyFiles[i].DescriptorPool;
+ dependencies.Add(dependencyFiles[i]);
+ ImportPublicDependencies(dependencyFiles[i]);
}
foreach (FileDescriptor dependency in dependencyFiles)
@@ -66,6 +67,17 @@ namespace Google.ProtocolBuffers.Descriptors
}
}
+ private void ImportPublicDependencies(FileDescriptor file)
+ {
+ foreach (FileDescriptor dependency in file.PublicDependencies)
+ {
+ if (dependencies.Add(dependency))
+ {
+ ImportPublicDependencies(dependency);
+ }
+ }
+ }
+
/// <summary>
/// Finds a symbol of the given name within the pool.
/// </summary>
@@ -83,9 +95,9 @@ namespace Google.ProtocolBuffers.Descriptors
return descriptor;
}
- foreach (DescriptorPool dependency in dependencies)
+ foreach (FileDescriptor dependency in dependencies)
{
- dependency.descriptorsByName.TryGetValue(fullName, out result);
+ dependency.DescriptorPool.descriptorsByName.TryGetValue(fullName, out result);
descriptor = result as T;
if (descriptor != null)
{