@@ -38,7 +38,7 @@ private static string ProjectFileName(string project) =>
3838 private static string SourceFileName ( string project , string fileName ) =>
3939 Path . Combine ( "TestProjects" , project , fileName ) ;
4040
41- private ( string , ProjectInformation ) Context ( string project )
41+ private ( string , ProjectInformation ? ) Context ( string project )
4242 {
4343 var relativePath = ProjectFileName ( project ) ;
4444 var uri = new Uri ( Path . GetFullPath ( relativePath ) ) ;
@@ -73,18 +73,18 @@ public void SupportedTargetFrameworks()
7373 [ TestMethod ]
7474 public void FindProjectTargetFramework ( )
7575 {
76- void CompareFramework ( string project , string expected )
76+ void CompareFramework ( string project , string ? expected )
7777 {
7878 var projectFileName = ProjectFileName ( project ) ;
7979 var props = new ProjectLoader ( ) . DesignTimeBuildProperties ( projectFileName , out var _ , ( x , y ) => ( y . Contains ( '.' ) ? 1 : 0 ) - ( x . Contains ( '.' ) ? 1 : 0 ) ) ;
80- if ( ! props . TryGetValue ( "TargetFramework" , out string actual ) )
80+ if ( ! props . TryGetValue ( "TargetFramework" , out var actual ) )
8181 {
8282 actual = null ;
8383 }
8484 Assert . AreEqual ( expected , actual ) ;
8585 }
8686
87- var testProjects = new ( string , string ) [ ]
87+ var testProjects = new ( string , string ? ) [ ]
8888 {
8989 ( "test1" , "netcoreapp2.1" ) ,
9090 ( "test2" , "netstandard2.0" ) ,
@@ -129,10 +129,10 @@ public void LoadNonQsharpProjects()
129129 public void LoadOutdatedQsharpProject ( )
130130 {
131131 var ( projectFile , context ) = this . Context ( "test9" ) ;
132- var projDir = Path . GetDirectoryName ( projectFile ) ;
132+ var projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
133133 Assert . IsNotNull ( context ) ;
134- Assert . AreEqual ( "test9.dll" , Path . GetFileName ( context . Properties . OutputPath ) ) ;
135- Assert . IsTrue ( Path . GetDirectoryName ( context . Properties . OutputPath ) . StartsWith ( projDir ) ) ;
134+ Assert . AreEqual ( "test9.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
135+ Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
136136
137137 var qsFiles = new string [ ]
138138 {
@@ -149,10 +149,10 @@ public void LoadOutdatedQsharpProject()
149149 public void LoadQsharpCoreLibraries ( )
150150 {
151151 var ( projectFile , context ) = this . Context ( "test3" ) ;
152- var projDir = Path . GetDirectoryName ( projectFile ) ;
152+ var projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
153153 Assert . IsNotNull ( context ) ;
154- Assert . AreEqual ( "test3.dll" , Path . GetFileName ( context . Properties . OutputPath ) ) ;
155- Assert . IsTrue ( Path . GetDirectoryName ( context . Properties . OutputPath ) . StartsWith ( projDir ) ) ;
154+ Assert . AreEqual ( "test3.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
155+ Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
156156
157157 var qsFiles = new string [ ]
158158 {
@@ -168,10 +168,10 @@ public void LoadQsharpCoreLibraries()
168168 CollectionAssert . AreEquivalent ( qsFiles , context . SourceFiles . ToArray ( ) ) ;
169169
170170 ( projectFile , context ) = this . Context ( "test12" ) ;
171- projDir = Path . GetDirectoryName ( projectFile ) ;
171+ projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
172172 Assert . IsNotNull ( context ) ;
173- Assert . AreEqual ( "test12.dll" , Path . GetFileName ( context . Properties . OutputPath ) ) ;
174- Assert . IsTrue ( Path . GetDirectoryName ( context . Properties . OutputPath ) . StartsWith ( projDir ) ) ;
173+ Assert . AreEqual ( "test12.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
174+ Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
175175
176176 qsFiles = new string [ ]
177177 {
@@ -191,10 +191,10 @@ public void LoadQsharpCoreLibraries()
191191 public void LoadQsharpFrameworkLibrary ( )
192192 {
193193 var ( projectFile , context ) = this . Context ( "test7" ) ;
194- var projDir = Path . GetDirectoryName ( projectFile ) ;
194+ var projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
195195 Assert . IsNotNull ( context ) ;
196- Assert . AreEqual ( "test7.dll" , Path . GetFileName ( context . Properties . OutputPath ) ) ;
197- Assert . IsTrue ( Path . GetDirectoryName ( context . Properties . OutputPath ) . StartsWith ( projDir ) ) ;
196+ Assert . AreEqual ( "test7.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
197+ Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
198198
199199 var qsFiles = new string [ ]
200200 {
@@ -211,10 +211,10 @@ public void LoadQsharpFrameworkLibrary()
211211 public void LoadQsharpConsoleApps ( )
212212 {
213213 var ( projectFile , context ) = this . Context ( "test4" ) ;
214- var projDir = Path . GetDirectoryName ( projectFile ) ;
214+ var projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
215215 Assert . IsNotNull ( context ) ;
216- Assert . AreEqual ( "test4.dll" , Path . GetFileName ( context . Properties . OutputPath ) ) ;
217- Assert . IsTrue ( Path . GetDirectoryName ( context . Properties . OutputPath ) . StartsWith ( projDir ) ) ;
216+ Assert . AreEqual ( "test4.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
217+ Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
218218
219219 var qsFiles = new string [ ]
220220 {
@@ -228,10 +228,10 @@ public void LoadQsharpConsoleApps()
228228 CollectionAssert . AreEquivalent ( qsFiles , context . SourceFiles . ToArray ( ) ) ;
229229
230230 ( projectFile , context ) = this . Context ( "test10" ) ;
231- projDir = Path . GetDirectoryName ( projectFile ) ;
231+ projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
232232 Assert . IsNotNull ( context ) ;
233- Assert . AreEqual ( "test10.dll" , Path . GetFileName ( context . Properties . OutputPath ) ) ;
234- Assert . IsTrue ( Path . GetDirectoryName ( context . Properties . OutputPath ) . StartsWith ( projDir ) ) ;
233+ Assert . AreEqual ( "test10.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
234+ Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
235235
236236 qsFiles = new string [ ]
237237 {
@@ -243,10 +243,10 @@ public void LoadQsharpConsoleApps()
243243 CollectionAssert . AreEquivalent ( qsFiles , context . SourceFiles . ToArray ( ) ) ;
244244
245245 ( projectFile , context ) = this . Context ( "test11" ) ;
246- projDir = Path . GetDirectoryName ( projectFile ) ;
246+ projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
247247 Assert . IsNotNull ( context ) ;
248- Assert . AreEqual ( "test11.dll" , Path . GetFileName ( context . Properties . OutputPath ) ) ;
249- Assert . IsTrue ( Path . GetDirectoryName ( context . Properties . OutputPath ) . StartsWith ( projDir ) ) ;
248+ Assert . AreEqual ( "test11.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
249+ Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
250250
251251 qsFiles = new string [ ]
252252 {
@@ -262,10 +262,10 @@ public void LoadQsharpConsoleApps()
262262 public void LoadQsharpUnitTest ( )
263263 {
264264 var ( projectFile , context ) = this . Context ( "test5" ) ;
265- var projDir = Path . GetDirectoryName ( projectFile ) ;
265+ var projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
266266 Assert . IsNotNull ( context ) ;
267- Assert . AreEqual ( "test5.dll" , Path . GetFileName ( context . Properties . OutputPath ) ) ;
268- Assert . IsTrue ( Path . GetDirectoryName ( context . Properties . OutputPath ) . StartsWith ( projDir ) ) ;
267+ Assert . AreEqual ( "test5.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
268+ Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
269269
270270 var qsFiles = new string [ ]
271271 {
@@ -286,10 +286,10 @@ public void LoadQsharpUnitTest()
286286 public void LoadQsharpMultiFrameworkLibrary ( )
287287 {
288288 var ( projectFile , context ) = this . Context ( "test6" ) ;
289- var projDir = Path . GetDirectoryName ( projectFile ) ;
289+ var projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
290290 Assert . IsNotNull ( context ) ;
291- Assert . AreEqual ( "test6.dll" , Path . GetFileName ( context . Properties . OutputPath ) ) ;
292- Assert . IsTrue ( Path . GetDirectoryName ( context . Properties . OutputPath ) . StartsWith ( projDir ) ) ;
291+ Assert . AreEqual ( "test6.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
292+ Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
293293
294294 var qsFiles = new string [ ]
295295 {
@@ -314,8 +314,9 @@ public void LoadQsharpTemporaryProject()
314314
315315 var qsFiles = new string [ ] { sourceFile } ;
316316 var projectInformation = CompilationContext . Load ( projectUri ) ;
317- Assert . IsTrue ( projectInformation . UsesCanon ( ) ) ;
318- CollectionAssert . AreEquivalent ( qsFiles , projectInformation . SourceFiles . ToArray ( ) ) ;
317+ Assert . IsNotNull ( projectInformation ) ;
318+ Assert . IsTrue ( projectInformation ! . UsesCanon ( ) ) ;
319+ CollectionAssert . AreEquivalent ( qsFiles , projectInformation ! . SourceFiles . ToArray ( ) ) ;
319320 }
320321 }
321322
@@ -324,7 +325,7 @@ internal static class CompilationContext
324325 private static void LogOutput ( string msg , MessageType level ) =>
325326 Console . WriteLine ( $ "[{ level } ]: { msg } ") ;
326327
327- internal static ProjectInformation Load ( Uri projectFile ) =>
328+ internal static ProjectInformation ? Load ( Uri projectFile ) =>
328329 new EditorState ( new ProjectLoader ( LogOutput ) , null , null , null , null , null )
329330 . QsProjectLoader ( projectFile , out var loaded ) ? loaded : null ;
330331
0 commit comments