From 35a163bcdb4474e9ea6053b21446bbad094fea9d Mon Sep 17 00:00:00 2001 From: Chris Sienkiewicz Date: Thu, 16 Sep 2021 11:20:45 -0700 Subject: [PATCH] Update component debugger to work for VS 2022 (#896) Update the component debugger to work in the new launch profiles format introduced in VS2022. See https://github.com/dotnet/project-system/blob/main/docs/repo/property-pages/how-to-add-a-new-launch-profile-kind.md for reference. Removes the old user control, and writing code which is now handled by the rule file (ComponentDebuggerLaunchProfile.xaml). Adds rule exporting and ProvideCodeBase so that VS can find the rule and apply it to matching projects. Tested on VS2022 using an existing launchsettings.json and confirmed projects show the new UI, and can add/remove as needed --- Roslyn-SDK.sln | 13 ++- eng/Versions.props | 5 +- .../AssemblyVersionGenerator.cs | 24 +++++ .../AssemblyVersionGenerator.csproj | 13 +++ .../ComponentDebuggerLaunchProfile.xaml | 43 ++++++++ .../ComponentDebugger/DebuggerOptions.xaml | 19 ---- .../ComponentDebugger/DebuggerOptions.xaml.cs | 14 --- .../DebuggerOptionsViewModel.cs | 61 ----------- .../LaunchSettingsManager.cs | 17 --- .../LaunchSettingsProvider.cs | 101 ------------------ .../ComponentDebugger/ProjectUtilities.cs | 28 +++++ .../Roslyn.ComponentDebugger.csproj | 18 +++- .../ComponentDebugger/RuleExporter.cs | 24 +++++ .../TargetProjectEnumProvider.cs | 67 ++++++++++++ ...ComponentDebuggerLaunchProfile.xaml.cs.xlf | 32 ++++++ ...ComponentDebuggerLaunchProfile.xaml.de.xlf | 32 ++++++ ...ComponentDebuggerLaunchProfile.xaml.es.xlf | 32 ++++++ ...ComponentDebuggerLaunchProfile.xaml.fr.xlf | 32 ++++++ ...ComponentDebuggerLaunchProfile.xaml.it.xlf | 32 ++++++ ...ComponentDebuggerLaunchProfile.xaml.ja.xlf | 32 ++++++ ...ComponentDebuggerLaunchProfile.xaml.ko.xlf | 32 ++++++ ...ComponentDebuggerLaunchProfile.xaml.pl.xlf | 32 ++++++ ...ponentDebuggerLaunchProfile.xaml.pt-BR.xlf | 32 ++++++ ...ComponentDebuggerLaunchProfile.xaml.ru.xlf | 32 ++++++ ...ComponentDebuggerLaunchProfile.xaml.tr.xlf | 32 ++++++ ...nentDebuggerLaunchProfile.xaml.zh-Hans.xlf | 32 ++++++ ...nentDebuggerLaunchProfile.xaml.zh-Hant.xlf | 32 ++++++ .../Roslyn.SDK/Properties/AssemblyInfo.cs | 1 + .../Roslyn.SDK/Roslyn.SDK.csproj | 4 +- 29 files changed, 648 insertions(+), 220 deletions(-) create mode 100644 src/VisualStudio.Roslyn.SDK/AssemblyVersionGenerator/AssemblyVersionGenerator.cs create mode 100644 src/VisualStudio.Roslyn.SDK/AssemblyVersionGenerator/AssemblyVersionGenerator.csproj create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/ComponentDebuggerLaunchProfile.xaml delete mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptions.xaml delete mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptions.xaml.cs delete mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptionsViewModel.cs delete mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/LaunchSettingsProvider.cs create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/RuleExporter.cs create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/TargetProjectEnumProvider.cs create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.cs.xlf create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.de.xlf create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.es.xlf create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.fr.xlf create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.it.xlf create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.ja.xlf create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.ko.xlf create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.pl.xlf create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.pt-BR.xlf create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.ru.xlf create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.tr.xlf create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.zh-Hans.xlf create mode 100644 src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.zh-Hant.xlf diff --git a/Roslyn-SDK.sln b/Roslyn-SDK.sln index ef1484fb0..ae7e94b1b 100644 --- a/Roslyn-SDK.sln +++ b/Roslyn-SDK.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29814.53 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31706.66 MinimumVisualStudioVersion = 15.0.26124.0 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{924F7971-780C-4E70-A306-86482469502E}" EndProject @@ -191,6 +191,10 @@ Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.Visu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.ComponentDebugger", "src\VisualStudio.Roslyn.SDK\ComponentDebugger\Roslyn.ComponentDebugger.csproj", "{421DE59C-8246-4679-9D69-79F16A7187BE}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "util", "util", "{7A94E723-ADD6-48C4-BBE7-1D5B311187A8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyVersionGenerator", "src\VisualStudio.Roslyn.SDK\AssemblyVersionGenerator\AssemblyVersionGenerator.csproj", "{AB6B3C69-9F6F-461C-BFD8-D3F25B9F44AD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -545,6 +549,10 @@ Global {421DE59C-8246-4679-9D69-79F16A7187BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {421DE59C-8246-4679-9D69-79F16A7187BE}.Release|Any CPU.ActiveCfg = Release|Any CPU {421DE59C-8246-4679-9D69-79F16A7187BE}.Release|Any CPU.Build.0 = Release|Any CPU + {AB6B3C69-9F6F-461C-BFD8-D3F25B9F44AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AB6B3C69-9F6F-461C-BFD8-D3F25B9F44AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AB6B3C69-9F6F-461C-BFD8-D3F25B9F44AD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AB6B3C69-9F6F-461C-BFD8-D3F25B9F44AD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -642,6 +650,7 @@ Global {7C3FE60E-055B-4E0C-BB85-C7E94A640074} = {9905147E-CC1F-42A0-BD27-05586C583DF7} {92BD1781-5DB4-4F72-BCCB-0D64C0790A2B} = {9905147E-CC1F-42A0-BD27-05586C583DF7} {421DE59C-8246-4679-9D69-79F16A7187BE} = {F9B73995-76C6-4056-ADA9-18342F951361} + {AB6B3C69-9F6F-461C-BFD8-D3F25B9F44AD} = {7A94E723-ADD6-48C4-BBE7-1D5B311187A8} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {56695AA9-EA80-47A7-8562-E51285906C54} diff --git a/eng/Versions.props b/eng/Versions.props index 24cdd4a44..f377a207d 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -38,8 +38,9 @@ 16.8.30705.32 16.8.30406.65-pre 16.8.239 - 16.8.1-beta1-1008-05 - 16.8.1-beta1-1008-05 + 16.8.1-beta1-1008-05 + 16.8.1-beta1-1008-05 + 16.8.338-pre 16.9.23-alpha 16.7.9 16.7.30329.88 diff --git a/src/VisualStudio.Roslyn.SDK/AssemblyVersionGenerator/AssemblyVersionGenerator.cs b/src/VisualStudio.Roslyn.SDK/AssemblyVersionGenerator/AssemblyVersionGenerator.cs new file mode 100644 index 000000000..84d961638 --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/AssemblyVersionGenerator/AssemblyVersionGenerator.cs @@ -0,0 +1,24 @@ +using System; +using System.Diagnostics; +using Microsoft.CodeAnalysis; + +namespace AssemblyVersionGenerator +{ + [Generator] + public class AssemblyVersionGenerator : ISourceGenerator + { + public void Execute(GeneratorExecutionContext context) + { + context.AddSource("assemblyversion.g.cs", $@" + +internal class AssemblyVersion +{{ + public const string Version = ""{context.Compilation.Assembly.Identity.Version}""; +}}"); + } + + public void Initialize(GeneratorInitializationContext context) + { + } + } +} diff --git a/src/VisualStudio.Roslyn.SDK/AssemblyVersionGenerator/AssemblyVersionGenerator.csproj b/src/VisualStudio.Roslyn.SDK/AssemblyVersionGenerator/AssemblyVersionGenerator.csproj new file mode 100644 index 000000000..6d0e593f4 --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/AssemblyVersionGenerator/AssemblyVersionGenerator.csproj @@ -0,0 +1,13 @@ + + + + netstandard2.0 + enable + true + + + + + + + diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/ComponentDebuggerLaunchProfile.xaml b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/ComponentDebuggerLaunchProfile.xaml new file mode 100644 index 000000000..656b12969 --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/ComponentDebuggerLaunchProfile.xaml @@ -0,0 +1,43 @@ + + + + + DebugRoslynComponent + + + AE27A6B0-E345-4288-96DF-5EAF394EE369 + + + 3644 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptions.xaml b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptions.xaml deleted file mode 100644 index b431658e4..000000000 --- a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptions.xaml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptions.xaml.cs b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptions.xaml.cs deleted file mode 100644 index 56459afeb..000000000 --- a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptions.xaml.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Roslyn.ComponentDebugger -{ - partial class DebuggerOptions - { - public DebuggerOptions() - { - InitializeComponent(); - } - } -} diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptionsViewModel.cs b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptionsViewModel.cs deleted file mode 100644 index 180012a97..000000000 --- a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptionsViewModel.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// 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; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.ComponentModel; -using System.Linq; -using System.Runtime.CompilerServices; - -namespace Roslyn.ComponentDebugger -{ - internal sealed class DebuggerOptionsViewModel : INotifyPropertyChanged - { - private readonly Action _indexChanged; - - private IEnumerable _projectNames = ImmutableArray.Empty; - - private int _selectedProjectIndex = -1; - - public event PropertyChangedEventHandler? PropertyChanged; - - public DebuggerOptionsViewModel(Action indexChanged) - { - _indexChanged = indexChanged; - } - - public IEnumerable ProjectNames - { - get => _projectNames; - set - { - if (!_projectNames.SequenceEqual(value)) - { - _projectNames = value; - NotifyPropertyChanged(); - } - } - } - - public int SelectedProjectIndex - { - get => _selectedProjectIndex; - set - { - if (_selectedProjectIndex != value) - { - _selectedProjectIndex = value; - NotifyPropertyChanged(); - _indexChanged?.Invoke(value); - } - } - } - - private void NotifyPropertyChanged([CallerMemberName]string propertyName = "") - { - this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - } -} diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/LaunchSettingsManager.cs b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/LaunchSettingsManager.cs index 6d9c97236..44a5d49a2 100644 --- a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/LaunchSettingsManager.cs +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/LaunchSettingsManager.cs @@ -38,22 +38,5 @@ public LaunchSettingsManager(UnconfiguredProject owningProject, IDebugTokenRepla } return targetProject; } - - public void WriteProjectForLaunch(IWritableLaunchProfile profile, UnconfiguredProject targetProject) - { - if (profile is null) - { - throw new System.ArgumentNullException(nameof(profile)); - } - - if (targetProject is null) - { - throw new System.ArgumentNullException(nameof(targetProject)); - } - - var rootedPath = _owningProject.MakeRelative(targetProject.FullPath); - profile.OtherSettings[Constants.TargetProjectKeyName] = rootedPath; - } - } } diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/LaunchSettingsProvider.cs b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/LaunchSettingsProvider.cs deleted file mode 100644 index 43b54a2d7..000000000 --- a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/LaunchSettingsProvider.cs +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// 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; -using System.Collections.Immutable; -using System.ComponentModel.Composition; -using System.IO; -using System.Linq; -using System.Windows.Controls; -using Microsoft.VisualStudio.ProjectSystem; -using Microsoft.VisualStudio.ProjectSystem.Debug; -using Microsoft.VisualStudio.Utilities; -using Task = System.Threading.Tasks.Task; - -namespace Roslyn.ComponentDebugger -{ - [Export(typeof(ILaunchSettingsUIProvider))] - [AppliesTo(Constants.RoslynComponentCapability)] - public class LaunchSettingsProvider : ILaunchSettingsUIProvider - { - private readonly IProjectThreadingService _threadingService; - private readonly UnconfiguredProject _unconfiguredProject; - private readonly LaunchSettingsManager _launchSettingsManager; - private readonly DebuggerOptionsViewModel _viewModel; - - private ImmutableArray _projects; - private IWritableLaunchProfile? _launchProfile; - - [ImportingConstructor] - [Obsolete("This exported object must be obtained through the MEF export provider.", error: true)] - public LaunchSettingsProvider(IProjectThreadingService threadingService, UnconfiguredProject unconfiguredProject, LaunchSettingsManager launchSettingsManager) - { - _threadingService = threadingService; - _unconfiguredProject = unconfiguredProject; - _launchSettingsManager = launchSettingsManager; - _viewModel = new DebuggerOptionsViewModel(IndexChanged); - } - - public string CommandName { get => Constants.CommandName; } - - // https://github.com/dotnet/roslyn-sdk/issues/730 : localization - public string FriendlyName { get => "Roslyn Component"; } - - public UserControl? CustomUI { get => new DebuggerOptions() { DataContext = _viewModel }; } - - public void ProfileSelected(IWritableLaunchSettings curSettings) - { - _launchProfile = curSettings?.ActiveProfile; - _threadingService.ExecuteSynchronously(UpdateViewModelAsync); - } - - public bool ShouldEnableProperty(string propertyName) - { - // we disable all the default options for a debugger. - // in the future we might want to enable env vars and (potentially) the exe to allow - // customization of the compiler used? - return false; - } - - private async Task UpdateViewModelAsync() - { - var targetProjects = ArrayBuilder.GetInstance(); - - // get the output assembly for this project - var projectArgs = await _unconfiguredProject.GetCompilationArgumentsAsync().ConfigureAwait(false); - var targetArg = projectArgs.LastOrDefault(a => a.StartsWith("/out:", StringComparison.OrdinalIgnoreCase)); - var target = Path.GetFileName(targetArg); - - var projectService = _unconfiguredProject.Services.ProjectService; - foreach (var targetProjectUnconfigured in projectService.LoadedUnconfiguredProjects) - { - // check if the args contain the project as an analyzer ref - foreach (var arg in await targetProjectUnconfigured.GetCompilationArgumentsAsync().ConfigureAwait(false)) - { - if (arg.StartsWith("/analyzer:", StringComparison.OrdinalIgnoreCase) - && arg.EndsWith(target, StringComparison.OrdinalIgnoreCase)) - { - targetProjects.Add(targetProjectUnconfigured); - } - } - } - _projects = targetProjects.ToImmutableAndFree(); - - var launchTargetProject = await _launchSettingsManager.TryGetProjectForLaunchAsync(_launchProfile?.ToLaunchProfile()).ConfigureAwait(true); - var index = _projects.IndexOf(launchTargetProject!); - - _viewModel.ProjectNames = _projects.Select(p => Path.GetFileNameWithoutExtension(p.FullPath)); - _viewModel.SelectedProjectIndex = index; - } - - private void IndexChanged(int newIndex) - { - if (_launchProfile is object && !_projects.IsDefaultOrEmpty && newIndex >= 0 && newIndex < _projects.Length) - { - var project = _projects[newIndex]; - _launchSettingsManager.WriteProjectForLaunch(_launchProfile, project); - } - } - } -} diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/ProjectUtilities.cs b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/ProjectUtilities.cs index b20cc3115..4c2a4a769 100644 --- a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/ProjectUtilities.cs +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/ProjectUtilities.cs @@ -4,13 +4,41 @@ using System; using System.Collections.Immutable; +using System.IO; +using System.Linq; using System.Threading.Tasks; using Microsoft.VisualStudio.ProjectSystem; +using Microsoft.VisualStudio.Utilities; namespace Roslyn.ComponentDebugger { public static class ProjectUtilities { + public static async Task> GetComponentReferencingProjectsAsync(this UnconfiguredProject unconfiguredProject) + { + var targetProjects = ArrayBuilder.GetInstance(); + + // get the output assembly for this project + var projectArgs = await unconfiguredProject.GetCompilationArgumentsAsync().ConfigureAwait(false); + var targetArg = projectArgs.LastOrDefault(a => a.StartsWith("/out:", StringComparison.OrdinalIgnoreCase)); + var target = Path.GetFileName(targetArg); + + var projectService = unconfiguredProject.Services.ProjectService; + foreach (var targetProjectUnconfigured in projectService.LoadedUnconfiguredProjects) + { + // check if the args contain the project as an analyzer ref + foreach (var arg in await targetProjectUnconfigured.GetCompilationArgumentsAsync().ConfigureAwait(false)) + { + if (arg.StartsWith("/analyzer:", StringComparison.OrdinalIgnoreCase) + && arg.EndsWith(target, StringComparison.OrdinalIgnoreCase)) + { + targetProjects.Add(targetProjectUnconfigured); + } + } + } + return targetProjects.ToImmutableAndFree(); + } + public static Task> GetCompilationArgumentsAsync(this UnconfiguredProject project) { if (project is null) diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/Roslyn.ComponentDebugger.csproj b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/Roslyn.ComponentDebugger.csproj index c64c4c359..70a284665 100644 --- a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/Roslyn.ComponentDebugger.csproj +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/Roslyn.ComponentDebugger.csproj @@ -8,13 +8,27 @@ enable true + + + + Never + MSBuild:GenerateRuleSourceFromXaml + Designer + None + None + + + + + - - + + + diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/RuleExporter.cs b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/RuleExporter.cs new file mode 100644 index 000000000..38382da9f --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/RuleExporter.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.VisualStudio.ProjectSystem; +using Microsoft.VisualStudio.ProjectSystem.Properties; + +namespace Roslyn.ComponentDebugger +{ + internal static class RuleExporter + { + /// + /// Used to export the XAML rule via MEF + /// + [ExportPropertyXamlRuleDefinition( + xamlResourceAssemblyName: "Roslyn.ComponentDebugger, Version=" + AssemblyVersion.Version + ", Culture=neutral, PublicKeyToken=31bf3856ad364e35", + xamlResourceStreamName: "XamlRuleToCode:ComponentDebuggerLaunchProfile.xaml", + context: PropertyPageContexts.Project)] + [AppliesTo(Constants.RoslynComponentCapability)] +#pragma warning disable CS0649 + public static int LaunchProfileRule; +#pragma warning restore CS0649 + } +} diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/TargetProjectEnumProvider.cs b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/TargetProjectEnumProvider.cs new file mode 100644 index 000000000..23582bd2a --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/TargetProjectEnumProvider.cs @@ -0,0 +1,67 @@ +// Licensed to the .NET Foundation under one or more agreements. +// 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; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.ComponentModel.Composition; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Build.Framework.XamlTypes; +using Microsoft.VisualStudio.ProjectSystem; +using Microsoft.VisualStudio.ProjectSystem.Properties; + +namespace Roslyn.ComponentDebugger +{ + [ExportDynamicEnumValuesProvider(nameof(TargetProjectEnumProvider))] + [AppliesTo(Constants.RoslynComponentCapability)] + public class TargetProjectEnumProvider : IDynamicEnumValuesProvider + { + private readonly UnconfiguredProject _unconfiguredProject; + private readonly LaunchSettingsManager _launchSettingsManager; + + [ImportingConstructor] + public TargetProjectEnumProvider(UnconfiguredProject unconfiguredProject, LaunchSettingsManager launchSettingsManager) + { + _unconfiguredProject = unconfiguredProject; + _launchSettingsManager = launchSettingsManager; + } + + public async Task GetProviderAsync(IList? options) + { + // get the targets for this project + var projects = await _unconfiguredProject.GetComponentReferencingProjectsAsync().ConfigureAwait(false); + + // convert to display values of friendly name + relative path + var displayValues = projects.Select(p => (Path.GetFileNameWithoutExtension(p.FullPath), _unconfiguredProject.MakeRelative(p.FullPath))).ToImmutableArray(); + + return new TargetProjectEnumValuesGenerator(displayValues); + } + + private class TargetProjectEnumValuesGenerator : IDynamicEnumValuesGenerator + { + private readonly ImmutableArray<(string display, string path)> _referencingProjects; + + public bool AllowCustomValues => false; + + public TargetProjectEnumValuesGenerator(ImmutableArray<(string display, string path)> referencingProjects) + { + _referencingProjects = referencingProjects; + } + + public Task> GetListedValuesAsync() + { + var values = _referencingProjects.Select(p => new PageEnumValue(new EnumValue() { DisplayName = p.display, Name = p.path})).Cast().ToImmutableArray(); + return Task.FromResult>(values); + } + + /// + /// The user can't add arbitrary projects from the UI, so this is unsupported + /// + public Task TryCreateEnumValueAsync(string userSuppliedValue) => Task.FromResult(null); + } + } +} diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.cs.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.cs.xlf new file mode 100644 index 000000000..70107d3d7 --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.cs.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.de.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.de.xlf new file mode 100644 index 000000000..3f73ba68a --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.de.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.es.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.es.xlf new file mode 100644 index 000000000..49696eefb --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.es.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.fr.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.fr.xlf new file mode 100644 index 000000000..b0ad7e720 --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.fr.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.it.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.it.xlf new file mode 100644 index 000000000..6e9993b18 --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.it.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.ja.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.ja.xlf new file mode 100644 index 000000000..38b0fc455 --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.ja.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.ko.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.ko.xlf new file mode 100644 index 000000000..55caf820f --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.ko.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.pl.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.pl.xlf new file mode 100644 index 000000000..d623a3953 --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.pl.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.pt-BR.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.pt-BR.xlf new file mode 100644 index 000000000..d93d99696 --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.pt-BR.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.ru.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.ru.xlf new file mode 100644 index 000000000..5890416c8 --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.ru.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.tr.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.tr.xlf new file mode 100644 index 000000000..8c8db3e8f --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.tr.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.zh-Hans.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.zh-Hans.xlf new file mode 100644 index 000000000..1e3273ef3 --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.zh-Hans.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.zh-Hant.xlf b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.zh-Hant.xlf new file mode 100644 index 000000000..5720b1a0c --- /dev/null +++ b/src/VisualStudio.Roslyn.SDK/ComponentDebugger/xlf/ComponentDebuggerLaunchProfile.xaml.zh-Hant.xlf @@ -0,0 +1,32 @@ + + + + + + A project that uses this component, whose compilation will be debugged. + A project that uses this component, whose compilation will be debugged. + + + + Target Project + Target Project + + + + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + Allows a user to debug a Roslyn Component by running it in the context of another projects build. + + + + Roslyn Component + Roslyn Component + + + + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + A Roslyn Component can be debugged in the context of compiling a second project that uses it. Ensure your target project is referencing this component for it to appear in the list. + + + + + \ No newline at end of file diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/Properties/AssemblyInfo.cs b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/Properties/AssemblyInfo.cs index 6ccb8544f..710a6f0cb 100644 --- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/Properties/AssemblyInfo.cs +++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/Properties/AssemblyInfo.cs @@ -5,3 +5,4 @@ using Microsoft.VisualStudio.Shell; [assembly: ProvideBindingRedirection(CodeBase = "Roslyn.SDK.Template.Wizard.dll", OldVersionLowerBound = "1.0.0.0")] +[assembly: ProvideCodeBase(AssemblyName = "Roslyn.ComponentDebugger", CodeBase = "$PackageFolder$\\Roslyn.ComponentDebugger.dll")] diff --git a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/Roslyn.SDK.csproj b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/Roslyn.SDK.csproj index 370c4ea74..13601d250 100644 --- a/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/Roslyn.SDK.csproj +++ b/src/VisualStudio.Roslyn.SDK/Roslyn.SDK/Roslyn.SDK.csproj @@ -122,8 +122,8 @@ Roslyn.ComponentDebugger - BuiltProjectOutputGroup%3bGetCopyToOutputDirectoryItems%3b - DebugSymbolsProjectOutputGroup%3b + BuiltProjectOutputGroup%3bGetCopyToOutputDirectoryItems + DebugSymbolsProjectOutputGroup true false