Skip to content

Commit

Permalink
Update component debugger to work for VS 2022 (#896)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chsienki authored Sep 16, 2021
1 parent e5420e2 commit 35a163b
Show file tree
Hide file tree
Showing 29 changed files with 648 additions and 220 deletions.
13 changes: 11 additions & 2 deletions Roslyn-SDK.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
5 changes: 3 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
<MicrosoftVisualStudioImagingInterop140DesignTimeVersion>16.8.30705.32</MicrosoftVisualStudioImagingInterop140DesignTimeVersion>
<MicrosoftVisualStudioImagingVersion>16.8.30406.65-pre</MicrosoftVisualStudioImagingVersion>
<MicrosoftVisualStudioLanguageStandardClassificationVersion>16.8.239</MicrosoftVisualStudioLanguageStandardClassificationVersion>
<MicrosoftVisualStudioProjectSystemManaged>16.8.1-beta1-1008-05</MicrosoftVisualStudioProjectSystemManaged>
<MicrosoftVisualStudioProjectSystemManagedVS>16.8.1-beta1-1008-05</MicrosoftVisualStudioProjectSystemManagedVS>
<MicrosoftVisualStudioProjectSystemManagedVersion>16.8.1-beta1-1008-05</MicrosoftVisualStudioProjectSystemManagedVersion>
<MicrosoftVisualStudioProjectSystemManagedVSVersion>16.8.1-beta1-1008-05</MicrosoftVisualStudioProjectSystemManagedVSVersion>
<MicrosoftVisualStudioProjectSystemSDKToolsVersion>16.8.338-pre</MicrosoftVisualStudioProjectSystemSDKToolsVersion>
<MicrosoftVisualStudioRpcContractsVersion>16.9.23-alpha</MicrosoftVisualStudioRpcContractsVersion>
<MicrosoftVisualStudioSDKAnalyzersVersion>16.7.9</MicrosoftVisualStudioSDKAnalyzersVersion>
<MicrosoftVisualStudioShell150Version>16.7.30329.88</MicrosoftVisualStudioShell150Version>
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Nullable>enable</Nullable>
<IsRoslynComponent>true</IsRoslynComponent>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="$(MicrosoftCodeAnalysisCommonVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8" ?>
<Rule Name="ComponentDebuggerLaunchProfile"
Description="Allows a user to debug a Roslyn Component by running it in the context of another projects build."
DisplayName="Roslyn Component"
PageTemplate="commandNameBasedDebugger"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns="http://schemas.microsoft.com/build/2009/properties">

<Rule.Metadata>
<sys:String x:Key="CommandName">DebugRoslynComponent</sys:String>

<!-- KnownImageIds.ImageCatalogGuid -->
<sys:Guid x:Key="ImageMonikerGuid">AE27A6B0-E345-4288-96DF-5EAF394EE369</sys:Guid>

<!-- KnownImageIds.Execute -->
<sys:Int32 x:Key="ImageMonikerId">3644</sys:Int32>
</Rule.Metadata>

<Rule.DataSource>
<DataSource Persistence="LaunchProfile"
HasConfigurationCondition="False"
ItemType="LaunchProfile"/>
</Rule.DataSource>

<DynamicEnumProperty Name="targetProject"
DisplayName="Target Project"
Description="A project that uses this component, whose compilation will be debugged."
EnumProvider="TargetProjectEnumProvider" />

<StringProperty Name="Description"
Description="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.">
<StringProperty.DataSource>
<DataSource PersistedName="Description"
Persistence="ProjectFileWithInterception"
HasConfigurationCondition="False" />
</StringProperty.DataSource>
<StringProperty.ValueEditors>
<ValueEditor EditorType="Description" />
</StringProperty.ValueEditors>
</StringProperty>

</Rule>
19 changes: 0 additions & 19 deletions src/VisualStudio.Roslyn.SDK/ComponentDebugger/DebuggerOptions.xaml

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
}

This file was deleted.

Loading

0 comments on commit 35a163b

Please sign in to comment.