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
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
3 changes: 1 addition & 2 deletions PRIVACY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Privacy

The code in this repository contains features that may enable you and Microsoft to collect data from users of the applications.
The data collection is disabled by default but can be enabled by setting the corresponding flag upon compilation.
The code in this repository contains features that may enable you and Microsoft to collect data from users of the applications. Data collection is disabled by default but can be enabled by setting the corresponding flag upon compilation.

## Data Collection

Expand Down
55 changes: 55 additions & 0 deletions build/Set-VersionNumbers.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
param(
[string]
$AssemblyVersion = $Env:ASSEMBLY_VERSION,

[string]
$SemverVersion = $Env:SEMVER_VERSION,

[string]
$NuGetVersion = $Env:NUGET_VERSION,

[string]
$VsixVersion = $Env:VSIX_VERSION,

[switch]
$EnableTelemetry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that instead of using this script to enable telemetry, we would do it via a different one; it's odd that set-versionnumber also enables telemetry. if we want to keep it here, maybe change the name of the script to "PopulateTemplates.ps1" or something like that?
Also, how do you envision we will call this to enable telemetry? this is called indirectly by bootstrap, which by default should not enable it. Do you need to modify bootstrap to check some environment variable too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good point. I'll rename and propagate it through to bootstrap. I also think we have to propagate that information into the language server and VS extension project files, which I haven't done yet. Let me wrap up this PR since a bunch of things now got mixed together (I shouldn't have started to do telemetry things in this PR), and set up a proper separate PR to fully add all needed handles.

);

if ("$AssemblyVersion".Trim().Length -eq 0) {
$Date = Get-Date;
$Year = $Date.Year.ToString().Substring(2);
$Month = $Date.Month.ToString().PadLeft(2, "0");
$Hour = (Get-Date).Hour.ToString().PadLeft(2, "0");
$Minute = (Get-Date).Minute.ToString().PadLeft(2, "0");
$AssemblyVersion = "0.0.$Year$Month.$Hour$Minute";
}

if ("$SemverVersion".Trim().Length -eq 0) {
$pieces = "$AssemblyVersion".split(".");
$SemverVersion = "$($pieces[0]).$($pieces[1]).$($pieces[2])$($pieces[3])";
}

if ("$NuGetVersion".Trim().Length -eq 0) {
$NuGetVersion = "$AssemblyVersion-alpha";
}

if ("$VsixVersion".Trim().Length -eq 0) {
$VsixVersion = "$AssemblyVersion";
}

Get-ChildItem -Recurse *.v.template `
| ForEach-Object {
$Source = $_.FullName;
$Target = $Source.Substring(0, $Source.Length - 11);
Write-Verbose "Replacing ASSEMBLY_VERSION with $AssemblyVersion in $Source and writing to $Target.";
Get-Content $Source `
| ForEach-Object {
$_.
Replace("#ASSEMBLY_VERSION#", $AssemblyVersion).
Replace("#NUGET_VERSION#", $NuGetVersion).
Replace("#VSIX_VERSION#", $VsixVersion).
Replace("#SEMVER_VERSION#", $SemverVersion).
Replace("#ENABLE_TELEMETRY#", $EnableTelemetry.IsPresent.ToString().ToLower())
} `
| Set-Content $Target -NoNewline
}
2 changes: 1 addition & 1 deletion build/bootstrap.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dotnet --info || GOTO missingDotnet
git --version || GOTO missingGit

:: Set Build number on all files that uses it
CALL build\setVersionNumber.cmd
call powershell -NoProfile build\Set-VersionNumbers.ps1

:: Initialize the compiler's nuspec file
CALL :nuspecBootstrap
Expand Down
29 changes: 0 additions & 29 deletions build/setVersionNumber.cmd

This file was deleted.

3 changes: 3 additions & 0 deletions src/ProjectTemplates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Quantum.App1/Quantum.App1.csproj
Quantum.Library1/Quantum.Library1.csproj
Quantum.Test1/Quantum.Test1.csproj
2 changes: 1 addition & 1 deletion src/QsCompiler/CommandLineTool/QsCommandLineTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<AssemblyName>qsc</AssemblyName>
<AssemblyTitle>Microsoft Q# compiler command line tool.</AssemblyTitle>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/QsCompiler/LanguageServer/QsLanguageServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup>
<AssemblyName>Microsoft.Quantum.QsLanguageServer</AssemblyName>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<AssemblyName>Tests.Microsoft.Quantum.QsCompiler</AssemblyName>
<OutputType>Library</OutputType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<RootNamespace>Microsoft.Quantum.QsCompiler.Documentation.Testing</RootNamespace>
<AssemblyName>Tests.Microsoft.Quantum.QsDocumentationParser</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<AssemblyName>Tests.Microsoft.Quantum.QsLanguageServer</AssemblyName>
<OutputType>Library</OutputType>
Expand Down
17 changes: 8 additions & 9 deletions src/VSCodeExtension/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ After doing so, `vsce` can be used from the command line.

## Steps ##

Building the VS Code extension follows in a few main steps:
Building the VS Code extension requires the following steps:

- Setting up the Solid build itself.
- Setting up the build pre-requisites (see below for details).
- Installing all Node.js dependencies required by the extension.
- Compiling the language server and copying its assemblies into `bin/`.
- Compiling the TypeScript for the extension itself.
This step is automatically invoked when debugging the extension from within VS Code.

To set up the Solid build, we require at a minimum that `package.json` was successfully created from `package.json.v.template`.
This is necessary as `package.json` specifies all of the dependencies which must be installed in order for the TypeScript comprising the VS Code extension to successfully compile and run.
Typically, `package.json` is created from `package.json.v.template` by running `setVersionNumber.cmd` from the root folder of the Solid repository.
To set up the build pre-requisites, we require to run `build/bootstrap.cmd` from the root folder of the repository.
This in particular creates `package.json` from `package.json.v.template`, which specifies all of the dependencies that must be installed in order for the TypeScript comprising the VS Code extension to successfully compile and run.

Once `package.json` exists, Node.js dependencies can be installed:

Expand All @@ -48,7 +47,7 @@ vsce package

## Debugging ##

As an alternative to using `vsce package` to produce an installable VSIX, the VS Code extension can be run in an experimental instance of VS Code.
As an alternative to using `vsce package` to produce an installable VSIX, the VS Code extension can be run in an experimental instance of VS Code.
To do so, make sure that you have run the build procedure above through to calling `Build-Dependencies.ps1`.
Then, from the Debug tab in VS Code, ensure that "Extension" is selected in the Debug target menu and press the green ‣.

Expand All @@ -67,8 +66,8 @@ Change back to the "Extension" debugger and resume.

## Common Problems ##

### semver Issues ###
### Semver Issues ###

You may see an error when packaging or debugging the VS Code extension indicating that the package is not semver compatible.
This indicates that `setVersionNumber.cmd` did not produce a SemVer 2.0–compatible version number when writing `package.json` from `package.json.v.template`, typically due to a mis-set environment variable.
If this happens, correct the environment variables used by `setVersionNumber.cmd` or manually edit the `version` property of `package.json` (note that any such manual edits **will** be overwritten by calls to `setVersionNumber.cmd` and will not be saved in the repo).
This indicates that the build script `Set-VersionNumbers.ps1` did not produce a SemVer 2.0–compatible version number when writing `package.json` from `package.json.v.template`, typically due to a mis-set environment variable.
If this happens, correct the environment variables used by `Set-VersionNumbers.ps1` or manually edit the `version` property of `package.json` (note that any such manual edits **will** be overwritten by calls to `Set-VersionNumbers.ps1` and will not be saved in the repo).
5 changes: 4 additions & 1 deletion src/VSCodeExtension/Build-Dependencies.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

param(
[string]
$Configuration = $null,
Expand All @@ -6,7 +9,7 @@ param(
$Force
)

$TargetMoniker = "netcoreapp2.2";
$TargetMoniker = "netcoreapp2.1";
$LanguageServerRoot = Resolve-Path "../QsCompiler/LanguageServer/";

# If we're not given a configuration, try to populate from an enviromnent variable.
Expand Down
10 changes: 0 additions & 10 deletions src/VSCodeExtension/CHANGELOG.md

This file was deleted.

9 changes: 6 additions & 3 deletions src/VSCodeExtension/language-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
// symbols used as brackets
"brackets": [
["[", "]"],
["(", ")"]
["(", ")"],
["{", "}"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
["[", "]"],
["(", ")"]
["(", ")"],
["{", "}"]
],
// symbols that that can be used to surround a selection
"surroundingPairs": [
["[", "]"],
["(", ")"]
["(", ")"],
["{", "}"]
]
}
3 changes: 2 additions & 1 deletion src/VSCodeExtension/package.json.v.template
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@
},
"repository": {},
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"requiredDotNetCoreSDK": "2.1.0"
"requiredDotNetCoreSDK": "2.1.0",
"enableTelemetry" : #ENABLE_TELEMETRY#
}
3 changes: 3 additions & 0 deletions src/VSCodeExtension/src/dotnet.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

// IMPORTS /////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions src/VSCodeExtension/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
Expand Down
7 changes: 6 additions & 1 deletion src/VSCodeExtension/src/packageInfo.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

'use strict';

// IMPORTS /////////////////////////////////////////////////////////////////////
Expand All @@ -11,6 +14,7 @@ export interface IPackageInfo {
version: string;
aiKey: string;
requiredDotNetCoreSDK: string;
enableTelemetry: string;
}

export function getPackageInfo(context: vscode.ExtensionContext): IPackageInfo | undefined {
Expand All @@ -20,7 +24,8 @@ export function getPackageInfo(context: vscode.ExtensionContext): IPackageInfo |
name: extensionPackage.name,
version: extensionPackage.version,
aiKey: extensionPackage.aiKey,
requiredDotNetCoreSDK: extensionPackage.requiredDotNetCoreSDK
requiredDotNetCoreSDK: extensionPackage.requiredDotNetCoreSDK,
enableTelemetry: extensionPackage.enableTelemetry
};
}
return;
Expand Down
11 changes: 7 additions & 4 deletions src/VSCodeExtension/src/telemetry.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import * as vscode from 'vscode';
import { getPackageInfo } from './packageInfo';
import TelemetryReporter from 'vscode-extension-telemetry';
Expand All @@ -10,7 +13,7 @@ export class Reporter extends vscode.Disposable {
constructor(ctx: vscode.ExtensionContext) {
super(() => reporter.dispose());
let packageInfo = getPackageInfo(ctx);
if (packageInfo !== undefined) {
if (packageInfo !== undefined && packageInfo.enableTelemetry) {
reporter = new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
}
}
Expand Down Expand Up @@ -38,7 +41,7 @@ export function startTelemetry(context: vscode.ExtensionContext) {
context.subscriptions.push(new Reporter(context));

// Send initial events.
reporter.sendTelemetryEvent(EventNames.activate, {}, {});
if (reporter) reporter.sendTelemetryEvent(EventNames.activate, {}, {});
}

export function sendTelemetryTiming<T>(
Expand All @@ -57,7 +60,7 @@ export function sendTelemetryTiming<T>(

measurements["elapsedTime"] = elapsedTime;

reporter.sendTelemetryEvent(eventName, properties, measurements);
if (reporter) reporter.sendTelemetryEvent(eventName, properties, measurements);

return returnValue;

Expand Down Expand Up @@ -154,5 +157,5 @@ export function forwardServerTelemetry(telemetryRequest : any) {
}

// TODO: pass more than just the event name.
sendTelemetryEvent(name, properties, measurements);
sendTelemetryEvent(name, properties, measurements);
}
5 changes: 3 additions & 2 deletions src/VSCodeExtension/src/tests/extension.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// Note: This example test is leveraging the Mocha test framework.
// Please refer to their documentation on https://mochajs.org/ for help.
//

// The module 'assert' provides assertion methods from node
import * as assert from 'assert';
Expand Down
6 changes: 3 additions & 3 deletions src/VSCodeExtension/src/tests/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// This file is providing the test runner to use when running extension tests.
// By default the test runner in use is Mocha based.
//
Expand Down
27 changes: 0 additions & 27 deletions src/VSCodeExtension/vsc-extension-quickstart.md

This file was deleted.

1 change: 0 additions & 1 deletion src/VisualStudioExtension/QsharpAppTemplate/Driver.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;

using Microsoft.Quantum.Simulation.Core;
using Microsoft.Quantum.Simulation.Simulators;

Expand Down
Loading