-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove direct dependency on CommandLineParser #1876
Conversation
get { return new VisualBasicParseCommandLineArguments(); } | ||
} | ||
|
||
internal class VisualBasicParseCommandLineArguments : IParseCommandLineArguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of continuing with the Export property approach, turn this inner class into the actual thing that is exporting.
|
||
internal class VisualBasicParseCommandLineArguments : IParseCommandLineArguments | ||
{ | ||
private VisualBasicCommandLineParser _parser = VisualBasicCommandLineParser.Default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you even need a field here - why can you just call through Default property in the Parse method?
While this removes the dependency on CommandLineParser - it still has a dependency on CommandLineArguments won't this suffer the same problem? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
I've made some changes as requested by @davkean by factoring out a class that only contains the properties consumed on Microsoft.CodeAnalysis.CommandLineArguments. There is one oddity, left, however: If I try to export the command line parser classes directly then I get the error:
But I get no error when I use an Edit: |
I think that warning comes from a buggy analyzer and the warning's been suppressed in other projects. |
@@ -25,6 +25,7 @@ | |||
<ProjectReference Include="..\DeployTestDependencies\DeployTestDependencies.csproj"> | |||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly> | |||
</ProjectReference> | |||
<ProjectReference Include="..\Microsoft.VisualStudio.ProjectSystem.CSharp\Microsoft.VisualStudio.ProjectSystem.CSharp.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right? Seems like a layer violation - managed.unittests shouldn't know about C#
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed.
CSharpCommandLineParser.Default.Parse(args, baseDirectory, sdkDirectory: null, additionalReferenceDirectories: null)); | ||
} | ||
|
||
[Export(typeof(IParseCommandLineArguments))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply this to the class, the property is unneeded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do; I'll have to disable the analyzer as per @srivatsn's comment.
|
||
public CommandLineArguments Parse(IEnumerable<string> args, string baseDirectory) | ||
{ | ||
return CommandLineArguments.FromCommonCommandLineArguments( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see below why, sync up with me and we can discuss the approach.
|
||
namespace Microsoft.VisualStudio.ProjectSystem.LanguageServices | ||
{ | ||
public class CSharpParseCommandLineArguments : IParseCommandLineArguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark this internal.
|
||
namespace Microsoft.VisualStudio.ProjectSystem.LanguageServices | ||
{ | ||
public class CommandLineArguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't do this - your throwing away all options. TBH, I'm not sure how this is compiling - we pass this over to IWorkspaceContext as a CommandLineArguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I searched for all references to the Microsoft.CodeAnalysis.CommandLineArguments
type and only the four properties reflected in this class were ever used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, we used to pass this thing as SetOptions but now we pass a string. I stand corrected. If you're doing the work here to open this up, why do you still need to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to expose the constructors so F# can create these types that are still used after this PR is merged. I originally looked at opening up the entire Microsoft.CodeAnalysis.CommandLineArguments
type but that quickly snowballed (Koala-balled? I'm having trouble coming up with an Australian version of this 😄) into exposing way more stuff than we probably ever wanted too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brettfo I'm still confuised, if we're opening up CommandLineArgunents why we do need to wrap the type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not opening up CommandLineArguments
, because that quickly snowballed into opening up way more internal stuff than we'd like. I'm only opening up the constructors to the structs that this new type contains in its IEnumerable<>
properties, and the properties on this class are the only things that were being used, anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
Updated with review feedback as per @davkean. |
This will enable non-Roslyn languages like F# to provide CommandLineOptions.
Ping for review now that I've fixed the latest merge conflicts. |
Okay, can we change the name of the type CommandLineArguments so that it doesn't conflict with the Code Analysis version and I can sign off. |
Given that the class doesn't have much to do with the command line any more I propose |
BuildOptions sounds good. |
This is based off of @srivatsn's work in #1670.
I wanted to get this out for review, but since #1670 hasn't been merged yet, I'm including those commits just so that stuff will build. I'll re-base from
master
before merging, but I really just wanted to get some feedback about this, first. As such, you should only be considering the last commit made by me. Refer to Sri's PR for the rest of the work.In short, this PR removes the dependence on the type
CommandLineParser
because it has numerousinternal
components and deriving from that for F# would either require additionalInternalsVisibleTo
elements in the Roslyn code base (which we don't want) or it would require making numerous types and APIs public, which seems heavy-handed. So the solution I went with simply adds an interface that has oneParse()
method that matchesCommandLineParser.Parse()
exactly so that F# can play along, too.This work is dependent on my other PR, dotnet/roslyn#18258.