diff --git a/.github/skills/run-vscode-local-testing/SKILL.md b/.github/skills/run-vscode-local-testing/SKILL.md deleted file mode 100644 index b48216ba10057..0000000000000 --- a/.github/skills/run-vscode-local-testing/SKILL.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -name: run-vscode-local-testing -description: Build the local Roslyn language server and Razor VS Code extension outputs, write a VS Code workspace that points at them, and launch VS Code for manual testing. -argument-hint: Ask which project folder VS Code should open for local testing. ---- - -# Run VS Code for Local Testing - -Use this skill when: -- manually testing Roslyn or Razor changes in VS Code against locally built bits -- asked to launch VS Code with `dotnet.server.path` pointing at the repo's `Microsoft.CodeAnalysis.LanguageServer.dll` -- asked to point the C# extension's Razor component at the locally built `Microsoft.VisualStudioCode.RazorExtension` output - -This workflow is currently **Windows-only**. It assumes: -- `code` is available on `PATH` -- the target project folder already exists on disk - -## First step - -If the user has not already given you a project folder, ask them which folder VS Code should open and wait for an absolute path before running the helper script. - -## Goal - -1. Build the local Roslyn language server and Razor VS Code extension outputs. -2. Write a `.code-workspace` file under `artifacts\`. -3. Point that workspace at the requested project folder. -4. Set: - - `dotnet.server.path` - - `dotnet.server.componentPaths.razorExtension` -5. Launch VS Code with that workspace. - -## Helper script - -Use the helper script in this skill: - -```powershell -.\.github\skills\run-vscode-local-testing\scripts\Start-LocalVsCode.ps1 ` - -ProjectPath C:\path\to\project -``` - -### Parameters - -- `-ProjectPath` (required): absolute path to the folder VS Code should open. -- `-Configuration`: build configuration. Defaults to `Debug`. -- `-WorkspacePath`: optional path for the generated workspace file. Defaults to `artifacts\-local-test.code-workspace`. -- `-SkipBuild`: skip `dotnet build` if the outputs are already up to date. -- `-NoLaunch`: write the workspace file without launching VS Code. -- `-NewWindow`: open VS Code in a new window instead of reusing the current one. - -## What the script builds - -Unless `-SkipBuild` is passed, the script builds: - -```powershell -dotnet build src\LanguageServer\Microsoft.CodeAnalysis.LanguageServer\Microsoft.CodeAnalysis.LanguageServer.csproj -c Debug -dotnet build src\Razor\src\Razor\src\Microsoft.VisualStudioCode.RazorExtension\Microsoft.VisualStudioCode.RazorExtension.csproj -c Debug -``` - -The generated workspace points at: - -```text -artifacts\bin\Microsoft.CodeAnalysis.LanguageServer\\net10.0\Microsoft.CodeAnalysis.LanguageServer.dll -artifacts\bin\Microsoft.VisualStudioCode.RazorExtension\\net10.0 -``` - -The Razor extension project has a local-only post-build target that copies its companion assemblies into that output folder for manual testing. That target is gated off in CI. - -## Generated workspace shape - -The script writes a workspace like this: - -```json -{ - "folders": [ - { - "path": "C:\\path\\to\\project" - } - ], - "settings": { - "dotnet.server.path": "D:\\repo\\artifacts\\bin\\Microsoft.CodeAnalysis.LanguageServer\\Debug\\net10.0\\Microsoft.CodeAnalysis.LanguageServer.dll", - "dotnet.server.componentPaths": { - "razorExtension": "D:\\repo\\artifacts\\bin\\Microsoft.VisualStudioCode.RazorExtension\\Debug\\net10.0" - } - } -} -``` - -## Troubleshooting - -If VS Code starts but Razor does not behave correctly, inspect the latest C# LSP trace log: - -```text -C:\Users\\AppData\Roaming\Code\logs\\window*\exthost\ms-dotnettools.csharp\C# LSP Trace Logs.log -``` - -Useful checks: -- Success markers: - - `Razor extension startup finished.` - - `textDocument/selectionRange` - - other `razor/log` activity for the opened `.razor` file -- Failure markers: - - `FileNotFoundException` - - `Could not load file or assembly` - - `No method by the name 'razor/documentClosed' is found` - -## Example follow-up - -If the user asks to re-open the same local-test workspace after rebuilding, rerun: - -```powershell -.\.github\skills\run-vscode-local-testing\scripts\Start-LocalVsCode.ps1 ` - -ProjectPath C:\path\to\project ` - -SkipBuild -``` diff --git a/.github/skills/run-vscode-local-testing/scripts/Start-LocalVsCode.ps1 b/.github/skills/run-vscode-local-testing/scripts/Start-LocalVsCode.ps1 deleted file mode 100644 index 4d3449dc42a6b..0000000000000 --- a/.github/skills/run-vscode-local-testing/scripts/Start-LocalVsCode.ps1 +++ /dev/null @@ -1,173 +0,0 @@ -<# -.SYNOPSIS -Creates a VS Code workspace for local Roslyn and Razor manual testing and optionally launches VS Code. - -.DESCRIPTION -Builds the local language server and Razor extension outputs, writes a .code-workspace file that points -the C# extension at those local bits, and launches VS Code against a chosen project folder. -#> - -[CmdletBinding()] -param( - [Parameter(Mandatory = $true)] - [string]$ProjectPath, - - [ValidateSet('Debug', 'Release')] - [string]$Configuration = 'Debug', - - [string]$WorkspacePath, - - [switch]$SkipBuild, - - [switch]$NoLaunch, - - [switch]$NewWindow -) - -Set-StrictMode -Version Latest -$ErrorActionPreference = 'Stop' - -function Get-RepositoryRoot { - return (Resolve-Path (Join-Path $PSScriptRoot '..\..\..\..')).Path -} - -function Get-AbsolutePath { - param( - [Parameter(Mandatory = $true)] - [string]$Path, - - [Parameter(Mandatory = $true)] - [string]$BasePath - ) - - if ([System.IO.Path]::IsPathRooted($Path)) - { - return [System.IO.Path]::GetFullPath($Path) - } - - return [System.IO.Path]::GetFullPath((Join-Path $BasePath $Path)) -} - -function Invoke-DotNetBuild { - param( - [Parameter(Mandatory = $true)] - [string]$ProjectFile, - - [Parameter(Mandatory = $true)] - [string]$BuildConfiguration - ) - - & dotnet build $ProjectFile -c $BuildConfiguration --nologo - if ($LASTEXITCODE -ne 0) - { - throw "Build failed for '$ProjectFile'." - } -} - -function Assert-PathExists { - param( - [Parameter(Mandatory = $true)] - [string]$Path, - - [Parameter(Mandatory = $true)] - [string]$Description - ) - - if (-not (Test-Path -LiteralPath $Path)) - { - throw "$Description was not found at '$Path'." - } -} - -function Get-DefaultWorkspacePath { - param( - [Parameter(Mandatory = $true)] - [string]$RepoRoot, - - [Parameter(Mandatory = $true)] - [string]$ResolvedProjectPath - ) - - $projectName = Split-Path -Leaf ($ResolvedProjectPath.TrimEnd('\', '/')) - if ([string]::IsNullOrWhiteSpace($projectName)) - { - $projectName = 'local' - } - - return Join-Path $RepoRoot "artifacts\$projectName-local-test.code-workspace" -} - -$repoRoot = Get-RepositoryRoot -$resolvedProjectPath = (Resolve-Path -LiteralPath $ProjectPath).Path -$resolvedWorkspacePath = if ($WorkspacePath) -{ - Get-AbsolutePath -Path $WorkspacePath -BasePath $repoRoot -} -else -{ - Get-DefaultWorkspacePath -RepoRoot $repoRoot -ResolvedProjectPath $resolvedProjectPath -} - -$languageServerProject = Join-Path $repoRoot 'src\LanguageServer\Microsoft.CodeAnalysis.LanguageServer\Microsoft.CodeAnalysis.LanguageServer.csproj' -$razorExtensionProject = Join-Path $repoRoot 'src\Razor\src\Razor\src\Microsoft.VisualStudioCode.RazorExtension\Microsoft.VisualStudioCode.RazorExtension.csproj' - -if (-not $SkipBuild) -{ - Invoke-DotNetBuild -ProjectFile $languageServerProject -BuildConfiguration $Configuration - Invoke-DotNetBuild -ProjectFile $razorExtensionProject -BuildConfiguration $Configuration -} - -$languageServerPath = Join-Path $repoRoot "artifacts\bin\Microsoft.CodeAnalysis.LanguageServer\$Configuration\net10.0\Microsoft.CodeAnalysis.LanguageServer.dll" -$razorExtensionPath = Join-Path $repoRoot "artifacts\bin\Microsoft.VisualStudioCode.RazorExtension\$Configuration\net10.0" - -Assert-PathExists -Path $languageServerPath -Description 'Local Roslyn language server' -Assert-PathExists -Path $razorExtensionPath -Description 'Local Razor VS Code extension output' - -$workspaceDirectory = Split-Path -Parent $resolvedWorkspacePath -if (-not [string]::IsNullOrWhiteSpace($workspaceDirectory)) -{ - New-Item -ItemType Directory -Path $workspaceDirectory -Force | Out-Null -} - -$workspace = [ordered]@{ - folders = @( - [ordered]@{ - path = $resolvedProjectPath - } - ) - settings = [ordered]@{ - 'dotnet.server.path' = $languageServerPath - 'dotnet.server.componentPaths' = [ordered]@{ - razorExtension = $razorExtensionPath - } - } -} - -$workspaceJson = $workspace | ConvertTo-Json -Depth 10 -[System.IO.File]::WriteAllText($resolvedWorkspacePath, $workspaceJson + [Environment]::NewLine) - -Write-Host "Workspace: $resolvedWorkspacePath" -Write-Host "Project folder: $resolvedProjectPath" -Write-Host "Roslyn language server: $languageServerPath" -Write-Host "Razor extension: $razorExtensionPath" - -if ($NoLaunch) -{ - return -} - -if (-not (Get-Command code -ErrorAction SilentlyContinue)) -{ - throw "VS Code command line launcher 'code' was not found on PATH." -} - -$arguments = if ($NewWindow) -{ - @($resolvedWorkspacePath) -} -else -{ - @('--reuse-window', $resolvedWorkspacePath) -} - -Start-Process code -ArgumentList $arguments | Out-Null diff --git a/eng/config/PublishData.json b/eng/config/PublishData.json index 36e9573cb2e09..aa81778aef180 100644 --- a/eng/config/PublishData.json +++ b/eng/config/PublishData.json @@ -92,7 +92,6 @@ "roslyn-language-server.win-arm64": "vs-impl", "roslyn-language-server.win-x64": "vs-impl", "Text.Analyzers": "arcade", - "Microsoft.VisualStudioCode.RazorExtension": "vs-impl", "Microsoft.AspNetCore.Mvc.Razor.Extensions.Tooling.Internal": "arcade", "Microsoft.AspNetCore.Razor.Test.Common": "arcade", "Microsoft.AspNetCore.Razor.Utilities.Shared": "arcade", diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs index ec91190de1c20..7b21e447286c4 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs @@ -68,7 +68,7 @@ public async Task CreatingDirectoryWatchRequestsDirectoryWatch() // Get rid of the registration and it should be gone again context.Dispose(); await WaitForFileWatcherAsync(testLspServer); - Assert.Empty(dynamicCapabilitiesRpcTarget.Registrations); + AssertNoFileWatcherRegistration(dynamicCapabilitiesRpcTarget); } [Fact] @@ -99,8 +99,9 @@ public async Task CreatingFileWatchRequestsFileWatch() // Get rid of the registration and it should be gone again watchedFile.Dispose(); + context.Dispose(); await WaitForFileWatcherAsync(testLspServer); - Assert.Empty(dynamicCapabilitiesRpcTarget.Registrations); + AssertNoFileWatcherRegistration(dynamicCapabilitiesRpcTarget); } private static Task WaitForFileWatcherAsync(TestLspServer testLspServer) @@ -108,12 +109,16 @@ private static Task WaitForFileWatcherAsync(TestLspServer testLspServer) private static FileSystemWatcher GetSingleFileWatcher(DynamicCapabilitiesRpcTarget dynamicCapabilities) { - var registrationJson = Assert.IsType(Assert.Single(dynamicCapabilities.Registrations).Value.RegisterOptions); + var registrationJson = Assert.IsType( + Assert.Single(dynamicCapabilities.Registrations.Values, static registration => registration.Method == Methods.WorkspaceDidChangeWatchedFilesName).RegisterOptions); var registration = JsonSerializer.Deserialize(registrationJson, ProtocolConversions.LspJsonSerializerOptions)!; return Assert.Single(registration.Watchers); } + private static void AssertNoFileWatcherRegistration(DynamicCapabilitiesRpcTarget dynamicCapabilities) + => Assert.DoesNotContain(dynamicCapabilities.Registrations.Values, static registration => registration.Method == Methods.WorkspaceDidChangeWatchedFilesName); + private sealed class DynamicCapabilitiesRpcTarget { public readonly ConcurrentDictionary Registrations = new(); diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/LanguageServerTestComposition.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/LanguageServerTestComposition.cs index 129149d4b3096..608ebbf30f5c1 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/LanguageServerTestComposition.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/LanguageServerTestComposition.cs @@ -24,7 +24,6 @@ internal sealed class LanguageServerTestComposition SessionId: null, ExtensionAssemblyPaths: extensionPaths ?? [], DevKitDependencyPath: devKitDependencyPath, - RazorDesignTimePath: null, CSharpDesignTimePath: null, ExtensionLogDirectory: string.Empty, ServerPipeName: null, diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectLoader.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectLoader.cs index d479cfc7ee4cc..1a10fce549e71 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectLoader.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectLoader.cs @@ -22,6 +22,8 @@ namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace; internal abstract class LanguageServerProjectLoader { + private static readonly string s_razorDesignTimePath = Path.Combine(AppContext.BaseDirectory, "Targets", "Microsoft.NET.Sdk.Razor.DesignTime.targets"); + private readonly AsyncBatchingWorkQueue _projectsToReload; protected readonly LanguageServerWorkspaceFactory _workspaceFactory; @@ -126,10 +128,7 @@ private static ImmutableDictionary BuildAdditionalProperties(Ser return properties; } - if (serverConfiguration.RazorDesignTimePath is { } razorDesignTimePath) - { - properties = properties.Add("RazorDesignTimeTargets", razorDesignTimePath); - } + properties = properties.Add("RazorDesignTimeTargets", s_razorDesignTimePath); if (serverConfiguration.CSharpDesignTimePath is { } csharpDesignTimePath) { diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServerExportProviderBuilder.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServerExportProviderBuilder.cs index aca4957310353..1eed6474029e3 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServerExportProviderBuilder.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServerExportProviderBuilder.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Collections.Frozen; using System.Collections.Immutable; using Microsoft.CodeAnalysis.LanguageServer.Logging; using Microsoft.CodeAnalysis.LanguageServer.Services; @@ -19,6 +20,17 @@ internal sealed class LanguageServerExportProviderBuilder : ExportProviderBuilde // For testing purposes, track the last cache write task. private static Task? s_cacheWriteTask_forTestingPurposesOnly; + private static readonly FrozenSet s_dllsToExcludeFromMef = FrozenSet.ToFrozenSet( + [ + // These DLLs are part of Razor, but should only be in their MEF composition not ours + "Microsoft.CodeAnalysis.Razor.Workspaces.dll", + "Microsoft.CodeAnalysis.Remote.Razor.dll", + + // This is a runtime dependency of Remote.Razor, but its host-layer exports belong to the remote host + // composition and conflict with the language server's workspace services if included here. + "Microsoft.CodeAnalysis.Remote.ServiceHub.dll", + ], StringComparer.OrdinalIgnoreCase); + private LanguageServerExportProviderBuilder( ImmutableArray assemblyPaths, Resolver resolver, @@ -39,13 +51,16 @@ public static async Task CreateExportProviderAsync( ILoggerFactory loggerFactory, CancellationToken cancellationToken) { - // Load any Roslyn assemblies from the extension directory + // Load Roslyn assemblies from the language server directory. using var _ = ArrayBuilder.GetInstance(out var assemblyPathsBuilder); // Don't catch IO exceptions as it's better to fail to build the catalog than give back // a partial catalog that will surely blow up later. - assemblyPathsBuilder.AddRange(Directory.EnumerateFiles(baseDirectory, "Microsoft.CodeAnalysis*.dll")); - assemblyPathsBuilder.AddRange(Directory.EnumerateFiles(baseDirectory, "Microsoft.ServiceHub*.dll")); + assemblyPathsBuilder.AddRange(FilterFiles(baseDirectory, "Microsoft.CodeAnalysis*.dll")); + assemblyPathsBuilder.AddRange(FilterFiles(baseDirectory, "Microsoft.ServiceHub*.dll")); + + // The Razor extension ships with Roslyn and so needs to be in our MEF composition + assemblyPathsBuilder.Add(Path.Combine(baseDirectory, "Microsoft.VisualStudioCode.RazorExtension.dll")); // DevKit assemblies are not shipped in the main language server folder // and not included in ExtensionAssemblyPaths (they get loaded into the default ALC). @@ -74,6 +89,15 @@ public static async Task CreateExportProviderAsync( return exportProvider; } + private static IEnumerable FilterFiles(string baseDirectory, string filter) + { + foreach (var file in Directory.EnumerateFiles(baseDirectory, filter)) + { + if (!s_dllsToExcludeFromMef.Contains(Path.GetFileName(file))) + yield return file; + } + } + protected override void LogError(string message, Exception exception) => _logger.LogError(exception, message); diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj index d63392a41a7b7..cd8117b1774ac 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj @@ -83,6 +83,8 @@ + + diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs index 00218652078f4..4965d418fc847 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs @@ -211,18 +211,6 @@ static RootCommand CreateCommand() Required = false }; - var razorSourceGeneratorOption = new Option("--razorSourceGenerator") - { - Description = "Full path to the Razor source generator (optional).", - Required = false - }; - - var razorDesignTimePathOption = new Option("--razorDesignTimePath") - { - Description = "Full path to the Razor design time target path (optional).", - Required = false - }; - var csharpDesignTimePathOption = new Option("--csharpDesignTimePath") { Description = "Full path to the C# design time target path (optional).", @@ -272,8 +260,6 @@ static RootCommand CreateCommand() sessionIdOption, extensionAssemblyPathsOption, devKitDependencyPathOption, - razorSourceGeneratorOption, - razorDesignTimePathOption, csharpDesignTimePathOption, extensionLogDirectoryOption, serverPipeNameOption, @@ -291,7 +277,6 @@ static RootCommand CreateCommand() var sessionId = parseResult.GetValue(sessionIdOption); var extensionAssemblyPaths = parseResult.GetValue(extensionAssemblyPathsOption) ?? []; var devKitDependencyPath = parseResult.GetValue(devKitDependencyPathOption); - var razorDesignTimePath = parseResult.GetValue(razorDesignTimePathOption); var csharpDesignTimePath = parseResult.GetValue(csharpDesignTimePathOption); var extensionLogDirectory = parseResult.GetValue(extensionLogDirectoryOption); var serverPipeName = parseResult.GetValue(serverPipeNameOption); @@ -307,7 +292,6 @@ static RootCommand CreateCommand() SessionId: sessionId, ExtensionAssemblyPaths: extensionAssemblyPaths, DevKitDependencyPath: devKitDependencyPath, - RazorDesignTimePath: razorDesignTimePath, CSharpDesignTimePath: csharpDesignTimePath, ServerPipeName: serverPipeName, UseStdIo: useStdIo, diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/ServerConfigurationFactory.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/ServerConfigurationFactory.cs index 3e7c5b5e54a16..aa54bed643d05 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/ServerConfigurationFactory.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/ServerConfigurationFactory.cs @@ -48,7 +48,6 @@ internal sealed record class ServerConfiguration( string? SessionId, IEnumerable ExtensionAssemblyPaths, string? DevKitDependencyPath, - string? RazorDesignTimePath, string? CSharpDesignTimePath, string? ServerPipeName, bool UseStdIo, diff --git a/src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Microsoft.CodeAnalysis.Remote.Razor.csproj b/src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Microsoft.CodeAnalysis.Remote.Razor.csproj index 50f066188c286..4c68036fc03ac 100644 --- a/src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Microsoft.CodeAnalysis.Remote.Razor.csproj +++ b/src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Microsoft.CodeAnalysis.Remote.Razor.csproj @@ -22,7 +22,7 @@ true - win-x64;win-arm64 + win-x64;win-arm64;linux-x64;linux-arm64;linux-musl-x64;linux-musl-arm64;osx-x64;osx-arm64 diff --git a/src/Razor/src/Razor/src/Microsoft.VisualStudioCode.RazorExtension/Microsoft.VisualStudioCode.RazorExtension.csproj b/src/Razor/src/Razor/src/Microsoft.VisualStudioCode.RazorExtension/Microsoft.VisualStudioCode.RazorExtension.csproj index 9f3e80fea5499..820a15049c088 100644 --- a/src/Razor/src/Razor/src/Microsoft.VisualStudioCode.RazorExtension/Microsoft.VisualStudioCode.RazorExtension.csproj +++ b/src/Razor/src/Razor/src/Microsoft.VisualStudioCode.RazorExtension/Microsoft.VisualStudioCode.RazorExtension.csproj @@ -4,19 +4,13 @@ $(NetVSCode) enable - true + + false + false $(DefineConstants);VSCODE - - true - - - $(NoWarn);NU5100 - - PackPublishContent;$(BeforePack) + + false @@ -55,39 +49,10 @@ - true - content\Targets PreserveNewest - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/VisualStudio/DevKit/Impl/Logging/VSCodeTelemetryLogger.cs b/src/VisualStudio/DevKit/Impl/Logging/VSCodeTelemetryLogger.cs index 99c70e13fc181..063fff70a7c5b 100644 --- a/src/VisualStudio/DevKit/Impl/Logging/VSCodeTelemetryLogger.cs +++ b/src/VisualStudio/DevKit/Impl/Logging/VSCodeTelemetryLogger.cs @@ -60,7 +60,10 @@ public void InitializeSession(string telemetryLevel, string? sessionId, bool isD public void Log(string name, List> properties) { - Debug.Assert(_telemetrySession != null); + if (_telemetrySession is null) + { + return; + } var telemetryEvent = new TelemetryEvent(name); SetProperties(telemetryEvent, properties); @@ -69,7 +72,10 @@ public void Log(string name, List> properties) public void LogBlockStart(string eventName, int kind, int blockId) { - Debug.Assert(_telemetrySession != null); + if (_telemetrySession is null) + { + return; + } _pendingScopes[blockId] = kind switch { @@ -81,8 +87,10 @@ public void LogBlockStart(string eventName, int kind, int blockId) public void LogBlockEnd(int blockId, List> properties, CancellationToken cancellationToken) { - var found = _pendingScopes.TryRemove(blockId, out var scope); - Debug.Assert(found); + if (!_pendingScopes.TryRemove(blockId, out var scope)) + { + return; + } var endEvent = GetEndEvent(scope); SetProperties(endEvent, properties); @@ -99,7 +107,10 @@ public void LogBlockEnd(int blockId, List> propert public void ReportFault(string eventName, string description, int logLevel, bool forceDump, int processId, Exception exception) { - Debug.Assert(_telemetrySession != null); + if (_telemetrySession is null) + { + return; + } var faultEvent = new FaultEvent( eventName: eventName,