project-system
project-system copied to clipboard
Blazor page relocation causes non compilable project
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
- Initialize a blazor project.
- Create a blazor page (in /Pages) Example.razor:
@page "/Example"
<h3>Example</h3>
@code {
protected override void OnInitialized()
{
base.OnInitialized();
Console.Out.Write("this should run, and compile");
}
}
- Move the code to a code behind class
Pages/Example.razor.cs
namespace Project.Pages;
public partial class Example
{
protected override void OnInitialized()
{
base.OnInitialized();
Console.Out.Write("this should run, and compile");
}
}
- Move the Example.razor from /Pages to /Areas/Core/Pages and change the namespace to Project.Areas.Core.Pages
- Run the project.
- Find that the project is not compiling due to
no suitable method to overide in Example.razor.cs
Expected Behavior
Relocating a blazorpage with code-behind should compile, like a relocated blazorpage with code within is compiling
Steps To Reproduce
S.a.
Exceptions (if any)
No response
.NET Version
6.0.104
Anything else?
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Removing the ItemGroups including the Pages directorys
<ItemGroup>
<AdditionalFiles Include="Areas[...]\Index.razor" />
</ItemGroup>
<ItemGroup>
<Folder Include="Areas\DatasetFeatures\Pages" />
</ItemGroup>
from the .csproj seems to fix the build exception
@NTaylorMullen I suspect this might be something that CSP is doing?
/cc: @jaredpar
Moving to project system. This seems like an issue with the sync namespaces feature.
If I follow the repro steps above, the namespace in Example.razor.cs is not updated. If I follow the repro, but in step 4 I just move the Example.razor.cs file directly, it does get updated. Seems project-system/CPS is not correctly syncing namespaces of nested files.