Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Fix plan: split fake namespace types into their own file (Task 2), C# forbids mixing file-scoped and block namespaces

KrzysztofPajak8ca05b816e42
diff --git a/docs/superpowers/plans/2026-08-17-arch001-phase2-view-consolidation.md b/docs/superpowers/plans/2026-08-17-arch001-phase2-view-consolidation.md
index 258c7941c..2acb2f8b9 100644
--- a/docs/superpowers/plans/2026-08-17-arch001-phase2-view-consolidation.md
+++ b/docs/superpowers/plans/2026-08-17-arch001-phase2-view-consolidation.md
@@ -136,6 +136,7 @@ git commit -m "Convert Grand.Web.AdminShared to a Razor Class Library (ARCH-001
**Files:**
- Modify: `src/Web/Grand.Web.Common/View/ViewLocationExpander.cs`
- Test: `src/Tests/Grand.Web.Common.Tests/View/ViewLocationExpanderTests.cs` (new file)
+- Test: `src/Tests/Grand.Web.Common.Tests/View/AdminSharedControllersNamespaceFakes.cs` (new file)
**Interfaces:**
- Produces: `ViewLocationExpander.ExpandViewLocations` gains a second,
@@ -152,26 +153,41 @@ create it alongside the test file in Step 2.
- [ ] **Step 2: Write the failing tests**
-```csharp
-using Grand.Web.Common.View;
-using Microsoft.AspNetCore.Mvc.Abstractions;
-using Microsoft.AspNetCore.Mvc.Controllers;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+C# allows only one namespace per file when using the file-scoped
+`namespace X;` form — the fake types standing in for a real
+`Grand.Web.AdminShared.Controllers`-namespaced base controller (this test
+project has no reference to `Grand.Web.AdminShared`, so a real
+`BaseProductController` isn't available; only the namespace string matters
+for `IsAdminSharedController`) go in their own file, block-scoped:
-namespace Grand.Web.Common.Tests.View;
+Create `src/Tests/Grand.Web.Common.Tests/View/AdminSharedControllersNamespaceFakes.cs`:
-// Dummy hierarchy standing in for BaseProductController living in
-// Grand.Web.AdminShared.Controllers — this test project doesn't reference
-// AdminShared, so the namespace string itself is what's under test, not a
-// real base type.
+```csharp
+// Stands in for a real Base*Controller living in Grand.Web.AdminShared.Controllers
+// (this test project has no reference to Grand.Web.AdminShared) — only the
+// namespace string matters to ViewLocationExpander.IsAdminSharedController.
namespace Grand.Web.AdminShared.Controllers
{
public abstract class FakeBaseController { }
}
-public class FakeAdminSharedSubclass : Grand.Web.AdminShared.Controllers.FakeBaseController { }
+namespace Grand.Web.Common.Tests.View
+{
+ public class FakeAdminSharedSubclass : Grand.Web.AdminShared.Controllers.FakeBaseController { }
-public class FakeUnrelatedController { }
+ public class FakeUnrelatedController { }
+}
+```
+
+Create `src/Tests/Grand.Web.Common.Tests/View/ViewLocationExpanderTests.cs`:
+
+```csharp
+using Grand.Web.Common.View;
+using Microsoft.AspNetCore.Mvc.Abstractions;
+using Microsoft.AspNetCore.Mvc.Controllers;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Grand.Web.Common.Tests.View;
[TestClass]
public class ViewLocationExpanderTests
@@ -304,7 +320,7 @@ only confirms the expander itself compiles and doesn't regress the existing
- [ ] **Step 8: Commit**
```bash
-git add src/Web/Grand.Web.Common/View/ViewLocationExpander.cs src/Web/Grand.Web.Common/Grand.Web.Common.csproj src/Tests/Grand.Web.Common.Tests/View/ViewLocationExpanderTests.cs
+git add src/Web/Grand.Web.Common/View/ViewLocationExpander.cs src/Web/Grand.Web.Common/Grand.Web.Common.csproj src/Tests/Grand.Web.Common.Tests/View/ViewLocationExpanderTests.cs src/Tests/Grand.Web.Common.Tests/View/AdminSharedControllersNamespaceFakes.cs
git commit -m "Add AdminShared view fallback branch to ViewLocationExpander (ARCH-001 Phase 2)"
```