Add component debugger - #726
Conversation
| // PROTOTYPE: is there a way to get this other than hardcoding it? | ||
| static readonly string[] CommandLineSchemaRuleNames = new[] { "CompilerCommandLineArgs" }; | ||
|
|
||
| public static async Task<IList<string>> GetCompilationArgumentsAsync(this ConfiguredProject project) |
There was a problem hiding this comment.
📝This is a place I'd like to get the project system folks to take a look at how we're getting the value.
|
@mikadumont @jaredpar @jasonmalinowski @sharwell for initial review of this. The code is in a fairly good shape, but there are I'd also like to get the project system folks involved as it's based on their stuff. @jjmew Can we get some of your folks to take a look at the implementation? |
|
|
||
| namespace Roslyn.ComponentDebugger | ||
| { | ||
| internal class Constants |
There was a problem hiding this comment.
| internal class Constants | |
| internal static class Constants | |
| ``` #Resolved |
jaredpar
left a comment
There was a problem hiding this comment.
Modulo getting the prototype comments shifted to point to an issue that we can trakc
- Implement token replacment for the launch settings file - Add issues for other prototypes
| // an alternative design could be to have 'IsRoslynComponent' just define the <Capability... directly in the managed.core targets | ||
| // but that would require a specific roslyn version to work, this allows it to be backwards compatible with older SDKs | ||
| var caps = Empty.CapabilitiesSet; | ||
| if (await IsRoslynComponentAsync(this.ConfiguredProject, cancellationToken).ConfigureAwait(false)) |
There was a problem hiding this comment.
This is mixing dataflow and live project data, which you can't do.
You need to listen to and pull on the ProjectInstance to get the property via dataflow, here's an example: https://github.com/dotnet/project-system/blob/b7fd4c439d1d39b656d89a8b88464fabffcc8e59/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Web/ProjectTypeGuidsDataSource.cs.
There was a problem hiding this comment.
@davkean Oh, interesting. There are classes in the devdiv repo that use this exact pattern. The base class seems to subscribe to events, so I figured it was designed to explicitly not need dataflow stuff.
I'll try and use the example to create a dataflow version.
tmeschter
left a comment
There was a problem hiding this comment.
Other than working out the data flow issue, mostly looks good.
Ordinal comparison for debug command more nuget
| var caps = Empty.CapabilitiesSet; | ||
| if (await IsRoslynComponentAsync(this.ConfiguredProject, cancellationToken).ConfigureAwait(false)) | ||
|
|
||
| var snapshot = await snapshotService.GetLatestVersionAsync(ConfiguredProject, cancellationToken: cancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
Thanks @davkean and @tmeschter. I switched the cap provider over to this, which is the same way the 'get command line args' stuff works. Is that a valid way to handle getting it via dataflow?
There was a problem hiding this comment.
No. This needs to chain similar to what I pointed out here: https://github.com/dotnet/project-system/blob/feature/AspNet/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Web/ProjectTypeGuidsDataSource.cs.
These systems flow data from one data source -> another, you need to transform the data as it flows along the pipe. This code just grabs the latest version from the snapshot pipe and sets up no relationship between the pipes, so we never know to call this pipe when the data changes.
There was a problem hiding this comment.
But isn't that handled by the base class? It sets up the pipe stuff and calls this method as it changes? I guess thats the bit I don't understand.
There was a problem hiding this comment.
No. Here you basically saying "I am the start of a pipe, and I will tell you when there are changes". What you want to say is "My pipe is based on the snapshot data, so when it changes, call me".
There was a problem hiding this comment.
This stuff is complicated and hard to get right - I can sit down and write it with you.
| namespace Roslyn.ComponentDebugger | ||
| { | ||
| [Export(ExportContractNames.Scopes.ConfiguredProject, typeof(IProjectCapabilitiesProvider))] | ||
| [AppliesTo(ProjectCapabilities.CSharp + " | " + ProjectCapabilities.VB)] |
There was a problem hiding this comment.
This component will load for every C# and VB project, we need a better approach for this. Is there something unique about these projects?
There was a problem hiding this comment.
This also loads for Shared Projects.
There was a problem hiding this comment.
It can apply to any project that has the <IsRoslyComponent>true</IsRoslynComponent>. So we load the provider for all projects and add the capability to any that match that.
Is there some better way to achieve that? I mentioned in the comments we could do it via the targets, but that does require a matching roslyn version.
There was a problem hiding this comment.
Is there a targets file that it imports we can match on?
There was a problem hiding this comment.
No, its just a regular old csharp project.
There was a problem hiding this comment.
I mentioned in the comments we could do it via the targets, but that does require a matching roslyn version.
Can you expand on what you mean by this? You mean if the project itself has a package reference to a different version of the compiler?
There was a problem hiding this comment.
Yeah. We could drop the capability provider altogether if we just added the following to the targets file
<ItemGroup Condition="'$(IsRoslynComponent)' == 'true'">
<Capability Include="RoslynComponent">
</ItemGroup>But anyone using an older version of the compiler via NuGet wouldn't get the capability, and be able to use it. That might be worth the tradeoff to remove some of the complexity here tho.
|
This got merged in without any sign off from any project-system folks, can we please undo that? |
|
I've reverted this change, sorry @chsienki! I think you will need to submit a new one. |
* Component Debugger - See #726 * Add command line data source: - add data source to obtain command line args - use data source in extension method - extract out shared logic into launchsettingsmanager - clean up VM code * Remove capability provider - Use targets directly instead
* Component Debugger - See dotnet/roslyn-sdk#726 * Add command line data source: - add data source to obtain command line args - use data source in extension method - extract out shared logic into launchsettingsmanager - clean up VM code * Remove capability provider - Use targets directly instead
Adds the prototype Roslyn component debugger to the SDK.
UX
User adds
<IsRoslynComponent>true</IsRoslynComponent>to their generator project fileThis enables the 'Roslyn Component' debugger option in debug settings (Project Properties -> Debug)
A user chooses the appropriate target project
User F5's the generator project which starts CSC.exe/VBC.exe building the target project allowing them to debug the generator code.
Known Issues
FAQ