From e0b98e451c7793b6f2761fd0b7618db69cb06574 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Tue, 26 Jan 2021 12:49:08 -0800 Subject: [PATCH 1/3] Use new Visibility compiler API --- .../Microsoft.Quantum.CSharpGeneration.fsproj | 2 +- .../CSharpGeneration/SimulationCode.fs | 16 ++++++++-------- ...tum.Simulation.QCTraceSimulatorRuntime.csproj | 2 +- .../Microsoft.Quantum.QSharp.Core.csproj | 2 +- .../HoneywellExe/HoneywellExe.csproj | 2 +- .../IntrinsicTests/IntrinsicTests.csproj | 2 +- .../TestProjects/IonQExe/IonQExe.csproj | 2 +- .../Library with Spaces.csproj | 2 +- .../TestProjects/Library1/Library1.csproj | 2 +- .../TestProjects/Library2/Library2.csproj | 2 +- .../TestProjects/QCIExe/QCIExe.csproj | 2 +- .../TestProjects/QSharpExe/QSharpExe.csproj | 2 +- .../TestProjects/TargetedExe/TargetedExe.csproj | 2 +- .../TestProjects/UnitTests/UnitTests.csproj | 2 +- .../Tests.Microsoft.Quantum.Simulators.csproj | 2 +- .../Microsoft.Quantum.Simulators.csproj | 2 +- 16 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj b/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj index a2d82a34698..d830960e04f 100644 --- a/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj +++ b/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj @@ -22,7 +22,7 @@ - + diff --git a/src/Simulation/CSharpGeneration/SimulationCode.fs b/src/Simulation/CSharpGeneration/SimulationCode.fs index 89e49873194..c4f0fd06f69 100644 --- a/src/Simulation/CSharpGeneration/SimulationCode.fs +++ b/src/Simulation/CSharpGeneration/SimulationCode.fs @@ -917,16 +917,16 @@ module SimulationCode = /// a Property that returns an instance of the operation by calling the /// IOperationFactory let buildOpsProperties context (operations : QsQualifiedName list): MemberDeclarationSyntax list = - let getCallableAccessModifier qualifiedName = + let getCallableVisibility qualifiedName = match context.allCallables.TryGetValue qualifiedName with - | true, callable -> Some callable.Modifiers.Access + | true, callable -> Some callable.Visibility | false, _ -> None let getPropertyModifiers qualifiedName = // Use the right accessibility for the property depending on the accessibility of the callable. // Note: In C#, "private protected" is the intersection of protected and internal. - match getCallableAccessModifier qualifiedName |> Option.defaultValue DefaultAccess with - | DefaultAccess -> [ ``protected`` ] + match getCallableVisibility qualifiedName |> Option.defaultValue Public with + | Public -> [ ``protected`` ] | Internal -> [ ``private``; ``protected`` ] let buildOne qualifiedName = @@ -1374,8 +1374,8 @@ module SimulationCode = (constructors @ properties @ methods) ``}`` - let private classAccessModifier = function - | DefaultAccess -> ``public`` + let private classVisibility = function + | Public -> ``public`` | Internal -> ``internal`` // Builds the .NET class for the given operation. @@ -1440,7 +1440,7 @@ module SimulationCode = let methods = [ opNames |> buildInit context; inData |> fst; outData |> fst; buildRun context nonGenericName op.ArgumentTuple op.Signature.ArgumentType op.Signature.ReturnType ] let modifiers = - let access = classAccessModifier op.Modifiers.Access + let access = classVisibility op.Visibility if isAbstract op then [ access; ``abstract``; ``partial`` ] else @@ -1535,7 +1535,7 @@ module SimulationCode = let baseClassName = udtBaseClassName context qsharpType let baseClass = ``simpleBase`` baseClassName - let modifiers = [ classAccessModifier udt.Modifiers.Access ] + let modifiers = [ classVisibility udt.Visibility ] let interfaces = [ ``simpleBase`` "IApplyData" ] let constructors = [ buildEmptyConstructor; buildBaseTupleConstructor ] let qubitsField = buildQubitsField context qsharpType diff --git a/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj b/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj index 49f799ff786..22856d43a84 100644 --- a/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj +++ b/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj b/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj index 3077b66fa29..4770fc52846 100644 --- a/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj +++ b/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj index 2e2aaa2419d..0444d1dfc78 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj @@ -1,4 +1,4 @@ - + Library diff --git a/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj b/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj index 0c26fcc91ab..b0b785a6a9d 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj index 823feef39e8..0973de80d17 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj @@ -1,4 +1,4 @@ - + Library diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj index 5579f6e7271..47253d0bd2f 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 false diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj index 8f491550555..82114e3e08d 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj index 8f491550555..82114e3e08d 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj index e7eae4c72d5..27fb6f5740a 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj @@ -1,4 +1,4 @@ - + Library diff --git a/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj index 5dd519483e3..2e87dd1296b 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj index 2085a1032e2..0e1262efbfa 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj index d494173e271..fb87501381f 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 diff --git a/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj b/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj index f827fddd63d..11775f4895d 100644 --- a/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj index 46bf637dc8e..211e3dca5d3 100644 --- a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj @@ -1,4 +1,4 @@ - + From 0b6372e529efcc93297d99b59a3370cee6634967 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Wed, 3 Feb 2021 12:25:54 -0800 Subject: [PATCH 2/3] Update C# gen and fix package versions --- src/Simulation/CSharpGeneration/SimulationCode.fs | 10 +++++----- .../Microsoft.Quantum.QSharp.Foundation.csproj | 2 +- .../Tests.Microsoft.Quantum.Simulators.Type1.csproj | 2 +- .../Tests.Microsoft.Quantum.Simulators.Type2.csproj | 2 +- .../Type1Core/Microsoft.Quantum.Type1.Core.csproj | 2 +- .../Type2Core/Microsoft.Quantum.Type2.Core.csproj | 2 +- src/Xunit/Microsoft.Quantum.Xunit.nuspec | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Simulation/CSharpGeneration/SimulationCode.fs b/src/Simulation/CSharpGeneration/SimulationCode.fs index 2db34fdd7c4..6dbe43ed517 100644 --- a/src/Simulation/CSharpGeneration/SimulationCode.fs +++ b/src/Simulation/CSharpGeneration/SimulationCode.fs @@ -946,15 +946,15 @@ module SimulationCode = /// a Property that returns an instance of the operation by calling the /// IOperationFactory let buildOpsProperties context (operations : QsQualifiedName list): MemberDeclarationSyntax list = - let getCallableVisibility qualifiedName = + let getCallableAccess qualifiedName = match context.allCallables.TryGetValue qualifiedName with - | true, callable -> Some callable.Visibility + | true, callable -> Some callable.Access | false, _ -> None let getPropertyModifiers qualifiedName = // Use the right accessibility for the property depending on the accessibility of the callable. // Note: In C#, "private protected" is the intersection of protected and internal. - match getCallableVisibility qualifiedName |> Option.defaultValue Public with + match getCallableAccess qualifiedName |> Option.defaultValue Public with | Public -> [ ``protected`` ] | Internal -> [ ``private``; ``protected`` ] @@ -1509,7 +1509,7 @@ module SimulationCode = let methods = [ opNames |> buildInit context; inData |> fst; outData |> fst; buildRun context nonGenericName op.ArgumentTuple op.Signature.ArgumentType op.Signature.ReturnType ] let modifiers = - let access = classVisibility op.Visibility + let access = classVisibility op.Access if opIsIntrinsic && not isConcreteIntrinsic then [ access; ``abstract``; ``partial`` ] else @@ -1604,7 +1604,7 @@ module SimulationCode = let baseClassName = udtBaseClassName context qsharpType let baseClass = ``simpleBase`` baseClassName - let modifiers = [ classVisibility udt.Visibility ] + let modifiers = [ classVisibility udt.Access ] let interfaces = [ ``simpleBase`` "IApplyData" ] let constructors = [ buildEmptyConstructor; buildBaseTupleConstructor ] let qubitsField = buildQubitsField context qsharpType diff --git a/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj b/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj index 7f1e17b0cc9..9a06580dd78 100644 --- a/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj +++ b/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj b/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj index 56ec206e682..8d865ec7c7b 100644 --- a/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj +++ b/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj b/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj index 094f95bf64b..37187cc9a86 100644 --- a/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj +++ b/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj b/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj index 2c079625605..fe81f6154b4 100644 --- a/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj +++ b/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj b/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj index ce3994546d3..1f0704bcf42 100644 --- a/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj +++ b/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Xunit/Microsoft.Quantum.Xunit.nuspec b/src/Xunit/Microsoft.Quantum.Xunit.nuspec index 0e798934212..0a48633bf1e 100644 --- a/src/Xunit/Microsoft.Quantum.Xunit.nuspec +++ b/src/Xunit/Microsoft.Quantum.Xunit.nuspec @@ -22,7 +22,7 @@ - + From bdc6a60008c93dba0ebbd7731bdddd1dad6c7834 Mon Sep 17 00:00:00 2001 From: Sarah Marshall Date: Wed, 3 Feb 2021 12:29:09 -0800 Subject: [PATCH 3/3] Update naming --- src/Simulation/CSharpGeneration/SimulationCode.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Simulation/CSharpGeneration/SimulationCode.fs b/src/Simulation/CSharpGeneration/SimulationCode.fs index 6dbe43ed517..f8fa92a5e65 100644 --- a/src/Simulation/CSharpGeneration/SimulationCode.fs +++ b/src/Simulation/CSharpGeneration/SimulationCode.fs @@ -1439,7 +1439,7 @@ module SimulationCode = (constructors @ properties @ methods) ``}`` - let private classVisibility = function + let private classAccess = function | Public -> ``public`` | Internal -> ``internal`` @@ -1509,7 +1509,7 @@ module SimulationCode = let methods = [ opNames |> buildInit context; inData |> fst; outData |> fst; buildRun context nonGenericName op.ArgumentTuple op.Signature.ArgumentType op.Signature.ReturnType ] let modifiers = - let access = classVisibility op.Access + let access = classAccess op.Access if opIsIntrinsic && not isConcreteIntrinsic then [ access; ``abstract``; ``partial`` ] else @@ -1604,7 +1604,7 @@ module SimulationCode = let baseClassName = udtBaseClassName context qsharpType let baseClass = ``simpleBase`` baseClassName - let modifiers = [ classVisibility udt.Access ] + let modifiers = [ classAccess udt.Access ] let interfaces = [ ``simpleBase`` "IApplyData" ] let constructors = [ buildEmptyConstructor; buildBaseTupleConstructor ] let qubitsField = buildQubitsField context qsharpType