|
|
|
@ -98,8 +98,9 @@ namespace Google.Protobuf.Reflection |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return dictionary; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
IDescriptor FindDescriptorForPath(IList<int> path) |
|
|
|
|
private IDescriptor FindDescriptorForPath(IList<int> path) |
|
|
|
|
{ |
|
|
|
|
// All complete declarations have an even, non-empty path length |
|
|
|
|
// (There can be an empty path for a descriptor declaration, but that can't have any comments, |
|
|
|
@ -119,7 +120,7 @@ namespace Google.Protobuf.Reflection |
|
|
|
|
return current; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DescriptorBase GetDescriptorFromList(IReadOnlyList<DescriptorBase> list, int index) |
|
|
|
|
private DescriptorBase GetDescriptorFromList(IReadOnlyList<DescriptorBase> list, int index) |
|
|
|
|
{ |
|
|
|
|
// This is fine: it may be a newer version of protobuf than we understand, with a new descriptor |
|
|
|
|
// field. |
|
|
|
@ -137,7 +138,7 @@ namespace Google.Protobuf.Reflection |
|
|
|
|
return list[index]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
IReadOnlyList<DescriptorBase> GetNestedDescriptorListForField(int fieldNumber) |
|
|
|
|
private IReadOnlyList<DescriptorBase> GetNestedDescriptorListForField(int fieldNumber) |
|
|
|
|
{ |
|
|
|
|
switch (fieldNumber) |
|
|
|
|
{ |
|
|
|
@ -151,11 +152,11 @@ namespace Google.Protobuf.Reflection |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal DescriptorDeclaration GetDeclaration(IDescriptor descriptor) |
|
|
|
|
{ |
|
|
|
|
declarations.Value.TryGetValue(descriptor, out var declaration); |
|
|
|
|
DescriptorDeclaration declaration; |
|
|
|
|
declarations.Value.TryGetValue(descriptor, out declaration); |
|
|
|
|
return declaration; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -191,7 +192,8 @@ namespace Google.Protobuf.Reflection |
|
|
|
|
throw new DescriptorValidationException(@this, "Invalid public dependency index."); |
|
|
|
|
} |
|
|
|
|
string name = proto.Dependency[index]; |
|
|
|
|
if (!nameToFileMap.TryGetValue(name, out var file)) |
|
|
|
|
FileDescriptor file; |
|
|
|
|
if (!nameToFileMap.TryGetValue(name, out file)) |
|
|
|
|
{ |
|
|
|
|
if (!allowUnknownDependencies) |
|
|
|
|
{ |
|
|
|
@ -414,7 +416,8 @@ namespace Google.Protobuf.Reflection |
|
|
|
|
var dependencies = new List<FileDescriptor>(); |
|
|
|
|
foreach (var dependencyName in proto.Dependency) |
|
|
|
|
{ |
|
|
|
|
if (!descriptorsByName.TryGetValue(dependencyName, out var dependency)) |
|
|
|
|
FileDescriptor dependency; |
|
|
|
|
if (!descriptorsByName.TryGetValue(dependencyName, out dependency)) |
|
|
|
|
{ |
|
|
|
|
throw new ArgumentException($"Dependency missing: {dependencyName}"); |
|
|
|
|
} |
|
|
|
|