From ba0a71ec15e93748eeb40f3714eed6fda88cea14 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Sun, 23 Jun 2019 20:03:00 -0700 Subject: [PATCH 01/15] disabling telemetry unless TELEMETRY is defined in the VS extension --- src/VisualStudioExtension/QsharpLanguageClient/Telemetry.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/VisualStudioExtension/QsharpLanguageClient/Telemetry.cs b/src/VisualStudioExtension/QsharpLanguageClient/Telemetry.cs index 9423fc0d1c..683ae4733d 100644 --- a/src/VisualStudioExtension/QsharpLanguageClient/Telemetry.cs +++ b/src/VisualStudioExtension/QsharpLanguageClient/Telemetry.cs @@ -36,11 +36,14 @@ public static string PrefixProperty(string propName) return $"{PUBLISHER}.{EXTENSION}.{propName?.ToLowerInvariant()}"; } - /// Sends the telemetry event for the event with the given name and properties. + /// Does nothing unless the corresponding flag is defined upon compilation. + /// If the telemetry flag is defined upon compilation, + /// sends the telemetry event for the event with the given name and properties. /// Ignores any properties where the key is null or "version" (case insensitive). /// Adds the version of the extension assembly as version. public static void SendEvent(string name, IEnumerable> props = null) { +#if TELEMETRY props = props ?? Enumerable.Empty>(); var evt = new TelemetryEvent(PrefixEventName(name)); foreach (var entry in props.Where(p => !string.IsNullOrEmpty(p.Key))) @@ -52,6 +55,7 @@ public static void SendEvent(string name, IEnumerable From 512bc459d4713803a25d7303b8fb084e308e8fa5 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Sun, 23 Jun 2019 20:20:05 -0700 Subject: [PATCH 02/15] forgot a couple of copyright headers --- src/VSCodeExtension/Build-Dependencies.ps1 | 3 +++ src/VSCodeExtension/CHANGELOG.md | 10 ---------- src/VSCodeExtension/src/dotnet.ts | 3 +++ src/VSCodeExtension/src/extension.ts | 3 +++ src/VSCodeExtension/src/packageInfo.ts | 3 +++ src/VSCodeExtension/src/telemetry.ts | 3 +++ src/VSCodeExtension/src/tests/extension.test.ts | 5 +++-- src/VSCodeExtension/src/tests/index.ts | 6 +++--- src/VisualStudioExtension/QsharpAppTemplate/Driver.cs | 1 - .../QsharpLanguageClient/QsContentTypeDefinition.cs | 5 ++++- .../QsharpLanguageClient/QsLanguageClient.cs | 5 ++++- .../QsharpLanguageClient/Telemetry.cs | 5 ++++- 12 files changed, 33 insertions(+), 19 deletions(-) delete mode 100644 src/VSCodeExtension/CHANGELOG.md diff --git a/src/VSCodeExtension/Build-Dependencies.ps1 b/src/VSCodeExtension/Build-Dependencies.ps1 index 1f5ed8f9e2..3e82bba363 100644 --- a/src/VSCodeExtension/Build-Dependencies.ps1 +++ b/src/VSCodeExtension/Build-Dependencies.ps1 @@ -1,3 +1,6 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + param( [string] $Configuration = $null, diff --git a/src/VSCodeExtension/CHANGELOG.md b/src/VSCodeExtension/CHANGELOG.md deleted file mode 100644 index e680ccbefd..0000000000 --- a/src/VSCodeExtension/CHANGELOG.md +++ /dev/null @@ -1,10 +0,0 @@ -# Change Log - -## 0.3.1810.2508-preview - -- Language server integration, including problem highlighting and hover information -- Updated syntax highlighting and snippets to Q# 0.3 -- Warning raised when .NET Core SDK is missing - -## 0.2.18022202 -- Initial release diff --git a/src/VSCodeExtension/src/dotnet.ts b/src/VSCodeExtension/src/dotnet.ts index 12f47c5044..9ba0c11f21 100644 --- a/src/VSCodeExtension/src/dotnet.ts +++ b/src/VSCodeExtension/src/dotnet.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + 'use strict'; // IMPORTS ///////////////////////////////////////////////////////////////////// diff --git a/src/VSCodeExtension/src/extension.ts b/src/VSCodeExtension/src/extension.ts index c1b64d9715..357ef56db0 100644 --- a/src/VSCodeExtension/src/extension.ts +++ b/src/VSCodeExtension/src/extension.ts @@ -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 diff --git a/src/VSCodeExtension/src/packageInfo.ts b/src/VSCodeExtension/src/packageInfo.ts index 188602a0a3..68303d1051 100644 --- a/src/VSCodeExtension/src/packageInfo.ts +++ b/src/VSCodeExtension/src/packageInfo.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + 'use strict'; // IMPORTS ///////////////////////////////////////////////////////////////////// diff --git a/src/VSCodeExtension/src/telemetry.ts b/src/VSCodeExtension/src/telemetry.ts index 95e61b2e7e..0f498d9c0d 100644 --- a/src/VSCodeExtension/src/telemetry.ts +++ b/src/VSCodeExtension/src/telemetry.ts @@ -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'; diff --git a/src/VSCodeExtension/src/tests/extension.test.ts b/src/VSCodeExtension/src/tests/extension.test.ts index a7a297f7c9..006c6b10cf 100644 --- a/src/VSCodeExtension/src/tests/extension.test.ts +++ b/src/VSCodeExtension/src/tests/extension.test.ts @@ -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'; diff --git a/src/VSCodeExtension/src/tests/index.ts b/src/VSCodeExtension/src/tests/index.ts index 9fa2ea0d14..8c84fa0c56 100644 --- a/src/VSCodeExtension/src/tests/index.ts +++ b/src/VSCodeExtension/src/tests/index.ts @@ -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. // diff --git a/src/VisualStudioExtension/QsharpAppTemplate/Driver.cs b/src/VisualStudioExtension/QsharpAppTemplate/Driver.cs index 0e6be4f8b0..fb29945fe9 100644 --- a/src/VisualStudioExtension/QsharpAppTemplate/Driver.cs +++ b/src/VisualStudioExtension/QsharpAppTemplate/Driver.cs @@ -1,5 +1,4 @@ using System; - using Microsoft.Quantum.Simulation.Core; using Microsoft.Quantum.Simulation.Simulators; diff --git a/src/VisualStudioExtension/QsharpLanguageClient/QsContentTypeDefinition.cs b/src/VisualStudioExtension/QsharpLanguageClient/QsContentTypeDefinition.cs index 4d5558bf49..b7bfa3faee 100644 --- a/src/VisualStudioExtension/QsharpLanguageClient/QsContentTypeDefinition.cs +++ b/src/VisualStudioExtension/QsharpLanguageClient/QsContentTypeDefinition.cs @@ -1,4 +1,7 @@ -using Microsoft.VisualStudio.LanguageServer.Client; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.VisualStudio.LanguageServer.Client; using Microsoft.VisualStudio.Utilities; using System.ComponentModel.Composition; diff --git a/src/VisualStudioExtension/QsharpLanguageClient/QsLanguageClient.cs b/src/VisualStudioExtension/QsharpLanguageClient/QsLanguageClient.cs index 5834789bac..af3d7b3dd3 100644 --- a/src/VisualStudioExtension/QsharpLanguageClient/QsLanguageClient.cs +++ b/src/VisualStudioExtension/QsharpLanguageClient/QsLanguageClient.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; using System.Collections.Generic; using System.ComponentModel.Composition; using System.Diagnostics; diff --git a/src/VisualStudioExtension/QsharpLanguageClient/Telemetry.cs b/src/VisualStudioExtension/QsharpLanguageClient/Telemetry.cs index 683ae4733d..c9eedd88b6 100644 --- a/src/VisualStudioExtension/QsharpLanguageClient/Telemetry.cs +++ b/src/VisualStudioExtension/QsharpLanguageClient/Telemetry.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; From b9fd678e371267a427ec29d68ba127712d138e7c Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Sun, 23 Jun 2019 21:36:22 -0700 Subject: [PATCH 03/15] editing PRIVACY.md to specify that the VS extension does collect data if the corresponding VS Code setting is chosen by the application user --- PRIVACY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVACY.md b/PRIVACY.md index c80e06d156..b8faae6fdb 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -1,7 +1,7 @@ # 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. +With the exception of the VS Code extension, data collection is disabled by default but can be enabled by setting the corresponding flag upon compilation. For the VS Code extension, the privacy settings for VS Code set by the application user determine whether any data is collected. ## Data Collection From e46c118d90bff113a502029b2da9884b3daadbfa Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Sun, 23 Jun 2019 22:08:12 -0700 Subject: [PATCH 04/15] going over the vs code extension folder --- src/VSCodeExtension/BUILDING.md | 13 +++++---- .../language-configuration.json | 9 ++++--- src/VSCodeExtension/src/telemetry.ts | 12 ++++++--- .../vsc-extension-quickstart.md | 27 ------------------- 4 files changed, 20 insertions(+), 41 deletions(-) delete mode 100644 src/VSCodeExtension/vsc-extension-quickstart.md diff --git a/src/VSCodeExtension/BUILDING.md b/src/VSCodeExtension/BUILDING.md index 175ca4f679..06d7f38bf2 100644 --- a/src/VSCodeExtension/BUILDING.md +++ b/src/VSCodeExtension/BUILDING.md @@ -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: @@ -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 ‣. @@ -70,5 +69,5 @@ Change back to the "Extension" debugger and resume. ### 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. +This indicates that the build script `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). \ No newline at end of file diff --git a/src/VSCodeExtension/language-configuration.json b/src/VSCodeExtension/language-configuration.json index 3e703a5507..8498d242eb 100644 --- a/src/VSCodeExtension/language-configuration.json +++ b/src/VSCodeExtension/language-configuration.json @@ -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": [ ["[", "]"], - ["(", ")"] + ["(", ")"], + ["{", "}"] ] } \ No newline at end of file diff --git a/src/VSCodeExtension/src/telemetry.ts b/src/VSCodeExtension/src/telemetry.ts index 0f498d9c0d..78d5586c43 100644 --- a/src/VSCodeExtension/src/telemetry.ts +++ b/src/VSCodeExtension/src/telemetry.ts @@ -5,6 +5,10 @@ import * as vscode from 'vscode'; import { getPackageInfo } from './packageInfo'; import TelemetryReporter from 'vscode-extension-telemetry'; +export class Settings { + static enableTelemetry = true; // TODO: make this a command line flag and disable by default +}; + export type TelemetryData = { [key: string]: T } | undefined; export var reporter: TelemetryReporter; @@ -13,7 +17,7 @@ export class Reporter extends vscode.Disposable { constructor(ctx: vscode.ExtensionContext) { super(() => reporter.dispose()); let packageInfo = getPackageInfo(ctx); - if (packageInfo !== undefined) { + if (packageInfo !== undefined && Settings.enableTelemetry) { reporter = new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey); } } @@ -41,7 +45,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( @@ -60,7 +64,7 @@ export function sendTelemetryTiming( measurements["elapsedTime"] = elapsedTime; - reporter.sendTelemetryEvent(eventName, properties, measurements); + if (reporter) reporter.sendTelemetryEvent(eventName, properties, measurements); return returnValue; @@ -157,5 +161,5 @@ export function forwardServerTelemetry(telemetryRequest : any) { } // TODO: pass more than just the event name. - sendTelemetryEvent(name, properties, measurements); + sendTelemetryEvent(name, properties, measurements); } diff --git a/src/VSCodeExtension/vsc-extension-quickstart.md b/src/VSCodeExtension/vsc-extension-quickstart.md deleted file mode 100644 index 68a618aa0d..0000000000 --- a/src/VSCodeExtension/vsc-extension-quickstart.md +++ /dev/null @@ -1,27 +0,0 @@ -# Welcome to your VS Code Extension - -## What's in the folder -* This folder contains all of the files necessary for your extension -* `package.json` - this is the manifest file in which you declare your language support and define -the location of the grammar file that has been copied into you extension. -* `syntaxes/qsharp.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization -* `language-configuration.json` - this the language configuration, defining the tokens that are used for -comments and brackets. - -## Get up and running straight away -* Make sure the language configuration settings in `language-configuration.json` are accurate -* press `F5` to open a new window with your extension loaded -* create a new file with a file name suffix matching your language -* verify that syntax highlight works and that the language configuration settings are working - -## Make changes -* you can relaunch the extension from the debug toolbar after making changes to the files listed above -* you can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes - -## Add more language features -* To add features such as intellisense, hovers and validators check out the VS Code extenders documentation at -https://code.visualstudio.com/docs - -## Install your extension -* To start using your extension with Visual Studio Code copy it into the `/.vscode/extensions` folder and restart Code. -* To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension. \ No newline at end of file From da855c2fb8f4a3e7eb45e1f7bb029bbaadaecde9 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 27 Jun 2019 10:13:52 -0700 Subject: [PATCH 05/15] replacing the setVersionNr script --- build/bootstrap.cmd | 2 +- build/setVersionNumber.cmd | 29 ---------------------------- build/setVersionNumer.ps1 | 34 +++++++++++++++++++++++++++++++++ src/VSCodeExtension/BUILDING.md | 4 ++-- 4 files changed, 37 insertions(+), 32 deletions(-) delete mode 100644 build/setVersionNumber.cmd create mode 100644 build/setVersionNumer.ps1 diff --git a/build/bootstrap.cmd b/build/bootstrap.cmd index e6eca1385a..c8b90a9cc7 100644 --- a/build/bootstrap.cmd +++ b/build/bootstrap.cmd @@ -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\setVersionNumber.ps1 :: Initialize the compiler's nuspec file CALL :nuspecBootstrap diff --git a/build/setVersionNumber.cmd b/build/setVersionNumber.cmd deleted file mode 100644 index 96041b66f8..0000000000 --- a/build/setVersionNumber.cmd +++ /dev/null @@ -1,29 +0,0 @@ -:: -:: This script finds all *.v.template files and replaces -:: their build tokens (e.g: #NUGET_VERSION#) with a valid value -:: based on the MAJOR.MINOR.BUILDNUMBER -:: -SET DATE=%date:~12,2%%date:~4,2% -SET TIME=%time:~0,2%%time:~3,2% -IF "%BUILD_MAJOR%" == "" SET BUILD_MAJOR=0 -IF "%BUILD_MINOR%" == "" SET BUILD_MINOR=0 -IF "%BUILD_BUILDNUMBER%" == "" SET BUILD_BUILDNUMBER=%BUILD_MAJOR%.%BUILD_MINOR%.%DATE%.%TIME% - -SET REVISION=%BUILD_BUILDNUMBER:~-9% -IF "%REVISION:~0,1%" == "." SET REVISION=%REVISION:~1% - -IF "%ASSEMBLY_VERSION%" == "" SET ASSEMBLY_VERSION=%BUILD_MAJOR%.%BUILD_MINOR%.%REVISION% -IF "%VSIX_VERSION%" == "" SET VSIX_VERSION=%ASSEMBLY_VERSION% -IF "%PYTHON_VERSION%" == "" SET PYTHON_VERSION=%ASSEMBLY_VERSION%a1 -IF "%SEMVER_VERSION%" == "" SET SEMVER_VERSION=%BUILD_MAJOR%.%BUILD_MINOR%.%REVISION:.=% -IF "%NUGET_VERSION%" == "" SET NUGET_VERSION=%VSIX_VERSION%-alpha - -FOR /R %%F IN (*.v.template) DO CALL :updateOne %%F -GOTO :done - -:updateOne -set original=%1 -SET target=%original:~0,-11% -powershell -NoProfile -Command "(Get-Content %original% -Raw) | ForEach-Object { $_.replace('#ASSEMBLY_VERSION#', '%ASSEMBLY_VERSION%').replace('#NUGET_VERSION#', '%NUGET_VERSION%').replace('#VSIX_VERSION#', '%VSIX_VERSION%').replace('#SEMVER_VERSION#', '%SEMVER_VERSION%') } | Set-Content %target% -NoNewline" - -:done diff --git a/build/setVersionNumer.ps1 b/build/setVersionNumer.ps1 new file mode 100644 index 0000000000..14b3c36707 --- /dev/null +++ b/build/setVersionNumer.ps1 @@ -0,0 +1,34 @@ +param( + [string] + $AssemblyVersion = $Env:ASSEMBLY_VERSION, + + [string] + $NuGetVersion = $Env:NUGET_VERSION +); + +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 ("$NuGetVersion".Trim().Length -eq 0) { + $NuGetVersion = "$AssemblyVersion-alpha"; +} + +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) + } ` + | Set-Content $Target -NoNewline + } \ No newline at end of file diff --git a/src/VSCodeExtension/BUILDING.md b/src/VSCodeExtension/BUILDING.md index 06d7f38bf2..c319523d34 100644 --- a/src/VSCodeExtension/BUILDING.md +++ b/src/VSCodeExtension/BUILDING.md @@ -69,5 +69,5 @@ Change back to the "Extension" debugger and resume. ### 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 the build script `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). \ No newline at end of file +This indicates that the build script `setVersionNumber.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 `setVersionNumber.ps1` or manually edit the `version` property of `package.json` (note that any such manual edits **will** be overwritten by calls to `setVersionNumber.ps1` and will not be saved in the repo). \ No newline at end of file From 64179d673813eabd97c02d022cf8bbb60265f581 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 27 Jun 2019 10:39:38 -0700 Subject: [PATCH 06/15] typo and gitignore --- build/{setVersionNumer.ps1 => setVersionNumber.ps1} | 0 src/ProjectTemplates/.gitignore | 3 +++ 2 files changed, 3 insertions(+) rename build/{setVersionNumer.ps1 => setVersionNumber.ps1} (100%) create mode 100644 src/ProjectTemplates/.gitignore diff --git a/build/setVersionNumer.ps1 b/build/setVersionNumber.ps1 similarity index 100% rename from build/setVersionNumer.ps1 rename to build/setVersionNumber.ps1 diff --git a/src/ProjectTemplates/.gitignore b/src/ProjectTemplates/.gitignore new file mode 100644 index 0000000000..ac85e53be1 --- /dev/null +++ b/src/ProjectTemplates/.gitignore @@ -0,0 +1,3 @@ +Quantum.App1/Quantum.App1.csproj +Quantum.Library1/Quantum.Library1.csproj +Quantum.Test1/Quantum.Test1.csproj \ No newline at end of file From eacd59bfc54bb07b57a45005855b226a351c6896 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 27 Jun 2019 11:01:07 -0700 Subject: [PATCH 07/15] setting the vsix version --- build/setVersionNumber.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/build/setVersionNumber.ps1 b/build/setVersionNumber.ps1 index 14b3c36707..9e511a619a 100644 --- a/build/setVersionNumber.ps1 +++ b/build/setVersionNumber.ps1 @@ -3,7 +3,10 @@ param( $AssemblyVersion = $Env:ASSEMBLY_VERSION, [string] - $NuGetVersion = $Env:NUGET_VERSION + $NuGetVersion = $Env:NUGET_VERSION, + + [string] + $VsixVersion = $Env:VSIX_VERSION ); if ("$AssemblyVersion".Trim().Length -eq 0) { @@ -19,6 +22,10 @@ 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; @@ -29,6 +36,7 @@ Get-ChildItem -Recurse *.v.template ` $_. Replace("#ASSEMBLY_VERSION#", $AssemblyVersion). Replace("#NUGET_VERSION#", $NuGetVersion) + Replace("#VSIX_VERSION#", $VsixVersion) } ` | Set-Content $Target -NoNewline } \ No newline at end of file From 9a45f75e785e0315ba035f7d928b7720f873722f Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 27 Jun 2019 14:20:10 -0700 Subject: [PATCH 08/15] semver --- build/setVersionNumber.ps1 | 9 +++++++++ src/VSCodeExtension/BUILDING.md | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/build/setVersionNumber.ps1 b/build/setVersionNumber.ps1 index 9e511a619a..246a3a8bd2 100644 --- a/build/setVersionNumber.ps1 +++ b/build/setVersionNumber.ps1 @@ -2,6 +2,9 @@ param( [string] $AssemblyVersion = $Env:ASSEMBLY_VERSION, + [string] + $SemverVersion = $Env:SEMVER_VERSION, + [string] $NuGetVersion = $Env:NUGET_VERSION, @@ -18,6 +21,11 @@ if ("$AssemblyVersion".Trim().Length -eq 0) { $AssemblyVersion = "0.0.$Year$Month.$Hour$Minute"; } +if ("$SemverVersion".Trim().Length -eq 0) { + $split = AssemblyVersion.split(".") + $SemverVersion = "$split[0].$split[1].$split[2]$split[3]" +} + if ("$NuGetVersion".Trim().Length -eq 0) { $NuGetVersion = "$AssemblyVersion-alpha"; } @@ -37,6 +45,7 @@ Get-ChildItem -Recurse *.v.template ` Replace("#ASSEMBLY_VERSION#", $AssemblyVersion). Replace("#NUGET_VERSION#", $NuGetVersion) Replace("#VSIX_VERSION#", $VsixVersion) + Replace("#SEMVER_VERSION#", $SemverVersion) } ` | Set-Content $Target -NoNewline } \ No newline at end of file diff --git a/src/VSCodeExtension/BUILDING.md b/src/VSCodeExtension/BUILDING.md index c319523d34..b0d0136750 100644 --- a/src/VSCodeExtension/BUILDING.md +++ b/src/VSCodeExtension/BUILDING.md @@ -66,7 +66,7 @@ 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 the build script `setVersionNumber.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. From a1596519aaa3184222f93535233acda0264a3d0c Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 27 Jun 2019 14:27:01 -0700 Subject: [PATCH 09/15] ...ps script --- build/setVersionNumber.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/setVersionNumber.ps1 b/build/setVersionNumber.ps1 index 246a3a8bd2..8e83d2bb39 100644 --- a/build/setVersionNumber.ps1 +++ b/build/setVersionNumber.ps1 @@ -22,8 +22,8 @@ if ("$AssemblyVersion".Trim().Length -eq 0) { } if ("$SemverVersion".Trim().Length -eq 0) { - $split = AssemblyVersion.split(".") - $SemverVersion = "$split[0].$split[1].$split[2]$split[3]" + $pieces = "$AssemblyVersion".split("."); + $SemverVersion = "$pieces[0].$pieces[1].$pieces[2]$pieces[3]"; } if ("$NuGetVersion".Trim().Length -eq 0) { @@ -43,8 +43,8 @@ Get-ChildItem -Recurse *.v.template ` | ForEach-Object { $_. Replace("#ASSEMBLY_VERSION#", $AssemblyVersion). - Replace("#NUGET_VERSION#", $NuGetVersion) - Replace("#VSIX_VERSION#", $VsixVersion) + Replace("#NUGET_VERSION#", $NuGetVersion). + Replace("#VSIX_VERSION#", $VsixVersion). Replace("#SEMVER_VERSION#", $SemverVersion) } ` | Set-Content $Target -NoNewline From 456351975d29e8b8e4a31daf53db0db1645e37e7 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 27 Jun 2019 15:01:12 -0700 Subject: [PATCH 10/15] handling telemetry for VS Code --- PRIVACY.md | 3 +-- build/{setVersionNumber.ps1 => Set-VersionNumbers.ps1} | 6 +++++- build/bootstrap.cmd | 2 +- src/VSCodeExtension/BUILDING.md | 4 ++-- src/VSCodeExtension/package.json.v.template | 3 ++- src/VSCodeExtension/src/packageInfo.ts | 4 +++- src/VSCodeExtension/src/telemetry.ts | 6 +----- 7 files changed, 15 insertions(+), 13 deletions(-) rename build/{setVersionNumber.ps1 => Set-VersionNumbers.ps1} (88%) diff --git a/PRIVACY.md b/PRIVACY.md index b8faae6fdb..33cdcdd6c7 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -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. -With the exception of the VS Code extension, data collection is disabled by default but can be enabled by setting the corresponding flag upon compilation. For the VS Code extension, the privacy settings for VS Code set by the application user determine whether any data is collected. +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 diff --git a/build/setVersionNumber.ps1 b/build/Set-VersionNumbers.ps1 similarity index 88% rename from build/setVersionNumber.ps1 rename to build/Set-VersionNumbers.ps1 index 8e83d2bb39..82ec48e305 100644 --- a/build/setVersionNumber.ps1 +++ b/build/Set-VersionNumbers.ps1 @@ -10,6 +10,9 @@ param( [string] $VsixVersion = $Env:VSIX_VERSION + + [switch] + $EnableTelemetry ); if ("$AssemblyVersion".Trim().Length -eq 0) { @@ -45,7 +48,8 @@ Get-ChildItem -Recurse *.v.template ` Replace("#ASSEMBLY_VERSION#", $AssemblyVersion). Replace("#NUGET_VERSION#", $NuGetVersion). Replace("#VSIX_VERSION#", $VsixVersion). - Replace("#SEMVER_VERSION#", $SemverVersion) + Replace("#SEMVER_VERSION#", $SemverVersion). + Replace("#ENABLE_TELEMETRY#", $EnableTelemetry.IsPresent.ToString().ToLower()) } ` | Set-Content $Target -NoNewline } \ No newline at end of file diff --git a/build/bootstrap.cmd b/build/bootstrap.cmd index c8b90a9cc7..1859e70843 100644 --- a/build/bootstrap.cmd +++ b/build/bootstrap.cmd @@ -6,7 +6,7 @@ dotnet --info || GOTO missingDotnet git --version || GOTO missingGit :: Set Build number on all files that uses it -call powershell -NoProfile build\setVersionNumber.ps1 +call powershell -NoProfile build\Set-VersionNumbers.ps1 :: Initialize the compiler's nuspec file CALL :nuspecBootstrap diff --git a/src/VSCodeExtension/BUILDING.md b/src/VSCodeExtension/BUILDING.md index b0d0136750..0343d23120 100644 --- a/src/VSCodeExtension/BUILDING.md +++ b/src/VSCodeExtension/BUILDING.md @@ -69,5 +69,5 @@ Change back to the "Extension" debugger and resume. ### 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 the build script `setVersionNumber.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 `setVersionNumber.ps1` or manually edit the `version` property of `package.json` (note that any such manual edits **will** be overwritten by calls to `setVersionNumber.ps1` and will not be saved in the repo). \ No newline at end of file +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). \ No newline at end of file diff --git a/src/VSCodeExtension/package.json.v.template b/src/VSCodeExtension/package.json.v.template index c3f1971830..55db2a66f2 100644 --- a/src/VSCodeExtension/package.json.v.template +++ b/src/VSCodeExtension/package.json.v.template @@ -98,5 +98,6 @@ }, "repository": {}, "aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217", - "requiredDotNetCoreSDK": "2.1.0" + "requiredDotNetCoreSDK": "2.2", + "enableTelemetry" : #ENABLE_TELEMETRY# } \ No newline at end of file diff --git a/src/VSCodeExtension/src/packageInfo.ts b/src/VSCodeExtension/src/packageInfo.ts index 68303d1051..36dee748e7 100644 --- a/src/VSCodeExtension/src/packageInfo.ts +++ b/src/VSCodeExtension/src/packageInfo.ts @@ -14,6 +14,7 @@ export interface IPackageInfo { version: string; aiKey: string; requiredDotNetCoreSDK: string; + enableTelemetry: string; } export function getPackageInfo(context: vscode.ExtensionContext): IPackageInfo | undefined { @@ -23,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; diff --git a/src/VSCodeExtension/src/telemetry.ts b/src/VSCodeExtension/src/telemetry.ts index 78d5586c43..a65170be72 100644 --- a/src/VSCodeExtension/src/telemetry.ts +++ b/src/VSCodeExtension/src/telemetry.ts @@ -5,10 +5,6 @@ import * as vscode from 'vscode'; import { getPackageInfo } from './packageInfo'; import TelemetryReporter from 'vscode-extension-telemetry'; -export class Settings { - static enableTelemetry = true; // TODO: make this a command line flag and disable by default -}; - export type TelemetryData = { [key: string]: T } | undefined; export var reporter: TelemetryReporter; @@ -17,7 +13,7 @@ export class Reporter extends vscode.Disposable { constructor(ctx: vscode.ExtensionContext) { super(() => reporter.dispose()); let packageInfo = getPackageInfo(ctx); - if (packageInfo !== undefined && Settings.enableTelemetry) { + if (packageInfo !== undefined && packageInfo.enableTelemetry) { reporter = new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey); } } From c0b05cd27d3a9b1936cc60f7342b60b33f1c6ecb Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 27 Jun 2019 15:04:39 -0700 Subject: [PATCH 11/15] semver fix --- build/Set-VersionNumbers.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Set-VersionNumbers.ps1 b/build/Set-VersionNumbers.ps1 index 82ec48e305..28fff4c18b 100644 --- a/build/Set-VersionNumbers.ps1 +++ b/build/Set-VersionNumbers.ps1 @@ -26,7 +26,7 @@ if ("$AssemblyVersion".Trim().Length -eq 0) { if ("$SemverVersion".Trim().Length -eq 0) { $pieces = "$AssemblyVersion".split("."); - $SemverVersion = "$pieces[0].$pieces[1].$pieces[2]$pieces[3]"; + $SemverVersion = "$($pieces[0]).$($pieces[1]).$($pieces[2])$($pieces[3])"; } if ("$NuGetVersion".Trim().Length -eq 0) { From 785494c62ebfc537e816ffe0e79087e3a3f84419 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 27 Jun 2019 15:19:11 -0700 Subject: [PATCH 12/15] missing comma --- build/Set-VersionNumbers.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Set-VersionNumbers.ps1 b/build/Set-VersionNumbers.ps1 index 28fff4c18b..597a120cf5 100644 --- a/build/Set-VersionNumbers.ps1 +++ b/build/Set-VersionNumbers.ps1 @@ -9,7 +9,7 @@ param( $NuGetVersion = $Env:NUGET_VERSION, [string] - $VsixVersion = $Env:VSIX_VERSION + $VsixVersion = $Env:VSIX_VERSION, [switch] $EnableTelemetry From 0a8dd04b7d0c794711e8e1080a2093dbaceee935 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 27 Jun 2019 17:47:09 -0700 Subject: [PATCH 13/15] version requirement 2.1 --- src/VSCodeExtension/package.json.v.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VSCodeExtension/package.json.v.template b/src/VSCodeExtension/package.json.v.template index 55db2a66f2..c85384e182 100644 --- a/src/VSCodeExtension/package.json.v.template +++ b/src/VSCodeExtension/package.json.v.template @@ -98,6 +98,6 @@ }, "repository": {}, "aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217", - "requiredDotNetCoreSDK": "2.2", + "requiredDotNetCoreSDK": "2.1", "enableTelemetry" : #ENABLE_TELEMETRY# } \ No newline at end of file From 215efb1efef490890775e4f3d50142083eb8a898 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 27 Jun 2019 18:08:52 -0700 Subject: [PATCH 14/15] switching back to .net core 2.1 --- src/QsCompiler/CommandLineTool/QsCommandLineTool.csproj | 2 +- src/QsCompiler/LanguageServer/QsLanguageServer.csproj | 2 +- src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj | 2 +- src/QsCompiler/Tests.DocGenerator/Tests.DocGenerator.csproj | 2 +- .../Tests.LanguageServer/Tests.LanguageServer.csproj | 2 +- src/VSCodeExtension/Build-Dependencies.ps1 | 2 +- src/VisualStudioExtension/QsharpVSIX/QsharpVSIX.csproj | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/QsCompiler/CommandLineTool/QsCommandLineTool.csproj b/src/QsCompiler/CommandLineTool/QsCommandLineTool.csproj index c8b9cb6e0f..70b9484144 100644 --- a/src/QsCompiler/CommandLineTool/QsCommandLineTool.csproj +++ b/src/QsCompiler/CommandLineTool/QsCommandLineTool.csproj @@ -4,7 +4,7 @@ qsc Microsoft Q# compiler command line tool. - netcoreapp2.2 + netcoreapp2.1 Exe diff --git a/src/QsCompiler/LanguageServer/QsLanguageServer.csproj b/src/QsCompiler/LanguageServer/QsLanguageServer.csproj index 1874d19fc2..9e9b88c808 100644 --- a/src/QsCompiler/LanguageServer/QsLanguageServer.csproj +++ b/src/QsCompiler/LanguageServer/QsLanguageServer.csproj @@ -3,7 +3,7 @@ Microsoft.Quantum.QsLanguageServer - netcoreapp2.2 + netcoreapp2.1 Exe diff --git a/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj b/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj index d7216c5ef2..f81328128a 100644 --- a/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj +++ b/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp2.1 false Tests.Microsoft.Quantum.QsCompiler Library diff --git a/src/QsCompiler/Tests.DocGenerator/Tests.DocGenerator.csproj b/src/QsCompiler/Tests.DocGenerator/Tests.DocGenerator.csproj index fe5bf88a38..c08adf6c0c 100644 --- a/src/QsCompiler/Tests.DocGenerator/Tests.DocGenerator.csproj +++ b/src/QsCompiler/Tests.DocGenerator/Tests.DocGenerator.csproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp2.1 false Microsoft.Quantum.QsCompiler.Documentation.Testing Tests.Microsoft.Quantum.QsDocumentationParser diff --git a/src/QsCompiler/Tests.LanguageServer/Tests.LanguageServer.csproj b/src/QsCompiler/Tests.LanguageServer/Tests.LanguageServer.csproj index ddb6cf37bc..9457a6c960 100644 --- a/src/QsCompiler/Tests.LanguageServer/Tests.LanguageServer.csproj +++ b/src/QsCompiler/Tests.LanguageServer/Tests.LanguageServer.csproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp2.1 false Tests.Microsoft.Quantum.QsLanguageServer Library diff --git a/src/VSCodeExtension/Build-Dependencies.ps1 b/src/VSCodeExtension/Build-Dependencies.ps1 index 42a671dd9b..3e82bba363 100644 --- a/src/VSCodeExtension/Build-Dependencies.ps1 +++ b/src/VSCodeExtension/Build-Dependencies.ps1 @@ -9,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. diff --git a/src/VisualStudioExtension/QsharpVSIX/QsharpVSIX.csproj b/src/VisualStudioExtension/QsharpVSIX/QsharpVSIX.csproj index def14f0c47..b29802b242 100644 --- a/src/VisualStudioExtension/QsharpVSIX/QsharpVSIX.csproj +++ b/src/VisualStudioExtension/QsharpVSIX/QsharpVSIX.csproj @@ -19,8 +19,8 @@ Microsoft.Quantum.VisualStudio Microsoft.Quantum.VisualStudio.Extension Microsoft.Quantum.Development.Kit-$(AssemblyVersion).vsix - ..\..\QsCompiler\LanguageServer\bin\$(Configuration)\netcoreapp2.2\publish\ - ..\..\QsCompiler\LanguageServer\bin\$(Configuration)\netcoreapp2.2\ + ..\..\QsCompiler\LanguageServer\bin\$(Configuration)\netcoreapp2.1\publish\ + ..\..\QsCompiler\LanguageServer\bin\$(Configuration)\netcoreapp2.1\ v3 true From 7913e6d520f5ab02e4256884e9b197928822a3f8 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 27 Jun 2019 18:27:23 -0700 Subject: [PATCH 15/15] forgot something --- src/VSCodeExtension/package.json.v.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VSCodeExtension/package.json.v.template b/src/VSCodeExtension/package.json.v.template index f420f3ea94..a8cad49587 100644 --- a/src/VSCodeExtension/package.json.v.template +++ b/src/VSCodeExtension/package.json.v.template @@ -98,6 +98,6 @@ }, "repository": {}, "aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217", - "requiredDotNetCoreSDK": "2.1", + "requiredDotNetCoreSDK": "2.1.0", "enableTelemetry" : #ENABLE_TELEMETRY# } \ No newline at end of file