Skip to content

Commit

Permalink
[generator] Don't process duplicate reference assemblies (#611)
Browse files Browse the repository at this point in the history
When a binding project references another binding project, the list
of references assemblies can contain duplicates, e.g. `mscorlib`:

	[0]: "C:\\Program Files (x86)\\Microsoft Visual 	Studio\\2019\\Preview\\Common7\\IDE\\ReferenceAssemblies\\Microsoft\\Framework\\MonoAndroid\\v1.0\\mscorlib.dll"
	[1]: "C:\\code\\XamarinComponents\\Android\\BetterPickers\\source\\AndroidSwitchBackport\\bin\\Debug\\AndroidSwitchBackport.dll"
	[2]: "C:\\Program Files (x86)\\Microsoft Visual 	Studio\\2019\\Preview\\Common7\\IDE\\ReferenceAssemblies\\Microsoft\\Framework\\MonoAndroid\\v1.0\\Java.Interop.dll"
	[3]: "C:\\Program Files (x86)\\Microsoft Visual 	Studio\\2019\\Preview\\Common7\\IDE\\ReferenceAssemblies\\Microsoft\\Framework\\MonoAndroid\\v9.0\\Mono.Android.dll"
	[4]: "C:\\Program Files (x86)\\Microsoft Visual 	Studio\\2019\\Preview\\Common7\\IDE\\ReferenceAssemblies\\Microsoft\\Framework\\MonoAndroid\\v1.0\\mscorlib.dll"
	[5]: "C:\\Program Files (x86)\\Microsoft Visual 	Studio\\2019\\Preview\\Common7\\IDE\\ReferenceAssemblies\\Microsoft\\Framework\\MonoAndroid\\v1.0\\System.Core.dll"
	[6]: "C:\\Program Files (x86)\\Microsoft Visual 	Studio\\2019\\Preview\\Common7\\IDE\\ReferenceAssemblies\\Microsoft\\Framework\\MonoAndroid\\v1.0\\System.dll"
	[7]: "C:\\Program Files (x86)\\Microsoft Visual 	Studio\\2019\\Preview\\Common7\\IDE\\ReferenceAssemblies\\Microsoft\\Framework\\MonoAndroid\\v1.0\\Facades\\System.Runtime.dll"
	[8]: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\Common7\\IDE\\ReferenceAssemblies\\Microsoft\\Framework\\MonoAndroid\\v1.0\\System.Xml.dll"

There is no reason to scan any duplicate assemblies a second time, so
add an `Enumerable.Distinct()` to prevent duplicates.
  • Loading branch information
jpobst authored Mar 24, 2020
1 parent f5fa462 commit cf3e7c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/generator/CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void Run (CodeGeneratorOptions options, DirectoryAssemblyResolver resolve
// every type to be fully populated.
opt.UseShallowReferencedTypes = apiSourceAttr != "class-parse";

foreach (var reference in references) {
foreach (var reference in references.Distinct ()) {
try {
Report.Verbose (0, "resolving assembly {0}.", reference);
var assembly = resolver.Load (reference);
Expand Down

0 comments on commit cf3e7c2

Please sign in to comment.