You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I got some unexpected behaviour when trying to optimise collection proto files.
Seems like imports a.proto won't be removed if any of proto file in collection has a dependency to a.proto
File test/file_with_redundant_dependency.proto contains redundant import import "test/dependency.proto";. After using Pruner, I expected to get a file without this import, but that's not really the case.
@Test
public void should_remove_redundant_import() {
// given
var loader = new SchemaLoader(FileSystems.getDefault());
var linker = new Linker(loader, new ErrorCollector(), true, true);
var testFileLocation = Location.get("<TEST_FILE_LOCATION>");
loader.initRoots(List.of(testFileLocation), List.of(testFileLocation));
var fileWithDependency = loader.load("test/file_with_dependency.proto");
var fileWithRedundantDependency = loader.load("test/file_with_redundant_dependency.proto");
var schema = linker.link(List.of(fileWithDependency, fileWithRedundantDependency));
// when
var optimizedSchema = schema.prune(new PruningRules.Builder()
.addRoot(List.of(
"test.dependency.TestMessage",
"test.dependency.TestMessageWithDependency"))
.build());
var optimizedProtoFile = optimizedSchema.protoFile("test/file_with_redundant_dependency.proto");
// then
assertThat(optimizedProtoFile.toSchema())
.isEqualTo("""
// Proto schema formatted by Wire, do not edit.
// Source: test/file_with_redundant_dependency.proto
syntax = "proto3";
package test.dependency;
message TestMessage {
string field_1 = 1;
}
""");
}
Hi! I got some unexpected behaviour when trying to optimise collection proto files.
Seems like
imports a.proto
won't be removed if any of proto file in collection has a dependency toa.proto
File
test/file_with_redundant_dependency.proto
contains redundant importimport "test/dependency.proto";
. After using Pruner, I expected to get a file without this import, but that's not really the case.test/file_with_dependency.proto
test/file_with_redundant_dependency.proto
test/dependency.proto
The text was updated successfully, but these errors were encountered: