├── .editorconfig ├── .gitattributes ├── .gitignore ├── Build.cmd ├── CODE-OF-CONDUCT.md ├── InteractiveWindow.sln ├── License.txt ├── NuGet.config ├── README.md ├── Restore.cmd ├── Test.cmd ├── azure-pipelines-codeql.yml ├── azure-pipelines-pr.yml ├── azure-pipelines.yml ├── build.sh ├── eng ├── TSAConfig.gdntsa ├── Version.Details.xml ├── Versions.props ├── build-utils.ps1 ├── common │ ├── BuildConfiguration │ │ └── build-configuration.json │ ├── CIBuild.cmd │ ├── PSScriptAnalyzerSettings.psd1 │ ├── README.md │ ├── SetupNugetSources.ps1 │ ├── SetupNugetSources.sh │ ├── build.cmd │ ├── build.ps1 │ ├── build.sh │ ├── cibuild.sh │ ├── core-templates │ │ ├── job │ │ │ ├── job.yml │ │ │ ├── onelocbuild.yml │ │ │ ├── publish-build-assets.yml │ │ │ ├── source-build.yml │ │ │ └── source-index-stage1.yml │ │ ├── jobs │ │ │ ├── codeql-build.yml │ │ │ ├── jobs.yml │ │ │ └── source-build.yml │ │ ├── post-build │ │ │ ├── common-variables.yml │ │ │ ├── post-build.yml │ │ │ └── setup-maestro-vars.yml │ │ ├── steps │ │ │ ├── component-governance.yml │ │ │ ├── enable-internal-runtimes.yml │ │ │ ├── enable-internal-sources.yml │ │ │ ├── generate-sbom.yml │ │ │ ├── get-delegation-sas.yml │ │ │ ├── get-federated-access-token.yml │ │ │ ├── publish-build-artifacts.yml │ │ │ ├── publish-logs.yml │ │ │ ├── publish-pipeline-artifacts.yml │ │ │ ├── retain-build.yml │ │ │ ├── send-to-helix.yml │ │ │ └── source-build.yml │ │ └── variables │ │ │ └── pool-providers.yml │ ├── cross │ │ ├── arm │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ ├── arm64 │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ ├── armel │ │ │ ├── armel.jessie.patch │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ ├── build-android-rootfs.sh │ │ ├── build-rootfs.sh │ │ ├── riscv64 │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ ├── tizen-build-rootfs.sh │ │ ├── tizen-fetch.sh │ │ ├── toolchain.cmake │ │ ├── x64 │ │ │ └── tizen │ │ │ │ └── tizen.patch │ │ └── x86 │ │ │ └── tizen │ │ │ └── tizen.patch │ ├── darc-init.ps1 │ ├── darc-init.sh │ ├── dotnet-install.cmd │ ├── dotnet-install.ps1 │ ├── dotnet-install.sh │ ├── enable-cross-org-publishing.ps1 │ ├── generate-locproject.ps1 │ ├── generate-sbom-prep.ps1 │ ├── generate-sbom-prep.sh │ ├── helixpublish.proj │ ├── init-tools-native.cmd │ ├── init-tools-native.ps1 │ ├── init-tools-native.sh │ ├── internal-feed-operations.ps1 │ ├── internal-feed-operations.sh │ ├── internal │ │ ├── Directory.Build.props │ │ ├── NuGet.config │ │ └── Tools.csproj │ ├── loc │ │ └── P22DotNetHtmlLocalization.lss │ ├── msbuild.ps1 │ ├── msbuild.sh │ ├── native │ │ ├── CommonLibrary.psm1 │ │ ├── common-library.sh │ │ ├── init-compiler.sh │ │ ├── init-distro-rid.sh │ │ ├── init-os-and-arch.sh │ │ ├── install-cmake-test.sh │ │ ├── install-cmake.sh │ │ └── install-tool.ps1 │ ├── pipeline-logging-functions.ps1 │ ├── pipeline-logging-functions.sh │ ├── post-build │ │ ├── check-channel-consistency.ps1 │ │ ├── nuget-validation.ps1 │ │ ├── nuget-verification.ps1 │ │ ├── publish-using-darc.ps1 │ │ ├── redact-logs.ps1 │ │ ├── sourcelink-validation.ps1 │ │ └── symbols-validation.ps1 │ ├── retain-build.ps1 │ ├── sdk-task.ps1 │ ├── sdl │ │ ├── NuGet.config │ │ ├── configure-sdl-tool.ps1 │ │ ├── execute-all-sdl-tools.ps1 │ │ ├── extract-artifact-archives.ps1 │ │ ├── extract-artifact-packages.ps1 │ │ ├── init-sdl.ps1 │ │ ├── packages.config │ │ ├── run-sdl.ps1 │ │ ├── sdl.ps1 │ │ └── trim-assets-version.ps1 │ ├── template-guidance.md │ ├── templates-official │ │ ├── job │ │ │ ├── job.yml │ │ │ ├── onelocbuild.yml │ │ │ ├── publish-build-assets.yml │ │ │ ├── source-build.yml │ │ │ └── source-index-stage1.yml │ │ ├── jobs │ │ │ ├── codeql-build.yml │ │ │ ├── jobs.yml │ │ │ └── source-build.yml │ │ ├── post-build │ │ │ ├── common-variables.yml │ │ │ ├── post-build.yml │ │ │ └── setup-maestro-vars.yml │ │ ├── steps │ │ │ ├── component-governance.yml │ │ │ ├── enable-internal-runtimes.yml │ │ │ ├── enable-internal-sources.yml │ │ │ ├── generate-sbom.yml │ │ │ ├── get-delegation-sas.yml │ │ │ ├── get-federated-access-token.yml │ │ │ ├── publish-build-artifacts.yml │ │ │ ├── publish-logs.yml │ │ │ ├── publish-pipeline-artifacts.yml │ │ │ ├── retain-build.yml │ │ │ ├── send-to-helix.yml │ │ │ └── source-build.yml │ │ └── variables │ │ │ ├── pool-providers.yml │ │ │ └── sdl-variables.yml │ ├── templates │ │ ├── job │ │ │ ├── job.yml │ │ │ ├── onelocbuild.yml │ │ │ ├── publish-build-assets.yml │ │ │ ├── source-build.yml │ │ │ └── source-index-stage1.yml │ │ ├── jobs │ │ │ ├── codeql-build.yml │ │ │ ├── jobs.yml │ │ │ └── source-build.yml │ │ ├── post-build │ │ │ ├── common-variables.yml │ │ │ ├── post-build.yml │ │ │ └── setup-maestro-vars.yml │ │ ├── steps │ │ │ ├── component-governance.yml │ │ │ ├── enable-internal-runtimes.yml │ │ │ ├── enable-internal-sources.yml │ │ │ ├── generate-sbom.yml │ │ │ ├── get-delegation-sas.yml │ │ │ ├── get-federated-access-token.yml │ │ │ ├── publish-build-artifacts.yml │ │ │ ├── publish-logs.yml │ │ │ ├── publish-pipeline-artifacts.yml │ │ │ ├── retain-build.yml │ │ │ ├── send-to-helix.yml │ │ │ └── source-build.yml │ │ └── variables │ │ │ └── pool-providers.yml │ ├── tools.ps1 │ └── tools.sh ├── config │ └── PublishData.json └── publish-assets.ps1 ├── global.json └── src ├── Directory.Build.props ├── Directory.Build.targets ├── Microsoft.VisualStudio.InteractiveWindow.Tests ├── EventListenerGuard.cs ├── HistoryTests.cs ├── InteractiveClipboardFormatTests.cs ├── InteractiveWindowEditorsFactoryService.cs ├── InteractiveWindowHistoryTests.cs ├── InteractiveWindowTestHost.cs ├── InteractiveWindowTests.cs ├── InteractiveWindowTests_ClipboardTests.cs ├── JoinableTaskContextMefHost.cs ├── Microsoft.VisualStudio.InteractiveWindow.UnitTests.csproj ├── SortedSpansTests.cs ├── TestClipboard.cs ├── TestContentTypeDefinition.cs ├── TestInteractiveEngine.cs ├── TestSmartIndent.cs ├── TestUtilities │ ├── Assert │ │ ├── AssertEx.cs │ │ ├── ConditionalFactAttribute.cs │ │ ├── DiffUtil.cs │ │ ├── EqualityTesting.cs │ │ ├── EqualityUnit.cs │ │ ├── EqualityUnit`1.cs │ │ ├── EqualityUtil.cs │ │ ├── EqualityUtil`1.cs │ │ ├── TestExceptionUtilities.cs │ │ └── WorkItemAttribute.cs │ ├── Async │ │ ├── AsynchronousOperationBlocker.cs │ │ ├── Checkpoint.cs │ │ └── WaitHelper.cs │ ├── Contract.cs │ ├── Threading │ │ ├── ConditionalWpfFactAttribute.cs │ │ ├── ForegroundThreadAffinitizedObject.cs │ │ ├── ForegroundThreadDataKind.cs │ │ ├── NativeMethods.cs │ │ ├── SemaphoreSlimExtensions.cs │ │ ├── SpecializedTasks.cs │ │ ├── StaTaskScheduler.cs │ │ ├── SynchronizationContextTaskScheduler.cs │ │ ├── TaskExtensions.cs │ │ ├── TaskFactoryExtensions.cs │ │ ├── WpfFactAttribute.cs │ │ ├── WpfFactDiscoverer.cs │ │ └── WpfTestCase.cs │ └── ThrowingTraceListener.cs └── app.config ├── Microsoft.VisualStudio.InteractiveWindow ├── BufferBlock.cs ├── Commands │ ├── CancelExecutionCommand.cs │ ├── ClearScreenCommand.cs │ ├── CommandClassifier.cs │ ├── CommandClassifierProvider.cs │ ├── HelpCommand.cs │ ├── IInteractiveWindowCommand.cs │ ├── IInteractiveWindowCommands.cs │ ├── IInteractiveWindowCommandsFactory.cs │ ├── InteractiveCommandsFactory.cs │ ├── InteractiveWindowCommand.cs │ ├── InteractiveWindowCommandExtensions.cs │ ├── InteractiveWindowCommands.cs │ ├── PredefinedInteractiveCommandsContentTypes.cs │ └── ResetCommand.cs ├── ContentTypeMetadata.cs ├── CustomTrackingSpan.cs ├── ExecutionResult.cs ├── History.cs ├── IInteractiveEvaluator.cs ├── IInteractiveWindow.cs ├── IInteractiveWindow2.cs ├── IInteractiveWindowEditorFactoryService.cs ├── IInteractiveWindowFactoryService.cs ├── IInteractiveWindowOperations.cs ├── IInteractiveWindowOperations2.cs ├── InteractiveClipboardFormat.cs ├── InteractiveContentTypeDefinitions.cs ├── InteractiveWindow.EditResolver.cs ├── InteractiveWindow.PendingSubmission.cs ├── InteractiveWindow.ReplSpanKind.cs ├── InteractiveWindow.SpanRangeEdit.cs ├── InteractiveWindow.State.cs ├── InteractiveWindow.SystemClipboard.cs ├── InteractiveWindow.UIThreadOnly.cs ├── InteractiveWindow.cs ├── InteractiveWindowClipboard.cs ├── InteractiveWindowExtensions.cs ├── InteractiveWindowOptions.cs ├── InteractiveWindowProvider.cs ├── InteractiveWindowResources.resx ├── InternalUtilities │ ├── ExceptionUtilities.cs │ └── FatalError.cs ├── Microsoft.VisualStudio.InteractiveWindow.csproj ├── Output │ ├── InlineAdornmentProvider.cs │ ├── OutputBuffer.cs │ ├── OutputClassifierProvider.cs │ ├── OutputWriter.cs │ ├── ResizingAdorner.cs │ ├── SortedSpans.cs │ └── ZoomableInlineAdornment.cs ├── PredefinedInteractiveContentTypes.cs ├── PredefinedInteractiveTextViewRoles.cs ├── ProjectionBufferExtensions.cs ├── PublicAPI.Shipped.txt ├── PublicAPI.Unshipped.txt ├── SmartIndent │ ├── InteractiveSmartIndenter.cs │ └── InteractiveSmartIndenterProvider.cs ├── SmartUpDownOption.cs ├── SubmissionBufferAddedEventArgs.cs ├── TextTransactionMergePolicy.cs ├── Utils │ ├── Contract.cs │ └── EditorExtensions.cs └── xlf │ ├── InteractiveWindowResources.cs.xlf │ ├── InteractiveWindowResources.de.xlf │ ├── InteractiveWindowResources.es.xlf │ ├── InteractiveWindowResources.fr.xlf │ ├── InteractiveWindowResources.it.xlf │ ├── InteractiveWindowResources.ja.xlf │ ├── InteractiveWindowResources.ko.xlf │ ├── InteractiveWindowResources.pl.xlf │ ├── InteractiveWindowResources.pt-BR.xlf │ ├── InteractiveWindowResources.ru.xlf │ ├── InteractiveWindowResources.tr.xlf │ ├── InteractiveWindowResources.zh-Hans.xlf │ └── InteractiveWindowResources.zh-Hant.xlf └── Microsoft.VisualStudio.VsInteractiveWindow ├── AssemblyRedirects.cs ├── CommandIds.cs ├── ContentTypeMetadata.cs ├── Guids.cs ├── IVsInteractiveWindow.cs ├── IVsInteractiveWindowFactory.cs ├── IVsInteractiveWindowFactory2.cs ├── IVsInteractiveWindowOleCommandTargetProvider.cs ├── InteractiveWindow.vsct ├── InteractiveWindowPackage.cs ├── MenuIds.cs ├── Microsoft.VisualStudio.VsInteractiveWindow.csproj ├── ProvideBindingRedirection.cs ├── ProvideInteractiveWindowAttribute.cs ├── PublicAPI.Shipped.txt ├── PublicAPI.Unshipped.txt ├── VSInteractiveWindowResources.resx ├── VSInteractiveWindowRules.ruleset ├── VSPackage.resx ├── VsInteractiveWindow.cs ├── VsInteractiveWindowCommandFilter.cs ├── VsInteractiveWindowEditorFactoryService.cs ├── VsInteractiveWindowExtensions.cs ├── VsInteractiveWindowFactory.cs ├── source.extension.vsixmanifest └── xlf ├── InteractiveWindow.vsct.cs.xlf ├── InteractiveWindow.vsct.de.xlf ├── InteractiveWindow.vsct.es.xlf ├── InteractiveWindow.vsct.fr.xlf ├── InteractiveWindow.vsct.it.xlf ├── InteractiveWindow.vsct.ja.xlf ├── InteractiveWindow.vsct.ko.xlf ├── InteractiveWindow.vsct.pl.xlf ├── InteractiveWindow.vsct.pt-BR.xlf ├── InteractiveWindow.vsct.ru.xlf ├── InteractiveWindow.vsct.tr.xlf ├── InteractiveWindow.vsct.zh-Hans.xlf ├── InteractiveWindow.vsct.zh-Hant.xlf ├── VSInteractiveWindowResources.cs.xlf ├── VSInteractiveWindowResources.de.xlf ├── VSInteractiveWindowResources.es.xlf ├── VSInteractiveWindowResources.fr.xlf ├── VSInteractiveWindowResources.it.xlf ├── VSInteractiveWindowResources.ja.xlf ├── VSInteractiveWindowResources.ko.xlf ├── VSInteractiveWindowResources.pl.xlf ├── VSInteractiveWindowResources.pt-BR.xlf ├── VSInteractiveWindowResources.ru.xlf ├── VSInteractiveWindowResources.tr.xlf ├── VSInteractiveWindowResources.zh-Hans.xlf ├── VSInteractiveWindowResources.zh-Hant.xlf ├── VSPackage.cs.xlf ├── VSPackage.de.xlf ├── VSPackage.es.xlf ├── VSPackage.fr.xlf ├── VSPackage.it.xlf ├── VSPackage.ja.xlf ├── VSPackage.ko.xlf ├── VSPackage.pl.xlf ├── VSPackage.pt-BR.xlf ├── VSPackage.ru.xlf ├── VSPackage.tr.xlf ├── VSPackage.zh-Hans.xlf └── VSPackage.zh-Hant.xlf /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: 2 | http://EditorConfig.org 3 | 4 | # top-most EditorConfig file 5 | root = true 6 | 7 | # Don't use tabs for indentation. 8 | [*] 9 | indent_style = space 10 | # (Please don't specify an indent_size here; that has too many unintended consequences.) 11 | 12 | # VSTHRD001: Avoid legacy thread switching APIs (deferred: https://github.com/dotnet/interactive-window/issues/179) 13 | dotnet_diagnostic.VSTHRD001.severity = none 14 | 15 | # VSTHRD002: Avoid problematic synchronous waits (deferred: https://github.com/dotnet/interactive-window/issues/180) 16 | dotnet_diagnostic.VSTHRD002.severity = none 17 | 18 | # VSTHRD003: Avoid awaiting foreign Tasks (deferred: https://github.com/dotnet/interactive-window/issues/181) 19 | dotnet_diagnostic.VSTHRD003.severity = none 20 | 21 | # VSTHRD103: Call async methods when in an async method (deferred: https://github.com/dotnet/interactive-window/issues/182) 22 | dotnet_diagnostic.VSTHRD103.severity = none 23 | 24 | # VSTHRD110: Observe result of async calls (deferred: https://github.com/dotnet/interactive-window/issues/183) 25 | dotnet_diagnostic.VSTHRD110.severity = none 26 | 27 | # VSTHRD114: Avoid returning a null Task (deferred: https://github.com/dotnet/interactive-window/issues/184) 28 | dotnet_diagnostic.VSTHRD114.severity = none 29 | 30 | # VSTHRD200: Use "Async" suffix for async methods (deferred: https://github.com/dotnet/interactive-window/issues/185) 31 | dotnet_diagnostic.VSTHRD200.severity = none 32 | 33 | [*.{sh}] 34 | end_of_line = lf 35 | indent_size = 2 36 | 37 | [*.{ps1}] 38 | indent_size = 2 39 | 40 | # Code files 41 | [*.cs,*.csx,*.vb,*.vbx] 42 | indent_size = 4 43 | 44 | # Xml project files 45 | [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] 46 | indent_size = 2 47 | 48 | # Xml config files 49 | [*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] 50 | indent_size = 2 51 | 52 | # JSON files 53 | [*.json] 54 | indent_size = 2 55 | 56 | [*.{cs}] 57 | file_header_template = Licensed to the.NET Foundation under one or more agreements.\nThe.NET Foundation licenses this file to you under the MIT license.\nSee the License.txt file in the project root for more information. 58 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to: 3 | # automatically normalize line endings on check-in, and 4 | # convert to Windows-style line endings on check-out 5 | ############################################################################### 6 | * text=auto encoding=UTF-8 7 | *.sh text eol=lf 8 | 9 | ############################################################################### 10 | # Set file behavior to: 11 | # treat as text, and 12 | # diff as C# source code 13 | ############################################################################### 14 | *.cs text diff=csharp 15 | 16 | ############################################################################### 17 | # Set file behavior to: 18 | # treat as text 19 | ############################################################################### 20 | *.cmd text 21 | *.config text 22 | *.csproj text 23 | *.groovy text 24 | *.json text 25 | *.md text 26 | *.nuspec text 27 | *.pkgdef text 28 | *.proj text 29 | *.projitems text 30 | *.props text 31 | *.ps1 text 32 | *.resx text 33 | *.ruleset text 34 | *.shproj text 35 | *.sln text 36 | *.targets text 37 | *.vb text 38 | *.vbproj text 39 | *.vcxproj text 40 | *.vcxproj.filters text 41 | *.vsct text 42 | *.vsixmanifest text 43 | 44 | ############################################################################### 45 | # Set file behavior to: 46 | # treat as binary 47 | ############################################################################### 48 | *.png binary 49 | *.snk binary 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | .vs/ 8 | .vscode/ 9 | 10 | # Build results 11 | artifacts/ 12 | Debug/ 13 | Release/ 14 | bin/ 15 | obj/ 16 | .dotnet/ 17 | .tools/ 18 | .packages/ 19 | 20 | # Per-user project properties 21 | launchSettings.json 22 | 23 | # Visual Studio profiler 24 | *.psess 25 | *.vsp 26 | *.vspx 27 | 28 | # ReSharper is a .NET coding add-in 29 | _ReSharper*/ 30 | *.[Rr]e[Ss]harper 31 | 32 | # DotCover is a Code Coverage Tool 33 | *.dotCover 34 | 35 | # NCrunch 36 | *.ncrunch* 37 | .*crunch*.local.xml 38 | -------------------------------------------------------------------------------- /Build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -restore -build %*" 3 | exit /b %ErrorLevel% 4 | -------------------------------------------------------------------------------- /CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | This project has adopted the code of conduct defined by the Contributor Covenant 4 | to clarify expected behavior in our community. 5 | 6 | For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct). 7 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) .NET Foundation and Contributors 4 | 5 | All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. -------------------------------------------------------------------------------- /NuGet.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Microsoft.VisualStudio.InteractiveWindow 2 | 3 | Implementation of Visual Studio Interactive Window. 4 | 5 | [![Build Status](https://dev.azure.com/dnceng/public/_apis/build/status/dotnet/interactive-window/InteractiveWindow%20PR?branchName=main)](https://dev.azure.com/dnceng/public/_build/latest?definitionId=300&branchName=main) 6 | -------------------------------------------------------------------------------- /Restore.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -restore %*" 3 | exit /b %ErrorLevel% 4 | -------------------------------------------------------------------------------- /Test.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -test %*" 3 | exit /b %ErrorLevel% -------------------------------------------------------------------------------- /azure-pipelines-codeql.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | # Optionally do not publish to TSA. Useful for e.g. verifying fixes before PR. 3 | - name: TSAEnabled 4 | displayName: Publish results to TSA 5 | type: boolean 6 | default: true 7 | 8 | variables: 9 | - template: eng/common/templates/variables/pool-providers.yml 10 | # CG is handled in the primary CI pipeline 11 | - name: skipComponentGovernanceDetection 12 | value: true 13 | # Force CodeQL enabled so it may be run on any branch 14 | - name: Codeql.Enabled 15 | value: true 16 | # Do not let CodeQL 3000 Extension gate scan frequency 17 | - name: Codeql.Cadence 18 | value: 0 19 | # CodeQL needs this plumbed along as a variable to enable TSA 20 | - name: Codeql.TSAEnabled 21 | value: ${{ parameters.TSAEnabled }} 22 | 23 | # Build variables 24 | - name: _BuildConfig 25 | value: Release 26 | 27 | trigger: none 28 | 29 | schedules: 30 | - cron: 0 12 * * 1 31 | displayName: Weekly Monday CodeQL run 32 | branches: 33 | include: 34 | - main 35 | always: true 36 | 37 | jobs: 38 | - job: codeql 39 | displayName: CodeQL 40 | pool: 41 | name: $(DncEngInternalBuildPool) 42 | demands: ImageOverride -equals 1es-windows-2022 43 | timeoutInMinutes: 90 44 | 45 | steps: 46 | 47 | - task: UseDotNet@2 48 | inputs: 49 | useGlobalJson: true 50 | 51 | - task: CodeQL3000Init@0 52 | displayName: CodeQL Initialize 53 | 54 | - script: eng\common\cibuild.cmd 55 | -configuration $(_BuildConfig) 56 | -prepareMachine 57 | /p:Test=false 58 | displayName: Windows Build 59 | 60 | - task: CodeQL3000Finalize@0 61 | displayName: CodeQL Finalize 62 | -------------------------------------------------------------------------------- /azure-pipelines-pr.yml: -------------------------------------------------------------------------------- 1 | # Branches that trigger builds on PR 2 | pr: 3 | branches: 4 | include: 5 | - main 6 | - release/* 7 | paths: 8 | exclude: 9 | - README.md 10 | - docs/* 11 | 12 | variables: 13 | - template: eng/common/templates/variables/pool-providers.yml 14 | - name: _PublishUsingPipelines 15 | value: true 16 | 17 | stages: 18 | - stage: build 19 | displayName: Build 20 | jobs: 21 | - template: /eng/common/templates/jobs/jobs.yml 22 | parameters: 23 | enableMicrobuild: true 24 | enablePublishBuildArtifacts: true 25 | enablePublishTestResults: true 26 | enablePublishBuildAssets: true 27 | enablePublishUsingPipelines: $(_PublishUsingPipelines) 28 | enableTelemetry: true 29 | enableSourceBuild: false 30 | helixRepo: dotnet/interactive-window 31 | jobs: 32 | - job: Windows 33 | pool: 34 | name: $(DncEngPublicBuildPool) 35 | demands: ImageOverride -equals windows.vs2022.amd64.open 36 | strategy: 37 | matrix: 38 | # PRs or external builds are not signed. 39 | Debug: 40 | _BuildConfig: Debug 41 | _SignType: test 42 | _DotNetPublishToBlobFeed: false 43 | _BuildArgs: '' 44 | Release: 45 | _BuildConfig: Release 46 | _SignType: test 47 | _DotNetPublishToBlobFeed: false 48 | _BuildArgs: '' 49 | steps: 50 | - checkout: self 51 | clean: true 52 | 53 | - task: UseDotNet@2 54 | displayName: 'Install .NET SDK' 55 | inputs: 56 | useGlobalJson: true 57 | 58 | - script: eng\common\cibuild.cmd -configuration $(_BuildConfig) -prepareMachine $(_BuildArgs) 59 | displayName: Build and Test -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source="${BASH_SOURCE[0]}" 4 | 5 | # resolve $SOURCE until the file is no longer a symlink 6 | while [[ -h $source ]]; do 7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 8 | source="$(readlink "$source")" 9 | 10 | # if $source was a relative symlink, we need to resolve it relative to the path where the 11 | # symlink file was located 12 | [[ $source != /* ]] && source="$scriptroot/$source" 13 | done 14 | 15 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 16 | "$scriptroot/eng/common/build.sh" --build --restore $@ -------------------------------------------------------------------------------- /eng/TSAConfig.gdntsa: -------------------------------------------------------------------------------- 1 | { 2 | "codebaseName": "Interactive-Window-GitHub", 3 | "notificationAliases": [ 4 | "mlinfraswat@microsoft.com" 5 | ], 6 | "codebaseAdmins": [ 7 | "REDMOND\\tmat", 8 | "REDMOND\\phillipa" 9 | ], 10 | "instanceUrl": "https://devdiv.visualstudio.com", 11 | "projectName": "DevDiv", 12 | "areaPath": "DevDiv\\NET Developer Experience\\Debugger and Interactive", 13 | "iterationPath": "DevDiv", 14 | "allTools": true 15 | } 16 | -------------------------------------------------------------------------------- /eng/Version.Details.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | https://github.com/dotnet/arcade 8 | 5ba9ca776c1d0bb72b2791591e54cf51fc52dfee 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /eng/common/BuildConfiguration/build-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "RetryCountLimit": 1, 3 | "RetryByAnyError": false 4 | } 5 | -------------------------------------------------------------------------------- /eng/common/CIBuild.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Build.ps1""" -restore -build -test -sign -pack -publish -ci %*" -------------------------------------------------------------------------------- /eng/common/PSScriptAnalyzerSettings.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | IncludeRules=@('PSAvoidUsingCmdletAliases', 3 | 'PSAvoidUsingWMICmdlet', 4 | 'PSAvoidUsingPositionalParameters', 5 | 'PSAvoidUsingInvokeExpression', 6 | 'PSUseDeclaredVarsMoreThanAssignments', 7 | 'PSUseCmdletCorrectly', 8 | 'PSStandardDSCFunctionsInResource', 9 | 'PSUseIdenticalMandatoryParametersForDSC', 10 | 'PSUseIdenticalParametersForDSC') 11 | } -------------------------------------------------------------------------------- /eng/common/README.md: -------------------------------------------------------------------------------- 1 | # Don't touch this folder 2 | 3 | uuuuuuuuuuuuuuuuuuuu 4 | u" uuuuuuuuuuuuuuuuuu "u 5 | u" u$$$$$$$$$$$$$$$$$$$$u "u 6 | u" u$$$$$$$$$$$$$$$$$$$$$$$$u "u 7 | u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u 8 | u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u 9 | u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u 10 | $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ 11 | $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ 12 | $ $$$" ... "$... ...$" ... "$$$ ... "$$$ $ 13 | $ $$$u `"$$$$$$$ $$$ $$$$$ $$ $$$ $$$ $ 14 | $ $$$$$$uu "$$$$ $$$ $$$$$ $$ """ u$$$ $ 15 | $ $$$""$$$ $$$$ $$$u "$$$" u$$ $$$$$$$$ $ 16 | $ $$$$....,$$$$$..$$$$$....,$$$$..$$$$$$$$ $ 17 | $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ 18 | "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u" 19 | "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u" 20 | "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u" 21 | "u "$$$$$$$$$$$$$$$$$$$$$$$$" u" 22 | "u "$$$$$$$$$$$$$$$$$$$$" u" 23 | "u """""""""""""""""" u" 24 | """""""""""""""""""" 25 | 26 | !!! Changes made in this directory are subject to being overwritten by automation !!! 27 | 28 | The files in this directory are shared by all Arcade repos and managed by automation. If you need to make changes to these files, open an issue or submit a pull request to https://github.com/dotnet/arcade first. 29 | -------------------------------------------------------------------------------- /eng/common/build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0build.ps1""" %*" 3 | exit /b %ErrorLevel% 4 | -------------------------------------------------------------------------------- /eng/common/cibuild.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source="${BASH_SOURCE[0]}" 4 | 5 | # resolve $SOURCE until the file is no longer a symlink 6 | while [[ -h $source ]]; do 7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 8 | source="$(readlink "$source")" 9 | 10 | # if $source was a relative symlink, we need to resolve it relative to the path where 11 | # the symlink file was located 12 | [[ $source != /* ]] && source="$scriptroot/$source" 13 | done 14 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 15 | 16 | . "$scriptroot/build.sh" --restore --build --test --pack --publish --ci $@ -------------------------------------------------------------------------------- /eng/common/core-templates/jobs/codeql-build.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | # See schema documentation in /Documentation/AzureDevOps/TemplateSchema.md 3 | continueOnError: false 4 | # Required: A collection of jobs to run - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#job 5 | jobs: [] 6 | # Optional: if specified, restore and use this version of Guardian instead of the default. 7 | overrideGuardianVersion: '' 8 | is1ESPipeline: '' 9 | 10 | jobs: 11 | - template: /eng/common/core-templates/jobs/jobs.yml 12 | parameters: 13 | is1ESPipeline: ${{ parameters.is1ESPipeline }} 14 | enableMicrobuild: false 15 | enablePublishBuildArtifacts: false 16 | enablePublishTestResults: false 17 | enablePublishBuildAssets: false 18 | enablePublishUsingPipelines: false 19 | enableTelemetry: true 20 | 21 | variables: 22 | - group: Publish-Build-Assets 23 | # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in 24 | # sync with the packages.config file. 25 | - name: DefaultGuardianVersion 26 | value: 0.109.0 27 | - name: GuardianPackagesConfigFile 28 | value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config 29 | - name: GuardianVersion 30 | value: ${{ coalesce(parameters.overrideGuardianVersion, '$(DefaultGuardianVersion)') }} 31 | 32 | jobs: ${{ parameters.jobs }} 33 | 34 | -------------------------------------------------------------------------------- /eng/common/core-templates/post-build/common-variables.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | - group: Publish-Build-Assets 3 | 4 | # Whether the build is internal or not 5 | - name: IsInternalBuild 6 | value: ${{ and(ne(variables['System.TeamProject'], 'public'), contains(variables['Build.SourceBranch'], 'internal')) }} 7 | 8 | # Default Maestro++ API Endpoint and API Version 9 | - name: MaestroApiEndPoint 10 | value: "https://maestro.dot.net" 11 | - name: MaestroApiVersion 12 | value: "2020-02-20" 13 | 14 | - name: SourceLinkCLIVersion 15 | value: 3.0.0 16 | - name: SymbolToolVersion 17 | value: 1.0.1 18 | - name: BinlogToolVersion 19 | value: 1.0.11 20 | 21 | - name: runCodesignValidationInjection 22 | value: false 23 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/component-governance.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | disableComponentGovernance: false 3 | componentGovernanceIgnoreDirectories: '' 4 | is1ESPipeline: false 5 | displayName: 'Component Detection' 6 | 7 | steps: 8 | - ${{ if eq(parameters.disableComponentGovernance, 'true') }}: 9 | - script: echo "##vso[task.setvariable variable=skipComponentGovernanceDetection]true" 10 | displayName: Set skipComponentGovernanceDetection variable 11 | - ${{ if ne(parameters.disableComponentGovernance, 'true') }}: 12 | - task: ComponentGovernanceComponentDetection@0 13 | continueOnError: true 14 | displayName: ${{ parameters.displayName }} 15 | inputs: 16 | ignoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }} 17 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/enable-internal-runtimes.yml: -------------------------------------------------------------------------------- 1 | # Obtains internal runtime download credentials and populates the 'dotnetbuilds-internal-container-read-token-base64' 2 | # variable with the base64-encoded SAS token, by default 3 | 4 | parameters: 5 | - name: federatedServiceConnection 6 | type: string 7 | default: 'dotnetbuilds-internal-read' 8 | - name: outputVariableName 9 | type: string 10 | default: 'dotnetbuilds-internal-container-read-token-base64' 11 | - name: expiryInHours 12 | type: number 13 | default: 1 14 | - name: base64Encode 15 | type: boolean 16 | default: true 17 | - name: is1ESPipeline 18 | type: boolean 19 | default: false 20 | 21 | steps: 22 | - ${{ if ne(variables['System.TeamProject'], 'public') }}: 23 | - template: /eng/common/core-templates/steps/get-delegation-sas.yml 24 | parameters: 25 | federatedServiceConnection: ${{ parameters.federatedServiceConnection }} 26 | outputVariableName: ${{ parameters.outputVariableName }} 27 | expiryInHours: ${{ parameters.expiryInHours }} 28 | base64Encode: ${{ parameters.base64Encode }} 29 | storageAccount: dotnetbuilds 30 | container: internal 31 | permissions: rl 32 | is1ESPipeline: ${{ parameters.is1ESPipeline }} -------------------------------------------------------------------------------- /eng/common/core-templates/steps/enable-internal-sources.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | # This is the Azure federated service connection that we log into to get an access token. 3 | - name: nugetFederatedServiceConnection 4 | type: string 5 | default: 'dnceng-artifacts-feeds-read' 6 | - name: is1ESPipeline 7 | type: boolean 8 | default: false 9 | # Legacy parameters to allow for PAT usage 10 | - name: legacyCredential 11 | type: string 12 | default: '' 13 | 14 | steps: 15 | - ${{ if ne(variables['System.TeamProject'], 'public') }}: 16 | - ${{ if ne(parameters.legacyCredential, '') }}: 17 | - task: PowerShell@2 18 | displayName: Setup Internal Feeds 19 | inputs: 20 | filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1 21 | arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config -Password $Env:Token 22 | env: 23 | Token: ${{ parameters.legacyCredential }} 24 | # If running on dnceng (internal project), just use the default behavior for NuGetAuthenticate. 25 | # If running on DevDiv, NuGetAuthenticate is not really an option. It's scoped to a single feed, and we have many feeds that 26 | # may be added. Instead, we'll use the traditional approach (add cred to nuget.config), but use an account token. 27 | - ${{ else }}: 28 | - ${{ if eq(variables['System.TeamProject'], 'internal') }}: 29 | - task: PowerShell@2 30 | displayName: Setup Internal Feeds 31 | inputs: 32 | filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1 33 | arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config 34 | - ${{ else }}: 35 | - template: /eng/common/templates/steps/get-federated-access-token.yml 36 | parameters: 37 | federatedServiceConnection: ${{ parameters.nugetFederatedServiceConnection }} 38 | outputVariableName: 'dnceng-artifacts-feeds-read-access-token' 39 | - task: PowerShell@2 40 | displayName: Setup Internal Feeds 41 | inputs: 42 | filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1 43 | arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config -Password $(dnceng-artifacts-feeds-read-access-token) 44 | # This is required in certain scenarios to install the ADO credential provider. 45 | # It installed by default in some msbuild invocations (e.g. VS msbuild), but needs to be installed for others 46 | # (e.g. dotnet msbuild). 47 | - task: NuGetAuthenticate@1 48 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/get-delegation-sas.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: federatedServiceConnection 3 | type: string 4 | - name: outputVariableName 5 | type: string 6 | - name: expiryInHours 7 | type: number 8 | default: 1 9 | - name: base64Encode 10 | type: boolean 11 | default: false 12 | - name: storageAccount 13 | type: string 14 | - name: container 15 | type: string 16 | - name: permissions 17 | type: string 18 | default: 'rl' 19 | - name: is1ESPipeline 20 | type: boolean 21 | default: false 22 | 23 | steps: 24 | - task: AzureCLI@2 25 | displayName: 'Generate delegation SAS Token for ${{ parameters.storageAccount }}/${{ parameters.container }}' 26 | inputs: 27 | azureSubscription: ${{ parameters.federatedServiceConnection }} 28 | scriptType: 'pscore' 29 | scriptLocation: 'inlineScript' 30 | inlineScript: | 31 | # Calculate the expiration of the SAS token and convert to UTC 32 | $expiry = (Get-Date).AddHours(${{ parameters.expiryInHours }}).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") 33 | 34 | # Temporarily work around a helix issue where SAS tokens with / in them will cause incorrect downloads 35 | # of correlation payloads. https://github.com/dotnet/dnceng/issues/3484 36 | $sas = "" 37 | do { 38 | $sas = az storage container generate-sas --account-name ${{ parameters.storageAccount }} --name ${{ parameters.container }} --permissions ${{ parameters.permissions }} --expiry $expiry --auth-mode login --as-user -o tsv 39 | if ($LASTEXITCODE -ne 0) { 40 | Write-Error "Failed to generate SAS token." 41 | exit 1 42 | } 43 | } while($sas.IndexOf('/') -ne -1) 44 | 45 | if ($LASTEXITCODE -ne 0) { 46 | Write-Error "Failed to generate SAS token." 47 | exit 1 48 | } 49 | 50 | if ('${{ parameters.base64Encode }}' -eq 'true') { 51 | $sas = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($sas)) 52 | } 53 | 54 | Write-Host "Setting '${{ parameters.outputVariableName }}' with the access token value" 55 | Write-Host "##vso[task.setvariable variable=${{ parameters.outputVariableName }};issecret=true]$sas" 56 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/get-federated-access-token.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: federatedServiceConnection 3 | type: string 4 | - name: outputVariableName 5 | type: string 6 | - name: is1ESPipeline 7 | type: boolean 8 | - name: stepName 9 | type: string 10 | default: 'getFederatedAccessToken' 11 | - name: condition 12 | type: string 13 | default: '' 14 | # Resource to get a token for. Common values include: 15 | # - '499b84ac-1321-427f-aa17-267ca6975798' for Azure DevOps 16 | # - 'https://storage.azure.com/' for storage 17 | # Defaults to Azure DevOps 18 | - name: resource 19 | type: string 20 | default: '499b84ac-1321-427f-aa17-267ca6975798' 21 | - name: isStepOutputVariable 22 | type: boolean 23 | default: false 24 | 25 | steps: 26 | - task: AzureCLI@2 27 | displayName: 'Getting federated access token for feeds' 28 | name: ${{ parameters.stepName }} 29 | ${{ if ne(parameters.condition, '') }}: 30 | condition: ${{ parameters.condition }} 31 | inputs: 32 | azureSubscription: ${{ parameters.federatedServiceConnection }} 33 | scriptType: 'pscore' 34 | scriptLocation: 'inlineScript' 35 | inlineScript: | 36 | $accessToken = az account get-access-token --query accessToken --resource ${{ parameters.resource }} --output tsv 37 | if ($LASTEXITCODE -ne 0) { 38 | Write-Error "Failed to get access token for resource '${{ parameters.resource }}'" 39 | exit 1 40 | } 41 | Write-Host "Setting '${{ parameters.outputVariableName }}' with the access token value" 42 | Write-Host "##vso[task.setvariable variable=${{ parameters.outputVariableName }};issecret=true;isOutput=${{ parameters.isStepOutputVariable }}]$accessToken" -------------------------------------------------------------------------------- /eng/common/core-templates/steps/publish-build-artifacts.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: is1ESPipeline 3 | type: boolean 4 | default: false 5 | - name: args 6 | type: object 7 | default: {} 8 | steps: 9 | - ${{ if ne(parameters.is1ESPipeline, true) }}: 10 | - template: /eng/common/templates/steps/publish-build-artifacts.yml 11 | parameters: 12 | is1ESPipeline: ${{ parameters.is1ESPipeline }} 13 | ${{ each parameter in parameters.args }}: 14 | ${{ parameter.key }}: ${{ parameter.value }} 15 | - ${{ else }}: 16 | - template: /eng/common/templates-official/steps/publish-build-artifacts.yml 17 | parameters: 18 | is1ESPipeline: ${{ parameters.is1ESPipeline }} 19 | ${{ each parameter in parameters.args }}: 20 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/core-templates/steps/publish-pipeline-artifacts.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: is1ESPipeline 3 | type: boolean 4 | default: false 5 | 6 | - name: args 7 | type: object 8 | default: {} 9 | 10 | steps: 11 | - ${{ if ne(parameters.is1ESPipeline, true) }}: 12 | - template: /eng/common/templates/steps/publish-pipeline-artifacts.yml 13 | parameters: 14 | ${{ each parameter in parameters }}: 15 | ${{ parameter.key }}: ${{ parameter.value }} 16 | - ${{ else }}: 17 | - template: /eng/common/templates-official/steps/publish-pipeline-artifacts.yml 18 | parameters: 19 | ${{ each parameter in parameters }}: 20 | ${{ parameter.key }}: ${{ parameter.value }} 21 | -------------------------------------------------------------------------------- /eng/common/core-templates/steps/retain-build.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | # Optional azure devops PAT with build execute permissions for the build's organization, 3 | # only needed if the build that should be retained ran on a different organization than 4 | # the pipeline where this template is executing from 5 | Token: '' 6 | # Optional BuildId to retain, defaults to the current running build 7 | BuildId: '' 8 | # Azure devops Organization URI for the build in the https://dev.azure.com/ format. 9 | # Defaults to the organization the current pipeline is running on 10 | AzdoOrgUri: '$(System.CollectionUri)' 11 | # Azure devops project for the build. Defaults to the project the current pipeline is running on 12 | AzdoProject: '$(System.TeamProject)' 13 | 14 | steps: 15 | - task: powershell@2 16 | inputs: 17 | targetType: 'filePath' 18 | filePath: eng/common/retain-build.ps1 19 | pwsh: true 20 | arguments: > 21 | -AzdoOrgUri: ${{parameters.AzdoOrgUri}} 22 | -AzdoProject ${{parameters.AzdoProject}} 23 | -Token ${{coalesce(parameters.Token, '$env:SYSTEM_ACCESSTOKEN') }} 24 | -BuildId ${{coalesce(parameters.BuildId, '$env:BUILD_ID')}} 25 | displayName: Enable permanent build retention 26 | env: 27 | SYSTEM_ACCESSTOKEN: $(System.AccessToken) 28 | BUILD_ID: $(Build.BuildId) -------------------------------------------------------------------------------- /eng/common/core-templates/variables/pool-providers.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | is1ESPipeline: false 3 | 4 | variables: 5 | - ${{ if eq(parameters.is1ESPipeline, 'true') }}: 6 | - template: /eng/common/templates-official/variables/pool-providers.yml 7 | - ${{ else }}: 8 | - template: /eng/common/templates/variables/pool-providers.yml -------------------------------------------------------------------------------- /eng/common/cross/arm/tizen/tizen.patch: -------------------------------------------------------------------------------- 1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so 2 | --- a/usr/lib/libc.so 2016-12-30 23:00:08.284951863 +0900 3 | +++ b/usr/lib/libc.so 2016-12-30 23:00:32.140951815 +0900 4 | @@ -2,4 +2,4 @@ 5 | Use the shared library, but some functions are only in 6 | the static library, so try that secondarily. */ 7 | OUTPUT_FORMAT(elf32-littlearm) 8 | -GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux-armhf.so.3 ) ) 9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-armhf.so.3 ) ) 10 | -------------------------------------------------------------------------------- /eng/common/cross/arm64/tizen/tizen.patch: -------------------------------------------------------------------------------- 1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so 2 | --- a/usr/lib64/libc.so 2016-12-30 23:00:08.284951863 +0900 3 | +++ b/usr/lib64/libc.so 2016-12-30 23:00:32.140951815 +0900 4 | @@ -2,4 +2,4 @@ 5 | Use the shared library, but some functions are only in 6 | the static library, so try that secondarily. */ 7 | OUTPUT_FORMAT(elf64-littleaarch64) 8 | -GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib/ld-linux-aarch64.so.1 ) ) 9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-aarch64.so.1 ) ) 10 | -------------------------------------------------------------------------------- /eng/common/cross/armel/armel.jessie.patch: -------------------------------------------------------------------------------- 1 | diff -u -r a/usr/include/urcu/uatomic/generic.h b/usr/include/urcu/uatomic/generic.h 2 | --- a/usr/include/urcu/uatomic/generic.h 2014-10-22 15:00:58.000000000 -0700 3 | +++ b/usr/include/urcu/uatomic/generic.h 2020-10-30 21:38:28.550000000 -0700 4 | @@ -69,10 +69,10 @@ 5 | #endif 6 | #ifdef UATOMIC_HAS_ATOMIC_SHORT 7 | case 2: 8 | - return __sync_val_compare_and_swap_2(addr, old, _new); 9 | + return __sync_val_compare_and_swap_2((uint16_t*) addr, old, _new); 10 | #endif 11 | case 4: 12 | - return __sync_val_compare_and_swap_4(addr, old, _new); 13 | + return __sync_val_compare_and_swap_4((uint32_t*) addr, old, _new); 14 | #if (CAA_BITS_PER_LONG == 64) 15 | case 8: 16 | return __sync_val_compare_and_swap_8(addr, old, _new); 17 | @@ -109,7 +109,7 @@ 18 | return; 19 | #endif 20 | case 4: 21 | - __sync_and_and_fetch_4(addr, val); 22 | + __sync_and_and_fetch_4((uint32_t*) addr, val); 23 | return; 24 | #if (CAA_BITS_PER_LONG == 64) 25 | case 8: 26 | @@ -148,7 +148,7 @@ 27 | return; 28 | #endif 29 | case 4: 30 | - __sync_or_and_fetch_4(addr, val); 31 | + __sync_or_and_fetch_4((uint32_t*) addr, val); 32 | return; 33 | #if (CAA_BITS_PER_LONG == 64) 34 | case 8: 35 | @@ -187,7 +187,7 @@ 36 | return __sync_add_and_fetch_2(addr, val); 37 | #endif 38 | case 4: 39 | - return __sync_add_and_fetch_4(addr, val); 40 | + return __sync_add_and_fetch_4((uint32_t*) addr, val); 41 | #if (CAA_BITS_PER_LONG == 64) 42 | case 8: 43 | return __sync_add_and_fetch_8(addr, val); 44 | -------------------------------------------------------------------------------- /eng/common/cross/armel/tizen/tizen.patch: -------------------------------------------------------------------------------- 1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so 2 | --- a/usr/lib/libc.so 2016-12-30 23:00:08.284951863 +0900 3 | +++ b/usr/lib/libc.so 2016-12-30 23:00:32.140951815 +0900 4 | @@ -2,4 +2,4 @@ 5 | Use the shared library, but some functions are only in 6 | the static library, so try that secondarily. */ 7 | OUTPUT_FORMAT(elf32-littlearm) 8 | -GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.3 ) ) 9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux.so.3 ) ) 10 | -------------------------------------------------------------------------------- /eng/common/cross/riscv64/tizen/tizen.patch: -------------------------------------------------------------------------------- 1 | diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so 2 | --- a/usr/lib64/libc.so 2016-12-30 23:00:08.284951863 +0900 3 | +++ b/usr/lib64/libc.so 2016-12-30 23:00:32.140951815 +0900 4 | @@ -2,4 +2,4 @@ 5 | Use the shared library, but some functions are only in 6 | the static library, so try that secondarily. */ 7 | OUTPUT_FORMAT(elf64-littleriscv) 8 | -GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-riscv64-lp64d.so.1 ) ) 9 | +GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-riscv64-lp64d.so.1 ) ) 10 | -------------------------------------------------------------------------------- /eng/common/cross/tizen-build-rootfs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | ARCH=$1 5 | LINK_ARCH=$ARCH 6 | 7 | case "$ARCH" in 8 | arm) 9 | TIZEN_ARCH="armv7hl" 10 | ;; 11 | armel) 12 | TIZEN_ARCH="armv7l" 13 | LINK_ARCH="arm" 14 | ;; 15 | arm64) 16 | TIZEN_ARCH="aarch64" 17 | ;; 18 | x86) 19 | TIZEN_ARCH="i686" 20 | ;; 21 | x64) 22 | TIZEN_ARCH="x86_64" 23 | LINK_ARCH="x86" 24 | ;; 25 | riscv64) 26 | TIZEN_ARCH="riscv64" 27 | LINK_ARCH="riscv" 28 | ;; 29 | *) 30 | echo "Unsupported architecture for tizen: $ARCH" 31 | exit 1 32 | esac 33 | 34 | __CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 35 | __TIZEN_CROSSDIR="$__CrossDir/${ARCH}/tizen" 36 | 37 | if [[ -z "$ROOTFS_DIR" ]]; then 38 | echo "ROOTFS_DIR is not defined." 39 | exit 1; 40 | fi 41 | 42 | TIZEN_TMP_DIR=$ROOTFS_DIR/tizen_tmp 43 | mkdir -p $TIZEN_TMP_DIR 44 | 45 | # Download files 46 | echo ">>Start downloading files" 47 | VERBOSE=1 $__CrossDir/tizen-fetch.sh $TIZEN_TMP_DIR $TIZEN_ARCH 48 | echo "<>Start constructing Tizen rootfs" 51 | TIZEN_RPM_FILES=`ls $TIZEN_TMP_DIR/*.rpm` 52 | cd $ROOTFS_DIR 53 | for f in $TIZEN_RPM_FILES; do 54 | rpm2cpio $f | cpio -idm --quiet 55 | done 56 | echo "<>Start configuring Tizen rootfs" 63 | ln -sfn asm-${LINK_ARCH} ./usr/include/asm 64 | patch -p1 < $__TIZEN_CROSSDIR/tizen.patch 65 | if [[ "$TIZEN_ARCH" == "riscv64" ]]; then 66 | echo "Fixing broken symlinks in $PWD" 67 | rm ./usr/lib64/libresolv.so 68 | ln -s ../../lib64/libresolv.so.2 ./usr/lib64/libresolv.so 69 | rm ./usr/lib64/libpthread.so 70 | ln -s ../../lib64/libpthread.so.0 ./usr/lib64/libpthread.so 71 | rm ./usr/lib64/libdl.so 72 | ln -s ../../lib64/libdl.so.2 ./usr/lib64/libdl.so 73 | rm ./usr/lib64/libutil.so 74 | ln -s ../../lib64/libutil.so.1 ./usr/lib64/libutil.so 75 | rm ./usr/lib64/libm.so 76 | ln -s ../../lib64/libm.so.6 ./usr/lib64/libm.so 77 | rm ./usr/lib64/librt.so 78 | ln -s ../../lib64/librt.so.1 ./usr/lib64/librt.so 79 | rm ./lib/ld-linux-riscv64-lp64d.so.1 80 | ln -s ../lib64/ld-linux-riscv64-lp64d.so.1 ./lib/ld-linux-riscv64-lp64d.so.1 81 | fi 82 | echo "<\\|?@*"() ]', '_' 11 | $SbomGenerationDir = Join-Path $ManifestDirPath $SafeArtifactName 12 | 13 | Write-Host "Artifact name before : $ArtifactName" 14 | Write-Host "Artifact name after : $SafeArtifactName" 15 | 16 | Write-Host "Creating dir $ManifestDirPath" 17 | 18 | # create directory for sbom manifest to be placed 19 | if (!(Test-Path -path $SbomGenerationDir)) 20 | { 21 | New-Item -ItemType Directory -path $SbomGenerationDir 22 | Write-Host "Successfully created directory $SbomGenerationDir" 23 | } 24 | else{ 25 | Write-PipelineTelemetryError -category 'Build' "Unable to create sbom folder." 26 | } 27 | 28 | Write-Host "Updating artifact name" 29 | Write-Host "##vso[task.setvariable variable=ARTIFACT_NAME]$SafeArtifactName" 30 | -------------------------------------------------------------------------------- /eng/common/generate-sbom-prep.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source="${BASH_SOURCE[0]}" 4 | 5 | # resolve $SOURCE until the file is no longer a symlink 6 | while [[ -h $source ]]; do 7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 8 | source="$(readlink "$source")" 9 | 10 | # if $source was a relative symlink, we need to resolve it relative to the path where the 11 | # symlink file was located 12 | [[ $source != /* ]] && source="$scriptroot/$source" 13 | done 14 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 15 | . $scriptroot/pipeline-logging-functions.sh 16 | 17 | 18 | # replace all special characters with _, some builds use special characters like : in Agent.Jobname, that is not a permissible name while uploading artifacts. 19 | artifact_name=$SYSTEM_STAGENAME"_"$AGENT_JOBNAME"_SBOM" 20 | safe_artifact_name="${artifact_name//["/:<>\\|?@*$" ]/_}" 21 | manifest_dir=$1 22 | 23 | # Normally - we'd listen to the manifest path given, but 1ES templates will overwrite if this level gets uploaded directly 24 | # with their own overwriting ours. So we create it as a sub directory of the requested manifest path. 25 | sbom_generation_dir="$manifest_dir/$safe_artifact_name" 26 | 27 | if [ ! -d "$sbom_generation_dir" ] ; then 28 | mkdir -p "$sbom_generation_dir" 29 | echo "Sbom directory created." $sbom_generation_dir 30 | else 31 | Write-PipelineTelemetryError -category 'Build' "Unable to create sbom folder." 32 | fi 33 | 34 | echo "Artifact name before : "$artifact_name 35 | echo "Artifact name after : "$safe_artifact_name 36 | export ARTIFACT_NAME=$safe_artifact_name 37 | echo "##vso[task.setvariable variable=ARTIFACT_NAME]$safe_artifact_name" 38 | 39 | exit 0 40 | -------------------------------------------------------------------------------- /eng/common/helixpublish.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | msbuild 6 | 7 | 8 | 9 | 10 | %(Identity) 11 | 12 | 13 | 14 | 15 | 16 | $(WorkItemDirectory) 17 | $(WorkItemCommand) 18 | $(WorkItemTimeout) 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /eng/common/init-tools-native.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | powershell -NoProfile -NoLogo -ExecutionPolicy ByPass -command "& """%~dp0init-tools-native.ps1""" %*" 3 | exit /b %ErrorLevel% -------------------------------------------------------------------------------- /eng/common/internal/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | false 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /eng/common/internal/NuGet.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /eng/common/internal/Tools.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | net472 6 | false 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /eng/common/loc/P22DotNetHtmlLocalization.lss: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /eng/common/msbuild.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding(PositionalBinding=$false)] 2 | Param( 3 | [string] $verbosity = 'minimal', 4 | [bool] $warnAsError = $true, 5 | [bool] $nodeReuse = $true, 6 | [switch] $ci, 7 | [switch] $prepareMachine, 8 | [switch] $excludePrereleaseVS, 9 | [string] $msbuildEngine = $null, 10 | [Parameter(ValueFromRemainingArguments=$true)][String[]]$extraArgs 11 | ) 12 | 13 | . $PSScriptRoot\tools.ps1 14 | 15 | try { 16 | if ($ci) { 17 | $nodeReuse = $false 18 | } 19 | 20 | MSBuild @extraArgs 21 | } 22 | catch { 23 | Write-Host $_.ScriptStackTrace 24 | Write-PipelineTelemetryError -Category 'Build' -Message $_ 25 | ExitWithExitCode 1 26 | } 27 | 28 | ExitWithExitCode 0 -------------------------------------------------------------------------------- /eng/common/msbuild.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source="${BASH_SOURCE[0]}" 4 | 5 | # resolve $source until the file is no longer a symlink 6 | while [[ -h "$source" ]]; do 7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 8 | source="$(readlink "$source")" 9 | # if $source was a relative symlink, we need to resolve it relative to the path where the 10 | # symlink file was located 11 | [[ $source != /* ]] && source="$scriptroot/$source" 12 | done 13 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" 14 | 15 | verbosity='minimal' 16 | warn_as_error=true 17 | node_reuse=true 18 | prepare_machine=false 19 | extra_args='' 20 | 21 | while (($# > 0)); do 22 | lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")" 23 | case $lowerI in 24 | --verbosity) 25 | verbosity=$2 26 | shift 2 27 | ;; 28 | --warnaserror) 29 | warn_as_error=$2 30 | shift 2 31 | ;; 32 | --nodereuse) 33 | node_reuse=$2 34 | shift 2 35 | ;; 36 | --ci) 37 | ci=true 38 | shift 1 39 | ;; 40 | --preparemachine) 41 | prepare_machine=true 42 | shift 1 43 | ;; 44 | *) 45 | extra_args="$extra_args $1" 46 | shift 1 47 | ;; 48 | esac 49 | done 50 | 51 | . "$scriptroot/tools.sh" 52 | 53 | if [[ "$ci" == true ]]; then 54 | node_reuse=false 55 | fi 56 | 57 | MSBuild $extra_args 58 | ExitWithExitCode 0 59 | -------------------------------------------------------------------------------- /eng/common/native/init-os-and-arch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Use uname to determine what the OS is. 4 | OSName=$(uname -s | tr '[:upper:]' '[:lower:]') 5 | 6 | if command -v getprop && getprop ro.product.system.model 2>&1 | grep -qi android; then 7 | OSName="android" 8 | fi 9 | 10 | case "$OSName" in 11 | freebsd|linux|netbsd|openbsd|sunos|android|haiku) 12 | os="$OSName" ;; 13 | darwin) 14 | os=osx ;; 15 | *) 16 | echo "Unsupported OS $OSName detected!" 17 | exit 1 ;; 18 | esac 19 | 20 | # On Solaris, `uname -m` is discouraged, see https://docs.oracle.com/cd/E36784_01/html/E36870/uname-1.html 21 | # and `uname -p` returns processor type (e.g. i386 on amd64). 22 | # The appropriate tool to determine CPU is isainfo(1) https://docs.oracle.com/cd/E36784_01/html/E36870/isainfo-1.html. 23 | if [ "$os" = "sunos" ]; then 24 | if uname -o 2>&1 | grep -q illumos; then 25 | os="illumos" 26 | else 27 | os="solaris" 28 | fi 29 | CPUName=$(isainfo -n) 30 | else 31 | # For the rest of the operating systems, use uname(1) to determine what the CPU is. 32 | CPUName=$(uname -m) 33 | fi 34 | 35 | case "$CPUName" in 36 | arm64|aarch64) 37 | arch=arm64 38 | if [ "$(getconf LONG_BIT)" -lt 64 ]; then 39 | # This is 32-bit OS running on 64-bit CPU (for example Raspberry Pi OS) 40 | arch=arm 41 | fi 42 | ;; 43 | 44 | loongarch64) 45 | arch=loongarch64 46 | ;; 47 | 48 | riscv64) 49 | arch=riscv64 50 | ;; 51 | 52 | amd64|x86_64) 53 | arch=x64 54 | ;; 55 | 56 | armv7l|armv8l) 57 | # shellcheck disable=SC1091 58 | if (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then 59 | arch=armel 60 | else 61 | arch=arm 62 | fi 63 | ;; 64 | 65 | armv6l) 66 | arch=armv6 67 | ;; 68 | 69 | i[3-6]86) 70 | echo "Unsupported CPU $CPUName detected, build might not succeed!" 71 | arch=x86 72 | ;; 73 | 74 | s390x) 75 | arch=s390x 76 | ;; 77 | 78 | ppc64le) 79 | arch=ppc64le 80 | ;; 81 | *) 82 | echo "Unknown CPU $CPUName detected!" 83 | exit 1 84 | ;; 85 | esac 86 | -------------------------------------------------------------------------------- /eng/common/post-build/check-channel-consistency.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [Parameter(Mandatory=$true)][string] $PromoteToChannels, # List of channels that the build should be promoted to 3 | [Parameter(Mandatory=$true)][array] $AvailableChannelIds # List of channel IDs available in the YAML implementation 4 | ) 5 | 6 | try { 7 | $ErrorActionPreference = 'Stop' 8 | Set-StrictMode -Version 2.0 9 | 10 | # `tools.ps1` checks $ci to perform some actions. Since the post-build 11 | # scripts don't necessarily execute in the same agent that run the 12 | # build.ps1/sh script this variable isn't automatically set. 13 | $ci = $true 14 | $disableConfigureToolsetImport = $true 15 | . $PSScriptRoot\..\tools.ps1 16 | 17 | if ($PromoteToChannels -eq "") { 18 | Write-PipelineTaskError -Type 'warning' -Message "This build won't publish assets as it's not configured to any Maestro channel. If that wasn't intended use Darc to configure a default channel using add-default-channel for this branch or to promote it to a channel using add-build-to-channel. See https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md#assigning-an-individual-build-to-a-channel for more info." 19 | ExitWithExitCode 0 20 | } 21 | 22 | # Check that every channel that Maestro told to promote the build to 23 | # is available in YAML 24 | $PromoteToChannelsIds = $PromoteToChannels -split "\D" | Where-Object { $_ } 25 | 26 | $hasErrors = $false 27 | 28 | foreach ($id in $PromoteToChannelsIds) { 29 | if (($id -ne 0) -and ($id -notin $AvailableChannelIds)) { 30 | Write-PipelineTaskError -Message "Channel $id is not present in the post-build YAML configuration! This is an error scenario. Please contact @dnceng." 31 | $hasErrors = $true 32 | } 33 | } 34 | 35 | # The `Write-PipelineTaskError` doesn't error the script and we might report several errors 36 | # in the previous lines. The check below makes sure that we return an error state from the 37 | # script if we reported any validation error 38 | if ($hasErrors) { 39 | ExitWithExitCode 1 40 | } 41 | 42 | Write-Host 'done.' 43 | } 44 | catch { 45 | Write-Host $_ 46 | Write-PipelineTelemetryError -Category 'CheckChannelConsistency' -Message "There was an error while trying to check consistency of Maestro default channels for the build and post-build YAML configuration." 47 | ExitWithExitCode 1 48 | } 49 | -------------------------------------------------------------------------------- /eng/common/post-build/nuget-validation.ps1: -------------------------------------------------------------------------------- 1 | # This script validates NuGet package metadata information using this 2 | # tool: https://github.com/NuGet/NuGetGallery/tree/jver-verify/src/VerifyMicrosoftPackage 3 | 4 | param( 5 | [Parameter(Mandatory=$true)][string] $PackagesPath # Path to where the packages to be validated are 6 | ) 7 | 8 | # `tools.ps1` checks $ci to perform some actions. Since the post-build 9 | # scripts don't necessarily execute in the same agent that run the 10 | # build.ps1/sh script this variable isn't automatically set. 11 | $ci = $true 12 | $disableConfigureToolsetImport = $true 13 | . $PSScriptRoot\..\tools.ps1 14 | 15 | try { 16 | & $PSScriptRoot\nuget-verification.ps1 ${PackagesPath}\*.nupkg 17 | } 18 | catch { 19 | Write-Host $_.ScriptStackTrace 20 | Write-PipelineTelemetryError -Category 'NuGetValidation' -Message $_ 21 | ExitWithExitCode 1 22 | } 23 | -------------------------------------------------------------------------------- /eng/common/post-build/publish-using-darc.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [Parameter(Mandatory=$true)][int] $BuildId, 3 | [Parameter(Mandatory=$true)][int] $PublishingInfraVersion, 4 | [Parameter(Mandatory=$true)][string] $AzdoToken, 5 | [Parameter(Mandatory=$false)][string] $MaestroApiEndPoint = 'https://maestro.dot.net', 6 | [Parameter(Mandatory=$true)][string] $WaitPublishingFinish, 7 | [Parameter(Mandatory=$false)][string] $ArtifactsPublishingAdditionalParameters, 8 | [Parameter(Mandatory=$false)][string] $SymbolPublishingAdditionalParameters 9 | ) 10 | 11 | try { 12 | # `tools.ps1` checks $ci to perform some actions. Since the post-build 13 | # scripts don't necessarily execute in the same agent that run the 14 | # build.ps1/sh script this variable isn't automatically set. 15 | $ci = $true 16 | $disableConfigureToolsetImport = $true 17 | . $PSScriptRoot\..\tools.ps1 18 | 19 | $darc = Get-Darc 20 | 21 | $optionalParams = [System.Collections.ArrayList]::new() 22 | 23 | if ("" -ne $ArtifactsPublishingAdditionalParameters) { 24 | $optionalParams.Add("--artifact-publishing-parameters") | Out-Null 25 | $optionalParams.Add($ArtifactsPublishingAdditionalParameters) | Out-Null 26 | } 27 | 28 | if ("" -ne $SymbolPublishingAdditionalParameters) { 29 | $optionalParams.Add("--symbol-publishing-parameters") | Out-Null 30 | $optionalParams.Add($SymbolPublishingAdditionalParameters) | Out-Null 31 | } 32 | 33 | if ("false" -eq $WaitPublishingFinish) { 34 | $optionalParams.Add("--no-wait") | Out-Null 35 | } 36 | 37 | & $darc add-build-to-channel ` 38 | --id $buildId ` 39 | --publishing-infra-version $PublishingInfraVersion ` 40 | --default-channels ` 41 | --source-branch main ` 42 | --azdev-pat "$AzdoToken" ` 43 | --bar-uri "$MaestroApiEndPoint" ` 44 | --ci ` 45 | --verbose ` 46 | @optionalParams 47 | 48 | if ($LastExitCode -ne 0) { 49 | Write-Host "Problems using Darc to promote build ${buildId} to default channels. Stopping execution..." 50 | exit 1 51 | } 52 | 53 | Write-Host 'done.' 54 | } 55 | catch { 56 | Write-Host $_ 57 | Write-PipelineTelemetryError -Category 'PromoteBuild' -Message "There was an error while trying to publish build '$BuildId' to default channels." 58 | ExitWithExitCode 1 59 | } 60 | -------------------------------------------------------------------------------- /eng/common/retain-build.ps1: -------------------------------------------------------------------------------- 1 | 2 | Param( 3 | [Parameter(Mandatory=$true)][int] $buildId, 4 | [Parameter(Mandatory=$true)][string] $azdoOrgUri, 5 | [Parameter(Mandatory=$true)][string] $azdoProject, 6 | [Parameter(Mandatory=$true)][string] $token 7 | ) 8 | 9 | $ErrorActionPreference = 'Stop' 10 | Set-StrictMode -Version 2.0 11 | 12 | function Get-AzDOHeaders( 13 | [string] $token) 14 | { 15 | $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":${token}")) 16 | $headers = @{"Authorization"="Basic $base64AuthInfo"} 17 | return $headers 18 | } 19 | 20 | function Update-BuildRetention( 21 | [string] $azdoOrgUri, 22 | [string] $azdoProject, 23 | [int] $buildId, 24 | [string] $token) 25 | { 26 | $headers = Get-AzDOHeaders -token $token 27 | $requestBody = "{ 28 | `"keepForever`": `"true`" 29 | }" 30 | 31 | $requestUri = "${azdoOrgUri}/${azdoProject}/_apis/build/builds/${buildId}?api-version=6.0" 32 | write-Host "Attempting to retain build using the following URI: ${requestUri} ..." 33 | 34 | try { 35 | Invoke-RestMethod -Uri $requestUri -Method Patch -Body $requestBody -Header $headers -contentType "application/json" 36 | Write-Host "Updated retention settings for build ${buildId}." 37 | } 38 | catch { 39 | Write-Error "Failed to update retention settings for build: $_.Exception.Response.StatusDescription" 40 | exit 1 41 | } 42 | } 43 | 44 | Update-BuildRetention -azdoOrgUri $azdoOrgUri -azdoProject $azdoProject -buildId $buildId -token $token 45 | exit 0 46 | -------------------------------------------------------------------------------- /eng/common/sdl/NuGet.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /eng/common/sdl/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /eng/common/sdl/run-sdl.ps1: -------------------------------------------------------------------------------- 1 | Param( 2 | [string] $GuardianCliLocation, 3 | [string] $WorkingDirectory, 4 | [string] $GdnFolder, 5 | [string] $UpdateBaseline, 6 | [string] $GuardianLoggerLevel='Standard' 7 | ) 8 | 9 | $ErrorActionPreference = 'Stop' 10 | Set-StrictMode -Version 2.0 11 | $disableConfigureToolsetImport = $true 12 | $global:LASTEXITCODE = 0 13 | 14 | try { 15 | # `tools.ps1` checks $ci to perform some actions. Since the SDL 16 | # scripts don't necessarily execute in the same agent that run the 17 | # build.ps1/sh script this variable isn't automatically set. 18 | $ci = $true 19 | . $PSScriptRoot\..\tools.ps1 20 | 21 | # We store config files in the r directory of .gdn 22 | $gdnConfigPath = Join-Path $GdnFolder 'r' 23 | $ValidPath = Test-Path $GuardianCliLocation 24 | 25 | if ($ValidPath -eq $False) 26 | { 27 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Invalid Guardian CLI Location." 28 | ExitWithExitCode 1 29 | } 30 | 31 | $gdnConfigFiles = Get-ChildItem $gdnConfigPath -Recurse -Include '*.gdnconfig' 32 | Write-Host "Discovered Guardian config files:" 33 | $gdnConfigFiles | Out-String | Write-Host 34 | 35 | Exec-BlockVerbosely { 36 | & $GuardianCliLocation run ` 37 | --working-directory $WorkingDirectory ` 38 | --baseline mainbaseline ` 39 | --update-baseline $UpdateBaseline ` 40 | --logger-level $GuardianLoggerLevel ` 41 | --config @gdnConfigFiles 42 | Exit-IfNZEC "Sdl" 43 | } 44 | } 45 | catch { 46 | Write-Host $_.ScriptStackTrace 47 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ 48 | ExitWithExitCode 1 49 | } 50 | -------------------------------------------------------------------------------- /eng/common/sdl/sdl.ps1: -------------------------------------------------------------------------------- 1 | 2 | function Install-Gdn { 3 | param( 4 | [Parameter(Mandatory=$true)] 5 | [string]$Path, 6 | 7 | # If omitted, install the latest version of Guardian, otherwise install that specific version. 8 | [string]$Version 9 | ) 10 | 11 | $ErrorActionPreference = 'Stop' 12 | Set-StrictMode -Version 2.0 13 | $disableConfigureToolsetImport = $true 14 | $global:LASTEXITCODE = 0 15 | 16 | # `tools.ps1` checks $ci to perform some actions. Since the SDL 17 | # scripts don't necessarily execute in the same agent that run the 18 | # build.ps1/sh script this variable isn't automatically set. 19 | $ci = $true 20 | . $PSScriptRoot\..\tools.ps1 21 | 22 | $argumentList = @("install", "Microsoft.Guardian.Cli", "-Source https://securitytools.pkgs.visualstudio.com/_packaging/Guardian/nuget/v3/index.json", "-OutputDirectory $Path", "-NonInteractive", "-NoCache") 23 | 24 | if ($Version) { 25 | $argumentList += "-Version $Version" 26 | } 27 | 28 | Start-Process nuget -Verbose -ArgumentList $argumentList -NoNewWindow -Wait 29 | 30 | $gdnCliPath = Get-ChildItem -Filter guardian.cmd -Recurse -Path $Path 31 | 32 | if (!$gdnCliPath) 33 | { 34 | Write-PipelineTelemetryError -Category 'Sdl' -Message 'Failure installing Guardian' 35 | } 36 | 37 | return $gdnCliPath.FullName 38 | } -------------------------------------------------------------------------------- /eng/common/sdl/trim-assets-version.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Install and run the 'Microsoft.DotNet.VersionTools.Cli' tool with the 'trim-artifacts-version' command to trim the version from the NuGet assets file name. 4 | 5 | .PARAMETER InputPath 6 | Full path to directory where artifact packages are stored 7 | 8 | .PARAMETER Recursive 9 | Search for NuGet packages recursively 10 | 11 | #> 12 | 13 | Param( 14 | [string] $InputPath, 15 | [bool] $Recursive = $true 16 | ) 17 | 18 | $CliToolName = "Microsoft.DotNet.VersionTools.Cli" 19 | 20 | function Install-VersionTools-Cli { 21 | param( 22 | [Parameter(Mandatory=$true)][string]$Version 23 | ) 24 | 25 | Write-Host "Installing the package '$CliToolName' with a version of '$version' ..." 26 | $feed = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" 27 | 28 | $argumentList = @("tool", "install", "--local", "$CliToolName", "--add-source $feed", "--no-cache", "--version $Version", "--create-manifest-if-needed") 29 | Start-Process "$dotnet" -Verbose -ArgumentList $argumentList -NoNewWindow -Wait 30 | } 31 | 32 | # ------------------------------------------------------------------- 33 | 34 | if (!(Test-Path $InputPath)) { 35 | Write-Host "Input Path '$InputPath' does not exist" 36 | ExitWithExitCode 1 37 | } 38 | 39 | $ErrorActionPreference = 'Stop' 40 | Set-StrictMode -Version 2.0 41 | 42 | $disableConfigureToolsetImport = $true 43 | $global:LASTEXITCODE = 0 44 | 45 | # `tools.ps1` checks $ci to perform some actions. Since the SDL 46 | # scripts don't necessarily execute in the same agent that run the 47 | # build.ps1/sh script this variable isn't automatically set. 48 | $ci = $true 49 | . $PSScriptRoot\..\tools.ps1 50 | 51 | try { 52 | $dotnetRoot = InitializeDotNetCli -install:$true 53 | $dotnet = "$dotnetRoot\dotnet.exe" 54 | 55 | $toolsetVersion = Read-ArcadeSdkVersion 56 | Install-VersionTools-Cli -Version $toolsetVersion 57 | 58 | $cliToolFound = (& "$dotnet" tool list --local | Where-Object {$_.Split(' ')[0] -eq $CliToolName}) 59 | if ($null -eq $cliToolFound) { 60 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "The '$CliToolName' tool is not installed." 61 | ExitWithExitCode 1 62 | } 63 | 64 | Exec-BlockVerbosely { 65 | & "$dotnet" $CliToolName trim-assets-version ` 66 | --assets-path $InputPath ` 67 | --recursive $Recursive 68 | Exit-IfNZEC "Sdl" 69 | } 70 | } 71 | catch { 72 | Write-Host $_ 73 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ 74 | ExitWithExitCode 1 75 | } 76 | -------------------------------------------------------------------------------- /eng/common/templates-official/job/onelocbuild.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/onelocbuild.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/job/publish-build-assets.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/publish-build-assets.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/job/source-build.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/source-build.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/job/source-index-stage1.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/source-index-stage1.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/jobs/codeql-build.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/jobs/codeql-build.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/jobs/jobs.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/jobs/jobs.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/jobs/source-build.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/jobs/source-build.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates-official/post-build/common-variables.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | - template: /eng/common/core-templates/post-build/common-variables.yml 3 | parameters: 4 | # Specifies whether to use 1ES 5 | is1ESPipeline: true 6 | 7 | ${{ each parameter in parameters }}: 8 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates-official/post-build/post-build.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - template: /eng/common/core-templates/post-build/post-build.yml 3 | parameters: 4 | # Specifies whether to use 1ES 5 | is1ESPipeline: true 6 | 7 | ${{ each parameter in parameters }}: 8 | ${{ parameter.key }}: ${{ parameter.value }} 9 | -------------------------------------------------------------------------------- /eng/common/templates-official/post-build/setup-maestro-vars.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/post-build/setup-maestro-vars.yml 3 | parameters: 4 | # Specifies whether to use 1ES 5 | is1ESPipeline: true 6 | 7 | ${{ each parameter in parameters }}: 8 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates-official/steps/component-governance.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/component-governance.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/enable-internal-runtimes.yml: -------------------------------------------------------------------------------- 1 | # Obtains internal runtime download credentials and populates the 'dotnetbuilds-internal-container-read-token-base64' 2 | # variable with the base64-encoded SAS token, by default 3 | steps: 4 | - template: /eng/common/core-templates/steps/enable-internal-runtimes.yml 5 | parameters: 6 | is1ESPipeline: true 7 | 8 | ${{ each parameter in parameters }}: 9 | ${{ parameter.key }}: ${{ parameter.value }} 10 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/enable-internal-sources.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/enable-internal-sources.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates-official/steps/generate-sbom.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/generate-sbom.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/get-delegation-sas.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/get-delegation-sas.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/get-federated-access-token.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/get-federated-access-token.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates-official/steps/publish-build-artifacts.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: displayName 3 | type: string 4 | default: 'Publish to Build Artifact' 5 | 6 | - name: condition 7 | type: string 8 | default: succeeded() 9 | 10 | - name: artifactName 11 | type: string 12 | 13 | - name: pathToPublish 14 | type: string 15 | 16 | - name: continueOnError 17 | type: boolean 18 | default: false 19 | 20 | - name: publishLocation 21 | type: string 22 | default: 'Container' 23 | 24 | - name: is1ESPipeline 25 | type: boolean 26 | default: true 27 | 28 | steps: 29 | - ${{ if ne(parameters.is1ESPipeline, true) }}: 30 | - 'eng/common/templates-official cannot be referenced from a non-1ES managed template': error 31 | - task: 1ES.PublishBuildArtifacts@1 32 | displayName: ${{ parameters.displayName }} 33 | condition: ${{ parameters.condition }} 34 | ${{ if parameters.continueOnError }}: 35 | continueOnError: ${{ parameters.continueOnError }} 36 | inputs: 37 | PublishLocation: ${{ parameters.publishLocation }} 38 | PathtoPublish: ${{ parameters.pathToPublish }} 39 | ${{ if parameters.artifactName }}: 40 | ArtifactName: ${{ parameters.artifactName }} 41 | 42 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/publish-logs.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/publish-logs.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/publish-pipeline-artifacts.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: is1ESPipeline 3 | type: boolean 4 | default: true 5 | 6 | - name: args 7 | type: object 8 | default: {} 9 | 10 | steps: 11 | - ${{ if ne(parameters.is1ESPipeline, true) }}: 12 | - 'eng/common/templates-official cannot be referenced from a non-1ES managed template': error 13 | - task: 1ES.PublishPipelineArtifact@1 14 | displayName: ${{ coalesce(parameters.args.displayName, 'Publish to Build Artifact') }} 15 | ${{ if parameters.args.condition }}: 16 | condition: ${{ parameters.args.condition }} 17 | ${{ else }}: 18 | condition: succeeded() 19 | ${{ if parameters.args.continueOnError }}: 20 | continueOnError: ${{ parameters.args.continueOnError }} 21 | inputs: 22 | targetPath: ${{ parameters.args.targetPath }} 23 | ${{ if parameters.args.artifactName }}: 24 | artifactName: ${{ parameters.args.artifactName }} 25 | ${{ if parameters.args.properties }}: 26 | properties: ${{ parameters.args.properties }} 27 | ${{ if parameters.args.sbomEnabled }}: 28 | sbomEnabled: ${{ parameters.args.sbomEnabled }} 29 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/retain-build.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/retain-build.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/send-to-helix.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/send-to-helix.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/steps/source-build.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/source-build.yml 3 | parameters: 4 | is1ESPipeline: true 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates-official/variables/pool-providers.yml: -------------------------------------------------------------------------------- 1 | # Select a pool provider based off branch name. Anything with branch name containing 'release' must go into an -Svc pool, 2 | # otherwise it should go into the "normal" pools. This separates out the queueing and billing of released branches. 3 | 4 | # Motivation: 5 | # Once a given branch of a repository's output has been officially "shipped" once, it is then considered to be COGS 6 | # (Cost of goods sold) and should be moved to a servicing pool provider. This allows both separation of queueing 7 | # (allowing release builds and main PR builds to not intefere with each other) and billing (required for COGS. 8 | # Additionally, the pool provider name itself may be subject to change when the .NET Core Engineering Services 9 | # team needs to move resources around and create new and potentially differently-named pools. Using this template 10 | # file from an Arcade-ified repo helps guard against both having to update one's release/* branches and renaming. 11 | 12 | # How to use: 13 | # This yaml assumes your shipped product branches use the naming convention "release/..." (which many do). 14 | # If we find alternate naming conventions in broad usage it can be added to the condition below. 15 | # 16 | # First, import the template in an arcade-ified repo to pick up the variables, e.g.: 17 | # 18 | # variables: 19 | # - template: /eng/common/templates-official/variables/pool-providers.yml 20 | # 21 | # ... then anywhere specifying the pool provider use the runtime variables, 22 | # $(DncEngInternalBuildPool) 23 | # 24 | # pool: 25 | # name: $(DncEngInternalBuildPool) 26 | # image: 1es-windows-2022 27 | 28 | variables: 29 | # Coalesce the target and source branches so we know when a PR targets a release branch 30 | # If these variables are somehow missing, fall back to main (tends to have more capacity) 31 | 32 | # Any new -Svc alternative pools should have variables added here to allow for splitting work 33 | 34 | - name: DncEngInternalBuildPool 35 | value: $[ 36 | replace( 37 | replace( 38 | eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'), 39 | True, 40 | 'NetCore1ESPool-Svc-Internal' 41 | ), 42 | False, 43 | 'NetCore1ESPool-Internal' 44 | ) 45 | ] -------------------------------------------------------------------------------- /eng/common/templates-official/variables/sdl-variables.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in 3 | # sync with the packages.config file. 4 | - name: DefaultGuardianVersion 5 | value: 0.109.0 6 | - name: GuardianPackagesConfigFile 7 | value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config -------------------------------------------------------------------------------- /eng/common/templates/job/onelocbuild.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/onelocbuild.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/job/publish-build-assets.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/publish-build-assets.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/job/source-build.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/source-build.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/job/source-index-stage1.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/job/source-index-stage1.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/jobs/codeql-build.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/jobs/codeql-build.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/jobs/jobs.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/jobs/jobs.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/jobs/source-build.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - template: /eng/common/core-templates/jobs/source-build.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates/post-build/common-variables.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | - template: /eng/common/core-templates/post-build/common-variables.yml 3 | parameters: 4 | # Specifies whether to use 1ES 5 | is1ESPipeline: false 6 | 7 | ${{ each parameter in parameters }}: 8 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates/post-build/post-build.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - template: /eng/common/core-templates/post-build/post-build.yml 3 | parameters: 4 | # Specifies whether to use 1ES 5 | is1ESPipeline: false 6 | 7 | ${{ each parameter in parameters }}: 8 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates/post-build/setup-maestro-vars.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/post-build/setup-maestro-vars.yml 3 | parameters: 4 | # Specifies whether to use 1ES 5 | is1ESPipeline: false 6 | 7 | ${{ each parameter in parameters }}: 8 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates/steps/component-governance.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/component-governance.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/enable-internal-runtimes.yml: -------------------------------------------------------------------------------- 1 | # Obtains internal runtime download credentials and populates the 'dotnetbuilds-internal-container-read-token-base64' 2 | # variable with the base64-encoded SAS token, by default 3 | 4 | steps: 5 | - template: /eng/common/core-templates/steps/enable-internal-runtimes.yml 6 | parameters: 7 | is1ESPipeline: false 8 | 9 | ${{ each parameter in parameters }}: 10 | ${{ parameter.key }}: ${{ parameter.value }} 11 | -------------------------------------------------------------------------------- /eng/common/templates/steps/enable-internal-sources.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/enable-internal-sources.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates/steps/generate-sbom.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/generate-sbom.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/get-delegation-sas.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/get-delegation-sas.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/get-federated-access-token.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/get-federated-access-token.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} -------------------------------------------------------------------------------- /eng/common/templates/steps/publish-build-artifacts.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: is1ESPipeline 3 | type: boolean 4 | default: false 5 | 6 | - name: displayName 7 | type: string 8 | default: 'Publish to Build Artifact' 9 | 10 | - name: condition 11 | type: string 12 | default: succeeded() 13 | 14 | - name: artifactName 15 | type: string 16 | 17 | - name: pathToPublish 18 | type: string 19 | 20 | - name: continueOnError 21 | type: boolean 22 | default: false 23 | 24 | - name: publishLocation 25 | type: string 26 | default: 'Container' 27 | 28 | steps: 29 | - ${{ if eq(parameters.is1ESPipeline, true) }}: 30 | - 'eng/common/templates cannot be referenced from a 1ES managed template': error 31 | - task: PublishBuildArtifacts@1 32 | displayName: ${{ parameters.displayName }} 33 | condition: ${{ parameters.condition }} 34 | ${{ if parameters.continueOnError }}: 35 | continueOnError: ${{ parameters.continueOnError }} 36 | inputs: 37 | PublishLocation: ${{ parameters.publishLocation }} 38 | PathtoPublish: ${{ parameters.pathToPublish }} 39 | ${{ if parameters.artifactName }}: 40 | ArtifactName: ${{ parameters.artifactName }} -------------------------------------------------------------------------------- /eng/common/templates/steps/publish-logs.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/publish-logs.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/publish-pipeline-artifacts.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: is1ESPipeline 3 | type: boolean 4 | default: false 5 | 6 | - name: args 7 | type: object 8 | default: {} 9 | 10 | steps: 11 | - ${{ if eq(parameters.is1ESPipeline, true) }}: 12 | - 'eng/common/templates cannot be referenced from a 1ES managed template': error 13 | - task: PublishPipelineArtifact@1 14 | displayName: ${{ coalesce(parameters.args.displayName, 'Publish to Build Artifact') }} 15 | ${{ if parameters.args.condition }}: 16 | condition: ${{ parameters.args.condition }} 17 | ${{ else }}: 18 | condition: succeeded() 19 | ${{ if parameters.args.continueOnError }}: 20 | continueOnError: ${{ parameters.args.continueOnError }} 21 | inputs: 22 | targetPath: ${{ parameters.args.targetPath }} 23 | ${{ if parameters.args.artifactName }}: 24 | artifactName: ${{ parameters.args.artifactName }} 25 | ${{ if parameters.args.publishLocation }}: 26 | publishLocation: ${{ parameters.args.publishLocation }} 27 | ${{ if parameters.args.fileSharePath }}: 28 | fileSharePath: ${{ parameters.args.fileSharePath }} 29 | ${{ if parameters.args.Parallel }}: 30 | parallel: ${{ parameters.args.Parallel }} 31 | ${{ if parameters.args.parallelCount }}: 32 | parallelCount: ${{ parameters.args.parallelCount }} 33 | ${{ if parameters.args.properties }}: 34 | properties: ${{ parameters.args.properties }} -------------------------------------------------------------------------------- /eng/common/templates/steps/retain-build.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/retain-build.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/send-to-helix.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/send-to-helix.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/common/templates/steps/source-build.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - template: /eng/common/core-templates/steps/source-build.yml 3 | parameters: 4 | is1ESPipeline: false 5 | 6 | ${{ each parameter in parameters }}: 7 | ${{ parameter.key }}: ${{ parameter.value }} 8 | -------------------------------------------------------------------------------- /eng/config/PublishData.json: -------------------------------------------------------------------------------- 1 | { 2 | "feeds": { 3 | "vssdk": "https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk/nuget/v3/index.json" 4 | }, 5 | "packages": { 6 | "default": { 7 | "Microsoft.VisualStudio.InteractiveWindow": "vssdk", 8 | "Microsoft.VisualStudio.VsInteractiveWindow": "vssdk" 9 | } 10 | }, 11 | "branches": { 12 | "main": { 13 | "nugetKind": "Shipping", 14 | "version": "4.0.*", 15 | "packageFeeds": "default", 16 | "vsBranch": "feature/d17initial" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "tools": { 3 | "dotnet": "9.0.104", 4 | "vs": { 5 | "version": "17.8.0" 6 | } 7 | }, 8 | "sdk": { 9 | "version": "9.0.104", 10 | "rollForward": "latestFeature" 11 | }, 12 | "msbuild-sdks": { 13 | "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25164.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Latest 7 | IW 8 | MIT 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Directory.Build.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/InteractiveWindowEditorsFactoryService.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.Text; 7 | using Microsoft.VisualStudio.Text.Editor; 8 | using Microsoft.VisualStudio.Utilities; 9 | using Roslyn.Test.Utilities; 10 | 11 | namespace Microsoft.VisualStudio.InteractiveWindow.UnitTests 12 | { 13 | [Export(typeof(IInteractiveWindowEditorFactoryService))] 14 | internal class InteractiveWindowEditorsFactoryService : IInteractiveWindowEditorFactoryService 15 | { 16 | public const string ContentType = "text"; 17 | 18 | private readonly ITextBufferFactoryService _textBufferFactoryService; 19 | private readonly ITextEditorFactoryService _textEditorFactoryService; 20 | private readonly IContentTypeRegistryService _contentTypeRegistry; 21 | 22 | [ImportingConstructor] 23 | public InteractiveWindowEditorsFactoryService(ITextBufferFactoryService textBufferFactoryService, ITextEditorFactoryService textEditorFactoryService, IContentTypeRegistryService contentTypeRegistry) 24 | { 25 | _textBufferFactoryService = textBufferFactoryService; 26 | _textEditorFactoryService = textEditorFactoryService; 27 | _contentTypeRegistry = contentTypeRegistry; 28 | } 29 | 30 | IWpfTextView IInteractiveWindowEditorFactoryService.CreateTextView(IInteractiveWindow window, ITextBuffer buffer, ITextViewRoleSet roles) 31 | { 32 | WpfTestCase.RequireWpfFact($"Creates an IWpfTextView in {nameof(InteractiveWindowEditorsFactoryService)}"); 33 | 34 | var textView = _textEditorFactoryService.CreateTextView(buffer, roles); 35 | return _textEditorFactoryService.CreateTextViewHost(textView, false).TextView; 36 | } 37 | 38 | ITextBuffer IInteractiveWindowEditorFactoryService.CreateAndActivateBuffer(IInteractiveWindow window) 39 | { 40 | IContentType contentType; 41 | if (!window.Properties.TryGetProperty(typeof(IContentType), out contentType)) 42 | { 43 | contentType = _contentTypeRegistry.GetContentType(ContentType); 44 | } 45 | 46 | return _textBufferFactoryService.CreateTextBuffer(contentType); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/JoinableTaskContextMefHost.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.Threading; 7 | 8 | namespace Microsoft.VisualStudio.InteractiveWindow.UnitTests 9 | { 10 | internal class JoinableTaskContextMefHost 11 | { 12 | /// 13 | /// Gets the singleton instance of joinable task context for directly working with async tasks on managed code 14 | /// 15 | [Export] 16 | internal readonly JoinableTaskContext JoinableTaskContext = new JoinableTaskContext(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/Microsoft.VisualStudio.InteractiveWindow.UnitTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net472 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestClipboard.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Windows; 7 | 8 | namespace Microsoft.VisualStudio.InteractiveWindow.UnitTests 9 | { 10 | internal sealed class TestClipboard : InteractiveWindowClipboard 11 | { 12 | private DataObject _data = null; 13 | 14 | internal void Clear() => _data = null; 15 | 16 | internal override bool ContainsData(string format) => _data?.GetData(format) != null; 17 | 18 | internal override object GetData(string format) => _data?.GetData(format); 19 | 20 | internal override bool ContainsText() => _data != null ? _data.ContainsText() : false; 21 | 22 | internal override string GetText() => _data?.GetText(); 23 | 24 | internal override void SetDataObject(object data, bool copy) => _data = (DataObject)data; 25 | 26 | internal override IDataObject GetDataObject() => _data; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestContentTypeDefinition.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.Utilities; 7 | 8 | namespace Microsoft.VisualStudio.InteractiveWindow.UnitTests 9 | { 10 | public sealed class TestContentTypeDefinition 11 | { 12 | public const string ContentTypeName = "InteractiveWindowTest"; 13 | 14 | [Export] 15 | [Name(ContentTypeName)] 16 | [BaseDefinition("code")] 17 | public static readonly ContentTypeDefinition Definition; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestInteractiveEngine.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Threading.Tasks; 7 | using Microsoft.VisualStudio.Utilities; 8 | 9 | namespace Microsoft.VisualStudio.InteractiveWindow.UnitTests 10 | { 11 | public sealed class TestInteractiveEngine : IInteractiveEvaluator 12 | { 13 | internal event EventHandler OnExecute; 14 | 15 | public TestInteractiveEngine() 16 | { 17 | } 18 | 19 | public IInteractiveWindow CurrentWindow { get; set; } 20 | 21 | public void Dispose() 22 | { 23 | } 24 | 25 | public Task InitializeAsync() 26 | { 27 | return Task.FromResult(ExecutionResult.Success); 28 | } 29 | 30 | public Task ResetAsync(bool initialize = true) 31 | { 32 | return Task.FromResult(ExecutionResult.Success); 33 | } 34 | 35 | public bool CanExecuteCode(string text) 36 | { 37 | return true; 38 | } 39 | 40 | public Task ExecuteCodeAsync(string text) 41 | { 42 | OnExecute?.Invoke(this, text); 43 | return Task.FromResult(ExecutionResult.Success); 44 | } 45 | 46 | public string FormatClipboard() 47 | { 48 | return null; 49 | } 50 | 51 | public void AbortExecution() 52 | { 53 | } 54 | 55 | public string GetConfiguration() 56 | { 57 | return "config"; 58 | } 59 | 60 | public string GetPrompt() 61 | { 62 | return "> "; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestSmartIndent.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.ComponentModel.Composition; 7 | using Microsoft.VisualStudio.Text; 8 | using Microsoft.VisualStudio.Text.Editor; 9 | using Microsoft.VisualStudio.Utilities; 10 | 11 | namespace Microsoft.VisualStudio.InteractiveWindow.UnitTests 12 | { 13 | internal class TestSmartIndent : ISmartIndent 14 | { 15 | private readonly int[] _lineToIndentMap; 16 | 17 | public TestSmartIndent(params int[] lineToIndentMap) 18 | { 19 | _lineToIndentMap = lineToIndentMap; 20 | } 21 | 22 | int? ISmartIndent.GetDesiredIndentation(ITextSnapshotLine line) 23 | { 24 | return _lineToIndentMap[line.LineNumber]; 25 | } 26 | 27 | void IDisposable.Dispose() 28 | { 29 | } 30 | } 31 | 32 | internal class DummySmartIndent : ISmartIndent 33 | { 34 | public static readonly ISmartIndent Instance = new DummySmartIndent(); 35 | 36 | private DummySmartIndent() 37 | { 38 | } 39 | 40 | int? ISmartIndent.GetDesiredIndentation(ITextSnapshotLine line) 41 | { 42 | return null; 43 | } 44 | 45 | void IDisposable.Dispose() 46 | { 47 | } 48 | } 49 | 50 | [Export(typeof(TestSmartIndentProvider))] 51 | [Export(typeof(ISmartIndentProvider))] 52 | [ContentType(InteractiveWindowEditorsFactoryService.ContentType)] 53 | internal class TestSmartIndentProvider : ISmartIndentProvider 54 | { 55 | public ISmartIndent SmartIndent; 56 | 57 | ISmartIndent ISmartIndentProvider.CreateSmartIndent(ITextView textView) => SmartIndent ?? DummySmartIndent.Instance; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Assert/ConditionalFactAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Globalization; 7 | using System.Text; 8 | using Xunit; 9 | 10 | namespace Roslyn.Test.Utilities 11 | { 12 | public class ConditionalFactAttribute : FactAttribute 13 | { 14 | public ConditionalFactAttribute(params Type[] skipConditions) 15 | { 16 | foreach (var skipCondition in skipConditions) 17 | { 18 | ExecutionCondition condition = (ExecutionCondition)Activator.CreateInstance(skipCondition); 19 | if (condition.ShouldSkip) 20 | { 21 | Skip = condition.SkipReason; 22 | break; 23 | } 24 | } 25 | } 26 | } 27 | 28 | public abstract class ExecutionCondition 29 | { 30 | public abstract bool ShouldSkip { get; } 31 | public abstract string SkipReason { get; } 32 | } 33 | 34 | public class x86 : ExecutionCondition 35 | { 36 | public override bool ShouldSkip => IntPtr.Size != 4; 37 | 38 | public override string SkipReason => "Target platform is not x86"; 39 | } 40 | 41 | public class HasShiftJisDefaultEncoding : ExecutionCondition 42 | { 43 | public override bool ShouldSkip => Encoding.GetEncoding(0)?.CodePage != 932; 44 | 45 | public override string SkipReason => "OS default codepage is not Shift-JIS (932)."; 46 | } 47 | 48 | public class IsEnglishLocal : ExecutionCondition 49 | { 50 | public override bool ShouldSkip => 51 | !CultureInfo.CurrentUICulture.Name.StartsWith("en", StringComparison.OrdinalIgnoreCase) || 52 | !CultureInfo.CurrentCulture.Name.StartsWith("en", StringComparison.OrdinalIgnoreCase); 53 | 54 | public override string SkipReason => "Current culture is not en"; 55 | } 56 | 57 | public class IsRelease : ExecutionCondition 58 | { 59 | #if DEBUG 60 | public override bool ShouldSkip => true; 61 | #else 62 | public override bool ShouldSkip => false; 63 | #endif 64 | 65 | public override string SkipReason => "Not in release mode."; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Assert/EqualityTesting.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using Xunit; 7 | 8 | namespace Microsoft.CodeAnalysis.Test.Utilities 9 | { 10 | /// 11 | /// Helpers for testing equality APIs. 12 | /// Gives us more control than calling Assert.Equals. 13 | /// 14 | public static class EqualityTesting 15 | { 16 | public static void AssertEqual(IEquatable x, IEquatable y) 17 | { 18 | Assert.True(x.Equals(y)); 19 | Assert.True(((object)x).Equals(y)); 20 | Assert.Equal(x.GetHashCode(), y.GetHashCode()); 21 | } 22 | 23 | public static void AssertNotEqual(IEquatable x, IEquatable y) 24 | { 25 | Assert.False(x.Equals(y)); 26 | Assert.False(((object)x).Equals(y)); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Assert/EqualityUnit.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | namespace Roslyn.Test.Utilities 6 | { 7 | public static class EqualityUnit 8 | { 9 | public static EqualityUnit Create(T value) 10 | { 11 | return new EqualityUnit(value); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Assert/EqualityUnit`1.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Collections.Generic; 6 | using System.Collections.ObjectModel; 7 | using System.Linq; 8 | 9 | namespace Roslyn.Test.Utilities 10 | { 11 | public sealed class EqualityUnit 12 | { 13 | private static readonly ReadOnlyCollection s_emptyCollection = new ReadOnlyCollection(new T[] { }); 14 | 15 | public readonly T Value; 16 | public readonly ReadOnlyCollection EqualValues; 17 | public readonly ReadOnlyCollection NotEqualValues; 18 | public IEnumerable AllValues 19 | { 20 | get { return Enumerable.Repeat(Value, 1).Concat(EqualValues).Concat(NotEqualValues); } 21 | } 22 | 23 | public EqualityUnit(T value) 24 | { 25 | Value = value; 26 | EqualValues = s_emptyCollection; 27 | NotEqualValues = s_emptyCollection; 28 | } 29 | 30 | public EqualityUnit( 31 | T value, 32 | ReadOnlyCollection equalValues, 33 | ReadOnlyCollection notEqualValues) 34 | { 35 | Value = value; 36 | EqualValues = equalValues; 37 | NotEqualValues = notEqualValues; 38 | } 39 | 40 | public EqualityUnit WithEqualValues(params T[] equalValues) 41 | { 42 | return new EqualityUnit( 43 | Value, 44 | EqualValues.Concat(equalValues).ToList().AsReadOnly(), 45 | NotEqualValues); 46 | } 47 | 48 | public EqualityUnit WithNotEqualValues(params T[] notEqualValues) 49 | { 50 | return new EqualityUnit( 51 | Value, 52 | EqualValues, 53 | NotEqualValues.Concat(notEqualValues).ToList().AsReadOnly()); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Assert/EqualityUtil.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | 7 | namespace Roslyn.Test.Utilities 8 | { 9 | public static class EqualityUtil 10 | { 11 | public static void RunAll( 12 | Func compEqualsOperator, 13 | Func compNotEqualsOperator, 14 | params EqualityUnit[] values) 15 | { 16 | var util = new EqualityUtil(values, compEqualsOperator, compNotEqualsOperator); 17 | util.RunAll(); 18 | } 19 | 20 | public static void RunAll(EqualityUnit unit, bool checkIEquatable = true) 21 | { 22 | RunAll(checkIEquatable, new[] { unit }); 23 | } 24 | 25 | public static void RunAll(params EqualityUnit[] values) 26 | { 27 | RunAll(checkIEquatable: true, values: values); 28 | } 29 | 30 | public static void RunAll(bool checkIEquatable, params EqualityUnit[] values) 31 | { 32 | var util = new EqualityUtil(values); 33 | util.RunAll(checkIEquatable); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Assert/TestExceptionUtilities.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace Microsoft.CodeAnalysis.Test.Utilities 12 | { 13 | public static class TestExceptionUtilities 14 | { 15 | public static InvalidOperationException UnexpectedValue(object o) 16 | { 17 | string output = String.Format("Unexpected value '{0}' of type '{1}'", o, (o != null) ? o.GetType().FullName : ""); 18 | System.Diagnostics.Debug.Fail(output); 19 | return new InvalidOperationException(output); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Assert/WorkItemAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | 7 | namespace Roslyn.Test.Utilities 8 | { 9 | /// 10 | /// Used to tag test methods or types which are created for a given WorkItem 11 | /// 12 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] 13 | public sealed class WorkItemAttribute : Attribute 14 | { 15 | private readonly int _id; 16 | private readonly string _description; 17 | 18 | public int Id 19 | { 20 | get { return _id; } 21 | } 22 | 23 | public string Description 24 | { 25 | get { return _description; } 26 | } 27 | 28 | public WorkItemAttribute(int id, string description) 29 | { 30 | _id = id; 31 | _description = description; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Async/Checkpoint.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace Roslyn.Test.Utilities 12 | { 13 | public class Checkpoint 14 | { 15 | private readonly TaskCompletionSource _tcs = new TaskCompletionSource(); 16 | 17 | public Task Task => _tcs.Task; 18 | 19 | public void Release() => _tcs.SetResult(null); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Async/WaitHelper.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Diagnostics; 8 | using System.Linq; 9 | using System.Threading; 10 | using System.Threading.Tasks; 11 | using System.Windows; 12 | using System.Windows.Threading; 13 | 14 | namespace Roslyn.Test.Utilities 15 | { 16 | public static class WaitHelper 17 | { 18 | public static void WaitForDispatchedOperationsToComplete(DispatcherPriority priority) 19 | { 20 | Action action = delegate { }; 21 | new FrameworkElement().Dispatcher.Invoke(action, priority); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Threading/ConditionalWpfFactAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | 7 | namespace Roslyn.Test.Utilities 8 | { 9 | public class ConditionalWpfFactAttribute : WpfFactAttribute 10 | { 11 | public ConditionalWpfFactAttribute(Type skipCondition) 12 | { 13 | var condition = Activator.CreateInstance(skipCondition) as ExecutionCondition; 14 | 15 | if (condition.ShouldSkip) 16 | { 17 | Skip = condition.SkipReason; 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Threading/ForegroundThreadDataKind.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Threading; 6 | using static Microsoft.CodeAnalysis.Utilities.ForegroundThreadDataKind; 7 | 8 | namespace Microsoft.CodeAnalysis.Utilities 9 | { 10 | internal enum ForegroundThreadDataKind 11 | { 12 | Wpf, 13 | WinForms, 14 | StaUnitTest, 15 | JoinableTask, 16 | ForcedByPackageInitialize, 17 | Unknown 18 | } 19 | 20 | internal static class ForegroundThreadDataInfo 21 | { 22 | private static readonly ForegroundThreadDataKind s_fallbackForegroundThreadDataKind; 23 | private static ForegroundThreadDataKind? s_currentForegroundThreadDataKind; 24 | 25 | static ForegroundThreadDataInfo() 26 | { 27 | s_fallbackForegroundThreadDataKind = CreateDefault(Unknown); 28 | } 29 | 30 | internal static ForegroundThreadDataKind CreateDefault(ForegroundThreadDataKind defaultKind) 31 | { 32 | var syncConextTypeName = SynchronizationContext.Current?.GetType().FullName; 33 | 34 | switch (syncConextTypeName) 35 | { 36 | case "System.Windows.Threading.DispatcherSynchronizationContext": 37 | 38 | return Wpf; 39 | 40 | case "Microsoft.VisualStudio.Threading.JoinableTask+JoinableTaskSynchronizationContext": 41 | 42 | return JoinableTask; 43 | 44 | case "System.Windows.Forms.WindowsFormsSynchronizationContext": 45 | 46 | return WinForms; 47 | 48 | default: 49 | 50 | return defaultKind; 51 | } 52 | } 53 | 54 | internal static ForegroundThreadDataKind CurrentForegroundThreadDataKind 55 | { 56 | get { return s_currentForegroundThreadDataKind ?? s_fallbackForegroundThreadDataKind; } 57 | } 58 | 59 | internal static void SetCurrentForegroundThreadDataKind(ForegroundThreadDataKind? kind) 60 | { 61 | s_currentForegroundThreadDataKind = kind; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Threading/NativeMethods.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Runtime.InteropServices; 6 | 7 | namespace Microsoft.CodeAnalysis.Editor.Shared.Utilities 8 | { 9 | internal static class NativeMethods 10 | { 11 | internal const uint MWMO_INPUTAVAILABLE = 0x0004; 12 | 13 | internal const uint 14 | QS_KEY = 0x0001, 15 | QS_MOUSEMOVE = 0x0002, 16 | QS_MOUSEBUTTON = 0x0004, 17 | QS_POSTMESSAGE = 0x0008, 18 | QS_TIMER = 0x0010, 19 | QS_PAINT = 0x0020, 20 | QS_SENDMESSAGE = 0x0040, 21 | QS_HOTKEY = 0x0080, 22 | QS_ALLPOSTMESSAGE = 0x0100, 23 | QS_MOUSE = QS_MOUSEMOVE | QS_MOUSEBUTTON, 24 | QS_INPUT = QS_MOUSE | QS_KEY, 25 | QS_ALLEVENTS = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY, 26 | QS_ALLINPUT = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY | QS_SENDMESSAGE, 27 | QS_EVENT = 0x2000; 28 | 29 | [DllImport("user32.dll")] 30 | internal static extern uint GetQueueStatus(uint flags); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Threading/SemaphoreSlimExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace Roslyn.Utilities 10 | { 11 | internal static class SemaphoreSlimExtensions 12 | { 13 | public static SemaphoreDisposer DisposableWait(this SemaphoreSlim semaphore, CancellationToken cancellationToken = default(CancellationToken)) 14 | { 15 | semaphore.Wait(cancellationToken); 16 | return new SemaphoreDisposer(semaphore); 17 | } 18 | 19 | public async static Task DisposableWaitAsync(this SemaphoreSlim semaphore, CancellationToken cancellationToken = default(CancellationToken)) 20 | { 21 | await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false); 22 | return new SemaphoreDisposer(semaphore); 23 | } 24 | 25 | internal struct SemaphoreDisposer : IDisposable 26 | { 27 | private readonly SemaphoreSlim _semaphore; 28 | 29 | public SemaphoreDisposer(SemaphoreSlim semaphore) 30 | { 31 | _semaphore = semaphore; 32 | } 33 | 34 | public void Dispose() 35 | { 36 | _semaphore.Release(); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Threading/SynchronizationContextTaskScheduler.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace Microsoft.CodeAnalysis.Editor.Shared.Utilities 11 | { 12 | // Based on CoreCLR's implementation of the TaskScheduler they return from TaskScheduler.FromCurrentSynchronizationContext 13 | internal class SynchronizationContextTaskScheduler : TaskScheduler 14 | { 15 | private readonly SendOrPostCallback _postCallback; 16 | private readonly SynchronizationContext _synchronizationContext; 17 | 18 | internal SynchronizationContextTaskScheduler(SynchronizationContext synchronizationContext) 19 | { 20 | if (synchronizationContext == null) 21 | throw new ArgumentNullException(nameof(synchronizationContext)); 22 | 23 | _postCallback = new SendOrPostCallback(PostCallback); 24 | _synchronizationContext = synchronizationContext; 25 | } 26 | 27 | public override Int32 MaximumConcurrencyLevel 28 | { 29 | get { return 1; } 30 | } 31 | 32 | protected override void QueueTask(Task task) 33 | { 34 | _synchronizationContext.Post(_postCallback, task); 35 | } 36 | protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued) 37 | { 38 | if (SynchronizationContext.Current == _synchronizationContext) 39 | { 40 | return TryExecuteTask(task); 41 | } 42 | 43 | return false; 44 | } 45 | 46 | protected override IEnumerable GetScheduledTasks() 47 | { 48 | return null; 49 | } 50 | 51 | private void PostCallback(object obj) 52 | { 53 | TryExecuteTask((Task)obj); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Threading/WpfFactAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | 7 | using Xunit; 8 | using Xunit.Sdk; 9 | 10 | namespace Roslyn.Test.Utilities 11 | { 12 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] 13 | [XunitTestCaseDiscoverer("Roslyn.Test.Utilities.WpfFactDiscoverer", "Microsoft.VisualStudio.InteractiveWindow.UnitTests")] 14 | public class WpfFactAttribute : FactAttribute { } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/TestUtilities/Threading/WpfFactDiscoverer.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Threading; 6 | using Xunit.Abstractions; 7 | using Xunit.Sdk; 8 | 9 | namespace Roslyn.Test.Utilities 10 | { 11 | public class WpfFactDiscoverer : FactDiscoverer 12 | { 13 | private readonly IMessageSink _diagnosticMessageSink; 14 | 15 | public WpfFactDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink) 16 | { 17 | _diagnosticMessageSink = diagnosticMessageSink; 18 | } 19 | 20 | protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) 21 | => new WpfTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow.Tests/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/BufferBlock.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.IO; 7 | using System.Runtime.Serialization; 8 | using System.Runtime.Serialization.Json; 9 | using System.Text; 10 | 11 | namespace Microsoft.VisualStudio.InteractiveWindow 12 | { 13 | /// 14 | /// REPL session buffer: input, output, or prompt. 15 | /// 16 | [DataContract] 17 | internal struct BufferBlock 18 | { 19 | [DataMember(Name = "kind")] 20 | internal readonly ReplSpanKind Kind; 21 | 22 | [DataMember(Name = "content")] 23 | internal readonly string Content; 24 | 25 | internal BufferBlock(ReplSpanKind kind, string content) 26 | { 27 | Kind = kind; 28 | Content = content; 29 | } 30 | 31 | internal static string Serialize(BufferBlock[] blocks) 32 | { 33 | var serializer = new DataContractJsonSerializer(typeof(BufferBlock[])); 34 | using (var stream = new MemoryStream()) 35 | { 36 | serializer.WriteObject(stream, blocks); 37 | return Encoding.UTF8.GetString(stream.GetBuffer(), 0, (int)stream.Length); 38 | } 39 | } 40 | 41 | /// 42 | internal static BufferBlock[] Deserialize(string str) 43 | { 44 | var serializer = new DataContractJsonSerializer(typeof(BufferBlock[])); 45 | try 46 | { 47 | var bytes = Encoding.UTF8.GetBytes(str); 48 | using (var stream = new MemoryStream(bytes)) 49 | { 50 | var obj = serializer.ReadObject(stream); 51 | return (BufferBlock[])obj; 52 | } 53 | } 54 | catch (Exception e) 55 | { 56 | throw new InvalidDataException(e.Message, e); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/Commands/CancelExecutionCommand.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | #if TODO 6 | using System.ComponentModel.Composition; 7 | using System.Reflection; 8 | using System.Threading.Tasks; 9 | using System.Windows.Controls; 10 | using System.Windows.Media.Imaging; 11 | 12 | namespace Microsoft.VisualStudio.InteractiveWindow { 13 | [Export(typeof(IInteractiveWindowCommand))] 14 | internal sealed class CancelExecutionCommand : InteractiveWindowCommand { 15 | public override Task Execute(IInteractiveWindow window, string arguments) { 16 | window.AbortCommand(); 17 | return ExecutionResult.Succeeded; 18 | } 19 | 20 | public override string Description { 21 | get { return "Stops execution of the current command."; } 22 | } 23 | 24 | public override object ButtonContent { 25 | get { 26 | var image = new BitmapImage(); 27 | image.BeginInit(); 28 | image.StreamSource = Assembly.GetExecutingAssembly().GetManifestResourceStream("Microsoft.VisualStudio.Resources.CancelEvaluation.gif"); 29 | image.EndInit(); 30 | var res = new Image(); 31 | res.Source = image; 32 | res.Width = res.Height = 16; 33 | return res; 34 | } 35 | } 36 | } 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/Commands/ClearScreenCommand.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.ComponentModel.Composition; 6 | using System.Collections.Generic; 7 | using System.Threading.Tasks; 8 | 9 | namespace Microsoft.VisualStudio.InteractiveWindow.Commands 10 | { 11 | [Export(typeof(IInteractiveWindowCommand))] 12 | internal sealed class ClearScreenCommand : InteractiveWindowCommand 13 | { 14 | public override Task Execute(IInteractiveWindow window, string arguments) 15 | { 16 | window.Operations.ClearView(); 17 | return ExecutionResult.Succeeded; 18 | } 19 | 20 | public override string Description 21 | { 22 | get { return InteractiveWindowResources.ClearScreenCommandDescription; } 23 | } 24 | 25 | public override IEnumerable Names 26 | { 27 | get { yield return "cls"; yield return "clear"; } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/Commands/CommandClassifier.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using Microsoft.VisualStudio.Language.StandardClassification; 9 | using Microsoft.VisualStudio.Text; 10 | using Microsoft.VisualStudio.Text.Classification; 11 | 12 | namespace Microsoft.VisualStudio.InteractiveWindow.Commands 13 | { 14 | internal sealed class CommandClassifier : IClassifier 15 | { 16 | private readonly IStandardClassificationService _registry; 17 | private readonly IInteractiveWindowCommands _commands; 18 | 19 | public CommandClassifier(IStandardClassificationService registry, IInteractiveWindowCommands commands) 20 | { 21 | _registry = registry; 22 | _commands = commands; 23 | } 24 | 25 | public IList GetClassificationSpans(SnapshotSpan span) 26 | { 27 | return _commands.Classify(span).ToArray(); 28 | } 29 | 30 | #pragma warning disable 67 // unused event 31 | // This event gets raised if a non-text change would affect the classification in some way, 32 | // for example typing /* would cause the classification to change in C# without directly 33 | // affecting the span. 34 | public event EventHandler ClassificationChanged; 35 | #pragma warning restore 67 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/Commands/CommandClassifierProvider.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.Language.StandardClassification; 7 | using Microsoft.VisualStudio.Text; 8 | using Microsoft.VisualStudio.Text.Classification; 9 | using Microsoft.VisualStudio.Text.Editor; 10 | using Microsoft.VisualStudio.Utilities; 11 | 12 | namespace Microsoft.VisualStudio.InteractiveWindow.Commands 13 | { 14 | [Export(typeof(IClassifierProvider))] 15 | [ContentType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)] 16 | internal sealed class CommandClassifierProvider : IClassifierProvider 17 | { 18 | [Import] 19 | public IStandardClassificationService ClassificationRegistry { get; set; } 20 | 21 | public IClassifier GetClassifier(ITextBuffer textBuffer) 22 | { 23 | var commands = textBuffer.GetInteractiveWindow().GetInteractiveCommands(); 24 | if (commands != null) 25 | { 26 | return new CommandClassifier(ClassificationRegistry, commands); 27 | } 28 | 29 | return null; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/Commands/IInteractiveWindowCommandsFactory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace Microsoft.VisualStudio.InteractiveWindow.Commands 12 | { 13 | /// 14 | /// Creates an which handles updating the context type for the command type, 15 | /// classification of commands, and execution of commands. 16 | /// 17 | /// 18 | /// Engines need to use this interface to respond to checks if code can be executed and to 19 | /// execute text when in a command mode. 20 | /// 21 | /// The commands that are available for this interactive window are provided at creation time 22 | /// along with the prefix which commands should be prefaced with. 23 | /// 24 | public interface IInteractiveWindowCommandsFactory 25 | { 26 | /// 27 | /// Creates the IInteractiveCommands instance. 28 | /// 29 | IInteractiveWindowCommands CreateInteractiveCommands(IInteractiveWindow window, string prefix, IEnumerable commands); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/Commands/InteractiveCommandsFactory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.ComponentModel.Composition; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using Microsoft.VisualStudio.Language.StandardClassification; 12 | using Microsoft.VisualStudio.Utilities; 13 | 14 | namespace Microsoft.VisualStudio.InteractiveWindow.Commands 15 | { 16 | [Export(typeof(IInteractiveWindowCommandsFactory))] 17 | internal class InteractiveCommandsFactory : IInteractiveWindowCommandsFactory 18 | { 19 | private readonly IContentTypeRegistryService _contentTypeRegistry; 20 | private readonly IStandardClassificationService _standardClassification; 21 | 22 | [ImportingConstructor] 23 | public InteractiveCommandsFactory(IContentTypeRegistryService contentTypeRegistry, IStandardClassificationService classification) 24 | { 25 | _contentTypeRegistry = contentTypeRegistry; 26 | _standardClassification = classification; 27 | } 28 | 29 | public IInteractiveWindowCommands CreateInteractiveCommands(IInteractiveWindow window, string prefix, IEnumerable commands) 30 | { 31 | return new Commands(window, prefix, commands.ToArray(), _contentTypeRegistry, _standardClassification); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/Commands/InteractiveWindowCommand.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | using Microsoft.VisualStudio.Text; 9 | using Microsoft.VisualStudio.Text.Classification; 10 | using Microsoft.VisualStudio.Utilities; 11 | 12 | namespace Microsoft.VisualStudio.InteractiveWindow.Commands 13 | { 14 | /// 15 | /// Represents a command which can be run from a REPL window. 16 | /// 17 | /// This interface is a MEF contract and can be implemented and exported to add commands to the REPL window. 18 | /// 19 | [ContentType(PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName)] 20 | internal abstract class InteractiveWindowCommand : IInteractiveWindowCommand 21 | { 22 | public abstract Task Execute(IInteractiveWindow window, string arguments); 23 | 24 | public abstract string Description { get; } 25 | 26 | public abstract IEnumerable Names { get; } 27 | 28 | public virtual IEnumerable ClassifyArguments(ITextSnapshot snapshot, Span argumentsSpan, Span spanToClassify) 29 | { 30 | return Enumerable.Empty(); 31 | } 32 | 33 | public virtual string CommandLine 34 | { 35 | get { return null; } 36 | } 37 | 38 | public virtual IEnumerable DetailedDescription 39 | { 40 | get { return null; } 41 | } 42 | 43 | public virtual IEnumerable> ParametersDescription 44 | { 45 | get { return null; } 46 | } 47 | 48 | protected void ReportInvalidArguments(IInteractiveWindow window) 49 | { 50 | var commands = (IInteractiveWindowCommands)window.Properties[typeof(IInteractiveWindowCommands)]; 51 | commands.DisplayCommandUsage(this, window.ErrorOutputWriter, displayDetails: false); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/Commands/InteractiveWindowCommandExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace Microsoft.VisualStudio.InteractiveWindow.Commands 12 | { 13 | public static class InteractiveWindowCommandExtensions 14 | { 15 | /// 16 | /// Gets the IInteractiveWindowCommands instance for the current interactive window if one is defined. 17 | /// 18 | /// Returns null if the interactive commands have not been created for this window. 19 | /// 20 | public static IInteractiveWindowCommands GetInteractiveCommands(this IInteractiveWindow window) 21 | { 22 | IInteractiveWindowCommands commands; 23 | if (window.Properties.TryGetProperty(typeof(IInteractiveWindowCommands), out commands)) 24 | { 25 | return commands; 26 | } 27 | 28 | return null; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/Commands/PredefinedInteractiveCommandsContentTypes.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.Utilities; 7 | 8 | #pragma warning disable CS0649 // field is not assigned to 9 | 10 | namespace Microsoft.VisualStudio.InteractiveWindow.Commands 11 | { 12 | public static class PredefinedInteractiveCommandsContentTypes 13 | { 14 | public const string InteractiveCommandContentTypeName = "Interactive Command"; 15 | 16 | [Export, Name(InteractiveCommandContentTypeName), BaseDefinition("code")] 17 | internal static readonly ContentTypeDefinition InteractiveCommandContentTypeDefinition; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/ContentTypeMetadata.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using Microsoft.VisualStudio.Utilities; 9 | 10 | namespace Microsoft.VisualStudio.InteractiveWindow 11 | { 12 | internal class ContentTypeMetadata 13 | { 14 | public IEnumerable ContentTypes { get; } 15 | 16 | public ContentTypeMetadata(IDictionary data) 17 | { 18 | this.ContentTypes = (IEnumerable)data["ContentTypes"]; 19 | } 20 | } 21 | 22 | internal static class ContentTypeMetadataHelpers 23 | { 24 | public static T OfContentType( 25 | this IEnumerable> exports, 26 | IContentType contentType, 27 | IContentTypeRegistryService contentTypeRegistry) 28 | { 29 | return (from export in exports 30 | from exportedContentTypeName in export.Metadata.ContentTypes 31 | let exportedContentType = contentTypeRegistry.GetContentType(exportedContentTypeName) 32 | where exportedContentType.IsOfType(contentType.TypeName) 33 | select export.Value).SingleOrDefault(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/ExecutionResult.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.VisualStudio.InteractiveWindow 8 | { 9 | /// 10 | /// The result of command execution. 11 | /// 12 | public struct ExecutionResult 13 | { 14 | public static readonly ExecutionResult Success = new ExecutionResult(true); 15 | public static readonly ExecutionResult Failure = new ExecutionResult(false); 16 | public static readonly Task Succeeded = Task.FromResult(Success); 17 | public static readonly Task Failed = Task.FromResult(Failure); 18 | 19 | private readonly bool _isSuccessful; 20 | 21 | public ExecutionResult(bool isSuccessful) 22 | { 23 | _isSuccessful = isSuccessful; 24 | } 25 | 26 | public bool IsSuccessful 27 | { 28 | get 29 | { 30 | return _isSuccessful; 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/IInteractiveWindow2.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | 7 | namespace Microsoft.VisualStudio.InteractiveWindow 8 | { 9 | public interface IInteractiveWindow2 : IInteractiveWindow 10 | { 11 | /// 12 | /// Adds to the history as if it has been executed. 13 | /// Method doesn't execute and doesn't affect current user input. 14 | /// 15 | /// The interactive window has not been initialized or is resetting. 16 | void AddToHistory(string input); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/IInteractiveWindowEditorFactoryService.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using Microsoft.VisualStudio.Text; 6 | using Microsoft.VisualStudio.Text.Editor; 7 | using Microsoft.VisualStudio.Text.Projection; 8 | using Microsoft.VisualStudio.Utilities; 9 | 10 | namespace Microsoft.VisualStudio.InteractiveWindow 11 | { 12 | /// 13 | /// Implements the service that creates text views and buffers for the interactive window. 14 | /// 15 | /// There is a single implementation of this service for each MEF composition catalog. The 16 | /// service understands how the editors and buffers need to be created and sets them up 17 | /// so that commands are properly routed to the editor window. 18 | /// 19 | /// This service is imported by 20 | /// to use in the creation of s. 21 | /// 22 | public interface IInteractiveWindowEditorFactoryService 23 | { 24 | /// 25 | /// Creates a new text view for an interactive window. 26 | /// Must be called on UI thread. 27 | /// 28 | /// The interactive window the text view is being created for. 29 | /// The projection buffer used for displaying the interactive window 30 | /// The requested text view roles. 31 | IWpfTextView CreateTextView(IInteractiveWindow window, ITextBuffer buffer, ITextViewRoleSet roles); 32 | 33 | /// 34 | /// Creates a new input buffer for the interactive window. 35 | /// Must be called on UI thread. 36 | /// 37 | ITextBuffer CreateAndActivateBuffer(IInteractiveWindow window); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/IInteractiveWindowFactoryService.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace Microsoft.VisualStudio.InteractiveWindow 12 | { 13 | /// 14 | /// Creates instances of the IInteractiveWindow. 15 | /// 16 | public interface IInteractiveWindowFactoryService 17 | { 18 | /// 19 | /// Creates a new interactive window which runs against the provided interactive evaluator. 20 | /// 21 | IInteractiveWindow CreateWindow(IInteractiveEvaluator evaluator); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/IInteractiveWindowOperations2.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | namespace Microsoft.VisualStudio.InteractiveWindow 6 | { 7 | public interface IInteractiveWindowOperations2 : IInteractiveWindowOperations 8 | { 9 | /// 10 | /// Copies the current selection to the clipboard. 11 | /// 12 | void Copy(); 13 | 14 | /// 15 | /// Copies code from user inputs to clipboard. 16 | /// If selection is empty, then copy from current line, otherwise copy from selected lines. 17 | /// 18 | void CopyCode(); 19 | 20 | /// 21 | /// Delete Line; Delete all selected lines, or the current line if no selection. 22 | /// 23 | void DeleteLine(); 24 | 25 | /// 26 | /// Line Cut; Cut all selected lines, or the current line if no selection, to the clipboard. 27 | /// 28 | void CutLine(); 29 | 30 | /// 31 | /// Handles character typed in by user. 32 | /// 33 | void TypeChar(char typedChar); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/InteractiveClipboardFormat.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.IO; 7 | using System.Text; 8 | 9 | namespace Microsoft.VisualStudio.InteractiveWindow 10 | { 11 | /// 12 | /// Implements deserialization for clipboard objects created by Interactive Window Copy operations. 13 | /// 14 | public static class InteractiveClipboardFormat 15 | { 16 | /// 17 | /// Unique identifier for the clipboard format. 18 | /// 19 | public const string Tag = "89344A36-9821-495A-8255-99A63969F87D"; 20 | 21 | /// 22 | /// Deserializes clipboard object. 23 | /// 24 | /// Object retrieved fromt the clipboard 25 | /// The value is not of the expected format. 26 | public static string Deserialize(object value) 27 | { 28 | if (value == null) 29 | { 30 | throw new ArgumentNullException(nameof(value)); 31 | } 32 | 33 | var text = value as string; 34 | if (text == null) 35 | { 36 | throw new InvalidDataException(); 37 | } 38 | 39 | var blocks = BufferBlock.Deserialize(text); 40 | 41 | var result = new StringBuilder(); 42 | foreach (var block in blocks) 43 | { 44 | switch (block.Kind) 45 | { 46 | // the actual linebreak was converted to regular Input when copied 47 | // This LineBreak block was created by coping box selection and is used as line separator when pasted 48 | case ReplSpanKind.LineBreak: 49 | result.Append(block.Content); 50 | break; 51 | 52 | case ReplSpanKind.Input: 53 | case ReplSpanKind.Output: 54 | case ReplSpanKind.StandardInput: 55 | result.Append(block.Content); 56 | break; 57 | } 58 | } 59 | 60 | return result.ToString(); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/InteractiveContentTypeDefinitions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.Utilities; 7 | 8 | #pragma warning disable CS0649 // field is not assigned to 9 | 10 | namespace Microsoft.VisualStudio.InteractiveWindow 11 | { 12 | internal static class InteractiveContentTypeDefinitions 13 | { 14 | [Export, Name(PredefinedInteractiveContentTypes.InteractiveContentTypeName), BaseDefinition("text"), BaseDefinition("projection")] 15 | internal static readonly ContentTypeDefinition InteractiveContentTypeDefinition; 16 | 17 | [Export, Name(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName), BaseDefinition("text")] 18 | internal static readonly ContentTypeDefinition InteractiveOutputContentTypeDefinition; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/InteractiveWindow.PendingSubmission.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.VisualStudio.InteractiveWindow 8 | { 9 | internal partial class InteractiveWindow 10 | { 11 | private class PendingSubmission 12 | { 13 | public readonly string Input; 14 | 15 | /// 16 | /// Set only on the last submission in each batch (to notify the caller). 17 | /// 18 | public readonly TaskCompletionSource Completion; 19 | 20 | public Task Task; 21 | 22 | public PendingSubmission(string input, TaskCompletionSource completion) 23 | { 24 | Input = input; 25 | Completion = completion; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/InteractiveWindow.ReplSpanKind.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Runtime.Serialization; 6 | 7 | namespace Microsoft.VisualStudio.InteractiveWindow 8 | { 9 | [DataContract] 10 | internal enum ReplSpanKind 11 | { 12 | /// 13 | /// Primary, secondary, or standard input prompt. 14 | /// 15 | [EnumMember] 16 | Prompt = 0, 17 | 18 | /// 19 | /// The span represents output from the program (standard output). 20 | /// 21 | [EnumMember] 22 | Output = 1, 23 | 24 | /// 25 | /// The span represents code inputted after a prompt or secondary prompt. 26 | /// 27 | [EnumMember] 28 | Input = 2, 29 | 30 | /// 31 | /// The span represents the input for a standard input (non code input). 32 | /// 33 | [EnumMember] 34 | StandardInput = 3, 35 | 36 | /// 37 | /// Line break inserted at end of output. 38 | /// 39 | [EnumMember] 40 | LineBreak = 4, 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/InteractiveWindow.SpanRangeEdit.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | 6 | namespace Microsoft.VisualStudio.InteractiveWindow 7 | { 8 | internal partial class InteractiveWindow 9 | { 10 | private struct SpanRangeEdit 11 | { 12 | public readonly int Start; 13 | public readonly int End; 14 | public readonly object[] Replacement; 15 | 16 | public SpanRangeEdit(int start, int count, object[] replacement) 17 | { 18 | Start = start; 19 | End = start + count; 20 | Replacement = replacement; 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/InteractiveWindow.SystemClipboard.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Windows; 6 | 7 | namespace Microsoft.VisualStudio.InteractiveWindow 8 | { 9 | internal partial class InteractiveWindow 10 | { 11 | private sealed class SystemClipboard : InteractiveWindowClipboard 12 | { 13 | internal override bool ContainsData(string format) => Clipboard.ContainsData(format); 14 | 15 | internal override object GetData(string format) => Clipboard.GetData(format); 16 | 17 | internal override bool ContainsText() => Clipboard.ContainsText(); 18 | 19 | internal override string GetText() => Clipboard.GetText(); 20 | 21 | internal override void SetDataObject(object data, bool copy) => Clipboard.SetDataObject(data, copy); 22 | 23 | internal override IDataObject GetDataObject() => Clipboard.GetDataObject(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/InteractiveWindowClipboard.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.Windows; 6 | 7 | namespace Microsoft.VisualStudio.InteractiveWindow 8 | { 9 | internal abstract class InteractiveWindowClipboard 10 | { 11 | internal abstract bool ContainsData(string format); 12 | 13 | internal abstract object GetData(string format); 14 | 15 | internal abstract bool ContainsText(); 16 | 17 | internal abstract string GetText(); 18 | 19 | internal abstract void SetDataObject(object data, bool copy); 20 | 21 | internal abstract IDataObject GetDataObject(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/InteractiveWindowExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using Microsoft.VisualStudio.Text; 6 | 7 | namespace Microsoft.VisualStudio.InteractiveWindow 8 | { 9 | public static class InteractiveWindowExtensions 10 | { 11 | /// 12 | /// Gets the interactive window associated with the text buffer if the text 13 | /// buffer is being hosted in the interactive window. 14 | /// 15 | /// Returns null if the text buffer is not hosted in the interactive window. 16 | /// 17 | public static IInteractiveWindow GetInteractiveWindow(this ITextBuffer buffer) 18 | { 19 | return InteractiveWindow.FromBuffer(buffer); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/InteractiveWindowOptions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using Microsoft.VisualStudio.Text.Editor; 11 | 12 | namespace Microsoft.VisualStudio.InteractiveWindow 13 | { 14 | public static class InteractiveWindowOptions 15 | { 16 | private static readonly EditorOptionKey s_smartUpDown = new EditorOptionKey(SmartUpDownOption.OptionName); 17 | 18 | /// 19 | /// Indicates that the window should be using smart up/down behavior. When enabled pressing 20 | /// the up or down arrow key will navigate history if the caret is at the end of the current 21 | /// input. When disabled the up/down arrow keys will always navigate the buffer. 22 | /// 23 | public static EditorOptionKey SmartUpDown 24 | { 25 | get 26 | { 27 | return s_smartUpDown; 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/InternalUtilities/ExceptionUtilities.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Diagnostics; 7 | 8 | namespace Microsoft.VisualStudio.InteractiveWindow 9 | { 10 | internal static class ExceptionUtilities 11 | { 12 | internal static Exception UnexpectedValue(object o) 13 | { 14 | string output = string.Format("Unexpected value '{0}' of type '{1}'", o, (o != null) ? o.GetType().FullName : ""); 15 | Debug.Assert(false, output); 16 | 17 | // We do not throw from here because we don't want all Watson reports to be bucketed to this call. 18 | return new InvalidOperationException(output); 19 | } 20 | 21 | internal static Exception Unreachable 22 | { 23 | get { return new InvalidOperationException("This program location is thought to be unreachable."); } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/PredefinedInteractiveContentTypes.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.Utilities; 7 | 8 | namespace Microsoft.VisualStudio.InteractiveWindow 9 | { 10 | public static class PredefinedInteractiveContentTypes 11 | { 12 | public const string InteractiveContentTypeName = "Interactive Content"; 13 | public const string InteractiveOutputContentTypeName = "Interactive Output"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/PredefinedInteractiveTextViewRoles.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace Microsoft.VisualStudio.InteractiveWindow 12 | { 13 | public static class PredefinedInteractiveTextViewRoles 14 | { 15 | /// 16 | /// The additional role found in any REPL editor window. 17 | /// 18 | public const string InteractiveTextViewRole = "REPL"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/ProjectionBufferExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using Microsoft.VisualStudio.Text; 6 | using Microsoft.VisualStudio.Text.Projection; 7 | 8 | namespace Microsoft.VisualStudio.InteractiveWindow 9 | { 10 | internal static class ProjectionBufferExtensions 11 | { 12 | internal static SnapshotSpan GetSourceSpan(this IProjectionSnapshot snapshot, int index) 13 | { 14 | return snapshot.GetSourceSpans(index, 1)[0]; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/PublicAPI.Unshipped.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/interactive-window/078e085193ca5ca8803d54e73ebae5f98cef92ab/src/Microsoft.VisualStudio.InteractiveWindow/PublicAPI.Unshipped.txt -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/SmartIndent/InteractiveSmartIndenterProvider.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.ComponentModel.Composition; 8 | using Microsoft.VisualStudio.Text.Editor; 9 | using Microsoft.VisualStudio.Utilities; 10 | 11 | namespace Microsoft.VisualStudio.InteractiveWindow 12 | { 13 | [Export(typeof(ISmartIndentProvider))] 14 | [ContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName)] 15 | internal class InteractiveSmartIndenterProvider : ISmartIndentProvider 16 | { 17 | private readonly ITextEditorFactoryService _editorFactory; 18 | private readonly IEnumerable> _indentProviders; 19 | 20 | [ImportingConstructor] 21 | public InteractiveSmartIndenterProvider( 22 | ITextEditorFactoryService editorFactory, 23 | [ImportMany] IEnumerable> indentProviders) 24 | { 25 | if (editorFactory == null) 26 | { 27 | throw new ArgumentNullException(nameof(editorFactory)); 28 | } 29 | 30 | if (indentProviders == null) 31 | { 32 | throw new ArgumentNullException(nameof(indentProviders)); 33 | } 34 | 35 | _editorFactory = editorFactory; 36 | _indentProviders = indentProviders; 37 | } 38 | 39 | public ISmartIndent CreateSmartIndent(ITextView view) 40 | { 41 | var window = view.TextBuffer.GetInteractiveWindow(); 42 | if (window == null || window.CurrentLanguageBuffer == null) 43 | { 44 | return null; 45 | } 46 | 47 | return InteractiveSmartIndenter.Create(_indentProviders, window.CurrentLanguageBuffer.ContentType, view); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/SmartUpDownOption.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.ComponentModel.Composition; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using Microsoft.VisualStudio.Text.Editor; 12 | using Microsoft.VisualStudio.Utilities; 13 | 14 | namespace Microsoft.VisualStudio.InteractiveWindow 15 | { 16 | [Export(typeof(EditorOptionDefinition))] 17 | [Name(OptionName)] 18 | internal sealed class SmartUpDownOption : EditorOptionDefinition 19 | { 20 | internal const string OptionName = "InteractiveSmartUpDown"; 21 | 22 | public override EditorOptionKey Key 23 | { 24 | get 25 | { 26 | return InteractiveWindowOptions.SmartUpDown; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/SubmissionBufferAddedEventArgs.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using Microsoft.VisualStudio.Text; 11 | 12 | namespace Microsoft.VisualStudio.InteractiveWindow 13 | { 14 | public sealed class SubmissionBufferAddedEventArgs : EventArgs 15 | { 16 | private readonly ITextBuffer _newBuffer; 17 | 18 | public SubmissionBufferAddedEventArgs(ITextBuffer newBuffer) 19 | { 20 | if (newBuffer == null) 21 | { 22 | throw new ArgumentNullException(nameof(newBuffer)); 23 | } 24 | 25 | _newBuffer = newBuffer; 26 | } 27 | 28 | public ITextBuffer NewBuffer 29 | { 30 | get 31 | { 32 | return _newBuffer; 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.InteractiveWindow/Utils/Contract.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Diagnostics; 7 | 8 | namespace Microsoft.VisualStudio.InteractiveWindow 9 | { 10 | internal static class Contract 11 | { 12 | [DebuggerDisplay("Unreachable")] 13 | public static Exception Unreachable 14 | { 15 | get 16 | { 17 | Debug.Fail("This code path should not be reachable"); 18 | return new InvalidOperationException(); 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/AssemblyRedirects.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using Microsoft.VisualStudio.InteractiveWindow.Shell; 6 | 7 | [assembly: ProvideInteractiveWindowBindingRedirection("Microsoft.VisualStudio.InteractiveWindow.dll")] 8 | [assembly: ProvideInteractiveWindowBindingRedirection("Microsoft.VisualStudio.VsInteractiveWindow.dll")] 9 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/CommandIds.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | namespace Microsoft.VisualStudio.InteractiveWindow.Shell 6 | { 7 | internal enum CommandIds : uint 8 | { 9 | // TODO (crwilcox): should all of these be in the editoroperations? 10 | SmartExecute = 0x103, 11 | AbortExecution = 0x104, 12 | Reset = 0x105, 13 | HistoryNext = 0x0106, 14 | HistoryPrevious = 0x0107, 15 | ClearScreen = 0x0108, 16 | BreakLine = 0x0109, 17 | SearchHistoryNext = 0x010A, 18 | SearchHistoryPrevious = 0x010B, 19 | ExecuteInInteractiveWindow = 0x010C, 20 | CopyToInteractiveWindow = 0x010D, 21 | CopyCode = 0x010E, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/ContentTypeMetadata.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using Microsoft.VisualStudio.Utilities; 9 | 10 | namespace Microsoft.VisualStudio.InteractiveWindow.Shell 11 | { 12 | internal class ContentTypeMetadata 13 | { 14 | public IEnumerable ContentTypes { get; } 15 | 16 | public ContentTypeMetadata(IDictionary data) 17 | { 18 | this.ContentTypes = (IEnumerable)data["ContentTypes"]; 19 | } 20 | } 21 | 22 | internal static class ContentTypeMetadataHelpers 23 | { 24 | public static T OfContentType( 25 | this IEnumerable> exports, 26 | IContentType contentType, 27 | IContentTypeRegistryService contentTypeRegistry) 28 | { 29 | return (from export in exports 30 | from exportedContentTypeName in export.Metadata.ContentTypes 31 | let exportedContentType = contentTypeRegistry.GetContentType(exportedContentTypeName) 32 | where exportedContentType.IsOfType(contentType.TypeName) 33 | select export.Value).SingleOrDefault(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/Guids.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | 7 | namespace Microsoft.VisualStudio.InteractiveWindow.Shell 8 | { 9 | public static class Guids 10 | { 11 | // vsct guids: 12 | // This GUID identifies the VsInteractiveWindow type. We need to pass it to VS in a string form. 13 | public const string InteractiveToolWindowIdString = "2D0A56AA-9527-4B78-B6E6-EBE6E05DA749"; 14 | public const string InteractiveWindowPackageIdString = "F5199A4E-6A60-4F79-82E9-FC92A41C4610"; 15 | public const string InteractiveCommandSetIdString = "00B8868B-F9F5-4970-A048-410B05508506"; 16 | 17 | public static readonly Guid InteractiveToolWindowId = new Guid(InteractiveToolWindowIdString); 18 | public static readonly Guid InteractiveWindowPackageId = new Guid(InteractiveWindowPackageIdString); 19 | public static readonly Guid InteractiveCommandSetId = new Guid(InteractiveCommandSetIdString); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/IVsInteractiveWindow.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using Microsoft.VisualStudio.InteractiveWindow; 7 | using Microsoft.VisualStudio.Utilities; 8 | 9 | namespace Microsoft.VisualStudio.InteractiveWindow.Shell 10 | { 11 | /// 12 | /// Provides access to an interactive window being hosted inside of Visual Studio's process using the 13 | /// default tool window. 14 | /// 15 | /// These tool windows are created using ProvideInteractiveWindowAttribute which provides the normal 16 | /// tool window registration options. Instances of the tool window are then created using 17 | /// IVsInteractiveWindowFactory when VS calls on your packages IVsToolWindowFactory.CreateToolWindow 18 | /// method. 19 | /// 20 | public interface IVsInteractiveWindow 21 | { 22 | /// 23 | /// Gets the interactive window instance. 24 | /// 25 | IInteractiveWindow InteractiveWindow { get; } 26 | 27 | /// 28 | /// Shows the window. 29 | /// 30 | void Show(bool focus); 31 | 32 | /// 33 | /// Configures the window for the specified VS language service guid language preferences. 34 | /// 35 | /// Also installs a language appropriate command filter if one is exported via IVsInteractiveWindowOleCommandTargetProvider. 36 | /// 37 | void SetLanguage(Guid languageServiceGuid, IContentType contentType); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/IVsInteractiveWindowFactory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using Microsoft.VisualStudio.InteractiveWindow; 7 | using Microsoft.VisualStudio.Shell.Interop; 8 | 9 | namespace Microsoft.VisualStudio.InteractiveWindow.Shell 10 | { 11 | public interface IVsInteractiveWindowFactory 12 | { 13 | IVsInteractiveWindow Create(Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator, __VSCREATETOOLWIN creationFlags = 0); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/IVsInteractiveWindowFactory2.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using Microsoft.VisualStudio.OLE.Interop; 7 | using Microsoft.VisualStudio.Shell.Interop; 8 | 9 | namespace Microsoft.VisualStudio.InteractiveWindow.Shell 10 | { 11 | public interface IVsInteractiveWindowFactory2: IVsInteractiveWindowFactory 12 | { 13 | IVsInteractiveWindow Create( 14 | Guid providerId, 15 | int instanceId, 16 | string title, 17 | IInteractiveEvaluator evaluator, 18 | __VSCREATETOOLWIN creationFlags, 19 | Guid toolbarCommandSet, 20 | uint toolbarId, 21 | IOleCommandTarget toolbarCommandTarget); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/IVsInteractiveWindowOleCommandTargetProvider.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using Microsoft.VisualStudio.OLE.Interop; 6 | using Microsoft.VisualStudio.Text.Editor; 7 | 8 | namespace Microsoft.VisualStudio.InteractiveWindow.Shell 9 | { 10 | /// 11 | /// The implementer is given a chance to attach a command filter that routes language services 12 | /// commands into the Interactive Window command filter chain. 13 | /// 14 | public interface IVsInteractiveWindowOleCommandTargetProvider 15 | { 16 | IOleCommandTarget GetCommandTarget(IWpfTextView textView, IOleCommandTarget nextTarget); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/InteractiveWindowPackage.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.ComponentModel; 7 | using System.Runtime.InteropServices; 8 | using Microsoft.VisualStudio.Shell; 9 | 10 | namespace Microsoft.VisualStudio.InteractiveWindow.Shell 11 | { 12 | /// 13 | /// This is the class that implements the package exposed by this assembly. 14 | /// 15 | /// The minimum requirement for a class to be considered a valid package for Visual Studio 16 | /// is to implement the IVsPackage interface and register itself with the shell. 17 | /// This package uses the helper classes defined inside the Managed Package Framework (MPF) 18 | /// to do it: it derives from the Package class that provides the implementation of the 19 | /// IVsPackage interface and uses the registration attributes defined in the framework to 20 | /// register itself and its components with the shell. 21 | /// 22 | // This attribute tells the PkgDef creation utility (CreatePkgDef.exe) that this class is 23 | // a package. 24 | [PackageRegistration(UseManagedResourcesOnly = true)] 25 | [Description("Visual Studio Interactive Window")] 26 | [ProvideKeyBindingTable(Guids.InteractiveToolWindowIdString, 200)] // Resource ID: "Interactive Window" 27 | [ProvideMenuResource("Menus.ctmenu", 4)] 28 | [Guid(Guids.InteractiveWindowPackageIdString)] 29 | [ProvideBindingPath] // make sure our DLLs are loadable from other packages 30 | internal sealed class InteractiveWindowPackage : Package 31 | { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/MenuIds.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | 10 | namespace Microsoft.VisualStudio 11 | { 12 | internal enum MenuIds : uint 13 | { 14 | InteractiveWindowToolbar = 0x2000, 15 | InteractiveWindowContextMenu = 0x2100, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/ProvideBindingRedirection.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using Microsoft.VisualStudio.Shell; 7 | using System.IO; 8 | 9 | namespace Microsoft.VisualStudio.InteractiveWindow.Shell 10 | { 11 | /// 12 | /// A that provides binding redirects with all of the settings we need. 13 | /// It's just a wrapper for that sets all the defaults rather than duplicating them. 14 | /// 15 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 16 | internal sealed class ProvideInteractiveWindowBindingRedirectionAttribute : RegistrationAttribute 17 | { 18 | private readonly ProvideBindingRedirectionAttribute _redirectionAttribute; 19 | 20 | public ProvideInteractiveWindowBindingRedirectionAttribute(string fileName) 21 | { 22 | // ProvideBindingRedirectionAttribute is sealed, so we can't inherit from it to provide defaults. 23 | // Instead, we'll do more of an aggregation pattern here. 24 | // Note that PublicKeyToken, NewVersion and OldVersionUpperBound are read from the actual assembly version of the dll. 25 | _redirectionAttribute = new ProvideBindingRedirectionAttribute 26 | { 27 | AssemblyName = Path.GetFileNameWithoutExtension(fileName), 28 | OldVersionLowerBound = "0.0.0.0", 29 | CodeBase = fileName, 30 | }; 31 | } 32 | 33 | public override void Register(RegistrationContext context) 34 | { 35 | _redirectionAttribute.Register(context); 36 | 37 | // Opt into overriding the devenv.exe.config binding redirect 38 | using (var key = context.CreateKey(@"RuntimeConfiguration\dependentAssembly\bindingRedirection\" + _redirectionAttribute.Guid.ToString("B").ToUpperInvariant())) 39 | { 40 | key.SetValue("isPkgDefOverrideEnabled", true); 41 | } 42 | } 43 | 44 | public override void Unregister(RegistrationContext context) 45 | { 46 | _redirectionAttribute.Unregister(context); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/PublicAPI.Unshipped.txt: -------------------------------------------------------------------------------- 1 | *REMOVED*Microsoft.VisualStudio.InteractiveWindow.Shell.InteractiveWindowPackage 2 | *REMOVED*Microsoft.VisualStudio.InteractiveWindow.Shell.InteractiveWindowPackage.InteractiveWindowPackage() -> void 3 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/VSInteractiveWindowRules.ruleset: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/VsInteractiveWindowFactory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | // See the License.txt file in the project root for more information. 4 | 5 | using System; 6 | using System.ComponentModel.Composition; 7 | using Microsoft.VisualStudio.ComponentModelHost; 8 | using Microsoft.VisualStudio.Shell; 9 | using Microsoft.VisualStudio.Shell.Interop; 10 | using Microsoft.VisualStudio.OLE.Interop; 11 | 12 | namespace Microsoft.VisualStudio.InteractiveWindow.Shell 13 | { 14 | [Export(typeof(IVsInteractiveWindowFactory))] 15 | [Export(typeof(IVsInteractiveWindowFactory2))] 16 | internal sealed class VsInteractiveWindowFactory : IVsInteractiveWindowFactory2 17 | { 18 | private readonly IComponentModel _componentModel; 19 | 20 | [ImportingConstructor] 21 | internal VsInteractiveWindowFactory(SVsServiceProvider serviceProvider) 22 | { 23 | _componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); 24 | } 25 | 26 | public IVsInteractiveWindow Create(Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator, __VSCREATETOOLWIN creationFlags) 27 | { 28 | return Create(providerId, instanceId, title, evaluator, creationFlags, Guid.Empty, 0, null); 29 | } 30 | 31 | public IVsInteractiveWindow Create( 32 | Guid providerId, 33 | int instanceId, 34 | string title, 35 | IInteractiveEvaluator evaluator, 36 | __VSCREATETOOLWIN creationFlags, 37 | Guid toolbarCommandSet, 38 | uint toolbarId, 39 | IOleCommandTarget toolbarCommandTarget) 40 | { 41 | return new VsInteractiveWindow(_componentModel, providerId, instanceId, title, evaluator, creationFlags, toolbarCommandSet, toolbarId, toolbarCommandTarget); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | VisualStudio Interactive Window 6 | Interactive components for Visual Studio. 7 | Microsoft.VisualStudio.InteractiveWindow 8 | 9 | 10 | 11 | x86 12 | 13 | 14 | amd64 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.cs.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.de.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.es.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.fr.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.it.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.ja.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.ko.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.pl.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.pt-BR.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.ru.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.tr.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.zh-Hans.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSInteractiveWindowResources.zh-Hant.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.cs.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Okno Interactive sady Microsoft Visual Studio 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Okno Interactive sady Microsoft Visual Studio 13 | 14 | 15 | 16 | Interactive Window 17 | Okno Interactive 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.de.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Microsoft Visual Studio – Interactive-Fenster 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Microsoft Visual Studio – Interactive-Fenster 13 | 14 | 15 | 16 | Interactive Window 17 | Interactive-Fenster 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.es.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Ventana interactiva de Microsoft Visual Studio 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Ventana interactiva de Microsoft Visual Studio 13 | 14 | 15 | 16 | Interactive Window 17 | Ventana interactiva 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.fr.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Fenêtre interactive de Microsoft Visual Studio 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Fenêtre interactive de Microsoft Visual Studio 13 | 14 | 15 | 16 | Interactive Window 17 | Fenêtre interactive 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.it.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Finestra interattiva di Microsoft Visual Studio 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Finestra interattiva di Microsoft Visual Studio 13 | 14 | 15 | 16 | Interactive Window 17 | Finestra interattiva 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.ja.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Microsoft Visual Studio インタラクティブ ウィンドウ 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Microsoft Visual Studio インタラクティブ ウィンドウ 13 | 14 | 15 | 16 | Interactive Window 17 | インタラクティブ ウィンドウ 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.ko.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Microsoft Visual Studio 대화형 창 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Microsoft Visual Studio 대화형 창 13 | 14 | 15 | 16 | Interactive Window 17 | 대화형 창 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.pl.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Okno Interactive programu Microsoft Visual Studio 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Okno Interactive programu Microsoft Visual Studio 13 | 14 | 15 | 16 | Interactive Window 17 | Okno Interactive 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.pt-BR.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Janela Interativa do Microsoft Visual Studio 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Janela Interativa do Microsoft Visual Studio 13 | 14 | 15 | 16 | Interactive Window 17 | Janela Interativa 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.ru.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Интерактивное окно Microsoft Visual Studio 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Интерактивное окно Microsoft Visual Studio 13 | 14 | 15 | 16 | Interactive Window 17 | Интерактивное окно 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.tr.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Microsoft Visual Studio Etkileşimli Penceresi 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Microsoft Visual Studio Etkileşimli Penceresi 13 | 14 | 15 | 16 | Interactive Window 17 | Etkileşimli Pencere 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.zh-Hans.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Microsoft Visual Studio 交互窗口 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Microsoft Visual Studio 交互窗口 13 | 14 | 15 | 16 | Interactive Window 17 | 交互窗口 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Microsoft.VisualStudio.VsInteractiveWindow/xlf/VSPackage.zh-Hant.xlf: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Microsoft Visual Studio Interactive Window 7 | Microsoft Visual Studio 互動視窗 8 | 9 | 10 | 11 | Microsoft Visual Studio Interactive Window 12 | Microsoft Visual Studio 互動視窗 13 | 14 | 15 | 16 | Interactive Window 17 | 互動視窗 18 | 19 | 20 | 21 | 22 | --------------------------------------------------------------------------------