Skip to content

Razor Pages squigglies for internal PageModel implementations #9352

Open
@lonix1

Description

@lonix1

Environment data

dotnet --info output: 7.0.401
VS Code version: 1.82.2
C# Extension version: 2.3.27

OmniSharp log

n/a

Steps to reproduce

Foo.cshtml.cs

internal sealed class FooModel : PageModel {                      // <--------- internal
  public string Name { get; set; } = "Mike";
  // ...
}

Foo.cshtml

@page /foo
@model FooModel
<div>
  Hello @Model.Name      @* red squigglies start at first invocation of Model, till end of document *@
  ...                    @* red squigglies *@
  ...                    @* red squigglies *@
</div>                   @* red squigglies *@

Expected behavior

No errors, no warnings, no squigglies.

Actual behavior

Many red squigglies in vscode. Example:

Inconsistent accessibility: property type 'IHtmlHelper<FooModel>' is less accessible than property 'Pages_Foo.Html' CS0053
Inconsistent accessibility: property type 'IHtmlHelper<FooModel>' is less accessible than property 'Pages_Foo.ViewData' CS0053
Inconsistent accessibility: property type 'IHtmlHelper<FooModel>' is less accessible than property 'Pages_Foo.Model' CS0053

Additional context

Even though reported as errors, the app works. It's perfectly valid code.

When I change internal to public, the squigglies disappear. But I don't want to do that, as the code I've written is best practice.

The above example is simplistic. For a real RP page, of non-trivial length, the entire editor is filled with red squigglies. It's completely unusable.

Metadata

Metadata

Assignees

Labels

area-compilerUmbrella for all compiler issuesbugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions