Skip to content

Commit

Permalink
Remove obsolete APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Feb 9, 2022
1 parent 471b57d commit d963f6b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

namespace Microsoft.CodeAnalysis.ExternalAccess.Razor
{
[Obsolete("Use IRazorDocumentExcerptServiceImplementation instead")]
internal interface IRazorDocumentExcerptService
{
Task<RazorExcerptResult?> TryExcerptAsync(Document document, TextSpan span, RazorExcerptMode mode, CancellationToken cancellationToken);
}

internal interface IRazorDocumentExcerptServiceImplementation
{
Task<RazorExcerptResult?> TryExcerptAsync(Document document, TextSpan span, RazorExcerptMode mode, RazorClassificationOptionsWrapper options, CancellationToken cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Classification;
Expand All @@ -15,14 +13,7 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.Razor
{
internal sealed class RazorDocumentExcerptServiceWrapper : IDocumentExcerptService
{
[Obsolete]
private readonly IRazorDocumentExcerptService? _legacyRazorDocumentExcerptService;

private readonly IRazorDocumentExcerptServiceImplementation? _impl;

[Obsolete]
public RazorDocumentExcerptServiceWrapper(IRazorDocumentExcerptService razorDocumentExcerptService)
=> _legacyRazorDocumentExcerptService = razorDocumentExcerptService;
private readonly IRazorDocumentExcerptServiceImplementation _impl;

public RazorDocumentExcerptServiceWrapper(IRazorDocumentExcerptServiceImplementation impl)
=> _impl = impl;
Expand All @@ -36,19 +27,7 @@ public RazorDocumentExcerptServiceWrapper(IRazorDocumentExcerptServiceImplementa
_ => throw ExceptionUtilities.UnexpectedValue(mode),
};

RazorExcerptResult? result;
if (_impl != null)
{
result = await _impl.TryExcerptAsync(document, span, razorMode, new RazorClassificationOptionsWrapper(classificationOptions), cancellationToken).ConfigureAwait(false);
}
else
{
#pragma warning disable CS0612 // Type or member is obsolete
Contract.ThrowIfNull(_legacyRazorDocumentExcerptService);
result = await _legacyRazorDocumentExcerptService.TryExcerptAsync(document, span, razorMode, cancellationToken).ConfigureAwait(false);
#pragma warning restore
}

var result = await _impl.TryExcerptAsync(document, span, razorMode, new RazorClassificationOptionsWrapper(classificationOptions), cancellationToken).ConfigureAwait(false);
var razorExcerpt = result.Value;
return new ExcerptResult(razorExcerpt.Content, razorExcerpt.MappedSpan, razorExcerpt.ClassifiedSpans, razorExcerpt.Document, razorExcerpt.Span);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,7 @@ public RazorDocumentServiceProviderWrapper(IRazorDocumentServiceProvider innerDo
static documentServiceProvider =>
{
var impl = documentServiceProvider.GetService<IRazorDocumentExcerptServiceImplementation>();
if (impl != null)
{
return new RazorDocumentExcerptServiceWrapper(impl);
}

#pragma warning disable CS0612, CS0618 // Type or member is obsolete
var legacyImpl = documentServiceProvider.GetService<IRazorDocumentExcerptService>();
if (legacyImpl != null)
{
return new RazorDocumentExcerptServiceWrapper(legacyImpl);
}
#pragma warning restore
return null;
return (impl != null) ? new RazorDocumentExcerptServiceWrapper(impl) : null;
},
_innerDocumentServiceProvider);

Expand Down

0 comments on commit d963f6b

Please sign in to comment.