-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Implement TypeScript ExternalAccess wrappers for AsynchronousOperationListener #77318
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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
18 changes: 18 additions & 0 deletions
18
src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/VSTypeScriptTaggerHost.cs
This file contains hidden or 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,18 @@ | ||
| // 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.Composition; | ||
| using Microsoft.CodeAnalysis.Editor.Tagging; | ||
| using Microsoft.CodeAnalysis.Host.Mef; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api; | ||
|
|
||
| [Export(typeof(VSTypeScriptTaggerHost)), Shared] | ||
| [method: ImportingConstructor] | ||
| [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
| internal sealed class VSTypeScriptTaggerHost(TaggerHost underlyingObject) | ||
| { | ||
| internal TaggerHost UnderlyingObject { get; } = underlyingObject; | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/Workspaces/Core/Portable/ExternalAccess/VSTypeScript/Api/TaskExtensions.cs
This file contains hidden or 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,16 @@ | ||
| // 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.Threading.Tasks; | ||
| using Microsoft.CodeAnalysis.Shared.TestHooks; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api; | ||
|
|
||
| internal static class TaskExtensions | ||
| { | ||
| #pragma warning disable VSTHRD200 // Use "Async" suffix for async methods | ||
| public static Task CompletesAsyncOperation(this Task task, VSTypeScriptAsyncToken asyncToken) | ||
| #pragma warning restore VSTHRD200 | ||
| => task.CompletesAsyncOperation(asyncToken.UnderlyingObject); | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/Workspaces/Core/Portable/ExternalAccess/VSTypeScript/Api/VSTypeScriptAsyncToken.cs
This file contains hidden or 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 @@ | ||
| // 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 Microsoft.CodeAnalysis.Shared.TestHooks; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api; | ||
|
|
||
| internal sealed class VSTypeScriptAsyncToken(IAsyncToken underlyingObject) : IDisposable | ||
| { | ||
| internal IAsyncToken UnderlyingObject | ||
| => underlyingObject; | ||
|
|
||
| public void Dispose() | ||
| => UnderlyingObject.Dispose(); | ||
| } |
14 changes: 14 additions & 0 deletions
14
...ore/Portable/ExternalAccess/VSTypeScript/Api/VSTypeScriptAsynchronousOperationListener.cs
This file contains hidden or 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,14 @@ | ||
| // 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.Runtime.CompilerServices; | ||
| using Microsoft.CodeAnalysis.Shared.TestHooks; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api; | ||
|
|
||
| internal readonly struct VSTypeScriptAsynchronousOperationListener(IAsynchronousOperationListener underlyingObject) | ||
| { | ||
| public VSTypeScriptAsyncToken BeginAsyncOperation(string name, object? tag = null, [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0) | ||
| => new(underlyingObject.BeginAsyncOperation(name, tag, filePath, lineNumber)); | ||
| } |
21 changes: 21 additions & 0 deletions
21
...able/ExternalAccess/VSTypeScript/Api/VSTypeScriptAsynchronousOperationListenerProvider.cs
This file contains hidden or 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,21 @@ | ||
| // 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.Composition; | ||
| using Microsoft.CodeAnalysis.Host.Mef; | ||
| using Microsoft.CodeAnalysis.Shared.TestHooks; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api; | ||
|
|
||
| [Shared] | ||
| [Export(typeof(VSTypeScriptAsynchronousOperationListenerProvider))] | ||
| [method: ImportingConstructor] | ||
| [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
| internal sealed class VSTypeScriptAsynchronousOperationListenerProvider( | ||
| IAsynchronousOperationListenerProvider provider) | ||
| { | ||
| public VSTypeScriptAsynchronousOperationListener GetListener(string featureName) | ||
| => new(provider.GetListener(featureName)); | ||
| } | ||
15 changes: 15 additions & 0 deletions
15
src/Workspaces/Core/Portable/ExternalAccess/VSTypeScript/Api/VSTypeScriptFeatureAttribute.cs
This file contains hidden or 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,15 @@ | ||
| // 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.CodeAnalysis.Shared.TestHooks; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api; | ||
|
|
||
| internal static class VSTypeScriptFeatureAttribute | ||
| { | ||
| public const string RenameTracking = FeatureAttribute.RenameTracking; | ||
| public const string Snippets = FeatureAttribute.Snippets; | ||
| public const string Workspace = FeatureAttribute.Workspace; | ||
| public const string SolutionCrawlerLegacy = FeatureAttribute.SolutionCrawlerLegacy; | ||
| } |
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.
Unlike the underlying provider, this means multiple calls for the same featureName will return different instances. Since it's stateless though I presume that's fine...
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.
Yeah, should be fine. Usually this is called in a ctor and then the listener is used in the type.