@@ -107,20 +107,6 @@ private void OnExecute(
107107 {
108108 ClassDeclarationSyntax sourceDeclaration = sourceSyntaxTree . GetRoot ( ) . DescendantNodes ( ) . OfType < ClassDeclarationSyntax > ( ) . First ( ) ;
109109 UsingDirectiveSyntax [ ] usingDirectives = sourceSyntaxTree . GetRoot ( ) . DescendantNodes ( ) . OfType < UsingDirectiveSyntax > ( ) . ToArray ( ) ;
110- BaseListSyntax ? baseListSyntax = BaseList ( SeparatedList (
111- sourceDeclaration . BaseList ? . Types
112- . OfType < SimpleBaseTypeSyntax > ( )
113- . Select ( static t => t . Type )
114- . OfType < IdentifierNameSyntax > ( )
115- . Where ( static t => t . Identifier . ValueText . StartsWith ( "I" ) )
116- . Select ( static t => SimpleBaseType ( t ) )
117- . ToArray ( )
118- ?? Array . Empty < BaseTypeSyntax > ( ) ) ) ;
119-
120- if ( baseListSyntax . Types . Count == 0 )
121- {
122- baseListSyntax = null ;
123- }
124110
125111 // Create the class declaration for the user type. This will produce a tree as follows:
126112 //
@@ -131,7 +117,7 @@ private void OnExecute(
131117 var classDeclarationSyntax =
132118 ClassDeclaration ( classDeclaration . Identifier . Text )
133119 . WithModifiers ( classDeclaration . Modifiers )
134- . WithBaseList ( baseListSyntax )
120+ . WithBaseList ( sourceDeclaration . BaseList )
135121 . AddMembers ( FilterDeclaredMembers ( context , attributeData , classDeclaration , classDeclarationSymbol , sourceDeclaration ) . ToArray ( ) ) ;
136122
137123 TypeDeclarationSyntax typeDeclarationSyntax = classDeclarationSyntax ;
@@ -151,16 +137,12 @@ private void OnExecute(
151137 // From this, we can finally generate the source code to output.
152138 var namespaceName = classDeclarationSymbol . ContainingNamespace . ToDisplayString ( new ( typeQualificationStyle : NameAndContainingTypesAndNamespaces ) ) ;
153139
140+ // Create the final compilation unit to generate (with using directives and the full type declaration)
154141 var source =
155142 CompilationUnit ( )
156143 . AddMembers ( NamespaceDeclaration ( IdentifierName ( namespaceName ) )
157144 . AddMembers ( typeDeclarationSyntax ) )
158- . AddUsings ( usingDirectives . First ( ) . WithLeadingTrivia ( TriviaList (
159- Comment ( "// Licensed to the .NET Foundation under one or more agreements." ) ,
160- Comment ( "// The .NET Foundation licenses this file to you under the MIT license." ) ,
161- Comment ( "// See the LICENSE file in the project root for more information." ) ,
162- Trivia ( PragmaWarningDirectiveTrivia ( Token ( SyntaxKind . DisableKeyword ) , true ) ) ) ) )
163- . AddUsings ( usingDirectives . Skip ( 1 ) . ToArray ( ) )
145+ . AddUsings ( usingDirectives )
164146 . NormalizeWhitespace ( )
165147 . ToFullString ( ) ;
166148
0 commit comments