Skip to content

Commit

Permalink
Workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Apr 11, 2022
1 parent d9c3610 commit e3cabdc
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,39 @@
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript
{
[ExportLanguageService(typeof(ICommentSelectionService), InternalLanguageNames.TypeScript), Shared]
internal sealed class VSTypeScriptCommentSelectionService : ICommentSelectionService
{
private readonly IVSTypeScriptCommentSelectionServiceImplementation _impl;
private readonly IVSTypeScriptCommentSelectionServiceImplementation? _impl;

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public VSTypeScriptCommentSelectionService(IVSTypeScriptCommentSelectionServiceImplementation impl)
=> _impl = impl;
public VSTypeScriptCommentSelectionService(
// Optional to work around test issue: https://github.com/dotnet/roslyn/issues/60690
[Import(AllowDefault = true)] IVSTypeScriptCommentSelectionServiceImplementation? impl)
{
_impl = impl;
}

public async Task<CommentSelectionInfo> GetInfoAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken)
{
// Will never be null in product.
Contract.ThrowIfNull(_impl);

var info = await _impl.GetInfoAsync(document, textSpan, cancellationToken).ConfigureAwait(false);
return info.UnderlyingObject;
}

public Task<Document> FormatAsync(Document document, ImmutableArray<TextSpan> changes, SyntaxFormattingOptions formattingOptions, CancellationToken cancellationToken)
=> _impl.FormatAsync(document, changes, cancellationToken);
{
// Will never be null in product.
Contract.ThrowIfNull(_impl);

return _impl.FormatAsync(document, changes, cancellationToken);
}
}
}

0 comments on commit e3cabdc

Please sign in to comment.