diff --git a/src/Simulation/CsharpGeneration/Context.fs b/src/Simulation/CsharpGeneration/Context.fs index db612b799c3..411ab9c5e9c 100644 --- a/src/Simulation/CsharpGeneration/Context.fs +++ b/src/Simulation/CsharpGeneration/Context.fs @@ -19,7 +19,7 @@ module internal DeclarationLocations = type TransformationState() = member val internal CurrentSource = null with get, set - member val internal DeclarationLocations = new List * (int * int)>() + member val internal DeclarationLocations = new List * Position>() type NamespaceTransformation(parent : SyntaxTreeTransformation) = inherit NamespaceTransformation(parent) @@ -60,7 +60,7 @@ type CodegenContext = { allQsElements : IEnumerable allUdts : ImmutableDictionary allCallables : ImmutableDictionary - declarationPositions : ImmutableDictionary, ImmutableSortedSet> + declarationPositions : ImmutableDictionary, ImmutableSortedSet> byName : ImmutableDictionary,(NonNullable*QsCallable) list> current : QsQualifiedName option signature : ResolvedSignature option diff --git a/src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.fsproj b/src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.fsproj index 59d46b17145..5f63b02f224 100644 --- a/src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.fsproj +++ b/src/Simulation/CsharpGeneration/Microsoft.Quantum.CsharpGeneration.fsproj @@ -21,7 +21,7 @@ - + diff --git a/src/Simulation/CsharpGeneration/SimulationCode.fs b/src/Simulation/CsharpGeneration/SimulationCode.fs index 30d8bcdd95a..e7a30aa50e4 100644 --- a/src/Simulation/CsharpGeneration/SimulationCode.fs +++ b/src/Simulation/CsharpGeneration/SimulationCode.fs @@ -274,7 +274,7 @@ module SimulationCode = override this.OnStatement (node:QsStatement) = match node.Location with | Value loc -> - let (current, _) = loc.Offset + let current = loc.Offset.Line parent.LineNumber <- parent.StartLine |> Option.map (fun start -> start + current + 1) // The Q# compiler reports 0-based line numbers. | Null -> parent.LineNumber <- None // auto-generated statement; the line number will be set to the specialization declaration @@ -839,7 +839,7 @@ module SimulationCode = override this.OnSpecializationDeclaration (sp : QsSpecialization) = count <- 0 match sp.Location with - | Value location -> parent.StartLine <- Some (location.Offset |> fst) + | Value location -> parent.StartLine <- Some location.Offset.Line | Null -> parent.StartLine <- None // TODO: we may need to have the means to know which original declaration the code came from base.OnSpecializationDeclaration sp @@ -1003,12 +1003,12 @@ module SimulationCode = | Null -> [] | Value location -> [ // since the line numbers throughout the generated code are 1-based, let's also choose them 1-based here - let startLine = fst location.Offset + 1 + let startLine = location.Offset.Line + 1 let endLine = match context.declarationPositions.TryGetValue sp.SourceFile with | true, startPositions -> let index = startPositions.IndexOf location.Offset - if index + 1 >= startPositions.Count then -1 else fst startPositions.[index + 1] + 1 + if index + 1 >= startPositions.Count then -1 else startPositions.[index + 1].Line + 1 //TODO: diagnostics. | false, _ -> startLine ``attribute`` None (``ident`` "SourceLocation") [ @@ -1328,7 +1328,7 @@ module SimulationCode = let properties = buildOutput () let methods = match op.Location with - | Value location -> [ buildUnitTest targetName opName (fst location.Offset) op.SourceFile.Value ] + | Value location -> [ buildUnitTest targetName opName location.Offset.Line op.SourceFile.Value ] // TODO: diagnostics | Null -> failwith "missing location for unit test" 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 4bbaca22c96..92aab6749f8 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 93ea0e58438..ffe59c9eaec 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 4e966759f8d..a8a9bf880bc 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj @@ -1,4 +1,4 @@ - + Library @@ -22,4 +22,4 @@ - \ No newline at end of file + diff --git a/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj index c9278c38294..50759c6ff87 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj @@ -1,4 +1,4 @@ - + Library @@ -22,4 +22,4 @@ - \ No newline at end of file + 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 89f9b7e7bf4..f3e9fa97083 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 2da5c023bb3..6bc3becc14d 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 2da5c023bb3..6bc3becc14d 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 fb279f5a569..c6f7416e993 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj @@ -1,4 +1,4 @@ - + Library @@ -22,4 +22,4 @@ - \ No newline at end of file + diff --git a/src/Simulation/Simulators.Tests/TestProjects/QsharpExe/QsharpExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/QsharpExe/QsharpExe.csproj index 85fe87c7403..6bf3908ba0c 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/UnitTests/UnitTests.csproj b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj index cff781acc39..93ba7b93252 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 4396deac881..3ba45db5b21 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 50eef571a8b..888406e6434 100644 --- a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj @@ -1,4 +1,4 @@ - +