@@ -17,6 +17,7 @@ import {
1717 InternalSymbol ,
1818 ExternalSymbol ,
1919} from "../../languagePlugins/csharp/usingResolver/index.js" ;
20+ import { CSharpInvocationResolver } from "../../languagePlugins/csharp/invocationResolver/index.js" ;
2021
2122/**
2223 * Extracts C# symbols from the given files.
@@ -86,20 +87,25 @@ export function extractCSharpSymbols(
8687 }
8788 }
8889 }
89- // For each extracted file, check if the using directives are still valid
90+ // For each extracted file, check if the using directives are still valid and useful
9091 const nsMapper = new CSharpNamespaceMapper ( parsedFiles ) ;
9192 const pjMapper = new CSharpProjectMapper ( csprojFiles ) ;
9293 const usingResolver = new CSharpUsingResolver ( nsMapper , pjMapper ) ;
94+ const invocationResolver = new CSharpInvocationResolver ( nsMapper , pjMapper ) ;
9395 for ( const extractedFile of extractedFiles ) {
9496 const imports = extractedFile . imports ;
97+ const invocations = invocationResolver . getInvocationsFromFile (
98+ extractedFile . name ,
99+ ) ;
95100 for ( const importDirective of imports ) {
96101 const resolvedInNewFile =
97102 usingResolver . resolveUsingDirective ( importDirective ) ;
98103 const resolvedInOldFile =
99104 extractor . usingResolver . resolveUsingDirective ( importDirective ) ;
100105 if (
101- resolvedInNewFile instanceof ExternalSymbol &&
102- resolvedInOldFile instanceof InternalSymbol
106+ ( resolvedInNewFile instanceof ExternalSymbol &&
107+ resolvedInOldFile instanceof InternalSymbol ) ||
108+ ! invocationResolver . isUsingUseful ( invocations , importDirective )
103109 ) {
104110 extractedFile . imports = extractedFile . imports . filter (
105111 ( imp ) => imp !== importDirective ,
0 commit comments