File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
nuget/Sqlite_net.SourceGenerator Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -335,7 +335,9 @@ static void Execute(
335335 {
336336 if ( classes . IsDefaultOrEmpty )
337337 return ;
338-
338+
339+ classes = RemoveDuplicates ( classes ) ;
340+
339341 // Get the assembly name/namespace from the compilation
340342 var assemblyName = compilation . AssemblyName ?? "Generated" ;
341343 var rootNamespace = GetRootNamespace ( configOptionsProvider , compilation ) ?? assemblyName ;
@@ -393,6 +395,25 @@ static void Execute(
393395 context . AddSource ( "SQLiteInitializer.g.cs" , SourceText . From ( sb . ToString ( ) , Encoding . UTF8 ) ) ;
394396 }
395397
398+ private static ImmutableArray < ClassInfo > RemoveDuplicates ( ImmutableArray < ClassInfo > classes )
399+ {
400+ Dictionary < string , ClassInfo > existing = new ( ) ;
401+
402+ foreach ( var it in classes ) {
403+ var fullTypeName = FullTypeName ( it ) ;
404+ if ( existing . TryGetValue ( fullTypeName , out var current ) ) {
405+ if ( it . Properties . Count > current . Properties . Count ) {
406+ existing [ fullTypeName ] = it ;
407+ }
408+ }
409+ else {
410+ existing [ fullTypeName ] = it ;
411+ }
412+ }
413+
414+ return existing . Values . ToImmutableArray ( ) ;
415+ }
416+
396417 static string FullTypeName ( ClassInfo classInfo )
397418 {
398419 return string . IsNullOrEmpty ( classInfo . Namespace )
You can’t perform that action at this time.
0 commit comments