зеркало из https://github.com/dotnet/razor.git
Defer to C# for component attribute GTD in cohosting
This was a subtle future bug, that we would have hit when we removed the C# syntax tree bits in future. By checking for Razor GTD first we weren't deferring to Roslyn for plain attributes (ie, the case without `@bind-` in the tests) which means at best we do some extra unnecessary work, and at worst we could lose features for things Roslyn supports but we don't. I did not intend to find this bug when I started. Sorry for missing it in the PR Dustin. The key is that `ignoreAttributes` should have been `true` when porting over the code, and changing that would have made the test fail in your branch.
This commit is contained in:
Родитель
efceb90f2d
Коммит
5ef490fbf3
|
@ -62,14 +62,6 @@ internal sealed class RemoteGoToDefinitionService(in ServiceArgs args) : RazorDo
|
|||
|
||||
var positionInfo = GetPositionInfo(codeDocument, hostDocumentIndex);
|
||||
|
||||
// First, see if this is a Razor component.
|
||||
var componentLocation = await _componentDefinitionService.GetDefinitionAsync(context.Snapshot, positionInfo, ignoreAttributes: false, cancellationToken).ConfigureAwait(false);
|
||||
if (componentLocation is not null)
|
||||
{
|
||||
// Convert from VS LSP Location to Roslyn. This can be removed when Razor moves fully onto Roslyn's LSP types.
|
||||
return Results([RoslynLspFactory.CreateLocation(componentLocation.Uri, componentLocation.Range.ToLinePositionSpan())]);
|
||||
}
|
||||
|
||||
if (positionInfo.LanguageKind == RazorLanguageKind.Html)
|
||||
{
|
||||
// Sometimes Html can actually be mapped to C#, like for example component attributes, which map to
|
||||
|
@ -83,9 +75,17 @@ internal sealed class RemoteGoToDefinitionService(in ServiceArgs args) : RazorDo
|
|||
}
|
||||
}
|
||||
|
||||
// If it isn't a Razor component, and it isn't C#, let the server know to delegate to HTML.
|
||||
if (positionInfo.LanguageKind != RazorLanguageKind.CSharp)
|
||||
if (positionInfo.LanguageKind is RazorLanguageKind.Html or RazorLanguageKind.Razor)
|
||||
{
|
||||
// First, see if this is a Razor component. We ignore attributes here, because they're better served by the C# handler.
|
||||
var componentLocation = await _componentDefinitionService.GetDefinitionAsync(context.Snapshot, positionInfo, ignoreAttributes: true, cancellationToken).ConfigureAwait(false);
|
||||
if (componentLocation is not null)
|
||||
{
|
||||
// Convert from VS LSP Location to Roslyn. This can be removed when Razor moves fully onto Roslyn's LSP types.
|
||||
return Results([RoslynLspFactory.CreateLocation(componentLocation.Uri, componentLocation.Range.ToLinePositionSpan())]);
|
||||
}
|
||||
|
||||
// If it isn't a Razor component, and it isn't C#, let the server know to delegate to HTML.
|
||||
return CallHtml;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче