Skip to content

Commit c6a4401

Browse files
committed
Fix issue with filekind from failed tests
1 parent 74fbc9c commit c6a4401

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/ExtractToCodeBehindCodeActionResolver.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,15 @@ public override async Task<WorkspaceEdit> ResolveAsync(JObject data, Cancellatio
5656
if (document is null)
5757
{
5858
return null;
59-
}
59+
}
6060

61-
var documentFileKind = document.FileKind;
62-
if (!FileKinds.IsComponent(documentFileKind))
61+
var codeDocument = await document.GetGeneratedOutputAsync().ConfigureAwait(false);
62+
if (codeDocument.IsUnsupported())
6363
{
6464
return null;
6565
}
6666

67-
var codeDocument = await document.GetGeneratedOutputAsync().ConfigureAwait(false);
68-
if (codeDocument.IsUnsupported())
67+
if (!FileKinds.IsComponent(codeDocument.GetFileKind()))
6968
{
7069
return null;
7170
}

src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/ExtractToCodeBehindCodeActionResolverTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class ExtractToCodeBehindCodeActionResolverTest : LanguageServerTestBase
2626
public async Task Handle_MissingFile()
2727
{
2828
// Arrange
29-
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), EmptyDocumentResolver, FilePathNormalizer, LoggerFactory);
29+
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), EmptyDocumentResolver, FilePathNormalizer);
3030
var data = JObject.FromObject(new ExtractToCodeBehindParams()
3131
{
3232
Uri = new Uri("c:/Test.razor"),
@@ -52,7 +52,7 @@ public async Task Handle_Unsupported()
5252
var codeDocument = CreateCodeDocument(contents);
5353
codeDocument.SetUnsupported();
5454

55-
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer, LoggerFactory);
55+
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer);
5656
var data = JObject.FromObject(new ExtractToCodeBehindParams()
5757
{
5858
Uri = new Uri("c:/Test.razor"),
@@ -78,7 +78,7 @@ public async Task Handle_InvalidFileKind()
7878
var codeDocument = CreateCodeDocument(contents);
7979
codeDocument.SetFileKind(FileKinds.Legacy);
8080

81-
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer, LoggerFactory);
81+
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer);
8282
var data = JObject.FromObject(new ExtractToCodeBehindParams()
8383
{
8484
Uri = new Uri("c:/Test.razor"),
@@ -104,7 +104,7 @@ public async Task Handle_ExtractCodeBlock()
104104
var contents = $"@page \"/test\"{Environment.NewLine}@code {{ private var x = 1; }}";
105105
var codeDocument = CreateCodeDocument(contents);
106106

107-
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer, LoggerFactory);
107+
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer);
108108
var actionParams = new ExtractToCodeBehindParams
109109
{
110110
Uri = documentUri,
@@ -148,7 +148,7 @@ public async Task Handle_ExtractFunctionsBlock()
148148
var contents = $"@page \"/test\"{Environment.NewLine}@functions {{ private var x = 1; }}";
149149
var codeDocument = CreateCodeDocument(contents);
150150

151-
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer, LoggerFactory);
151+
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer);
152152
var actionParams = new ExtractToCodeBehindParams
153153
{
154154
Uri = documentUri,
@@ -192,7 +192,7 @@ public async Task Handle_ExtractCodeBlockWithUsing()
192192
var contents = $"@page \"/test\"\n@using System.Diagnostics{Environment.NewLine}@code {{ private var x = 1; }}";
193193
var codeDocument = CreateCodeDocument(contents);
194194

195-
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer, LoggerFactory);
195+
var resolver = new ExtractToCodeBehindCodeActionResolver(new DefaultForegroundDispatcher(), CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer);
196196
var actionParams = new ExtractToCodeBehindParams
197197
{
198198
Uri = documentUri,

0 commit comments

Comments
 (0)