-
Notifications
You must be signed in to change notification settings - Fork 417
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
Codeactions with options/ui. #1406
Merged
filipw
merged 58 commits into
OmniSharp:master
from
savpek:feature/codeactions-with-options
Jul 10, 2019
Merged
Changes from 28 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
eea9dfc
Initial version of actions with options.
savpek cbf1877
Fixes.
savpek 70d3dc9
Fixes for extract interface.
savpek 9d95a01
First test.
savpek 84224b5
More tests.
savpek 5437959
Tweaks and comments.
savpek 761f657
Original global.json
savpek 274e3c7
Merge branch 'master' into feature/codeactions-with-options
savpek ca9ecb3
Blacklisting.
savpek a7c21ff
Merge branch 'feature/codeactions-with-options' of https://github.com…
savpek 8a298e5
Added test to keep track is official support added.
savpek c773575
Tests for blacklisting.
savpek f17aeeb
small comment tweak.
savpek 9dd4cef
Merge branch 'master' into feature/codeactions-with-options
savpek 2a199b1
Merge branch 'master' into feature/codeactions-with-options
savpek fca2bb4
Merge branch 'master' into feature/codeactions-with-options
savpek 17eb6d9
Merge branch 'master' into feature/codeactions-with-options
savpek ac93122
Merge branch 'master' into feature/codeactions-with-options
savpek 4659787
Moved to dispatch proxy.
savpek 596cbe6
Merge from upstream/master
savpek 5690dc1
Fixes for extract interface test.
savpek 401e66e
Removed debug line which was forgotten.
savpek 4a65088
Merge branch 'master' into feature/codeactions-with-options
savpek 9efd76d
Merge branch 'master' into feature/codeactions-with-options
savpek f1a6061
Few review fixes.
savpek a06b47b
Merge branch 'feature/codeactions-with-options' of https://github.com…
savpek f136bf1
Refactored action facts to base class.
savpek a04812a
Merge branch 'master' into feature/codeactions-with-options
savpek 0332ef6
Removed multiple reflection calls.
savpek 1f47071
Merge branch 'feature/codeactions-with-options' of https://github.com…
savpek e60dc68
Merge branch 'master' into feature/codeactions-with-options
savpek 1aeab24
Merge branch 'master' into feature/codeactions-with-options
savpek 963c708
Attempt to fix test with net 472 hash code genenerator function.
savpek 515f691
Additional fix.
savpek c6a3683
Trigger build.
savpek 57543fc
Testfix to support multiple hashcode implementations per frameworks.
savpek 2afb64a
Merge branch 'master' into feature/codeactions-with-options
savpek 9949e56
Merge branch 'master' into feature/codeactions-with-options
savpek 1138ac8
Merge branch 'master' into feature/codeactions-with-options
savpek 79e0390
Merge branch 'master' into feature/codeactions-with-options
savpek 7099e22
Merge branch 'master' into feature/codeactions-with-options
savpek 26aaac9
Merge branch 'master' into feature/codeactions-with-options
savpek 9b9ac63
Merge branch 'master' into feature/codeactions-with-options
savpek 0471c2e
Merge branch 'master' into feature/codeactions-with-options
savpek dab7a8c
Merge branch 'master' into feature/codeactions-with-options
savpek 03c31f6
Merge branch 'master' into feature/codeactions-with-options
savpek a463572
Merge branch 'master' into feature/codeactions-with-options
savpek bbc31ad
Merge branch 'master' into feature/codeactions-with-options
filipw 2c13068
Merge branch 'master' into feature/codeactions-with-options
savpek 90c7d93
Merge.
savpek fbf7d36
Testfix.
savpek 49c01c1
Merge branch 'master' into feature/codeactions-with-options
savpek 281ad00
Merge branch 'master' into feature/codeactions-with-options
savpek 22e1789
Merge branch 'master' into feature/codeactions-with-options
david-driscoll 672a012
Merge branch 'master' into feature/codeactions-with-options
savpek c8085c0
Merge branch 'master' into feature/codeactions-with-options
filipw 67277c1
Merge branch 'master' into feature/codeactions-with-options
savpek 01a5aca
Merge branch 'master' into feature/codeactions-with-options
savpek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...slyn/WorkspaceServices/ExportWorkspaceServiceFactoryWithAssemblyQualifiedNameAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Composition; | ||
using System.Reflection; | ||
using Microsoft.CodeAnalysis.Host.Mef; | ||
|
||
namespace OmniSharp | ||
{ | ||
[MetadataAttribute] | ||
[AttributeUsage(AttributeTargets.Class)] | ||
public class ExportWorkspaceServiceFactoryWithAssemblyQualifiedNameAttribute : ExportAttribute | ||
{ | ||
public string ServiceType { get; } | ||
public string Layer { get; } | ||
|
||
// Theres builtin public attribute for this, but since we target internal types | ||
// this is needed to build service. MEF doesn't care is it internal or not. | ||
public ExportWorkspaceServiceFactoryWithAssemblyQualifiedNameAttribute(string typeAssembly, string typeName, string layer = ServiceLayer.Host) | ||
: base(typeof(IWorkspaceServiceFactory)) | ||
{ | ||
var type = Assembly.Load(typeAssembly).GetType(typeName) | ||
?? throw new InvalidOperationException($"Could not resolve '{typeName} from '{typeAssembly}'"); | ||
|
||
this.ServiceType = type.AssemblyQualifiedName; | ||
this.Layer = layer ?? throw new ArgumentNullException(nameof(layer)); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/OmniSharp.Roslyn/WorkspaceServices/ExtractInterfaceWorkspaceService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace OmniSharp | ||
{ | ||
public class ExtractInterfaceWorkspaceService : DispatchProxy | ||
{ | ||
protected override object Invoke(MethodInfo targetMethod, object[] args) | ||
{ | ||
// IExtractInterfaceOptionsService and extract interface results are internal types -> workaround with proxy. | ||
// This service simply passes all members through as selected and doesn't try show UI. | ||
// When roslyn exposes this interface and members -> remove this workaround. | ||
var resultTypeInternal = Assembly.Load("Microsoft.CodeAnalysis.Features").GetType("Microsoft.CodeAnalysis.ExtractInterface.ExtractInterfaceOptionsResult"); | ||
var enumType = resultTypeInternal.GetNestedTypes().Single(x => x.Name == "ExtractLocation"); | ||
|
||
var toSameFileEnumValue = Enum.Parse(enumType, "SameFile"); | ||
|
||
var interfaceName = args[3] ?? throw new InvalidOperationException($"{nameof(ExtractInterfaceWorkspaceService)} default interface name was null."); | ||
|
||
var resultObject = Activator.CreateInstance(resultTypeInternal, new object[] { | ||
false, // isCancelled | ||
((List<ISymbol>)args[2]).ToImmutableArray(), // InterfaceMembers selected -> select all. | ||
interfaceName, | ||
$"{interfaceName}.cs", | ||
toSameFileEnumValue | ||
}); | ||
|
||
return typeof(Task).GetMethod("FromResult").MakeGenericMethod(resultTypeInternal).Invoke(null, new[] { resultObject }); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/OmniSharp.Roslyn/WorkspaceServices/ExtractInterfaceWorkspaceServiceFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Composition; | ||
using System.Reflection; | ||
using Microsoft.CodeAnalysis.Host; | ||
using Microsoft.CodeAnalysis.Host.Mef; | ||
|
||
namespace OmniSharp | ||
{ | ||
[Shared] | ||
[ExportWorkspaceServiceFactoryWithAssemblyQualifiedName("Microsoft.CodeAnalysis.Features", "Microsoft.CodeAnalysis.ExtractInterface.IExtractInterfaceOptionsService")] | ||
public class ExtractInterfaceWorkspaceServiceFactory : IWorkspaceServiceFactory | ||
{ | ||
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) | ||
{ | ||
// Generates proxy class to get around issue that IExtractInterfaceOptionsService is internal at this point. | ||
var internalType = Assembly.Load("Microsoft.CodeAnalysis.Features").GetType("Microsoft.CodeAnalysis.ExtractInterface.IExtractInterfaceOptionsService"); | ||
return (IWorkspaceService)typeof(DispatchProxy).GetMethod(nameof(DispatchProxy.Create)).MakeGenericMethod(internalType, typeof(ExtractInterfaceWorkspaceService)).Invoke(null, null); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/OmniSharp.Roslyn/WorkspaceServices/PickMemberWorkspaceService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace OmniSharp | ||
{ | ||
public class PickMemberWorkspaceService : DispatchProxy | ||
{ | ||
protected override object Invoke(MethodInfo targetMethod, object[] args) | ||
{ | ||
// IPickMember and PickMemberResults are internal types -> workaround with proxy. | ||
// This service simply passes all members through as selected and doesn't try show UI. | ||
// When roslyn exposes this interface and members -> remove this workaround. | ||
var resultTypeInternal = Assembly.Load("Microsoft.CodeAnalysis.Features").GetType("Microsoft.CodeAnalysis.PickMembers.PickMembersResult"); | ||
return Activator.CreateInstance(resultTypeInternal, new object[] { args[1], args[2] }); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/OmniSharp.Roslyn/WorkspaceServices/PickMemberWorkspaceServiceFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Composition; | ||
using System.Reflection; | ||
using Microsoft.CodeAnalysis.Host; | ||
using Microsoft.CodeAnalysis.Host.Mef; | ||
|
||
namespace OmniSharp | ||
{ | ||
[Shared] | ||
[ExportWorkspaceServiceFactoryWithAssemblyQualifiedName("Microsoft.CodeAnalysis.Features", "Microsoft.CodeAnalysis.PickMembers.IPickMembersService")] | ||
public class PickMemberWorkspaceServiceFactory : IWorkspaceServiceFactory | ||
{ | ||
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) | ||
{ | ||
// Generates proxy class to get around issue that IPickMembersService is internal at this point. | ||
var internalType = Assembly.Load("Microsoft.CodeAnalysis.Features").GetType("Microsoft.CodeAnalysis.PickMembers.IPickMembersService"); | ||
return (IWorkspaceService)typeof(DispatchProxy).GetMethod(nameof(DispatchProxy.Create)).MakeGenericMethod(internalType, typeof(PickMemberWorkspaceService)).Invoke(null, null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we reduce this to one reflection invocation?
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 think Ravi was looking at only calling
x.CodeAction.GetType().Name
once instead of three times.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.