From 8f5bdd48182aec28b227cf9612d457f1d9e66c05 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 28 May 2020 09:21:03 -0700 Subject: [PATCH 01/24] Add EntryPointDriver to pack.ps1 --- build/pack.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/build/pack.ps1 b/build/pack.ps1 index 7aa7227d8da..9980020536b 100644 --- a/build/pack.ps1 +++ b/build/pack.ps1 @@ -56,6 +56,7 @@ function Pack-Dotnet() { Write-Host "##[info]Using nuget to create packages" Pack-Dotnet '../src/Azure/Azure.Quantum.Client/Microsoft.Azure.Quantum.Client.csproj' Pack-One '../src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.fsproj' '-IncludeReferencedProjects' +Pack-Dotnet '../src/Simulation/EntryPointDriver/EntryPointDriver.csproj' Pack-Dotnet '../src/Simulation/Core/Microsoft.Quantum.Runtime.Core.csproj' Pack-Dotnet '../src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj' Pack-One '../src/Simulation/Simulators/Microsoft.Quantum.Simulators.nuspec' From 889ca51eb923aac3386c5129be07d67ad1b94f04 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 28 May 2020 09:55:57 -0700 Subject: [PATCH 02/24] Rename Microsoft.Quantum.Simulation.Simulators to Microsoft.Quantum.Simulators --- Simulation.sln | 4 ++-- src/Simulation/Common/Simulators.Dev.props | 2 +- src/Simulation/Core/Properties/AssemblyInfo.cs | 2 +- .../CsharpGeneration.Tests/Tests.CsharpGeneration.fsproj | 2 +- src/Simulation/EntryPointDriver/EntryPointDriver.csproj | 2 +- ...ators.csproj => Tests.Microsoft.Quantum.Simulators.csproj} | 0 ....Simulators.csproj => Microsoft.Quantum.Simulators.csproj} | 0 src/Simulation/Simulators/Properties/AssemblyInfo.cs | 2 +- 8 files changed, 7 insertions(+), 7 deletions(-) rename src/Simulation/Simulators.Tests/{Tests.Microsoft.Quantum.Simulation.Simulators.csproj => Tests.Microsoft.Quantum.Simulators.csproj} (100%) rename src/Simulation/Simulators/{Microsoft.Quantum.Simulation.Simulators.csproj => Microsoft.Quantum.Simulators.csproj} (100%) diff --git a/Simulation.sln b/Simulation.sln index 2242d066ddd..4187f21e77f 100644 --- a/Simulation.sln +++ b/Simulation.sln @@ -17,11 +17,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulatio EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulation.Common", "src\Simulation\Common\Microsoft.Quantum.Simulation.Common.csproj", "{8EC46ADB-7FAA-49EA-BA63-E7B32C4F4445}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulation.Simulators", "src\Simulation\Simulators\Microsoft.Quantum.Simulation.Simulators.csproj", "{72B7E75C-D305-45BD-929E-C86298AAA8DE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Simulators", "src\Simulation\Simulators\Microsoft.Quantum.Simulators.csproj", "{72B7E75C-D305-45BD-929E-C86298AAA8DE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime", "src\Simulation\QCTraceSimulator.Tests\Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj", "{DD50D2D9-2765-449B-8C4B-835A428E160D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Microsoft.Quantum.Simulation.Simulators", "src\Simulation\Simulators.Tests\Tests.Microsoft.Quantum.Simulation.Simulators.csproj", "{23461B29-F9DE-4F5B-BC30-50BBE1A10B48}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Microsoft.Quantum.Simulators", "src\Simulation\Simulators.Tests\Tests.Microsoft.Quantum.Simulators.csproj", "{23461B29-F9DE-4F5B-BC30-50BBE1A10B48}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "simulation", "simulation", "{34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4}" EndProject diff --git a/src/Simulation/Common/Simulators.Dev.props b/src/Simulation/Common/Simulators.Dev.props index d459a4b6634..f92092e9568 100644 --- a/src/Simulation/Common/Simulators.Dev.props +++ b/src/Simulation/Common/Simulators.Dev.props @@ -28,7 +28,7 @@ - + diff --git a/src/Simulation/Core/Properties/AssemblyInfo.cs b/src/Simulation/Core/Properties/AssemblyInfo.cs index 9781d4c4d84..c2a5d12dced 100644 --- a/src/Simulation/Core/Properties/AssemblyInfo.cs +++ b/src/Simulation/Core/Properties/AssemblyInfo.cs @@ -6,4 +6,4 @@ using System.Runtime.InteropServices; // Allow the test assembly to use our internal methods -[assembly: InternalsVisibleTo("Tests.Microsoft.Quantum.Simulation.Simulators" + SigningConstants.PUBLIC_KEY)] +[assembly: InternalsVisibleTo("Tests.Microsoft.Quantum.Simulators" + SigningConstants.PUBLIC_KEY)] diff --git a/src/Simulation/CsharpGeneration.Tests/Tests.CsharpGeneration.fsproj b/src/Simulation/CsharpGeneration.Tests/Tests.CsharpGeneration.fsproj index 45d4e5dfe37..906f812078b 100644 --- a/src/Simulation/CsharpGeneration.Tests/Tests.CsharpGeneration.fsproj +++ b/src/Simulation/CsharpGeneration.Tests/Tests.CsharpGeneration.fsproj @@ -54,7 +54,7 @@ - + diff --git a/src/Simulation/EntryPointDriver/EntryPointDriver.csproj b/src/Simulation/EntryPointDriver/EntryPointDriver.csproj index 7f04ac0ba36..c57f78954ec 100644 --- a/src/Simulation/EntryPointDriver/EntryPointDriver.csproj +++ b/src/Simulation/EntryPointDriver/EntryPointDriver.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulation.Simulators.csproj b/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj similarity index 100% rename from src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulation.Simulators.csproj rename to src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj diff --git a/src/Simulation/Simulators/Microsoft.Quantum.Simulation.Simulators.csproj b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj similarity index 100% rename from src/Simulation/Simulators/Microsoft.Quantum.Simulation.Simulators.csproj rename to src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj diff --git a/src/Simulation/Simulators/Properties/AssemblyInfo.cs b/src/Simulation/Simulators/Properties/AssemblyInfo.cs index ed09e5cdc2b..4dc75e0a503 100644 --- a/src/Simulation/Simulators/Properties/AssemblyInfo.cs +++ b/src/Simulation/Simulators/Properties/AssemblyInfo.cs @@ -6,4 +6,4 @@ using System.Runtime.InteropServices; // Allow the test assembly to use our internal methods -[assembly: InternalsVisibleTo("Tests.Microsoft.Quantum.Simulation.Simulators" + SigningConstants.PUBLIC_KEY)] \ No newline at end of file +[assembly: InternalsVisibleTo("Tests.Microsoft.Quantum.Simulators" + SigningConstants.PUBLIC_KEY)] \ No newline at end of file From 09c888462072613bc4058dda1067cd0ad873b413 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 28 May 2020 12:47:08 -0700 Subject: [PATCH 03/24] Rename EntryPointDriver to Microsoft.Quantum.EntryPointDriver --- Simulation.sln | 2 +- build/pack.ps1 | 2 +- .../EntryPointDriver.Tests/Tests.EntryPointDriver.fsproj | 2 +- src/Simulation/EntryPointDriver.Tests/Tests.fs | 4 ++-- ...river.csproj => Microsoft.Quantum.EntryPointDriver.csproj} | 2 -- .../Simulators.Tests/TestProjects/QsharpExe/QsharpExe.csproj | 3 +-- 6 files changed, 6 insertions(+), 9 deletions(-) rename src/Simulation/EntryPointDriver/{EntryPointDriver.csproj => Microsoft.Quantum.EntryPointDriver.csproj} (82%) diff --git a/Simulation.sln b/Simulation.sln index 4187f21e77f..e65d464f180 100644 --- a/Simulation.sln +++ b/Simulation.sln @@ -47,7 +47,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestProjects", "TestProject EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QsharpExe", "src\Simulation\Simulators.Tests\TestProjects\QsharpExe\QsharpExe.csproj", "{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntryPointDriver", "src\Simulation\EntryPointDriver\EntryPointDriver.csproj", "{944FE7EF-9220-4CC6-BB20-CE517195B922}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Quantum.EntryPointDriver", "src\Simulation\EntryPointDriver\Microsoft.Quantum.EntryPointDriver.csproj", "{944FE7EF-9220-4CC6-BB20-CE517195B922}" EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Tests.EntryPointDriver", "src\Simulation\EntryPointDriver.Tests\Tests.EntryPointDriver.fsproj", "{E2F30496-19D8-46A8-9BC0-26936FFE70D2}" EndProject diff --git a/build/pack.ps1 b/build/pack.ps1 index 9980020536b..f495e4f2a2e 100644 --- a/build/pack.ps1 +++ b/build/pack.ps1 @@ -56,7 +56,7 @@ function Pack-Dotnet() { Write-Host "##[info]Using nuget to create packages" Pack-Dotnet '../src/Azure/Azure.Quantum.Client/Microsoft.Azure.Quantum.Client.csproj' Pack-One '../src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.fsproj' '-IncludeReferencedProjects' -Pack-Dotnet '../src/Simulation/EntryPointDriver/EntryPointDriver.csproj' +Pack-Dotnet '../src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj' Pack-Dotnet '../src/Simulation/Core/Microsoft.Quantum.Runtime.Core.csproj' Pack-Dotnet '../src/Simulation/QsharpCore/Microsoft.Quantum.QSharp.Core.csproj' Pack-One '../src/Simulation/Simulators/Microsoft.Quantum.Simulators.nuspec' diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.EntryPointDriver.fsproj b/src/Simulation/EntryPointDriver.Tests/Tests.EntryPointDriver.fsproj index 24ea7c82cda..4d5a2974aef 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.EntryPointDriver.fsproj +++ b/src/Simulation/EntryPointDriver.Tests/Tests.EntryPointDriver.fsproj @@ -29,7 +29,7 @@ - + diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.fs b/src/Simulation/EntryPointDriver.Tests/Tests.fs index 6df1ce5472d..ac0ce1bb1f0 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.fs +++ b/src/Simulation/EntryPointDriver.Tests/Tests.fs @@ -95,12 +95,12 @@ let private compileCsharp (sources : string seq) = "System.Runtime" "System.Runtime.Extensions" "System.Runtime.Numerics" - "Microsoft.Quantum.CsharpGeneration.EntryPointDriver" + "Microsoft.Quantum.EntryPointDriver" "Microsoft.Quantum.QSharp.Core" "Microsoft.Quantum.QsDataStructures" "Microsoft.Quantum.Runtime.Core" "Microsoft.Quantum.Simulation.Common" - "Microsoft.Quantum.Simulation.Simulators" + "Microsoft.Quantum.Simulators" ] |> List.map (fun name -> upcast MetadataReference.CreateFromFile (referencedAssembly name)) diff --git a/src/Simulation/EntryPointDriver/EntryPointDriver.csproj b/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj similarity index 82% rename from src/Simulation/EntryPointDriver/EntryPointDriver.csproj rename to src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj index c57f78954ec..b914f364f2a 100644 --- a/src/Simulation/EntryPointDriver/EntryPointDriver.csproj +++ b/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj @@ -4,8 +4,6 @@ netstandard2.1 - Microsoft.Quantum.CsharpGeneration.EntryPointDriver - Microsoft.Quantum.CsharpGeneration.EntryPointDriver enable diff --git a/src/Simulation/Simulators.Tests/TestProjects/QsharpExe/QsharpExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/QsharpExe/QsharpExe.csproj index 5423e097463..1d25c3db5f5 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QsharpExe/QsharpExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/QsharpExe/QsharpExe.csproj @@ -11,7 +11,7 @@ - + @@ -36,4 +36,3 @@ - From afea971cdf5a3bad4fa3051f19b753cade3560f4 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 28 May 2020 13:01:10 -0700 Subject: [PATCH 04/24] Rename Tests.EntryPointDriver to Microsoft.Quantum.EntryPointDriver.Tests --- Simulation.sln | 2 +- build/test.ps1 | 6 ++---- ...proj => Microsoft.Quantum.EntryPointDriver.Tests.fsproj} | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) rename src/Simulation/EntryPointDriver.Tests/{Tests.EntryPointDriver.fsproj => Microsoft.Quantum.EntryPointDriver.Tests.fsproj} (92%) diff --git a/Simulation.sln b/Simulation.sln index e65d464f180..4b23c8712b5 100644 --- a/Simulation.sln +++ b/Simulation.sln @@ -49,7 +49,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QsharpExe", "src\Simulation EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Quantum.EntryPointDriver", "src\Simulation\EntryPointDriver\Microsoft.Quantum.EntryPointDriver.csproj", "{944FE7EF-9220-4CC6-BB20-CE517195B922}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Tests.EntryPointDriver", "src\Simulation\EntryPointDriver.Tests\Tests.EntryPointDriver.fsproj", "{E2F30496-19D8-46A8-9BC0-26936FFE70D2}" +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Microsoft.Quantum.EntryPointDriver.Tests", "src\Simulation\EntryPointDriver.Tests\Microsoft.Quantum.EntryPointDriver.Tests.fsproj", "{E2F30496-19D8-46A8-9BC0-26936FFE70D2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/build/test.ps1 b/build/test.ps1 index 4a879f1fb13..582381551b8 100644 --- a/build/test.ps1 +++ b/build/test.ps1 @@ -34,7 +34,7 @@ function Test-One { Test-One '../src/Simulation/CsharpGeneration.Tests/Tests.CsharpGeneration.fsproj' -Test-One '../src/Simulation/EntryPointDriver.Tests/Tests.EntryPointDriver.fsproj' +Test-One '../src/Simulation/EntryPointDriver.Tests/Microsoft.Quantum.EntryPointDriver.Tests.fsproj' Test-One '../src/Simulation/RoslynWrapper.Tests/Tests.RoslynWrapper.fsproj' @@ -42,8 +42,6 @@ Test-One '../src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simul Test-One '../src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulation.Simulators.csproj' -if (-not $all_ok) -{ +if (-not $all_ok) { throw "At least one project failed to compile. Check the logs." } - diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.EntryPointDriver.fsproj b/src/Simulation/EntryPointDriver.Tests/Microsoft.Quantum.EntryPointDriver.Tests.fsproj similarity index 92% rename from src/Simulation/EntryPointDriver.Tests/Tests.EntryPointDriver.fsproj rename to src/Simulation/EntryPointDriver.Tests/Microsoft.Quantum.EntryPointDriver.Tests.fsproj index 4d5a2974aef..d81eef102d4 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.EntryPointDriver.fsproj +++ b/src/Simulation/EntryPointDriver.Tests/Microsoft.Quantum.EntryPointDriver.Tests.fsproj @@ -4,7 +4,6 @@ netcoreapp3.1 false false - Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests From f281e2f19ba962f7e033e83f102c34e06c743844 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 28 May 2020 13:52:33 -0700 Subject: [PATCH 05/24] Add package description for EntryPointDriver --- .../EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj b/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj index b914f364f2a..29c2fae85f7 100644 --- a/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj +++ b/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj @@ -5,6 +5,7 @@ netstandard2.1 enable + The standard command-line interface for standalone Q# console applications. From bf3ac893b3069d3c3713f83e5801d745f3a4c3b7 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 28 May 2020 14:00:54 -0700 Subject: [PATCH 06/24] Remove EntryPointDriver from CsharpGeneration package --- src/Simulation/CsharpGeneration/FindNuspecReferences.ps1 | 7 ------- .../Microsoft.Quantum.CsharpGeneration.nuspec.template | 7 ------- 2 files changed, 14 deletions(-) diff --git a/src/Simulation/CsharpGeneration/FindNuspecReferences.ps1 b/src/Simulation/CsharpGeneration/FindNuspecReferences.ps1 index 68d012099af..0c3695812f9 100644 --- a/src/Simulation/CsharpGeneration/FindNuspecReferences.ps1 +++ b/src/Simulation/CsharpGeneration/FindNuspecReferences.ps1 @@ -59,13 +59,6 @@ function Add-PackageReferenceDependencies($ProjectFileName) { # Add dependencies for the projects included in this NuGet package. Add-PackageReferenceDependencies 'Microsoft.Quantum.CsharpGeneration.fsproj' -Add-PackageReferenceDependencies '..\EntryPointDriver\EntryPointDriver.csproj' - -# Manually add EntryPointDriver's project references as package references to avoid a build-time dependency cycle. -# $version$ is replaced with the current package version when the package is built. -Add-Dependency 'Microsoft.Quantum.Runtime.Core' '$version$' -Add-Dependency 'Microsoft.Quantum.Simulators' '$version$' -Add-Dependency 'Microsoft.Azure.Quantum.Client' '$version$' $nuspec.package.metadata.AppendChild($dependencies) $nuspec.Save([Path]::Combine((Get-Location), $target)) diff --git a/src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.nuspec.template b/src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.nuspec.template index cf3797a7b0a..997341009c3 100644 --- a/src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.nuspec.template +++ b/src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.nuspec.template @@ -23,12 +23,5 @@ - - - - From 9c39ba005085106e33b5a23c4d099c5bcc2fafe3 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 28 May 2020 14:13:14 -0700 Subject: [PATCH 07/24] Update namespace in EntryPointDriver --- src/Simulation/CsharpGeneration/EntryPoint.fs | 2 +- src/Simulation/EntryPointDriver/Azure.cs | 4 ++-- src/Simulation/EntryPointDriver/Driver.cs | 4 ++-- src/Simulation/EntryPointDriver/IEntryPoint.cs | 2 +- src/Simulation/EntryPointDriver/NothingMachine.cs | 2 +- src/Simulation/EntryPointDriver/OptionInfo.cs | 2 +- src/Simulation/EntryPointDriver/Options.cs | 2 +- src/Simulation/EntryPointDriver/Parsers.cs | 2 +- src/Simulation/EntryPointDriver/Simulation.cs | 4 ++-- src/Simulation/EntryPointDriver/Validation.cs | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Simulation/CsharpGeneration/EntryPoint.fs b/src/Simulation/CsharpGeneration/EntryPoint.fs index b975bf374a8..9f5607df517 100644 --- a/src/Simulation/CsharpGeneration/EntryPoint.fs +++ b/src/Simulation/CsharpGeneration/EntryPoint.fs @@ -24,7 +24,7 @@ type private Parameter = let entryPointClassName = "__QsEntryPoint__" /// The namespace containing the non-generated parts of the entry point driver. -let private driverNamespace = "Microsoft.Quantum.CsharpGeneration.EntryPointDriver" +let private driverNamespace = "Microsoft.Quantum.EntryPointDriver" /// A sequence of all of the named parameters in the argument tuple and their respective C# and Q# types. let rec private parameters context doc = function diff --git a/src/Simulation/EntryPointDriver/Azure.cs b/src/Simulation/EntryPointDriver/Azure.cs index 40a0ad01e44..bed9614e585 100644 --- a/src/Simulation/EntryPointDriver/Azure.cs +++ b/src/Simulation/EntryPointDriver/Azure.cs @@ -8,9 +8,9 @@ using Microsoft.Azure.Quantum.Exceptions; using Microsoft.Quantum.Runtime; using Microsoft.Quantum.Simulation.Common.Exceptions; -using static Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Driver; +using static Microsoft.Quantum.EntryPointDriver.Driver; -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver +namespace Microsoft.Quantum.EntryPointDriver { /// /// Provides entry point submission to Azure Quantum. diff --git a/src/Simulation/EntryPointDriver/Driver.cs b/src/Simulation/EntryPointDriver/Driver.cs index 9bca59fe327..d3cdefca7e2 100644 --- a/src/Simulation/EntryPointDriver/Driver.cs +++ b/src/Simulation/EntryPointDriver/Driver.cs @@ -13,9 +13,9 @@ using System.Threading.Tasks; using Microsoft.Quantum.QsCompiler.ReservedKeywords; using Microsoft.Quantum.Simulation.Core; -using static Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Driver; +using static Microsoft.Quantum.EntryPointDriver.Driver; -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver +namespace Microsoft.Quantum.EntryPointDriver { /// /// The entry point driver is the entry point for the C# application that executes the Q# entry point. diff --git a/src/Simulation/EntryPointDriver/IEntryPoint.cs b/src/Simulation/EntryPointDriver/IEntryPoint.cs index 65250d086d3..1d89c252db0 100644 --- a/src/Simulation/EntryPointDriver/IEntryPoint.cs +++ b/src/Simulation/EntryPointDriver/IEntryPoint.cs @@ -7,7 +7,7 @@ using System.CommandLine.Parsing; using Microsoft.Quantum.Simulation.Core; -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver +namespace Microsoft.Quantum.EntryPointDriver { /// /// The interface between the entry point and the command-line program. diff --git a/src/Simulation/EntryPointDriver/NothingMachine.cs b/src/Simulation/EntryPointDriver/NothingMachine.cs index f4bf6942e99..9a9aea70c4f 100644 --- a/src/Simulation/EntryPointDriver/NothingMachine.cs +++ b/src/Simulation/EntryPointDriver/NothingMachine.cs @@ -7,7 +7,7 @@ using Microsoft.Quantum.Runtime; using Microsoft.Quantum.Simulation.Core; -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver +namespace Microsoft.Quantum.EntryPointDriver { /// /// A quantum machine that does nothing. diff --git a/src/Simulation/EntryPointDriver/OptionInfo.cs b/src/Simulation/EntryPointDriver/OptionInfo.cs index 7f96ec423de..ad221e8d549 100644 --- a/src/Simulation/EntryPointDriver/OptionInfo.cs +++ b/src/Simulation/EntryPointDriver/OptionInfo.cs @@ -4,7 +4,7 @@ using System.CommandLine.Parsing; using System.Linq; -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver +namespace Microsoft.Quantum.EntryPointDriver { /// /// Information about a command-line option. diff --git a/src/Simulation/EntryPointDriver/Options.cs b/src/Simulation/EntryPointDriver/Options.cs index fb64d2dce5c..7f23ca8dcaa 100644 --- a/src/Simulation/EntryPointDriver/Options.cs +++ b/src/Simulation/EntryPointDriver/Options.cs @@ -8,7 +8,7 @@ using Microsoft.Quantum.Simulation.Core; using static System.Reflection.BindingFlags; -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver +namespace Microsoft.Quantum.EntryPointDriver { /// /// Creates command-line options. diff --git a/src/Simulation/EntryPointDriver/Parsers.cs b/src/Simulation/EntryPointDriver/Parsers.cs index a2514c4ab13..1eddc4bf2d1 100644 --- a/src/Simulation/EntryPointDriver/Parsers.cs +++ b/src/Simulation/EntryPointDriver/Parsers.cs @@ -8,7 +8,7 @@ using System.Numerics; using Microsoft.Quantum.Simulation.Core; -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver +namespace Microsoft.Quantum.EntryPointDriver { /// /// Parsers for command-line arguments. diff --git a/src/Simulation/EntryPointDriver/Simulation.cs b/src/Simulation/EntryPointDriver/Simulation.cs index a1949a07d8a..d101e8980d0 100644 --- a/src/Simulation/EntryPointDriver/Simulation.cs +++ b/src/Simulation/EntryPointDriver/Simulation.cs @@ -7,9 +7,9 @@ using Microsoft.Quantum.QsCompiler.ReservedKeywords; using Microsoft.Quantum.Simulation.Core; using Microsoft.Quantum.Simulation.Simulators; -using static Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Driver; +using static Microsoft.Quantum.EntryPointDriver.Driver; -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver +namespace Microsoft.Quantum.EntryPointDriver { /// /// Provides entry point simulation. diff --git a/src/Simulation/EntryPointDriver/Validation.cs b/src/Simulation/EntryPointDriver/Validation.cs index d9d0726cbbe..f03b3da95e1 100644 --- a/src/Simulation/EntryPointDriver/Validation.cs +++ b/src/Simulation/EntryPointDriver/Validation.cs @@ -7,7 +7,7 @@ using System.Linq; using Microsoft.Quantum.QsCompiler.CompilationBuilder; -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver +namespace Microsoft.Quantum.EntryPointDriver { /// /// Represents either a success or a failure of a process. From 4474cb8af5629c76724930dea795d192db1e7744 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 28 May 2020 14:16:45 -0700 Subject: [PATCH 08/24] Update namespace in EntryPointDriver.Tests --- .../EntryPointDriver.Tests/Tests.fs | 4 +- .../EntryPointDriver.Tests/Tests.qs | 62 +++++++++---------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.fs b/src/Simulation/EntryPointDriver.Tests/Tests.fs index ac0ce1bb1f0..9c2a8c64dc7 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.fs +++ b/src/Simulation/EntryPointDriver.Tests/Tests.fs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -module Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests +module Microsoft.Quantum.EntryPointDriver.Tests open System open System.Collections.Immutable @@ -33,7 +33,7 @@ let private intrinsicFile = Path.GetFullPath "Intrinsic.qs" let private testFile = Path.GetFullPath "Tests.qs" /// The namespace used for the test cases. -let private testNamespace = "Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests" +let private testNamespace = "Microsoft.Quantum.EntryPointDriver.Tests" /// The test case for the given test number. let private testCase = diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.qs b/src/Simulation/EntryPointDriver.Tests/Tests.qs index f45080104db..399c91f920d 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.qs +++ b/src/Simulation/EntryPointDriver.Tests/Tests.qs @@ -5,14 +5,14 @@ // No Options // -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation ReturnUnit() : Unit { } } // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation ReturnInt() : Int { return 42; @@ -21,7 +21,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation ReturnString() : String { return "Hello, World!"; @@ -34,7 +34,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // Single Option // -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptInt(n : Int) : Int { return n; @@ -43,7 +43,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptBigInt(n : BigInt) : BigInt { return n; @@ -52,7 +52,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptDouble(n : Double) : Double { return n; @@ -61,7 +61,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptBool(b : Bool) : Bool { return b; @@ -70,7 +70,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptPauli(p : Pauli) : Pauli { return p; @@ -79,7 +79,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptResult(r : Result) : Result { return r; @@ -88,7 +88,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptRange(r : Range) : Range { return r; @@ -97,7 +97,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptString(s : String) : String { return s; @@ -106,7 +106,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptUnit(u : Unit) : Unit { return u; @@ -115,7 +115,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptStringArray(xs : String[]) : String[] { return xs; @@ -124,7 +124,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptBigIntArray(bs : BigInt[]) : BigInt[] { return bs; @@ -133,7 +133,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptPauliArray(ps : Pauli[]) : Pauli[] { return ps; @@ -142,7 +142,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptRangeArray(rs : Range[]) : Range[] { return rs; @@ -151,7 +151,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptResultArray(rs : Result[]) : Result[] { return rs; @@ -160,7 +160,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation AcceptUnitArray(us : Unit[]) : Unit[] { return us; @@ -173,7 +173,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // Multiple Options // -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation TwoOptions(n : Int, b : Bool) : String { return $"{n} {b}"; @@ -182,7 +182,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation ThreeOptions(n : Int, b : Bool, xs : String[]) : String { return $"{n} {b} {xs}"; @@ -195,7 +195,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // Tuples // -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation RedundantOneTuple((x : Int)) : String { return $"{x}"; @@ -204,7 +204,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation RedundantTwoTuple((x : Int, y : Int)) : String { return $"{x} {y}"; @@ -213,7 +213,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation OneTuple(x : Int, (y : Int)) : String { return $"{x} {y}"; @@ -222,7 +222,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation TwoTuple(x : Int, (y : Int, z : Int)) : String { return $"{x} {y} {z}"; @@ -235,7 +235,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // Name Conversion // -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation CamelCase(camelCaseName : String) : String { return camelCaseName; @@ -244,7 +244,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation SingleLetter(x : String) : String { return x; @@ -257,7 +257,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // Shadowing // -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation ShadowSimulator(simulator : String) : String { return simulator; @@ -266,7 +266,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation ShadowS(s : String) : String { return s; @@ -275,7 +275,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation ShadowVersion(version : String) : String { return version; @@ -288,7 +288,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // Simulators // -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { open Microsoft.Quantum.Intrinsic; @EntryPoint() @@ -314,7 +314,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // Help // -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { /// # Summary /// This test checks that the entry point documentation appears correctly in the command line help message. /// From 60fd6abd881aee8e6319305052f10e9b5c52b46e Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 28 May 2020 14:55:49 -0700 Subject: [PATCH 09/24] Update simulator test project filename --- build/test.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/test.ps1 b/build/test.ps1 index 582381551b8..8a0fb668434 100644 --- a/build/test.ps1 +++ b/build/test.ps1 @@ -40,7 +40,7 @@ Test-One '../src/Simulation/RoslynWrapper.Tests/Tests.RoslynWrapper.fsproj' Test-One '../src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj' -Test-One '../src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulation.Simulators.csproj' +Test-One '../src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj' if (-not $all_ok) { throw "At least one project failed to compile. Check the logs." From 8cc2fad6711186d38b8d45eb10562b69071c8389 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 28 May 2020 16:09:45 -0700 Subject: [PATCH 10/24] Update manifest.ps1 --- build/manifest.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/manifest.ps1 b/build/manifest.ps1 index 07a8fca41f3..29ea070beb7 100644 --- a/build/manifest.ps1 +++ b/build/manifest.ps1 @@ -8,6 +8,7 @@ "Microsoft.Azure.Quantum.Client", "Microsoft.Quantum.CsharpGeneration", "Microsoft.Quantum.Development.Kit", + "Microsoft.Quantum.EntryPointDriver", "Microsoft.Quantum.QSharp.Core", "Microsoft.Quantum.Runtime.Core", "Microsoft.Quantum.Simulators", @@ -19,10 +20,11 @@ ".\src\simulation\CsharpGeneration.App\bin\$Env:BUILD_CONFIGURATION\netcoreapp3.1\Microsoft.Quantum.CsharpGeneration.App.dll", ".\src\simulation\CsharpGeneration.App\bin\$Env:BUILD_CONFIGURATION\netcoreapp3.1\Microsoft.Quantum.RoslynWrapper.dll", ".\src\simulation\Core\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Runtime.Core.dll", + ".\src\simulation\EntryPointDriver\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.EntryPointDriver.dll", ".\src\simulation\QsharpCore\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.QSharp.Core.dll", ".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.Common.dll", ".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.dll", - ".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.Simulators.dll", + ".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulators.dll", ".\src\Xunit\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Xunit.dll" ) | ForEach-Object { Get-Item (Join-Path $PSScriptRoot (Join-Path ".." $_)) }; -} | Write-Output; \ No newline at end of file +} | Write-Output; From 22bb7f95ef8a3e3139f2f52a5f04da452308ff0a Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 28 May 2020 17:20:28 -0700 Subject: [PATCH 11/24] Rename Microsoft.Quantum.EntryPointDriver.Tests to Tests.Microsoft.Quantum.EntryPointDriver --- Simulation.sln | 2 +- build/test.ps1 | 2 +- ...s.fsproj => Tests.Microsoft.Quantum.EntryPointDriver.fsproj} | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) rename src/Simulation/EntryPointDriver.Tests/{Microsoft.Quantum.EntryPointDriver.Tests.fsproj => Tests.Microsoft.Quantum.EntryPointDriver.fsproj} (93%) diff --git a/Simulation.sln b/Simulation.sln index 4b23c8712b5..c7c1004463c 100644 --- a/Simulation.sln +++ b/Simulation.sln @@ -49,7 +49,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QsharpExe", "src\Simulation EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Quantum.EntryPointDriver", "src\Simulation\EntryPointDriver\Microsoft.Quantum.EntryPointDriver.csproj", "{944FE7EF-9220-4CC6-BB20-CE517195B922}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Microsoft.Quantum.EntryPointDriver.Tests", "src\Simulation\EntryPointDriver.Tests\Microsoft.Quantum.EntryPointDriver.Tests.fsproj", "{E2F30496-19D8-46A8-9BC0-26936FFE70D2}" +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Tests.Microsoft.Quantum.EntryPointDriver", "src\Simulation\EntryPointDriver.Tests\Tests.Microsoft.Quantum.EntryPointDriver.fsproj", "{E2F30496-19D8-46A8-9BC0-26936FFE70D2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/build/test.ps1 b/build/test.ps1 index 8a0fb668434..65cbecb7bbb 100644 --- a/build/test.ps1 +++ b/build/test.ps1 @@ -34,7 +34,7 @@ function Test-One { Test-One '../src/Simulation/CsharpGeneration.Tests/Tests.CsharpGeneration.fsproj' -Test-One '../src/Simulation/EntryPointDriver.Tests/Microsoft.Quantum.EntryPointDriver.Tests.fsproj' +Test-One '../src/Simulation/EntryPointDriver.Tests/Tests.Microsoft.Quantum.EntryPointDriver.fsproj' Test-One '../src/Simulation/RoslynWrapper.Tests/Tests.RoslynWrapper.fsproj' diff --git a/src/Simulation/EntryPointDriver.Tests/Microsoft.Quantum.EntryPointDriver.Tests.fsproj b/src/Simulation/EntryPointDriver.Tests/Tests.Microsoft.Quantum.EntryPointDriver.fsproj similarity index 93% rename from src/Simulation/EntryPointDriver.Tests/Microsoft.Quantum.EntryPointDriver.Tests.fsproj rename to src/Simulation/EntryPointDriver.Tests/Tests.Microsoft.Quantum.EntryPointDriver.fsproj index d81eef102d4..8ab17e90bed 100644 --- a/src/Simulation/EntryPointDriver.Tests/Microsoft.Quantum.EntryPointDriver.Tests.fsproj +++ b/src/Simulation/EntryPointDriver.Tests/Tests.Microsoft.Quantum.EntryPointDriver.fsproj @@ -4,6 +4,7 @@ netcoreapp3.1 false false + Microsoft.Quantum.EntryPointDriver.Tests From 1b07637c50eac8a2d8e3bbbcdd90b8f5650d9f53 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Thu, 28 May 2020 19:03:36 -0700 Subject: [PATCH 12/24] Restore name of simulators assembly --- build/manifest.ps1 | 2 +- src/Simulation/EntryPointDriver.Tests/Tests.fs | 2 +- src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/manifest.ps1 b/build/manifest.ps1 index 29ea070beb7..5e825f828dd 100644 --- a/build/manifest.ps1 +++ b/build/manifest.ps1 @@ -24,7 +24,7 @@ ".\src\simulation\QsharpCore\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.QSharp.Core.dll", ".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.Common.dll", ".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.dll", - ".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulators.dll", + ".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.Simulators.dll", ".\src\Xunit\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Xunit.dll" ) | ForEach-Object { Get-Item (Join-Path $PSScriptRoot (Join-Path ".." $_)) }; } | Write-Output; diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.fs b/src/Simulation/EntryPointDriver.Tests/Tests.fs index 9c2a8c64dc7..2dac25c0499 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.fs +++ b/src/Simulation/EntryPointDriver.Tests/Tests.fs @@ -100,7 +100,7 @@ let private compileCsharp (sources : string seq) = "Microsoft.Quantum.QsDataStructures" "Microsoft.Quantum.Runtime.Core" "Microsoft.Quantum.Simulation.Common" - "Microsoft.Quantum.Simulators" + "Microsoft.Quantum.Simulation.Simulators" ] |> List.map (fun name -> upcast MetadataReference.CreateFromFile (referencedAssembly name)) diff --git a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj index 2b39d659044..05993b27a27 100644 --- a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj @@ -7,6 +7,7 @@ netstandard2.1 false + Microsoft.Quantum.Simulation.Simulators false @@ -25,4 +26,3 @@ - From 2e74a08ae931cb87c1195624161602d6aae32547 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Fri, 29 May 2020 10:24:26 -0700 Subject: [PATCH 13/24] Add DelaySign.cs to EntryPointDriver --- .../Microsoft.Quantum.EntryPointDriver.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj b/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj index 29c2fae85f7..5c377fb345d 100644 --- a/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj +++ b/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj @@ -18,4 +18,8 @@ + + + + From 04d76560b59b8ab4f3ba94dddc54b90405148650 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Mon, 1 Jun 2020 11:03:39 -0700 Subject: [PATCH 14/24] Use same assembly name as package name again --- build/manifest.ps1 | 2 +- src/Simulation/EntryPointDriver.Tests/Tests.fs | 2 +- src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build/manifest.ps1 b/build/manifest.ps1 index 5e825f828dd..29ea070beb7 100644 --- a/build/manifest.ps1 +++ b/build/manifest.ps1 @@ -24,7 +24,7 @@ ".\src\simulation\QsharpCore\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.QSharp.Core.dll", ".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.Common.dll", ".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.dll", - ".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulation.Simulators.dll", + ".\src\simulation\Simulators\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Simulators.dll", ".\src\Xunit\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Xunit.dll" ) | ForEach-Object { Get-Item (Join-Path $PSScriptRoot (Join-Path ".." $_)) }; } | Write-Output; diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.fs b/src/Simulation/EntryPointDriver.Tests/Tests.fs index 2dac25c0499..9c2a8c64dc7 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.fs +++ b/src/Simulation/EntryPointDriver.Tests/Tests.fs @@ -100,7 +100,7 @@ let private compileCsharp (sources : string seq) = "Microsoft.Quantum.QsDataStructures" "Microsoft.Quantum.Runtime.Core" "Microsoft.Quantum.Simulation.Common" - "Microsoft.Quantum.Simulation.Simulators" + "Microsoft.Quantum.Simulators" ] |> List.map (fun name -> upcast MetadataReference.CreateFromFile (referencedAssembly name)) diff --git a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj index 05993b27a27..a9378cb312e 100644 --- a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj @@ -7,7 +7,6 @@ netstandard2.1 false - Microsoft.Quantum.Simulation.Simulators false From 020b60b191a1080a357f522d09032fa1198c0efe Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Mon, 1 Jun 2020 11:17:47 -0700 Subject: [PATCH 15/24] Update reference to simulators csproj --- src/Simulation/Simulators/FindNuspecReferences.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Simulation/Simulators/FindNuspecReferences.ps1 b/src/Simulation/Simulators/FindNuspecReferences.ps1 index a4d6843ba40..a1fd46b8f2b 100644 --- a/src/Simulation/Simulators/FindNuspecReferences.ps1 +++ b/src/Simulation/Simulators/FindNuspecReferences.ps1 @@ -97,7 +97,7 @@ function Add-NuGetDependencyFromCsprojToNuspec($PathToCsproj) # Find all dependencies packaged as part of Microsoft.Quantum.Simulators Add-NuGetDependencyFromCsprojToNuspec "../QCTraceSimulator/Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj" # has a dependency on Common, need to list this because it is listed only in an imported props file ... -Add-NuGetDependencyFromCsprojToNuspec "../Simulators/Microsoft.Quantum.Simulation.Simulators.csproj" +Add-NuGetDependencyFromCsprojToNuspec "../Simulators/Microsoft.Quantum.Simulators.csproj" # Save into .nuspec file: $nuspec.package.metadata.AppendChild($dep) From 0ff2120b6f892d81dc3093f89c049f2300a2d5ae Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Mon, 1 Jun 2020 12:37:47 -0700 Subject: [PATCH 16/24] Update simulators nuspec --- .../Simulators/Microsoft.Quantum.Simulators.nuspec.template | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.nuspec.template b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.nuspec.template index 36b266522d6..756eaca2e6b 100644 --- a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.nuspec.template +++ b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.nuspec.template @@ -22,6 +22,9 @@ + + + From 6dc19949b1a42ed942a91700df4692691d904562 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Mon, 8 Jun 2020 11:21:46 -0700 Subject: [PATCH 17/24] Update project reference to simulators --- .../Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj index b60e6984a22..2e5d0bd73cd 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj @@ -12,7 +12,7 @@ - + From 2024adc25173f45e98b1250cc135ef08b6fb9345 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Mon, 8 Jun 2020 17:05:18 -0700 Subject: [PATCH 18/24] Update namespace names in test --- src/Simulation/EntryPointDriver.Tests/Tests.qs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.qs b/src/Simulation/EntryPointDriver.Tests/Tests.qs index 6c19c05da75..89ff907bde9 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.qs +++ b/src/Simulation/EntryPointDriver.Tests/Tests.qs @@ -284,7 +284,7 @@ namespace Microsoft.Quantum.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation ShadowTarget(target : String) : String { return target; @@ -293,7 +293,7 @@ namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { // --- -namespace Microsoft.Quantum.CsharpGeneration.EntryPointDriver.Tests { +namespace Microsoft.Quantum.EntryPointDriver.Tests { @EntryPoint() operation ShadowShots(shots : Int) : Int { return shots; From 6103c252437140892e3b1fd46a85fd5b938645ab Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Tue, 9 Jun 2020 12:38:14 -0700 Subject: [PATCH 19/24] Remove package reference to Q# compiler --- src/Simulation/CsharpGeneration/EntryPoint.fs | 23 ++++++- src/Simulation/EntryPointDriver/Driver.cs | 66 ++++++++++--------- .../EntryPointDriver/DriverSettings.cs | 30 +++++++++ .../EntryPointDriver/IEntryPoint.cs | 8 +-- .../Microsoft.Quantum.EntryPointDriver.csproj | 1 - src/Simulation/EntryPointDriver/OptionInfo.cs | 14 ++-- src/Simulation/EntryPointDriver/Simulation.cs | 16 ++--- src/Simulation/EntryPointDriver/Validation.cs | 23 ++----- 8 files changed, 109 insertions(+), 72 deletions(-) create mode 100644 src/Simulation/EntryPointDriver/DriverSettings.cs diff --git a/src/Simulation/CsharpGeneration/EntryPoint.fs b/src/Simulation/CsharpGeneration/EntryPoint.fs index 9f5607df517..3a95bb284a3 100644 --- a/src/Simulation/CsharpGeneration/EntryPoint.fs +++ b/src/Simulation/CsharpGeneration/EntryPoint.fs @@ -26,6 +26,23 @@ let entryPointClassName = "__QsEntryPoint__" /// The namespace containing the non-generated parts of the entry point driver. let private driverNamespace = "Microsoft.Quantum.EntryPointDriver" +/// The driver settings object. +let private driverSettings = + let immutableList elements = + invoke (ident "System.Collections.Immutable.ImmutableList.Create") + ``(`` [``new array`` (Some "") elements] ``)`` + let simulatorOptionAliases = + [ "--" + fst CommandLineArguments.SimulatorOption |> literal + "-" + snd CommandLineArguments.SimulatorOption |> literal ] + |> immutableList + ``new init`` (driverNamespace + ".DriverSettings" |> ``type``) ``(`` [] ``)`` + ``{`` + [ ident "SimulatorOptionAliases" <-- simulatorOptionAliases + ident "QuantumSimulatorName" <-- literal AssemblyConstants.QuantumSimulator + ident "ToffoliSimulatorName" <-- literal AssemblyConstants.ToffoliSimulator + ident "ResourcesEstimatorName" <-- literal AssemblyConstants.ResourcesEstimator ] + ``}`` + /// A sequence of all of the named parameters in the argument tuple and their respective C# and Q# types. let rec private parameters context doc = function | QsTupleItem variable -> @@ -104,7 +121,7 @@ let private mainMethod context entryPoint = let callableName, argTypeName, returnTypeName = callableTypeNames context entryPoint let driverType = generic (driverNamespace + ".Driver") ``<<`` [callableName; argTypeName; returnTypeName] ``>>`` let entryPointInstance = ``new`` (``type`` entryPointClassName) ``(`` [] ``)`` - let driver = ``new`` driverType ``(`` [entryPointInstance] ``)`` + let driver = ``new`` driverType ``(`` [driverSettings; entryPointInstance] ``)`` let commandLineArgsName = "args" arrow_method "System.Threading.Tasks.Task" "Main" ``<<`` [] ``>>`` ``(`` [param commandLineArgsName ``of`` (``type`` "string[]")] ``)`` @@ -121,7 +138,7 @@ let private entryPointClass context entryPoint = context.assemblyConstants.TryGetValue AssemblyConstants.DefaultSimulator |> snd |> (fun value -> if String.IsNullOrWhiteSpace value then AssemblyConstants.QuantumSimulator else value) - let defaultSimulatorProperty = property "DefaultSimulator" "string" (literal defaultSimulator) + let defaultSimulatorNameProperty = property "DefaultSimulatorName" "string" (literal defaultSimulator) let infoProperty = property "Info" (sprintf "EntryPointInfo<%s, %s>" argTypeName returnTypeName) @@ -129,7 +146,7 @@ let private entryPointClass context entryPoint = let members : MemberDeclarationSyntax list = [ summaryProperty parameterOptionsProperty parameters - defaultSimulatorProperty + defaultSimulatorNameProperty infoProperty customSimulatorFactory defaultSimulator createArgument context entryPoint diff --git a/src/Simulation/EntryPointDriver/Driver.cs b/src/Simulation/EntryPointDriver/Driver.cs index f5482391a9f..1b04ea12795 100644 --- a/src/Simulation/EntryPointDriver/Driver.cs +++ b/src/Simulation/EntryPointDriver/Driver.cs @@ -11,7 +11,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Quantum.QsCompiler.ReservedKeywords; using Microsoft.Quantum.Simulation.Core; using static Microsoft.Quantum.EntryPointDriver.Driver; @@ -25,6 +24,11 @@ namespace Microsoft.Quantum.EntryPointDriver /// The entry point's return type. public sealed class Driver where TCallable : AbstractCallable, ICallable { + /// + /// The driver settings. + /// + private readonly DriverSettings settings; + /// /// The entry point. /// @@ -38,24 +42,22 @@ public sealed class Driver where TCallable : AbstractCalla /// /// Creates a new driver for the entry point. /// + /// The driver settings. /// The entry point. - public Driver(IEntryPoint entryPoint) + public Driver(DriverSettings settings, IEntryPoint entryPoint) { + this.settings = settings; this.entryPoint = entryPoint; SimulatorOption = new OptionInfo( - new[] - { - "--" + CommandLineArguments.SimulatorOption.Item1, - "-" + CommandLineArguments.SimulatorOption.Item2 - }, - entryPoint.DefaultSimulator, + settings.SimulatorOptionAliases, + entryPoint.DefaultSimulatorName, "The name of the simulator to use.", suggestions: new[] { - AssemblyConstants.QuantumSimulator, - AssemblyConstants.ToffoliSimulator, - AssemblyConstants.ResourcesEstimator, - entryPoint.DefaultSimulator + settings.QuantumSimulatorName, + settings.ToffoliSimulatorName, + settings.ResourcesEstimatorName, + entryPoint.DefaultSimulatorName }); } @@ -119,28 +121,28 @@ public async Task Run(string[] args) /// The exit code. private async Task Simulate(ParseResult parseResult, string simulator) => await Simulation.Simulate( - entryPoint, parseResult, DefaultIfShadowed(SimulatorOption, simulator)); + settings, entryPoint, parseResult, DefaultIfShadowed(SimulatorOption, simulator)); /// /// Submits the entry point to Azure Quantum. /// /// The command-line parsing result. - /// The submission settings. - private async Task Submit(ParseResult parseResult, AzureSettings settings) => + /// The Azure submission settings. + private async Task Submit(ParseResult parseResult, AzureSettings azureSettings) => await Azure.Submit(entryPoint, parseResult, new AzureSettings { - Target = settings.Target, - Storage = settings.Storage, - Subscription = settings.Subscription, - ResourceGroup = settings.ResourceGroup, - Workspace = settings.Workspace, - AadToken = DefaultIfShadowed(AadTokenOption, settings.AadToken), - BaseUri = DefaultIfShadowed(BaseUriOption, settings.BaseUri), - JobName = DefaultIfShadowed(JobNameOption, settings.JobName), - Shots = DefaultIfShadowed(ShotsOption, settings.Shots), - Output = DefaultIfShadowed(OutputOption, settings.Output), - DryRun = DefaultIfShadowed(DryRunOption, settings.DryRun), - Verbose = DefaultIfShadowed(VerboseOption, settings.Verbose) + Target = azureSettings.Target, + Storage = azureSettings.Storage, + Subscription = azureSettings.Subscription, + ResourceGroup = azureSettings.ResourceGroup, + Workspace = azureSettings.Workspace, + AadToken = DefaultIfShadowed(AadTokenOption, azureSettings.AadToken), + BaseUri = DefaultIfShadowed(BaseUriOption, azureSettings.BaseUri), + JobName = DefaultIfShadowed(JobNameOption, azureSettings.JobName), + Shots = DefaultIfShadowed(ShotsOption, azureSettings.Shots), + Output = DefaultIfShadowed(OutputOption, azureSettings.Output), + DryRun = DefaultIfShadowed(DryRunOption, azureSettings.DryRun), + Verbose = DefaultIfShadowed(VerboseOption, azureSettings.Verbose) }); /// @@ -213,7 +215,7 @@ internal static class Driver /// internal static readonly OptionInfo StorageOption = new OptionInfo( new[] { "--storage" }, "The storage account connection string."); - + /// /// The subscription option. /// @@ -237,7 +239,7 @@ internal static class Driver /// internal static readonly OptionInfo AadTokenOption = new OptionInfo( new[] { "--aad-token" }, default, "The Azure Active Directory authentication token."); - + /// /// The base URI option. /// @@ -249,7 +251,7 @@ internal static class Driver /// internal static readonly OptionInfo JobNameOption = new OptionInfo( new[] { "--job-name" }, default, "The name of the submitted job."); - + /// /// The shots option. /// @@ -308,7 +310,9 @@ internal sealed class QsHelpBuilder : HelpBuilder /// Creates a new help builder using the given console. /// /// The console to use. - internal QsHelpBuilder(IConsole console) : base(console) { } + internal QsHelpBuilder(IConsole console) : base(console) + { + } protected override string ArgumentDescriptor(IArgument argument) { diff --git a/src/Simulation/EntryPointDriver/DriverSettings.cs b/src/Simulation/EntryPointDriver/DriverSettings.cs new file mode 100644 index 00000000000..19a1124d1b2 --- /dev/null +++ b/src/Simulation/EntryPointDriver/DriverSettings.cs @@ -0,0 +1,30 @@ +using System.Collections.Immutable; + +namespace Microsoft.Quantum.EntryPointDriver +{ + /// + /// Settings for the entry point driver. + /// + public sealed class DriverSettings + { + /// + /// The aliases for the simulator command-line option. + /// + public IImmutableList SimulatorOptionAliases { get; set; } + + /// + /// The name of the quantum simulator. + /// + public string QuantumSimulatorName { get; set; } + + /// + /// The name of the Toffoli simulator. + /// + public string ToffoliSimulatorName { get; set; } + + /// + /// The name of the resources estimator. + /// + public string ResourcesEstimatorName { get; set; } + } +} diff --git a/src/Simulation/EntryPointDriver/IEntryPoint.cs b/src/Simulation/EntryPointDriver/IEntryPoint.cs index 1d89c252db0..b06f3e7c016 100644 --- a/src/Simulation/EntryPointDriver/IEntryPoint.cs +++ b/src/Simulation/EntryPointDriver/IEntryPoint.cs @@ -24,17 +24,17 @@ public interface IEntryPoint /// The summary from the entry point's documentation comment. /// string Summary { get; } - + /// /// The command-line options corresponding to the entry point's parameters. /// IEnumerable private readonly IEnumerable? suggestions; - + /// /// The option validator. /// private readonly ValidateSymbol? validator; - + /// /// Creates an for a non-required option. /// @@ -57,7 +57,7 @@ internal sealed class OptionInfo /// The option suggestions. /// The option validator. internal OptionInfo( - IReadOnlyCollection aliases, + IReadOnlyList aliases, T defaultValue, string description, IEnumerable? suggestions = default, @@ -70,7 +70,7 @@ internal OptionInfo( this.suggestions = suggestions; this.validator = validator; } - + /// /// Creates an for a required option. /// @@ -79,7 +79,7 @@ internal OptionInfo( /// The option suggestions. /// The option validator. internal OptionInfo( - IReadOnlyCollection aliases, + IReadOnlyList aliases, string description, IEnumerable? suggestions = default, ValidateSymbol? validator = default) diff --git a/src/Simulation/EntryPointDriver/Simulation.cs b/src/Simulation/EntryPointDriver/Simulation.cs index d101e8980d0..88f9882777d 100644 --- a/src/Simulation/EntryPointDriver/Simulation.cs +++ b/src/Simulation/EntryPointDriver/Simulation.cs @@ -4,7 +4,6 @@ using System; using System.CommandLine.Parsing; using System.Threading.Tasks; -using Microsoft.Quantum.QsCompiler.ReservedKeywords; using Microsoft.Quantum.Simulation.Core; using Microsoft.Quantum.Simulation.Simulators; using static Microsoft.Quantum.EntryPointDriver.Driver; @@ -22,14 +21,15 @@ internal static class Simulation where TCallable : Abstrac /// /// Simulates the entry point. /// + /// The driver settings. /// The entry point. /// The command-line parsing result. /// The simulator to use. /// The exit code. internal static async Task Simulate( - IEntryPoint entryPoint, ParseResult parseResult, string simulator) + DriverSettings settings, IEntryPoint entryPoint, ParseResult parseResult, string simulator) { - if (simulator == AssemblyConstants.ResourcesEstimator) + if (simulator == settings.ResourcesEstimatorName) { var resourcesEstimator = new ResourcesEstimator(); await resourcesEstimator.Run(entryPoint.CreateArgument(parseResult)); @@ -38,12 +38,12 @@ internal static async Task Simulate( else { var (isCustom, createSimulator) = - simulator == AssemblyConstants.QuantumSimulator + simulator == settings.QuantumSimulatorName ? (false, () => new QuantumSimulator()) - : simulator == AssemblyConstants.ToffoliSimulator + : simulator == settings.ToffoliSimulatorName ? (false, new Func(() => new ToffoliSimulator())) : (true, entryPoint.CreateDefaultCustomSimulator); - if (isCustom && simulator != entryPoint.DefaultSimulator) + if (isCustom && simulator != entryPoint.DefaultSimulatorName) { DisplayCustomSimulatorError(simulator); return 1; @@ -52,7 +52,7 @@ internal static async Task Simulate( } return 0; } - + /// /// Runs the entry point on a simulator and displays its return value. /// @@ -79,7 +79,7 @@ private static async Task RunSimulator( } } } - + /// /// Displays an error message for using a non-default custom simulator. /// diff --git a/src/Simulation/EntryPointDriver/Validation.cs b/src/Simulation/EntryPointDriver/Validation.cs index f03b3da95e1..9beed2ba4ff 100644 --- a/src/Simulation/EntryPointDriver/Validation.cs +++ b/src/Simulation/EntryPointDriver/Validation.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; -using Microsoft.Quantum.QsCompiler.CompilationBuilder; namespace Microsoft.Quantum.EntryPointDriver { @@ -19,7 +18,7 @@ internal readonly struct Validation /// True if the validation succeeded. /// internal bool IsSuccess { get; } - + /// /// True if the validation failed. /// @@ -38,7 +37,7 @@ internal readonly struct Validation /// [MaybeNull] internal T ValueOrDefault { get; } - + /// /// The error message of the validation, or null if the validation has no error message. /// @@ -107,24 +106,12 @@ internal static Validation Bind(this Validation validation, Func /// internal static Validation> Sequence(this IEnumerable> validations) { - var (successes, failures) = validations.Partition(validation => validation.IsSuccess); + var results = validations.ToLookup(validation => validation.IsSuccess); + var successes = results[true]; + var failures = results[false]; return failures.Any() ? Validation>.Failure(failures.First().ErrorMessage) : Validation>.Success(successes.Select(validation => validation.Value)); } - - /// - /// Calls the action on the validation value if the validation is a success. - /// - /// The type of the validation's success value. - /// The validation. - /// The action to call if the validation is a success. - internal static void Then(this Validation validation, Action onSuccess) - { - if (validation.IsSuccess) - { - onSuccess(validation.Value); - } - } } } From ac999bec8b3e74fa3e0b872ea025a7f1c2bf15d2 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Tue, 9 Jun 2020 12:47:00 -0700 Subject: [PATCH 20/24] Use IImmutableList instead of IReadOnlyList --- src/Simulation/EntryPointDriver/Driver.cs | 25 ++++++++++--------- src/Simulation/EntryPointDriver/OptionInfo.cs | 7 +++--- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Simulation/EntryPointDriver/Driver.cs b/src/Simulation/EntryPointDriver/Driver.cs index 1b04ea12795..daabf992cde 100644 --- a/src/Simulation/EntryPointDriver/Driver.cs +++ b/src/Simulation/EntryPointDriver/Driver.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System; +using System.Collections.Immutable; using System.CommandLine; using System.CommandLine.Builder; using System.CommandLine.Help; @@ -208,55 +209,55 @@ internal static class Driver /// The target option. /// internal static readonly OptionInfo TargetOption = new OptionInfo( - new[] { "--target" }, "The target device ID."); + ImmutableList.Create("--target"), "The target device ID."); /// /// The storage option. /// internal static readonly OptionInfo StorageOption = new OptionInfo( - new[] { "--storage" }, "The storage account connection string."); + ImmutableList.Create("--storage"), "The storage account connection string."); /// /// The subscription option. /// internal static readonly OptionInfo SubscriptionOption = new OptionInfo( - new[] { "--subscription" }, "The subscription ID."); + ImmutableList.Create("--subscription"), "The subscription ID."); /// /// The resource group option. /// internal static readonly OptionInfo ResourceGroupOption = new OptionInfo( - new[] { "--resource-group" }, "The resource group name."); + ImmutableList.Create("--resource-group"), "The resource group name."); /// /// The workspace option. /// internal static readonly OptionInfo WorkspaceOption = new OptionInfo( - new[] { "--workspace" }, "The workspace name."); + ImmutableList.Create("--workspace"), "The workspace name."); /// /// The AAD token option. /// internal static readonly OptionInfo AadTokenOption = new OptionInfo( - new[] { "--aad-token" }, default, "The Azure Active Directory authentication token."); + ImmutableList.Create("--aad-token"), default, "The Azure Active Directory authentication token."); /// /// The base URI option. /// internal static readonly OptionInfo BaseUriOption = new OptionInfo( - new[] { "--base-uri" }, default, "The base URI of the Azure Quantum endpoint."); + ImmutableList.Create("--base-uri"), default, "The base URI of the Azure Quantum endpoint."); /// /// The job name option. /// internal static readonly OptionInfo JobNameOption = new OptionInfo( - new[] { "--job-name" }, default, "The name of the submitted job."); + ImmutableList.Create("--job-name"), default, "The name of the submitted job."); /// /// The shots option. /// internal static readonly OptionInfo ShotsOption = new OptionInfo( - new[] { "--shots" }, + ImmutableList.Create("--shots"), 500, "The number of times the program is executed on the target machine.", validator: result => @@ -268,7 +269,7 @@ internal static class Driver /// The output option. /// internal static readonly OptionInfo OutputOption = new OptionInfo( - new[] { "--output" }, + ImmutableList.Create("--output"), OutputFormat.FriendlyUri, "The information to show in the output after the job is submitted."); @@ -276,7 +277,7 @@ internal static class Driver /// The dry run option. /// internal static readonly OptionInfo DryRunOption = new OptionInfo( - new[] { "--dry-run" }, + ImmutableList.Create("--dry-run"), false, "Validate the program and options, but do not submit to Azure Quantum."); @@ -284,7 +285,7 @@ internal static class Driver /// The verbose option. /// internal static readonly OptionInfo VerboseOption = new OptionInfo( - new[] { "--verbose" }, false, "Show additional information about the submission."); + ImmutableList.Create("--verbose"), false, "Show additional information about the submission."); /// /// Displays a message to the console using the given color and text writer. diff --git a/src/Simulation/EntryPointDriver/OptionInfo.cs b/src/Simulation/EntryPointDriver/OptionInfo.cs index 03a42902971..78758a93c46 100644 --- a/src/Simulation/EntryPointDriver/OptionInfo.cs +++ b/src/Simulation/EntryPointDriver/OptionInfo.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.CommandLine; using System.CommandLine.Parsing; using System.Linq; @@ -15,7 +16,7 @@ internal sealed class OptionInfo /// /// The option aliases. /// - internal IReadOnlyList Aliases { get; } + internal IImmutableList Aliases { get; } /// /// The option's default value if the option has one. @@ -57,7 +58,7 @@ internal sealed class OptionInfo /// The option suggestions. /// The option validator. internal OptionInfo( - IReadOnlyList aliases, + IImmutableList aliases, T defaultValue, string description, IEnumerable? suggestions = default, @@ -79,7 +80,7 @@ internal OptionInfo( /// The option suggestions. /// The option validator. internal OptionInfo( - IReadOnlyList aliases, + IImmutableList aliases, string description, IEnumerable? suggestions = default, ValidateSymbol? validator = default) From afe66aada1b727311fccbda521c7fad40e6b7984 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Tue, 9 Jun 2020 12:57:15 -0700 Subject: [PATCH 21/24] Use ImmutableList.Create with params array --- src/Simulation/CsharpGeneration/EntryPoint.fs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Simulation/CsharpGeneration/EntryPoint.fs b/src/Simulation/CsharpGeneration/EntryPoint.fs index 3a95bb284a3..1bd1d481a94 100644 --- a/src/Simulation/CsharpGeneration/EntryPoint.fs +++ b/src/Simulation/CsharpGeneration/EntryPoint.fs @@ -28,9 +28,7 @@ let private driverNamespace = "Microsoft.Quantum.EntryPointDriver" /// The driver settings object. let private driverSettings = - let immutableList elements = - invoke (ident "System.Collections.Immutable.ImmutableList.Create") - ``(`` [``new array`` (Some "") elements] ``)`` + let immutableList elements = invoke (ident "System.Collections.Immutable.ImmutableList.Create") ``(`` elements ``)`` let simulatorOptionAliases = [ "--" + fst CommandLineArguments.SimulatorOption |> literal "-" + snd CommandLineArguments.SimulatorOption |> literal ] From f2be8e67cb9b50cf1f6f9b3bcc4ad158e94dc106 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Tue, 9 Jun 2020 14:52:28 -0700 Subject: [PATCH 22/24] Make DriverSettings immutable --- src/Simulation/CsharpGeneration/EntryPoint.fs | 21 ++++++++------- .../EntryPointDriver/DriverSettings.cs | 27 ++++++++++++++++--- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/Simulation/CsharpGeneration/EntryPoint.fs b/src/Simulation/CsharpGeneration/EntryPoint.fs index 1bd1d481a94..8906a7403c7 100644 --- a/src/Simulation/CsharpGeneration/EntryPoint.fs +++ b/src/Simulation/CsharpGeneration/EntryPoint.fs @@ -28,18 +28,21 @@ let private driverNamespace = "Microsoft.Quantum.EntryPointDriver" /// The driver settings object. let private driverSettings = + let newDriverSettings = driverNamespace + ".DriverSettings" |> ``type`` |> SyntaxFactory.ObjectCreationExpression + let namedArg (name : string) expr = SyntaxFactory.NameColon name |> (SyntaxFactory.Argument expr).WithNameColon let immutableList elements = invoke (ident "System.Collections.Immutable.ImmutableList.Create") ``(`` elements ``)`` let simulatorOptionAliases = - [ "--" + fst CommandLineArguments.SimulatorOption |> literal - "-" + snd CommandLineArguments.SimulatorOption |> literal ] + [ literal <| "--" + fst CommandLineArguments.SimulatorOption + literal <| "-" + snd CommandLineArguments.SimulatorOption ] |> immutableList - ``new init`` (driverNamespace + ".DriverSettings" |> ``type``) ``(`` [] ``)`` - ``{`` - [ ident "SimulatorOptionAliases" <-- simulatorOptionAliases - ident "QuantumSimulatorName" <-- literal AssemblyConstants.QuantumSimulator - ident "ToffoliSimulatorName" <-- literal AssemblyConstants.ToffoliSimulator - ident "ResourcesEstimatorName" <-- literal AssemblyConstants.ResourcesEstimator ] - ``}`` + [ namedArg "simulatorOptionAliases" simulatorOptionAliases + namedArg "quantumSimulatorName" <| literal AssemblyConstants.QuantumSimulator + namedArg "toffoliSimulatorName" <| literal AssemblyConstants.ToffoliSimulator + namedArg "resourcesEstimatorName" <| literal AssemblyConstants.ResourcesEstimator ] + |> SyntaxFactory.SeparatedList + |> SyntaxFactory.ArgumentList + |> newDriverSettings.WithArgumentList + :> ExpressionSyntax /// A sequence of all of the named parameters in the argument tuple and their respective C# and Q# types. let rec private parameters context doc = function diff --git a/src/Simulation/EntryPointDriver/DriverSettings.cs b/src/Simulation/EntryPointDriver/DriverSettings.cs index 19a1124d1b2..86ad41f66dc 100644 --- a/src/Simulation/EntryPointDriver/DriverSettings.cs +++ b/src/Simulation/EntryPointDriver/DriverSettings.cs @@ -10,21 +10,40 @@ public sealed class DriverSettings /// /// The aliases for the simulator command-line option. /// - public IImmutableList SimulatorOptionAliases { get; set; } + public IImmutableList SimulatorOptionAliases { get; } /// /// The name of the quantum simulator. /// - public string QuantumSimulatorName { get; set; } + public string QuantumSimulatorName { get; } /// /// The name of the Toffoli simulator. /// - public string ToffoliSimulatorName { get; set; } + public string ToffoliSimulatorName { get; } /// /// The name of the resources estimator. /// - public string ResourcesEstimatorName { get; set; } + public string ResourcesEstimatorName { get; } + + /// + /// Creates a new driver settings instance. + /// + /// The aliases for the simulator command-line option. + /// The name of the quantum simulator. + /// The name of the Toffoli simulator. + /// The name of the resources estimator. + public DriverSettings( + IImmutableList simulatorOptionAliases, + string quantumSimulatorName, + string toffoliSimulatorName, + string resourcesEstimatorName) + { + SimulatorOptionAliases = simulatorOptionAliases; + QuantumSimulatorName = quantumSimulatorName; + ToffoliSimulatorName = toffoliSimulatorName; + ResourcesEstimatorName = resourcesEstimatorName; + } } } From 939017353d7e8564ae41196cc44a1e3975129471 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Tue, 9 Jun 2020 14:56:33 -0700 Subject: [PATCH 23/24] Make DriverSettings properties internal --- src/Simulation/EntryPointDriver/DriverSettings.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Simulation/EntryPointDriver/DriverSettings.cs b/src/Simulation/EntryPointDriver/DriverSettings.cs index 86ad41f66dc..4b513cf50e4 100644 --- a/src/Simulation/EntryPointDriver/DriverSettings.cs +++ b/src/Simulation/EntryPointDriver/DriverSettings.cs @@ -10,22 +10,22 @@ public sealed class DriverSettings /// /// The aliases for the simulator command-line option. /// - public IImmutableList SimulatorOptionAliases { get; } + internal IImmutableList SimulatorOptionAliases { get; } /// /// The name of the quantum simulator. /// - public string QuantumSimulatorName { get; } + internal string QuantumSimulatorName { get; } /// /// The name of the Toffoli simulator. /// - public string ToffoliSimulatorName { get; } + internal string ToffoliSimulatorName { get; } /// /// The name of the resources estimator. /// - public string ResourcesEstimatorName { get; } + internal string ResourcesEstimatorName { get; } /// /// Creates a new driver settings instance. From e3f08c42e42c30dd8181a0f515c9875ba40db387 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Wed, 10 Jun 2020 16:02:29 -0700 Subject: [PATCH 24/24] Add PackageId to EntryPointDriver.csproj --- .../EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj b/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj index 02ed33563f6..ee9dd9b1dd8 100644 --- a/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj +++ b/src/Simulation/EntryPointDriver/Microsoft.Quantum.EntryPointDriver.csproj @@ -1,10 +1,11 @@ - + netstandard2.1 enable + Microsoft.Quantum.EntryPointDriver The standard command-line interface for standalone Q# console applications.