File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -76,4 +76,15 @@ describe("CSharpExtractor", () => {
7676 subprojectUsingDirectives . includes ( "global using MyApp.Models;" ) ,
7777 ) . toBe ( true ) ;
7878 } ) ;
79+
80+ test ( "should manage nested classes" , ( ) => {
81+ const extracted = extractor . extractSymbolFromFile ( programpath , "Program" ) ;
82+ const symbols = extracted ?. map ( ( file ) =>
83+ file . symbol . namespace !== ""
84+ ? file . symbol . namespace + "." + file . symbol . name
85+ : file . symbol . name ,
86+ ) ;
87+ expect ( symbols ) . not . toContain ( "OuterNamespace.OuterInnerClass" ) ;
88+ expect ( symbols ) . toContain ( "OuterNamespace.OuterClass" ) ;
89+ } ) ;
7990} ) ;
Original file line number Diff line number Diff line change @@ -141,6 +141,10 @@ export class CSharpExtractor {
141141 const visitedSymbols = new Set < string > ( ) ;
142142
143143 const addExtractedFile = ( symbol : SymbolNode ) => {
144+ // If the symbol is nested, we export the parent.
145+ while ( symbol . parent ) {
146+ symbol = symbol . parent ;
147+ }
144148 if ( ! visitedSymbols . has ( symbol . name ) ) {
145149 visitedSymbols . add ( symbol . name ) ;
146150 const subproject = this . projectMapper . findSubprojectForFile (
You can’t perform that action at this time.
0 commit comments