Skip to content

[Cohosting] Model directive contents don't get classified as expected #11329

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

Closed
davidwengier opened this issue Dec 22, 2024 · 5 comments · Fixed by #11844
Closed

[Cohosting] Model directive contents don't get classified as expected #11329

davidwengier opened this issue Dec 22, 2024 · 5 comments · Fixed by #11844
Assignees
Labels
Milestone

Comments

@davidwengier
Copy link
Member

davidwengier commented Dec 22, 2024

This issue is referenced from a skipped test. The test has been unskipped, so you'll have to take my work for it, but the PR doing so is linked below.

Given:

@model AppThing.Model

In non-FUSE the classifications look like this:

0 1 5 razorDirective [] [model]
0 6 8 variable [] [AppThing]
0 8 1 operator [] [.]
0 1 5 variable [] [Model]

In FUSE, we get only the razorDirective for "model"

@chsienki
Copy link
Member

chsienki commented May 6, 2025

Fixed via #11007

@chsienki chsienki closed this as completed May 6, 2025
@davidwengier
Copy link
Member Author

I'm not sure that's true... The test still shows nothing coming back from C# after the @model.

It's hard to read, but this line is the "model" being classified as a directive, and the next line is the @ for an @using:
https://github.com/dotnet/razor/blob/main/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/TestFiles/SemanticTokens/Legacy.txt#L6

@davidwengier davidwengier reopened this May 7, 2025
@davidwengier davidwengier assigned davidwengier and unassigned chsienki May 7, 2025
@davidwengier
Copy link
Member Author

Reopened and assigned to myself to investigate. Could be a cohosting difference, rather than FUSE.

@davidwengier
Copy link
Member Author

davidwengier commented May 8, 2025

Okay, found the issue, it's specific to Razor Pages, our test just happened to be one. Adding AssertSourceMappingsMatchBaseline(compiled.CodeDocument); to the RazorPagesWithRouteTemplate_Runtime test (source) generates this:

Source Location: (36:3,1 [41] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml)
|using Microsoft.AspNetCore.Mvc.RazorPages|
Generated Location: (1098:16,0 [41] )
|using Microsoft.AspNetCore.Mvc.RazorPages|

Source Location: (6:0,6 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml)
|"/About"|
Generated Location: (1464:26,0 [8] )
|"/About"|

Source Location: (6:0,6 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml)
|"/About"|
Generated Location: (1464:26,0 [8] )
|"/About"|

Source Location: (213:12,18 [10] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml)
|Model.Name|
Generated Location: (2690:48,0 [10] )
|Model.Name|

Source Location: (93:5,12 [97] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/RazorPagesWithRouteTemplate.cshtml)
|
    public class NewModel : PageModel
    {
        public string Name { get; set; }
    }
|
Generated Location: (2991:59,0 [97] )
|
    public class NewModel : PageModel
    {
        public string Name { get; set; }
    }
|

Note the lack of NewModel in the mappings (and not sure if the double-up of /About is relevant.)

Sorry, back to you @chsienki 😁

@davidwengier davidwengier assigned chsienki and unassigned davidwengier May 8, 2025
@chsienki
Copy link
Member

chsienki commented May 8, 2025

Ah ok, yeah that makes sense, I'll take a look. Thanks for digging in!

@davidwengier davidwengier changed the title [FUSE] Model directive contents don't get classified as expected [Cohosting] Model directive contents don't get classified as expected May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants