Skip to content

Commit

Permalink
Simplify with one project and new namespace tests to enforce correct … (
Browse files Browse the repository at this point in the history
#39)

* Simplify with one project and new namespace tests to enforce correct usage

* Readme update
  • Loading branch information
james-d12 authored Mar 6, 2025
1 parent 989c971 commit 6990836
Show file tree
Hide file tree
Showing 117 changed files with 384 additions and 528 deletions.
80 changes: 12 additions & 68 deletions CodeHub.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Backend", "Backend", "{6BBA
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Api", "src\backend\CodeHub.Api\CodeHub.Api.csproj", "{0B59B285-BE8E-48DA-9A9D-AFAF8B4D1C50}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Shared", "src\backend\CodeHub.Shared\CodeHub.Shared.csproj", "{8D2E2CFA-8324-40CA-8D0D-C1F273363F6E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Frontend", "Frontend", "{FD7D4EDA-3EEC-4989-B479-563417E6848F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Portal.Services", "src\frontend\CodeHub.Portal.Services\CodeHub.Portal.Services.csproj", "{5A58BC92-EC25-49F9-991A-3A2F03E5899F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Portal", "src\frontend\CodeHub.Portal\CodeHub.Portal.csproj", "{E6AF518B-3FAC-4D3F-8BF2-7C8411B153CA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Platform.AzureDevOps", "src\backend\CodeHub.Platform.AzureDevOps\CodeHub.Platform.AzureDevOps.csproj", "{5A4A50EF-186E-4FD0-BB09-BA7A46D6B8C4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Platform.AzureDevOps.Tests", "src\backend\CodeHub.Platform.AzureDevOps.Tests\CodeHub.Platform.AzureDevOps.Tests.csproj", "{F8B9B097-D031-4E97-8F65-41078E810E3D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{794E0C1D-6331-49C2-B835-D02C1FE83D01}"
ProjectSection(SolutionItems) = preProject
src\backend\Directory.Build.props = src\backend\Directory.Build.props
Expand All @@ -46,19 +40,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{21C839
src\frontend\README.md = src\frontend\README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Platform.Azure", "src\backend\CodeHub.Platform.Azure\CodeHub.Platform.Azure.csproj", "{58014886-DBFC-4D3B-9EA3-03B8A228B601}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Platform.Azure.Tests", "src\backend\CodeHub.Platform.Azure.Tests\CodeHub.Platform.Azure.Tests.csproj", "{4D69214A-521E-413C-8732-A228A50753DD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Platform.GitHub", "src\backend\CodeHub.Platform.GitHub\CodeHub.Platform.GitHub.csproj", "{8AFCA3A8-0CDB-4FF7-B484-803EA74E94D5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Platform.GitLab", "src\backend\CodeHub.Platform.GitLab\CodeHub.Platform.GitLab.csproj", "{7014F74C-506D-4DC3-85DC-DF14EC446FB4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Platform.GitHub.Tests", "src\backend\CodeHub.Platform.GitHub.Tests\CodeHub.Platform.GitHub.Tests.csproj", "{8BD76230-630B-42A1-AAB3-E3A6E2EAB8A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Platform.GitLab.Tests", "src\backend\CodeHub.Platform.GitLab.Tests\CodeHub.Platform.GitLab.Tests.csproj", "{6A915CB9-8153-433B-9DC1-0AFE159486B7}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Core", "src\backend\CodeHub.Core\CodeHub.Core.csproj", "{013D18D4-D0B7-4226-A6EB-4D22AD8345FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Shared.Tests", "src\backend\CodeHub.Shared.Tests\CodeHub.Shared.Tests.csproj", "{97CBF632-FA60-42E7-AD2E-7DBD672C7FEA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeHub.Core.Tests", "src\backend\CodeHub.Core.Tests\CodeHub.Core.Tests.csproj", "{2B8AEA40-107F-4360-8CF8-540513CCBF54}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -70,10 +54,6 @@ Global
{0B59B285-BE8E-48DA-9A9D-AFAF8B4D1C50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B59B285-BE8E-48DA-9A9D-AFAF8B4D1C50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B59B285-BE8E-48DA-9A9D-AFAF8B4D1C50}.Release|Any CPU.Build.0 = Release|Any CPU
{8D2E2CFA-8324-40CA-8D0D-C1F273363F6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D2E2CFA-8324-40CA-8D0D-C1F273363F6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D2E2CFA-8324-40CA-8D0D-C1F273363F6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D2E2CFA-8324-40CA-8D0D-C1F273363F6E}.Release|Any CPU.Build.0 = Release|Any CPU
{5A58BC92-EC25-49F9-991A-3A2F03E5899F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A58BC92-EC25-49F9-991A-3A2F03E5899F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A58BC92-EC25-49F9-991A-3A2F03E5899F}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -82,61 +62,25 @@ Global
{E6AF518B-3FAC-4D3F-8BF2-7C8411B153CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6AF518B-3FAC-4D3F-8BF2-7C8411B153CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6AF518B-3FAC-4D3F-8BF2-7C8411B153CA}.Release|Any CPU.Build.0 = Release|Any CPU
{5A4A50EF-186E-4FD0-BB09-BA7A46D6B8C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A4A50EF-186E-4FD0-BB09-BA7A46D6B8C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A4A50EF-186E-4FD0-BB09-BA7A46D6B8C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A4A50EF-186E-4FD0-BB09-BA7A46D6B8C4}.Release|Any CPU.Build.0 = Release|Any CPU
{F8B9B097-D031-4E97-8F65-41078E810E3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F8B9B097-D031-4E97-8F65-41078E810E3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8B9B097-D031-4E97-8F65-41078E810E3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8B9B097-D031-4E97-8F65-41078E810E3D}.Release|Any CPU.Build.0 = Release|Any CPU
{58014886-DBFC-4D3B-9EA3-03B8A228B601}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{58014886-DBFC-4D3B-9EA3-03B8A228B601}.Debug|Any CPU.Build.0 = Debug|Any CPU
{58014886-DBFC-4D3B-9EA3-03B8A228B601}.Release|Any CPU.ActiveCfg = Release|Any CPU
{58014886-DBFC-4D3B-9EA3-03B8A228B601}.Release|Any CPU.Build.0 = Release|Any CPU
{4D69214A-521E-413C-8732-A228A50753DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D69214A-521E-413C-8732-A228A50753DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D69214A-521E-413C-8732-A228A50753DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D69214A-521E-413C-8732-A228A50753DD}.Release|Any CPU.Build.0 = Release|Any CPU
{8AFCA3A8-0CDB-4FF7-B484-803EA74E94D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8AFCA3A8-0CDB-4FF7-B484-803EA74E94D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8AFCA3A8-0CDB-4FF7-B484-803EA74E94D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8AFCA3A8-0CDB-4FF7-B484-803EA74E94D5}.Release|Any CPU.Build.0 = Release|Any CPU
{7014F74C-506D-4DC3-85DC-DF14EC446FB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7014F74C-506D-4DC3-85DC-DF14EC446FB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7014F74C-506D-4DC3-85DC-DF14EC446FB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7014F74C-506D-4DC3-85DC-DF14EC446FB4}.Release|Any CPU.Build.0 = Release|Any CPU
{8BD76230-630B-42A1-AAB3-E3A6E2EAB8A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BD76230-630B-42A1-AAB3-E3A6E2EAB8A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BD76230-630B-42A1-AAB3-E3A6E2EAB8A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8BD76230-630B-42A1-AAB3-E3A6E2EAB8A1}.Release|Any CPU.Build.0 = Release|Any CPU
{6A915CB9-8153-433B-9DC1-0AFE159486B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A915CB9-8153-433B-9DC1-0AFE159486B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A915CB9-8153-433B-9DC1-0AFE159486B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A915CB9-8153-433B-9DC1-0AFE159486B7}.Release|Any CPU.Build.0 = Release|Any CPU
{97CBF632-FA60-42E7-AD2E-7DBD672C7FEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97CBF632-FA60-42E7-AD2E-7DBD672C7FEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97CBF632-FA60-42E7-AD2E-7DBD672C7FEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97CBF632-FA60-42E7-AD2E-7DBD672C7FEA}.Release|Any CPU.Build.0 = Release|Any CPU
{013D18D4-D0B7-4226-A6EB-4D22AD8345FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{013D18D4-D0B7-4226-A6EB-4D22AD8345FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{013D18D4-D0B7-4226-A6EB-4D22AD8345FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{013D18D4-D0B7-4226-A6EB-4D22AD8345FC}.Release|Any CPU.Build.0 = Release|Any CPU
{2B8AEA40-107F-4360-8CF8-540513CCBF54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B8AEA40-107F-4360-8CF8-540513CCBF54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B8AEA40-107F-4360-8CF8-540513CCBF54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B8AEA40-107F-4360-8CF8-540513CCBF54}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0B59B285-BE8E-48DA-9A9D-AFAF8B4D1C50} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{8D2E2CFA-8324-40CA-8D0D-C1F273363F6E} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{5A58BC92-EC25-49F9-991A-3A2F03E5899F} = {FD7D4EDA-3EEC-4989-B479-563417E6848F}
{E6AF518B-3FAC-4D3F-8BF2-7C8411B153CA} = {FD7D4EDA-3EEC-4989-B479-563417E6848F}
{5A4A50EF-186E-4FD0-BB09-BA7A46D6B8C4} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{794E0C1D-6331-49C2-B835-D02C1FE83D01} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{21C8395D-3B75-46E3-AAAE-396CDE1679DB} = {FD7D4EDA-3EEC-4989-B479-563417E6848F}
{58014886-DBFC-4D3B-9EA3-03B8A228B601} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{8AFCA3A8-0CDB-4FF7-B484-803EA74E94D5} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{7014F74C-506D-4DC3-85DC-DF14EC446FB4} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{4D69214A-521E-413C-8732-A228A50753DD} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{F8B9B097-D031-4E97-8F65-41078E810E3D} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{8BD76230-630B-42A1-AAB3-E3A6E2EAB8A1} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{6A915CB9-8153-433B-9DC1-0AFE159486B7} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{97CBF632-FA60-42E7-AD2E-7DBD672C7FEA} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{013D18D4-D0B7-4226-A6EB-4D22AD8345FC} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
{2B8AEA40-107F-4360-8CF8-540513CCBF54} = {6BBAFA79-C6EC-4415-8249-3AF0BF69A8F8}
EndGlobalSection
EndGlobal
11 changes: 4 additions & 7 deletions src/backend/CodeHub.Api/CodeHub.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@
<PackageReference Include="Swashbuckle.AspNetCore"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CodeHub.Platform.AzureDevOps\CodeHub.Platform.AzureDevOps.csproj"/>
<ProjectReference Include="..\CodeHub.Platform.Azure\CodeHub.Platform.Azure.csproj"/>
<ProjectReference Include="..\CodeHub.Platform.GitHub\CodeHub.Platform.GitHub.csproj" />
<ProjectReference Include="..\CodeHub.Platform.GitLab\CodeHub.Platform.GitLab.csproj" />
</ItemGroup>

<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CodeHub.Core\CodeHub.Core.csproj" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/backend/CodeHub.Api/Controllers/AzureController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using CodeHub.Platform.Azure.Models;
using CodeHub.Platform.Azure.Services;
using CodeHub.Core.Azure.Models;
using CodeHub.Core.Azure.Services;
using Microsoft.AspNetCore.Mvc;

namespace CodeHub.Api.Controllers;
Expand Down
7 changes: 3 additions & 4 deletions src/backend/CodeHub.Api/Controllers/ResourceController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using CodeHub.Shared.Models;
using CodeHub.Shared.Query;
using CodeHub.Shared.Query.Requests;
using CodeHub.Core.Shared.Models;
using CodeHub.Core.Shared.Query;
using CodeHub.Core.Shared.Query.Requests;
using Microsoft.AspNetCore.Mvc;
using PipelineQueryRequest = CodeHub.Shared.Query.Requests.PipelineQueryRequest;

namespace CodeHub.Api.Controllers;

Expand Down
2 changes: 1 addition & 1 deletion src/backend/CodeHub.Api/Jobs/DiscoveryHostedService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CodeHub.Shared.Services;
using CodeHub.Core.Shared.Services;

namespace CodeHub.Api.Jobs;

Expand Down
8 changes: 4 additions & 4 deletions src/backend/CodeHub.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using System.Text.Json.Serialization;
using CodeHub.Api.Jobs;
using CodeHub.Api.Settings;
using CodeHub.Platform.Azure.Extensions;
using CodeHub.Platform.AzureDevOps.Extensions;
using CodeHub.Platform.GitHub.Extensions;
using CodeHub.Platform.GitLab.Extensions;
using CodeHub.Core.Azure.Extensions;
using CodeHub.Core.AzureDevOps.Extensions;
using CodeHub.Core.GitHub.Extensions;
using CodeHub.Core.GitLab.Extensions;
using Microsoft.VisualStudio.Services.Common;

var builder = WebApplication.CreateBuilder(args);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using CodeHub.Platform.Azure.Extensions;
using CodeHub.Platform.Azure.Services;
using CodeHub.Shared.Services;
using CodeHub.Core.Azure.Extensions;
using CodeHub.Core.Azure.Services;
using CodeHub.Core.Shared.Services;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace CodeHub.Platform.Azure.Tests.Extensions;
namespace CodeHub.Core.Tests.Azure.Extensions;

public sealed class AzureExtensionsTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using CodeHub.Platform.AzureDevOps.Extensions;
using CodeHub.Platform.AzureDevOps.Services;
using CodeHub.Shared.Services;
using CodeHub.Core.AzureDevOps.Extensions;
using CodeHub.Core.AzureDevOps.Services;
using CodeHub.Core.Shared.Services;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace CodeHub.Platform.AzureDevOps.Tests.Extensions;
namespace CodeHub.Core.Tests.AzureDevOps.Extensions;

public sealed class AzureDevOpsExtensionsTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="coverlet.collector"/>
Expand All @@ -15,7 +15,14 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CodeHub.Platform.Azure\CodeHub.Platform.Azure.csproj"/>
<ProjectReference Include="..\CodeHub.Core\CodeHub.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="AzureDevOps\" />
<Folder Include="GitHub\" />
<Folder Include="GitLab\" />
</ItemGroup>


</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using CodeHub.Platform.GitHub.Extensions;
using CodeHub.Platform.GitHub.Services;
using CodeHub.Shared.Services;
using CodeHub.Core.GitHub.Extensions;
using CodeHub.Core.GitHub.Services;
using CodeHub.Core.Shared.Services;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace CodeHub.Platform.GitHub.Tests.Extensions;
namespace CodeHub.Core.Tests.GitHub.Extensions;

public sealed class GitHubExtensionsTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using CodeHub.Platform.GitLab.Extensions;
using CodeHub.Platform.GitLab.Services;
using CodeHub.Shared.Services;
using CodeHub.Core.GitLab.Extensions;
using CodeHub.Core.GitLab.Services;
using CodeHub.Core.Shared.Services;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace CodeHub.Platform.GitLab.Tests.Extensions;
namespace CodeHub.Core.Tests.GitLab.Extensions;

public sealed class GitLabExtensionsTests
{
Expand Down
48 changes: 48 additions & 0 deletions src/backend/CodeHub.Core.Tests/NamespaceUsageTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Text.RegularExpressions;

namespace CodeHub.Core.Tests;

public sealed class NamespaceUsageTests
{
private static readonly string[] AllowedNamespaces =
{
"CodeHub.Core.Shared"
};

private static string GetRootPath()
{
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
var solutionDir =
Directory.GetParent(baseDir)?.Parent?.Parent?.Parent?.Parent?.FullName ?? string.Empty;
return Path.Combine(solutionDir, "CodeHub.Core");
}

[Theory]
[InlineData("Azure")]
[InlineData("AzureDevOps")]
[InlineData("GitHub")]
[InlineData("GitLab")]
public void UsingStatements_ShouldOnlyAllowThirdPartySelfAndSharedUsings(string moduleName)
{
var rootPath = GetRootPath();
var modulePath = Path.Combine(rootPath, moduleName);
var files = Directory.GetFiles(modulePath, "*.cs", SearchOption.AllDirectories);

foreach (var file in files)
{
var content = File.ReadAllText(file);
var usings = Regex.Matches(content, @"^\s*using\s+([\w\.]+);", RegexOptions.Multiline)
.Select(m => m.Groups[1].Value)
.ToList();

foreach (var usedNamespace in usings)
{
if (!usedNamespace.StartsWith("CodeHub.Core")) continue;

var isAllowed = usedNamespace.StartsWith($"CodeHub.Core.{moduleName}") ||
AllowedNamespaces.Any(n => usedNamespace.StartsWith(n));
Assert.True(isAllowed, $"Disallowed namespace '{usedNamespace}' found in file '{file}'");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CodeHub.Shared.Models;
using CodeHub.Core.Shared.Models;

namespace CodeHub.Shared.Tests.Validation;
namespace CodeHub.Core.Tests.Shared.Validation;

internal sealed class ValidationBuilderTestSettings : Settings
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using CodeHub.Shared.Validation;
using CodeHub.Core.Shared.Validation;
using Microsoft.Extensions.Configuration;

namespace CodeHub.Shared.Tests.Validation;
namespace CodeHub.Core.Tests.Shared.Validation;

public sealed class ValidationBuilderTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using CodeHub.Platform.Azure.Services;
using CodeHub.Platform.Azure.Validation;
using CodeHub.Shared.Services;
using CodeHub.Core.Azure.Services;
using CodeHub.Core.Azure.Validation;
using CodeHub.Core.Shared.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

namespace CodeHub.Platform.Azure.Extensions;
namespace CodeHub.Core.Azure.Extensions;

public static class AzureExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Azure.ResourceManager.Resources;
using CodeHub.Platform.Azure.Models;
using CodeHub.Shared.Models;
using CodeHub.Core.Azure.Models;
using CodeHub.Core.Shared.Models;

namespace CodeHub.Platform.Azure.Extensions;
namespace CodeHub.Core.Azure.Extensions;

internal static class AzureMappingExtensions
public static class AzureMappingExtensions
{
internal static AzureResource MapToAzureResource(
public static AzureResource MapToAzureResource(
this GenericResourceData genericResourceData,
string tenantName,
string subscriptionName)
Expand All @@ -30,7 +30,7 @@ internal static AzureResource MapToAzureResource(
};
}

internal static AzureSubscription MapToAzureSubscription(
public static AzureSubscription MapToAzureSubscription(
this SubscriptionResource subscriptionResource,
string tenantName)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CodeHub.Shared.Models;
using CodeHub.Core.Shared.Models;

namespace CodeHub.Platform.Azure.Models;
namespace CodeHub.Core.Azure.Models;

public sealed record AzureResource : CloudResource
{
Expand Down
Loading

0 comments on commit 6990836

Please sign in to comment.