File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 22using System . Collections . Concurrent ;
33using System . Collections . Generic ;
44using System . Diagnostics ;
5+ using System . IO ;
56using System . Linq ;
67using Microsoft . CodeAnalysis ;
78using Microsoft . CodeAnalysis . CSharp ;
@@ -53,6 +54,20 @@ private static void AnalyseStandalone(
5354 }
5455
5556 progressMonitor . MissingSummary ( analyser . ExtractionContext ! . MissingTypes . Count ( ) , analyser . ExtractionContext ! . MissingNamespaces . Count ( ) ) ;
57+
58+ // If extracting a base database, we need to create an empty metadata file.
59+ if ( EnvironmentVariables . GetBaseMetaDataOutPath ( ) is string baseMetaDataOutPath )
60+ {
61+ try
62+ {
63+ analyser . Logger . LogInfo ( $ "Creating base metadata file at { baseMetaDataOutPath } ") ;
64+ File . WriteAllText ( baseMetaDataOutPath , string . Empty ) ;
65+ }
66+ catch ( Exception ex )
67+ {
68+ analyser . Logger . LogError ( $ "Failed to create base metadata file: { ex . Message } ") ;
69+ }
70+ }
5671 } ) ;
5772 }
5873 finally
Original file line number Diff line number Diff line change @@ -67,5 +67,14 @@ public static IEnumerable<string> GetURLs(string name)
6767 {
6868 return Environment . GetEnvironmentVariable ( "CODEQL_EXTRACTOR_CSHARP_OVERLAY_CHANGES" ) ;
6969 }
70+
71+ /// <summary>
72+ /// If the environment variable is set, the extractor is being called to extract a base database.
73+ /// Its value will be a path, and the extractor must create either a file or directory at that location.
74+ /// </summary>
75+ public static string ? GetBaseMetaDataOutPath ( )
76+ {
77+ return Environment . GetEnvironmentVariable ( "CODEQL_EXTRACTOR_CSHARP_OVERLAY_BASE_METADATA_OUT" ) ;
78+ }
7079 }
7180}
You can’t perform that action at this time.
0 commit comments