Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
32 changes: 26 additions & 6 deletions src/QsCompiler/CompilationManager/CompilationUnitManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,34 @@ public void Dispose()
// routines related to tracking the source files

/// <summary>
/// Returns the string with the file ID associated with the given URI used throughout the compilation.
/// Converts a URI into the file ID used during compilation if the URI is an absolute file URI.
/// </summary>
public static bool TryGetFileId(Uri uri, out NonNullable<string> id)
/// <exception cref="ArgumentNullException">Thrown if the URI is null.</exception>
/// <exception cref="ArgumentException">Thrown if the URI is not an absolute URI or not a file URI.</exception>
public static NonNullable<string> GetFileId(Uri uri) =>
uri is null
? throw new ArgumentNullException(nameof(uri))
: TryGetFileId(uri, out var fileId)
? fileId
: throw new ArgumentException("The URI is not an absolute file URI.", nameof(uri));

/// <summary>
/// Converts a URI into the file ID used during compilation if the URI is an absolute file URI.
/// </summary>
/// <returns>True if converting the URI to a file ID succeeded.</returns>
[Obsolete("Use GetFileId instead after ensuring that the URI is an absolute file URI.")]
public static bool TryGetFileId(Uri uri, out NonNullable<string> fileId)
{
id = NonNullable<string>.New("");
if (uri == null || !uri.IsFile || !uri.IsAbsoluteUri) return false;
id = NonNullable<string>.New(uri.IsUnc ? uri.LocalPath : uri.AbsolutePath);
return true;
if (!(uri is null) && uri.IsFile && uri.IsAbsoluteUri)
{
fileId = NonNullable<string>.New(uri.LocalPath);
return true;
}
else
{
fileId = default;
return false;
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.11.2006.2118-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.11.2006.2409-alpha" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)../build/Library.props"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.11.2006.2118-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.11.2006.2409-alpha" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)../build/Library.props"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.CsharpGeneration" Version="0.11.2006.2118-beta" />
<PackageReference Include="Microsoft.Quantum.CsharpGeneration" Version="0.11.2006.2409-alpha" />
</ItemGroup>

</Project>
Expand Down
9 changes: 3 additions & 6 deletions src/QsCompiler/Tests.Compiler/SerializationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ module SerializationTests =

open System
open System.Collections.Immutable
open System.IO;
open System.Reflection
open System.Reflection.PortableExecutable;
open System.Web
open Microsoft.Quantum.QsCompiler
open Microsoft.Quantum.QsCompiler.CompilationBuilder
open Microsoft.Quantum.QsCompiler.DataTypes
Expand Down Expand Up @@ -261,7 +260,8 @@ module SerializationTests =
let specs = attrs.Specializations |> Seq.map (fun s -> (s.ToTuple() |> fst).ToJson()) |> Seq.toList
let AssertEqual (expected : string list) (got : _ list) =
Assert.Equal(expected.Length, got.Length)
expected |> List.iteri (fun i ex -> Assert.Equal (ex.Replace("%%%", dllId.Value), got.[i]))
expected |> List.iteri (fun i ex ->
Assert.Equal (ex.Replace("%%%", HttpUtility.JavaScriptStringEncode dllId.Value), got.[i]))
AssertEqual [CALLABLE_1; CALLABLE_2; CALLABLE_3] callables
AssertEqual [SPECIALIZATION_1; SPECIALIZATION_3] specs
AssertEqual [TYPE_1] types
Expand All @@ -275,6 +275,3 @@ module SerializationTests =
[<assembly: Attributes.CallableDeclaration(CALLABLE_3)>]
[<assembly: Attributes.SpecializationDeclaration(SPECIALIZATION_3)>]
do ()