Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
501ad89
Start set up for entry point code generation
Apr 7, 2020
d5787a2
Generate sequence of command-line options
Apr 7, 2020
bb1b8a2
Generate argument properties
Apr 8, 2020
b2de6e5
Capitalize first letter of argument property
Apr 8, 2020
c345fa4
Add autogen comment to entry point file
Apr 8, 2020
b8e939f
Add run method to runner
Apr 8, 2020
3b0f10f
Check if temp entry point exists in CodegenContext.Create
Apr 8, 2020
ba6fb11
Get entry points from compilation
Apr 8, 2020
50b14bb
Add non-generated entry point driver source
Apr 8, 2020
b9010cc
Use IEnumerable for array types
Apr 8, 2020
41d599b
Convert argument names to kebab-case
Apr 8, 2020
75e5a7c
Undo changes to CodegenContext
Apr 9, 2020
737ed37
Remove unnecessary string interpolation
Apr 9, 2020
a2dc23a
Use entry point summary as description for root command
Apr 9, 2020
1799688
Use doc comment for option descriptions
Apr 9, 2020
913b265
One-letter parameters get one dash
Apr 10, 2020
17b122e
Don't output anything if return type is Unit
Apr 11, 2020
93f8867
Handle parameters of type Range
Apr 14, 2020
7abfca2
Add doc comments to driver
Apr 14, 2020
f356c8a
Add argument handler for BigInt
Apr 14, 2020
f854579
Don't allow more dots than necessary in range
Apr 14, 2020
29798f1
Don't show duplicate errors
Apr 14, 2020
12041a8
Add function to create error messages
Apr 14, 2020
af30876
Add argument handler for Result type
Apr 14, 2020
b768e31
Add argument handler for type Unit
Apr 14, 2020
091ce83
Change readonly fields to properties
Apr 14, 2020
1fa663d
Refactor argument parsers
Apr 14, 2020
c77cf9f
Refactor getArgumentHandler
Apr 14, 2020
7b6e8ad
Merge remote-tracking branch 'origin/master' into samarsha/standalone
Apr 14, 2020
f30a397
Remove extra blank line
Apr 14, 2020
0925f76
Use Enum.TryParse for Result
Apr 15, 2020
261eb2d
Combine simulate and resources commands
Apr 15, 2020
b0e2044
Pass simulate description to constructor
Apr 15, 2020
1a63d62
Set simulate command as the default
Apr 15, 2020
e106ace
Add suggestions for custom argument types
Apr 15, 2020
59175c0
Entry point option names shadow standard names
Apr 15, 2020
39997c6
Support custom simulators
Apr 16, 2020
8bca47e
Merge branch 'master' into samarsha/standalone
bamarsha Apr 16, 2020
f0a6b51
Use DefaultSimulator property
Apr 16, 2020
583168f
Support custom DefaultSimulator; remove reflection
Apr 16, 2020
88801bc
Add TODO for option alias constants
Apr 16, 2020
5fd5720
Merge branch 'master' into samarsha/standalone
bamarsha Apr 17, 2020
fb4cbcd
Verify not more than one entry point
Apr 17, 2020
5d44673
Use CommandLineArguments.SimulatorOption
Apr 18, 2020
ee15b5c
Simplify function names
Apr 18, 2020
e85a806
Add constants for simulator names
Apr 18, 2020
c331f48
Protect namespace name instead of class names
Apr 18, 2020
e5a790a
Support tab completion for simulators
Apr 18, 2020
bc7a216
Consistent trailing newlines for generatedClasses and driver
Apr 20, 2020
0cb3ef0
Add basic unit tests
Apr 20, 2020
e6b266c
Add tests for option types
Apr 21, 2020
84b71b5
Add failure cases
Apr 21, 2020
d2afefb
Better test syntax
Apr 21, 2020
a3ba32d
Add help message test
Apr 21, 2020
1778b9e
Add tests for name conversions and shadowing
Apr 21, 2020
d8a9fd0
Add tests for multiple options
Apr 21, 2020
d5819ba
Add simulator tests
Apr 21, 2020
f4b6357
Should be private
Apr 21, 2020
db81d14
More detailed error message for missing reference
Apr 21, 2020
c7fcc70
Use platform-specific delimiter
Apr 21, 2020
42f8fd3
Use default simulator when --simulator is shadowed
Apr 21, 2020
92a1f1c
Normalize whitespace in tests
Apr 21, 2020
d56c837
Update DefaultIfShadowed summary
Apr 21, 2020
fcd1c20
Add DefaultSimulator tests
Apr 21, 2020
960cc71
Use AssemblyConstants for simulator names
Apr 21, 2020
b006c3b
Use H gate to test for ToffoliSimulator
Apr 21, 2020
a26a637
Use try/finally for console redirects and current culture
Apr 21, 2020
52c2873
Add missing dashes in test name
Apr 21, 2020
6f426a8
Better way to write the testAssembly function
Apr 22, 2020
c938ae8
adding an execution test (#174)
bettinaheim Apr 22, 2020
7ed88f0
forgot to use dll instead of exe
Apr 22, 2020
bba191c
Merge branch 'master' into samarsha/standalone
bettinaheim Apr 22, 2020
f1dc2f6
Add TODO
Apr 22, 2020
a422cf8
Merge branch 'samarsha/standalone' of https://github.com/microsoft/qs…
Apr 22, 2020
0de879d
Remove space-separated range parsing
Apr 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,4 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/
/src/Simulation/Simulators.Tests/TestProjects/QsharpExe/built
22 changes: 22 additions & 0 deletions Simulation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Tests.RoslynWrapper", "src\
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Microsoft.Quantum.CsharpGeneration", "src\Simulation\CsharpGeneration\Microsoft.Quantum.CsharpGeneration.fsproj", "{B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestProjects", "TestProjects", "{09C842CB-930C-4C7D-AD5F-E30DE4A55820}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QsharpExe", "src\Simulation\Simulators.Tests\TestProjects\QsharpExe\QsharpExe.csproj", "{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -239,6 +243,22 @@ Global
{B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{B96E97F4-2DC8-45AC-ADF5-861D0D3073FC}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Debug|x64.ActiveCfg = Debug|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Debug|x64.Build.0 = Debug|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Release|Any CPU.Build.0 = Release|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Release|x64.ActiveCfg = Release|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.Release|x64.Build.0 = Release|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -256,6 +276,8 @@ Global
{618FBF9D-4EF3-435D-9728-81C726236668} = {A567C185-A429-418B-AFDE-6F1785BA4A77}
{48206BD6-48DD-4442-A395-3A6594E4C9C6} = {A567C185-A429-418B-AFDE-6F1785BA4A77}
{B96E97F4-2DC8-45AC-ADF5-861D0D3073FC} = {A567C185-A429-418B-AFDE-6F1785BA4A77}
{09C842CB-930C-4C7D-AD5F-E30DE4A55820} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4}
{2F5796A7-4AF8-4B78-928A-0A3A80752F9D} = {09C842CB-930C-4C7D-AD5F-E30DE4A55820}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {929C0464-86D8-4F70-8835-0A5EAF930821}
Expand Down
10 changes: 10 additions & 0 deletions src/Simulation/CsharpGeneration.Tests/Circuits/Core.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Microsoft.Quantum.Core {
@Attribute()
newtype Attribute = Unit;

@Attribute()
newtype EntryPoint = Unit;
}
247 changes: 247 additions & 0 deletions src/Simulation/CsharpGeneration.Tests/Circuits/EntryPointTests.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

//
// No Options
//

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation ReturnUnit() : Unit { }
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation ReturnInt() : Int {
return 42;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation ReturnString() : String {
return "Hello, World!";
}
}

// ---

//
// Single Option
//

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation AcceptInt(n : Int) : Int {
return n;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation AcceptBigInt(n : BigInt) : BigInt {
return n;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation AcceptDouble(n : Double) : Double {
return n;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation AcceptBool(b : Bool) : Bool {
return b;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation AcceptPauli(p : Pauli) : Pauli {
return p;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation AcceptResult(r : Result) : Result {
return r;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation AcceptRange(r : Range) : Range {
return r;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation AcceptString(s : String) : String {
return s;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation AcceptStringArray(xs : String[]) : String[] {
return xs;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation AcceptUnit(u : Unit) : Unit {
return u;
}
}

// ---

//
// Multiple Options
//

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation TwoOptions(n : Int, b : Bool) : String {
return $"{n} {b}";
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation ThreeOptions(n : Int, b : Bool, xs : String[]) : String {
return $"{n} {b} {xs}";
}
}

// ---

//
// Name Conversion
//

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation CamelCase(camelCaseName : String) : String {
return camelCaseName;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation SingleLetter(x : String) : String {
return x;
}
}

// ---

//
// Shadowing
//

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation ShadowSimulator(simulator : String) : String {
return simulator;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation ShadowS(s : String) : String {
return s;
}
}

// ---

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
@EntryPoint()
operation ShadowVersion(version : String) : String {
return version;
}
}

// ---

//
// Simulators
//

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
open Microsoft.Quantum.Intrinsic;

@EntryPoint()
operation XOrH(useH : Bool) : String {
using (q = Qubit()) {
if (useH) {
H(q);
} else {
X(q);
}

if (M(q) == One) {
X(q);
}
}
return "Hello, World!";
}
}

// ---

//
// Help
//

namespace Microsoft.Quantum.CsharpGeneration.Testing.EntryPoint {
/// # Summary
/// This test checks that the entry point documentation appears correctly in the command line help message.
///
/// # Input
/// ## n
/// A number.
///
/// ## pauli
/// The name of a Pauli matrix.
///
/// ## myCoolBool
/// A neat bit.
@EntryPoint()
operation Help(n : Int, pauli : Pauli, myCoolBool : Bool) : Unit { }
}
Loading