@@ -39,11 +39,13 @@ private static string ProjectFileName(string project) =>
3939 private static string SourceFileName ( string project , string fileName ) =>
4040 Path . Combine ( "TestProjects" , project , fileName ) ;
4141
42- private ( string , ProjectInformation ? ) Context ( string project )
42+ internal static Uri ProjectUri ( string project ) =>
43+ new Uri ( Path . GetFullPath ( ProjectFileName ( project ) ) ) ;
44+
45+ internal static ( Uri , ProjectInformation ? ) Context ( string project )
4346 {
44- var relativePath = ProjectFileName ( project ) ;
45- var uri = new Uri ( Path . GetFullPath ( relativePath ) ) ;
46- return ( uri . LocalPath , CompilationContext . Load ( uri ) ) ;
47+ var uri = ProjectUri ( project ) ;
48+ return ( uri , CompilationContext . Load ( uri ) ) ;
4749 }
4850
4951 [ TestMethod ]
@@ -75,7 +77,7 @@ public void SupportedTargetFrameworks()
7577 [ TestMethod ]
7678 public void FindProjectTargetFramework ( )
7779 {
78- void CompareFramework ( string project , string ? expected )
80+ static void CompareFramework ( string project , string ? expected )
7981 {
8082 var projectFileName = ProjectFileName ( project ) ;
8183 var props = new ProjectLoader ( ) . DesignTimeBuildProperties ( projectFileName , out var _ , ( x , y ) => ( y . Contains ( '.' ) ? 1 : 0 ) - ( x . Contains ( '.' ) ? 1 : 0 ) ) ;
@@ -123,16 +125,16 @@ public void LoadNonQSharpProjects()
123125
124126 foreach ( var project in invalidProjects )
125127 {
126- var ( _, context ) = this . Context ( project ) ;
128+ var ( _, context ) = Context ( project ) ;
127129 Assert . IsNull ( context ) ;
128130 }
129131 }
130132
131133 [ TestMethod ]
132134 public void LoadOutdatedQSharpProject ( )
133135 {
134- var ( projectFile , context ) = this . Context ( "test9" ) ;
135- var projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
136+ var ( projectFile , context ) = Context ( "test9" ) ;
137+ var projDir = Path . GetDirectoryName ( projectFile . LocalPath ) ?? "" ;
136138 Assert . IsNotNull ( context ) ;
137139 Assert . AreEqual ( "test9.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
138140 Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
@@ -151,8 +153,8 @@ public void LoadOutdatedQSharpProject()
151153 [ TestMethod ]
152154 public void LoadQSharpCoreLibraries ( )
153155 {
154- var ( projectFile , context ) = this . Context ( "test3" ) ;
155- var projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
156+ var ( projectFile , context ) = Context ( "test3" ) ;
157+ var projDir = Path . GetDirectoryName ( projectFile . LocalPath ) ?? "" ;
156158 Assert . IsNotNull ( context ) ;
157159 Assert . AreEqual ( "test3.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
158160 Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
@@ -170,8 +172,8 @@ public void LoadQSharpCoreLibraries()
170172 Assert . IsFalse ( context . UsesXunitHelper ( ) ) ;
171173 CollectionAssert . AreEquivalent ( qsFiles , context . SourceFiles . ToArray ( ) ) ;
172174
173- ( projectFile , context ) = this . Context ( "test12" ) ;
174- projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
175+ ( projectFile , context ) = Context ( "test12" ) ;
176+ projDir = Path . GetDirectoryName ( projectFile . LocalPath ) ?? "" ;
175177 Assert . IsNotNull ( context ) ;
176178 Assert . AreEqual ( "test12.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
177179 Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
@@ -193,8 +195,8 @@ public void LoadQSharpCoreLibraries()
193195 [ TestMethod ]
194196 public void LoadQSharpFrameworkLibrary ( )
195197 {
196- var ( projectFile , context ) = this . Context ( "test7" ) ;
197- var projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
198+ var ( projectFile , context ) = Context ( "test7" ) ;
199+ var projDir = Path . GetDirectoryName ( projectFile . LocalPath ) ?? "" ;
198200 Assert . IsNotNull ( context ) ;
199201 Assert . AreEqual ( "test7.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
200202 Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
@@ -213,8 +215,8 @@ public void LoadQSharpFrameworkLibrary()
213215 [ TestMethod ]
214216 public void LoadQSharpConsoleApps ( )
215217 {
216- var ( projectFile , context ) = this . Context ( "test4" ) ;
217- var projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
218+ var ( projectFile , context ) = Context ( "test4" ) ;
219+ var projDir = Path . GetDirectoryName ( projectFile . LocalPath ) ?? "" ;
218220 Assert . IsNotNull ( context ) ;
219221 Assert . AreEqual ( "test4.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
220222 Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
@@ -230,8 +232,8 @@ public void LoadQSharpConsoleApps()
230232 Assert . IsTrue ( context . UsesProject ( "test3.csproj" ) ) ;
231233 CollectionAssert . AreEquivalent ( qsFiles , context . SourceFiles . ToArray ( ) ) ;
232234
233- ( projectFile , context ) = this . Context ( "test10" ) ;
234- projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
235+ ( projectFile , context ) = Context ( "test10" ) ;
236+ projDir = Path . GetDirectoryName ( projectFile . LocalPath ) ?? "" ;
235237 Assert . IsNotNull ( context ) ;
236238 Assert . AreEqual ( "test10.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
237239 Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
@@ -245,8 +247,8 @@ public void LoadQSharpConsoleApps()
245247 Assert . IsTrue ( context . UsesCanon ( ) ) ;
246248 CollectionAssert . AreEquivalent ( qsFiles , context . SourceFiles . ToArray ( ) ) ;
247249
248- ( projectFile , context ) = this . Context ( "test11" ) ;
249- projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
250+ ( projectFile , context ) = Context ( "test11" ) ;
251+ projDir = Path . GetDirectoryName ( projectFile . LocalPath ) ?? "" ;
250252 Assert . IsNotNull ( context ) ;
251253 Assert . AreEqual ( "test11.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
252254 Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
@@ -264,8 +266,8 @@ public void LoadQSharpConsoleApps()
264266 [ TestMethod ]
265267 public void LoadQSharpUnitTest ( )
266268 {
267- var ( projectFile , context ) = this . Context ( "test5" ) ;
268- var projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
269+ var ( projectFile , context ) = Context ( "test5" ) ;
270+ var projDir = Path . GetDirectoryName ( projectFile . LocalPath ) ?? "" ;
269271 Assert . IsNotNull ( context ) ;
270272 Assert . AreEqual ( "test5.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
271273 Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
@@ -288,8 +290,8 @@ public void LoadQSharpUnitTest()
288290 [ TestMethod ]
289291 public void LoadQSharpMultiFrameworkLibrary ( )
290292 {
291- var ( projectFile , context ) = this . Context ( "test6" ) ;
292- var projDir = Path . GetDirectoryName ( projectFile ) ?? "" ;
293+ var ( projectFile , context ) = Context ( "test6" ) ;
294+ var projDir = Path . GetDirectoryName ( projectFile . LocalPath ) ?? "" ;
293295 Assert . IsNotNull ( context ) ;
294296 Assert . AreEqual ( "test6.dll" , Path . GetFileName ( context ! . Properties . OutputPath ) ) ;
295297 Assert . IsTrue ( ( Path . GetDirectoryName ( context . Properties . OutputPath ) ?? "" ) . StartsWith ( projDir ) ) ;
@@ -307,34 +309,18 @@ public void LoadQSharpMultiFrameworkLibrary()
307309 Assert . IsTrue ( context . UsesProject ( "test3.csproj" ) ) ;
308310 CollectionAssert . AreEquivalent ( qsFiles , context . SourceFiles . ToArray ( ) ) ;
309311 }
310-
311- [ TestMethod ]
312- public void LoadQSharpTemporaryProject ( )
313- {
314- var sourceFile = Path . GetFullPath ( SourceFileName ( "test14" , "Operation14.qs" ) ) ;
315- var projectUri = CompilationContext . CreateTemporaryProject ( new Uri ( sourceFile ) , "0.12.20072031" ) ;
316- Assert . IsNotNull ( projectUri ) ;
317-
318- var qsFiles = new string [ ] { sourceFile } ;
319- var projectInformation = CompilationContext . Load ( projectUri ) ;
320- Assert . IsNotNull ( projectInformation ) ;
321- Assert . IsTrue ( projectInformation ! . UsesCanon ( ) ) ;
322- CollectionAssert . AreEquivalent ( qsFiles , projectInformation ! . SourceFiles . ToArray ( ) ) ;
323- }
324312 }
325313
326314 internal static class CompilationContext
327315 {
328316 private static void LogOutput ( string msg , MessageType level ) =>
329317 Console . WriteLine ( $ "[{ level } ]: { msg } ") ;
330318
331- internal static ProjectInformation ? Load ( Uri projectFile ) =>
332- new EditorState ( new ProjectLoader ( LogOutput ) , null , null , null , null , null )
333- . QsProjectLoader ( projectFile , out var loaded ) ? loaded : null ;
319+ internal static EditorState Editor =>
320+ new EditorState ( new ProjectLoader ( LogOutput ) , null , null , null , null ) ;
334321
335- internal static Uri CreateTemporaryProject ( Uri sourceFile , string sdkVersion ) =>
336- new EditorState ( new ProjectLoader ( LogOutput ) , null , null , null , null , null )
337- . QsTemporaryProjectLoader ( sourceFile , sdkVersion ) ;
322+ internal static ProjectInformation ? Load ( Uri projectFile ) =>
323+ Editor . QsProjectLoader ( projectFile , out var loaded ) ? loaded : null ;
338324
339325 internal static bool UsesDll ( this ProjectInformation info , string dll ) => info . References . Any ( r => r . EndsWith ( dll ) ) ;
340326
@@ -343,6 +329,8 @@ internal static Uri CreateTemporaryProject(Uri sourceFile, string sdkVersion) =>
343329 // NB: We check whether the project uses either the 0.3–0.5 name (Primitives) or the 0.6– name (Intrinsic).
344330 internal static bool UsesIntrinsics ( this ProjectInformation info ) => info . UsesDll ( "Microsoft.Quantum.Intrinsic.dll" ) || info . UsesDll ( "Microsoft.Quantum.Primitives.dll" ) ;
345331
332+ internal static bool UsesQSharpCore ( this ProjectInformation info ) => info . UsesDll ( "Microsoft.Quantum.QSharp.Core.dll" ) ;
333+
346334 internal static bool UsesCanon ( this ProjectInformation info ) =>
347335 info . UsesDll ( "Microsoft.Quantum.Canon.dll" ) ||
348336 info . UsesDll ( "Microsoft.Quantum.Standard.dll" ) ;
0 commit comments