Use Distinct on depended extensions to filter duplicate extensions

pull/6938/head
Sydney Acksman 5 years ago
parent a9f390f44e
commit 3c2a32a75f
  1. 7
      csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs

@ -422,7 +422,8 @@ namespace Google.Protobuf.Reflection
GeneratedClrTypeInfo generatedCodeInfo)
{
ExtensionRegistry registry = new ExtensionRegistry();
AddAllExtensions(dependencies, generatedCodeInfo, registry);
registry.AddRange(GetAllExtensions(dependencies, generatedCodeInfo));
FileDescriptorProto proto;
try
{
@ -445,9 +446,9 @@ namespace Google.Protobuf.Reflection
}
}
private static void AddAllExtensions(FileDescriptor[] dependencies, GeneratedClrTypeInfo generatedInfo, ExtensionRegistry registry)
private static IEnumerable<Extension> GetAllExtensions(FileDescriptor[] dependencies, GeneratedClrTypeInfo generatedInfo)
{
registry.AddRange(dependencies.SelectMany(GetAllDependedExtensions).Concat(GetAllGeneratedExtensions(generatedInfo)).ToArray());
return dependencies.SelectMany(GetAllDependedExtensions).Distinct().Concat(GetAllGeneratedExtensions(generatedInfo));
}
private static IEnumerable<Extension> GetAllGeneratedExtensions(GeneratedClrTypeInfo generated)

Loading…
Cancel
Save